libwinpr-nt: stub more of the native file API
This commit is contained in:
parent
7ceecb6279
commit
888812eaa0
@ -32,6 +32,7 @@
|
||||
#define HANDLE_TYPE_NAMED_PIPE 7
|
||||
#define HANDLE_TYPE_ANONYMOUS_PIPE 8
|
||||
#define HANDLE_TYPE_ACCESS_TOKEN 9
|
||||
#define HANDLE_TYPE_FILE 10
|
||||
|
||||
#define WINPR_HANDLE_DEF() \
|
||||
ULONG Type
|
||||
|
@ -32,6 +32,8 @@
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "nt.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
@ -202,7 +204,24 @@ NTSTATUS NtCreateFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess,
|
||||
PLARGE_INTEGER AllocationSize, ULONG FileAttributes, ULONG ShareAccess,
|
||||
ULONG CreateDisposition, ULONG CreateOptions, PVOID EaBuffer, ULONG EaLength)
|
||||
{
|
||||
return 0;
|
||||
WINPR_FILE* pFileHandle;
|
||||
|
||||
pFileHandle = (WINPR_FILE*) malloc(sizeof(WINPR_FILE));
|
||||
|
||||
if (!pFileHandle)
|
||||
return 0;
|
||||
|
||||
ZeroMemory(pFileHandle, sizeof(WINPR_FILE));
|
||||
|
||||
pFileHandle->DesiredAccess = DesiredAccess;
|
||||
pFileHandle->FileAttributes = FileAttributes;
|
||||
pFileHandle->ShareAccess = ShareAccess;
|
||||
pFileHandle->CreateDisposition = CreateDisposition;
|
||||
pFileHandle->CreateOptions = CreateOptions;
|
||||
|
||||
*((PULONG_PTR) FileHandle) = (ULONG_PTR) pFileHandle;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,7 +233,43 @@ NTSTATUS NtOpenFile(PHANDLE FileHandle, ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes, PIO_STATUS_BLOCK IoStatusBlock,
|
||||
ULONG ShareAccess, ULONG OpenOptions)
|
||||
{
|
||||
return 0;
|
||||
WINPR_FILE* pFileHandle;
|
||||
|
||||
pFileHandle = (WINPR_FILE*) malloc(sizeof(WINPR_FILE));
|
||||
|
||||
if (!pFileHandle)
|
||||
return 0;
|
||||
|
||||
ZeroMemory(pFileHandle, sizeof(WINPR_FILE));
|
||||
|
||||
pFileHandle->DesiredAccess = DesiredAccess;
|
||||
pFileHandle->ShareAccess = ShareAccess;
|
||||
|
||||
*((PULONG_PTR) FileHandle) = (ULONG_PTR) pFileHandle;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* NtReadFile function:
|
||||
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff567072/
|
||||
*/
|
||||
|
||||
NTSTATUS NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* NtWriteFile function:
|
||||
* http://msdn.microsoft.com/en-us/library/windows/hardware/ff567121/
|
||||
*/
|
||||
|
||||
NTSTATUS NtWriteFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
|
||||
{
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,7 +292,16 @@ NTSTATUS NtDeviceIoControlFile(HANDLE FileHandle, HANDLE Event,
|
||||
|
||||
NTSTATUS NtClose(HANDLE Handle)
|
||||
{
|
||||
return 0;
|
||||
WINPR_FILE* pFileHandle;
|
||||
|
||||
if (!Handle)
|
||||
return 0;
|
||||
|
||||
pFileHandle = (WINPR_FILE*) Handle;
|
||||
|
||||
free(pFileHandle);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
45
winpr/libwinpr/nt/nt.h
Normal file
45
winpr/libwinpr/nt/nt.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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 */
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
int TestNtCreateFile(int argc, char* argv[])
|
||||
{
|
||||
#if 0
|
||||
#ifndef _WIN32
|
||||
|
||||
HANDLE handle;
|
||||
NTSTATUS ntstatus;
|
||||
ULONG CreateOptions;
|
||||
@ -18,7 +19,7 @@ int TestNtCreateFile(int argc, char* argv[])
|
||||
RtlInitAnsiString(&aString, "\\Device\\FreeRDP\\TEST");
|
||||
RtlAnsiStringToUnicodeString(&uString, &aString, TRUE);
|
||||
|
||||
InitializeObjectAttributes(&attributes, NULL, 0, NULL, NULL);
|
||||
InitializeObjectAttributes(&attributes, &uString, 0, NULL, NULL);
|
||||
|
||||
DesiredAccess = GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE;
|
||||
CreateOptions = FILE_DIRECTORY_FILE | FILE_WRITE_THROUGH;
|
||||
@ -26,6 +27,7 @@ int TestNtCreateFile(int argc, char* argv[])
|
||||
ntstatus = NtCreateFile(&handle, DesiredAccess, &attributes, &ioStatusBlock, 0, 0, 0, CreateOptions, 0, 0, 0);
|
||||
|
||||
RtlFreeUnicodeString(&uString);
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user