From aa2709a999d87ef03b2f0ad5ca196ede7c7e496b Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Wed, 16 Dec 2015 16:25:09 +0100 Subject: [PATCH] winpr: create a specific winpr nt file handle There exist two definitions of WINPR_FILE: in file/ and in nt/. Both are different definitions used differently. Therefore split them into WINPR_FILE and WINPR_NT_FILE. --- winpr/libwinpr/nt/nt.c | 29 +++++++++++++++++++-------- winpr/libwinpr/nt/nt.h | 45 ------------------------------------------ 2 files changed, 21 insertions(+), 53 deletions(-) delete mode 100644 winpr/libwinpr/nt/nt.h diff --git a/winpr/libwinpr/nt/nt.c b/winpr/libwinpr/nt/nt.c index b45509ff0..7b6d2128b 100644 --- a/winpr/libwinpr/nt/nt.c +++ b/winpr/libwinpr/nt/nt.c @@ -57,12 +57,25 @@ VOID _InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes, #ifndef _WIN32 -#include "nt.h" #include - #include +#include "../handle/handle.h" + +struct winpr_nt_file +{ + WINPR_HANDLE_DEF(); + + ACCESS_MASK DesiredAccess; + OBJECT_ATTRIBUTES ObjectAttributes; + ULONG FileAttributes; + ULONG ShareAccess; + ULONG CreateDisposition; + ULONG CreateOptions; +}; +typedef struct winpr_nt_file WINPR_NT_FILE; + static pthread_once_t _TebOnceControl = PTHREAD_ONCE_INIT; static pthread_key_t _TebKey; @@ -210,9 +223,9 @@ NTSTATUS _NtCreateFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess, PLARGE_INTEGER AllocationSize, ULONG FileAttributes, ULONG ShareAccess, ULONG CreateDisposition, ULONG CreateOptions, PVOID EaBuffer, ULONG EaLength) { - WINPR_FILE* pFileHandle; + WINPR_NT_FILE* pFileHandle; - pFileHandle = (WINPR_FILE*) calloc(1, sizeof(WINPR_FILE)); + pFileHandle = (WINPR_NT_FILE*) calloc(1, sizeof(WINPR_NT_FILE)); if (!pFileHandle) return STATUS_NO_MEMORY; @@ -241,9 +254,9 @@ NTSTATUS _NtOpenFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, PIO_STATUS_BLOCK IoStatusBlock, ULONG ShareAccess, ULONG OpenOptions) { - WINPR_FILE* pFileHandle; + WINPR_NT_FILE* pFileHandle; - pFileHandle = (WINPR_FILE*) calloc(1, sizeof(WINPR_FILE)); + pFileHandle = (WINPR_NT_FILE*) calloc(1, sizeof(WINPR_NT_FILE)); if (!pFileHandle) return STATUS_NO_MEMORY; @@ -298,12 +311,12 @@ NTSTATUS _NtDeviceIoControlFile(HANDLE FileHandle, HANDLE Event, NTSTATUS _NtClose(HANDLE Handle) { - WINPR_FILE* pFileHandle; + WINPR_NT_FILE* pFileHandle; if (!Handle) return 0; - pFileHandle = (WINPR_FILE*) Handle; + pFileHandle = (WINPR_NT_FILE*) Handle; free(pFileHandle); diff --git a/winpr/libwinpr/nt/nt.h b/winpr/libwinpr/nt/nt.h deleted file mode 100644 index 52eda2f98..000000000 --- a/winpr/libwinpr/nt/nt.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * WinPR: Windows Portable Runtime - * Windows Native System Services - * - * Copyright 2013 Marc-Andre Moreau - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WINPR_NT_PRIVATE_H -#define WINPR_NT_PRIVATE_H - -#ifndef _WIN32 - -#include - -#include "../handle/handle.h" - -struct winpr_file -{ - WINPR_HANDLE_DEF(); - - ACCESS_MASK DesiredAccess; - OBJECT_ATTRIBUTES ObjectAttributes; - ULONG FileAttributes; - ULONG ShareAccess; - ULONG CreateDisposition; - ULONG CreateOptions; -}; -typedef struct winpr_file WINPR_FILE; - -#endif - -#endif /* WINPR_NT_PRIVATE_H */ -