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.
This commit is contained in:
Bernhard Miklautz 2015-12-16 16:25:09 +01:00
parent c3ce0c3b09
commit aa2709a999
2 changed files with 21 additions and 53 deletions

View File

@ -57,12 +57,25 @@ VOID _InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
#ifndef _WIN32
#include "nt.h"
#include <pthread.h>
#include <winpr/crt.h>
#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);

View File

@ -1,45 +0,0 @@
/**
* WinPR: Windows Portable Runtime
* Windows Native System Services
*
* Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
* 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 <winpr/nt.h>
#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 */