2013-03-16 20:48:10 +00:00
|
|
|
/*
|
1999-04-14 00:52:19 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-11-14 14:57:11 +00:00
|
|
|
* FILE: dll/win32/kernel32/client/file/rw.c
|
1999-04-14 00:52:19 +00:00
|
|
|
* PURPOSE: Read/write functions
|
2013-06-30 18:48:45 +00:00
|
|
|
* PROGRAMMER: Ariadne (ariadne@xs4all.nl)
|
1999-04-14 00:52:19 +00:00
|
|
|
* UPDATE HISTORY:
|
|
|
|
* Created 01/11/98
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ****************************************************************/
|
|
|
|
|
2003-01-15 21:24:36 +00:00
|
|
|
#include <k32.h>
|
[KERNEL32]: While working on the CMAKE branch, Amine and myself discovered a rather serious issue in kernel32 (and perhaps other libraries as well). Unlike rbuild, CMake does not allow you to export non-existant DLL functions (try it: add "poopyhead" in kernel32's exports under RBuild, and will it export "poopyhead", God knowing what that will actually link to).
As an additional feature on top of the "allow non-existing functions to be exported" "feature", because rbuild generates and links STDCALL function names without the proper decoration (vs. enforcing decoration at linking, but only removing it at export-time), this allows the definition (as an export) of a STDCALL function that is completely different from the actual function itself.
For example, the 5-parameter Foo function is normally Foo@20, while the 3-parameter Foo function woudl be Foo@12. Linking one against the other would fail (say, 2 parameters were added to Foo in a newer version). However, under RBUILD, both of these would appear as "Foo", and the linker/compiler would happilly connect the caller of Foo@3 (that has pushed 3 parameters) to the receiving side of Foo@5 (that is about to pop 5 parameters).
Even -if- decorations WERE to be applied, Foo@12 would STILL succeed, because of the first feature, which would enable the export of Foo@12 even though no such function exist.
In a further, bizare, twist of fate, the behavior of this RBUILD "feature", when the target function is not found, is to link the exported DLL TO ITSELF.
Therefore, one can see how, previously to this patch, kernel32.dll would import a dozen functions from itself (all the non-existing functions).
To really seal the deal, the behavior of exported functions used by kernel32, but that are actually forwarded to another DLL deserves a special mention.
GetLastError, for example, merely forwards to RtlGetLastWin32Error, so it is normal behavior to use a #define in the C code so that all internal calls to the function are routed correctly.
This did not happen, so instead, kernel32 tried importing/linking/exporting GetLastError, but this symbol is not found in the binary, because it is only a forwarder.
This caused kernel32 to import from itself (the behavior when an exported symbol is not found). When importing from itself, the loader would now find the _forwarded_ for GetLastError, and correctly link with ntdll.
What should be a one-liner of assembly (inline TEB access) thus became a triple-call indirection (GetLastError@0->StubLastError@0->__impGetLastError@0->__impRtlGetLastWin32Error->RtlGetLastWin32Error.
While analyzing these issues, we also realized a strange macro SetLastErrorByStatus that manually tried to perform what there already exists a function for: RtlSetLastNtStatusFromWin32Error.
And, in an exciting coda, we also realized that our Server 2003 Kernel32 exports more than a dozen Windows 95 APIs, through an auto-stub generation mechanism within winebuild, that gets linked as an object behind the scenes.
[KERNEL32]: Removed all Win95 exports, cleaned up exports.
[KERNEL32]: Fixed up set/get error macros by making them inline and/or calling the correct ntdll function.
[KERNEL32]: Removed bizare calls to Wine-internal/specific APIs from our core Win32 DLL.
[KERNEL32]: Wrote stubs for all functions which should be exported, and set the correct number of parameters for them.
[KERNEL32]: Kernel32 is smaller, loads faster, does not export Windows 95 functions, does not export non-existing functions, and does not import from itself anymore.
Note: This is one of the many failings of RBUILD the CMAKE system has helped us discover. I believe these issues are serious enough to warrant an immediate sync with trunk, but rest assured, there are many more completely broken, infinitely-regressing things that we discovered while switching to CMAKE.
svn path=/trunk/; revision=48475
2010-08-07 05:02:58 +00:00
|
|
|
#define NDEBUG
|
|
|
|
#include <debug.h>
|
2010-09-21 17:14:22 +00:00
|
|
|
DEBUG_CHANNEL(kernel32file);
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
/* FUNCTIONS ****************************************************************/
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2005-05-06 14:02:45 +00:00
|
|
|
WriteFile(IN HANDLE hFile,
|
|
|
|
IN LPCVOID lpBuffer,
|
2013-06-30 18:48:45 +00:00
|
|
|
IN DWORD nNumberOfBytesToWrite OPTIONAL,
|
2019-01-05 09:50:11 +00:00
|
|
|
OUT LPDWORD lpNumberOfBytesWritten,
|
2013-06-30 18:48:45 +00:00
|
|
|
IN LPOVERLAPPED lpOverlapped OPTIONAL)
|
1999-04-14 00:52:19 +00:00
|
|
|
{
|
2013-06-30 18:48:45 +00:00
|
|
|
NTSTATUS Status;
|
2000-03-22 18:36:00 +00:00
|
|
|
|
2013-08-29 20:37:02 +00:00
|
|
|
TRACE("WriteFile(hFile %p)\n", hFile);
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (lpNumberOfBytesWritten != NULL) *lpNumberOfBytesWritten = 0;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
hFile = TranslateStdHandle(hFile);
|
2008-08-04 17:08:52 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (IsConsoleHandle(hFile))
|
|
|
|
{
|
|
|
|
return WriteConsoleA(hFile,
|
2005-05-06 14:02:45 +00:00
|
|
|
lpBuffer,
|
|
|
|
nNumberOfBytesToWrite,
|
|
|
|
lpNumberOfBytesWritten,
|
|
|
|
lpOverlapped);
|
2013-06-30 18:48:45 +00:00
|
|
|
}
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (lpOverlapped != NULL)
|
|
|
|
{
|
2005-05-06 14:02:45 +00:00
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
PVOID ApcContext;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2005-05-06 14:02:45 +00:00
|
|
|
Offset.u.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.u.HighPart = lpOverlapped->OffsetHigh;
|
2013-06-30 18:48:45 +00:00
|
|
|
lpOverlapped->Internal = STATUS_PENDING;
|
|
|
|
ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
Status = NtWriteFile(hFile,
|
2005-05-06 14:02:45 +00:00
|
|
|
lpOverlapped->hEvent,
|
|
|
|
NULL,
|
|
|
|
ApcContext,
|
|
|
|
(PIO_STATUS_BLOCK)lpOverlapped,
|
|
|
|
(PVOID)lpBuffer,
|
|
|
|
nNumberOfBytesToWrite,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* return FALSE in case of failure and pending operations! */
|
|
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
|
|
|
if (lpNumberOfBytesWritten != NULL)
|
2013-06-30 18:48:45 +00:00
|
|
|
*lpNumberOfBytesWritten = lpOverlapped->InternalHigh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-06 14:02:45 +00:00
|
|
|
IO_STATUS_BLOCK Iosb;
|
2005-05-09 01:46:57 +00:00
|
|
|
|
2005-05-06 14:02:45 +00:00
|
|
|
Status = NtWriteFile(hFile,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&Iosb,
|
|
|
|
(PVOID)lpBuffer,
|
|
|
|
nNumberOfBytesToWrite,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
1999-05-29 00:15:17 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
/* Wait in case operation is pending */
|
2005-05-06 14:02:45 +00:00
|
|
|
if (Status == STATUS_PENDING)
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
Status = NtWaitForSingleObject(hFile, FALSE, NULL);
|
|
|
|
if (NT_SUCCESS(Status)) Status = Iosb.Status;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* lpNumberOfBytesWritten must not be NULL here, in fact Win doesn't
|
|
|
|
* check that case either and crashes (only after the operation
|
|
|
|
* completed).
|
|
|
|
*/
|
|
|
|
*lpNumberOfBytesWritten = Iosb.Information;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
else
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("WriteFile() succeeded\n");
|
|
|
|
return TRUE;
|
1999-04-14 00:52:19 +00:00
|
|
|
}
|
|
|
|
|
1999-10-02 20:20:44 +00:00
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2005-05-06 14:02:45 +00:00
|
|
|
ReadFile(IN HANDLE hFile,
|
|
|
|
IN LPVOID lpBuffer,
|
|
|
|
IN DWORD nNumberOfBytesToRead,
|
2013-06-30 18:48:45 +00:00
|
|
|
OUT LPDWORD lpNumberOfBytesRead OPTIONAL,
|
|
|
|
IN LPOVERLAPPED lpOverlapped OPTIONAL)
|
1999-04-14 00:52:19 +00:00
|
|
|
{
|
2013-06-30 18:48:45 +00:00
|
|
|
NTSTATUS Status;
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-08-29 20:37:02 +00:00
|
|
|
TRACE("ReadFile(hFile %p)\n", hFile);
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (lpNumberOfBytesRead != NULL) *lpNumberOfBytesRead = 0;
|
2009-11-11 08:29:08 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
hFile = TranslateStdHandle(hFile);
|
2008-08-04 17:08:52 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (IsConsoleHandle(hFile))
|
|
|
|
{
|
2009-08-02 18:56:05 +00:00
|
|
|
if (ReadConsoleA(hFile,
|
2013-06-30 18:48:45 +00:00
|
|
|
lpBuffer,
|
|
|
|
nNumberOfBytesToRead,
|
|
|
|
lpNumberOfBytesRead,
|
|
|
|
NULL))
|
|
|
|
{
|
|
|
|
DWORD dwMode;
|
|
|
|
GetConsoleMode(hFile, &dwMode);
|
|
|
|
if ((dwMode & ENABLE_PROCESSED_INPUT) && *(PCHAR)lpBuffer == 0x1a)
|
|
|
|
{
|
|
|
|
/* EOF character entered; simulate end-of-file */
|
|
|
|
*lpNumberOfBytesRead = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-08-02 18:56:05 +00:00
|
|
|
return FALSE;
|
2013-06-30 18:48:45 +00:00
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
if (lpOverlapped != NULL)
|
|
|
|
{
|
2005-05-06 14:02:45 +00:00
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
PVOID ApcContext;
|
|
|
|
|
|
|
|
Offset.u.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.u.HighPart = lpOverlapped->OffsetHigh;
|
2013-06-30 18:48:45 +00:00
|
|
|
lpOverlapped->Internal = STATUS_PENDING;
|
|
|
|
ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
Status = NtReadFile(hFile,
|
2005-05-06 14:02:45 +00:00
|
|
|
lpOverlapped->hEvent,
|
|
|
|
NULL,
|
|
|
|
ApcContext,
|
|
|
|
(PIO_STATUS_BLOCK)lpOverlapped,
|
|
|
|
lpBuffer,
|
|
|
|
nNumberOfBytesToRead,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* return FALSE in case of failure and pending operations! */
|
|
|
|
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
if (Status == STATUS_END_OF_FILE && lpNumberOfBytesRead != NULL)
|
|
|
|
*lpNumberOfBytesRead = 0;
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
|
|
|
if (lpNumberOfBytesRead != NULL)
|
2013-06-30 18:48:45 +00:00
|
|
|
*lpNumberOfBytesRead = lpOverlapped->InternalHigh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-06 14:02:45 +00:00
|
|
|
IO_STATUS_BLOCK Iosb;
|
|
|
|
|
|
|
|
Status = NtReadFile(hFile,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&Iosb,
|
|
|
|
lpBuffer,
|
|
|
|
nNumberOfBytesToRead,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
/* Wait in case operation is pending */
|
2005-05-06 14:02:45 +00:00
|
|
|
if (Status == STATUS_PENDING)
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
Status = NtWaitForSingleObject(hFile, FALSE, NULL);
|
|
|
|
if (NT_SUCCESS(Status)) Status = Iosb.Status;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
|
|
|
if (Status == STATUS_END_OF_FILE)
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
|
|
|
|
* check that case either and crashes (only after the operation
|
|
|
|
* completed).
|
|
|
|
*/
|
|
|
|
*lpNumberOfBytesRead = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
|
|
|
|
* check that case either and crashes (only after the operation
|
|
|
|
* completed).
|
|
|
|
*/
|
|
|
|
*lpNumberOfBytesRead = Iosb.Information;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
else
|
2013-06-30 18:48:45 +00:00
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("ReadFile() succeeded\n");
|
|
|
|
return TRUE;
|
1999-04-14 00:52:19 +00:00
|
|
|
}
|
|
|
|
|
2008-11-30 11:42:05 +00:00
|
|
|
VOID WINAPI
|
2005-05-09 01:46:57 +00:00
|
|
|
ApcRoutine(PVOID ApcContext,
|
2013-06-30 18:48:45 +00:00
|
|
|
PIO_STATUS_BLOCK IoStatusBlock,
|
|
|
|
ULONG Reserved)
|
1999-10-02 20:20:44 +00:00
|
|
|
{
|
2013-06-30 18:48:45 +00:00
|
|
|
DWORD dwErrorCode;
|
|
|
|
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine =
|
|
|
|
(LPOVERLAPPED_COMPLETION_ROUTINE)ApcContext;
|
|
|
|
|
|
|
|
dwErrorCode = RtlNtStatusToDosError(IoStatusBlock->Status);
|
|
|
|
lpCompletionRoutine(dwErrorCode,
|
|
|
|
IoStatusBlock->Information,
|
|
|
|
(LPOVERLAPPED)IoStatusBlock);
|
1999-10-02 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2005-05-06 14:02:45 +00:00
|
|
|
WriteFileEx(IN HANDLE hFile,
|
|
|
|
IN LPCVOID lpBuffer,
|
2013-06-30 18:48:45 +00:00
|
|
|
IN DWORD nNumberOfBytesToWrite OPTIONAL,
|
2005-05-06 14:02:45 +00:00
|
|
|
IN LPOVERLAPPED lpOverlapped,
|
|
|
|
IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
1999-04-14 00:52:19 +00:00
|
|
|
{
|
2013-06-30 18:48:45 +00:00
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Offset.u.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.u.HighPart = lpOverlapped->OffsetHigh;
|
|
|
|
lpOverlapped->Internal = STATUS_PENDING;
|
|
|
|
|
|
|
|
Status = NtWriteFile(hFile,
|
|
|
|
NULL,
|
|
|
|
ApcRoutine,
|
|
|
|
lpCompletionRoutine,
|
|
|
|
(PIO_STATUS_BLOCK)lpOverlapped,
|
|
|
|
(PVOID)lpBuffer,
|
|
|
|
nNumberOfBytesToWrite,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-05-06 14:02:45 +00:00
|
|
|
|
2013-06-30 18:48:45 +00:00
|
|
|
return TRUE;
|
1999-04-14 00:52:19 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 18:50:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2005-05-06 14:02:45 +00:00
|
|
|
ReadFileEx(IN HANDLE hFile,
|
|
|
|
IN LPVOID lpBuffer,
|
2013-06-30 18:48:45 +00:00
|
|
|
IN DWORD nNumberOfBytesToRead OPTIONAL,
|
2005-05-06 14:02:45 +00:00
|
|
|
IN LPOVERLAPPED lpOverlapped,
|
|
|
|
IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
1999-04-14 00:52:19 +00:00
|
|
|
{
|
2013-06-30 18:48:45 +00:00
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
Offset.u.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.u.HighPart = lpOverlapped->OffsetHigh;
|
|
|
|
lpOverlapped->Internal = STATUS_PENDING;
|
|
|
|
|
|
|
|
Status = NtReadFile(hFile,
|
|
|
|
NULL,
|
|
|
|
ApcRoutine,
|
|
|
|
lpCompletionRoutine,
|
|
|
|
(PIO_STATUS_BLOCK)lpOverlapped,
|
|
|
|
lpBuffer,
|
|
|
|
nNumberOfBytesToRead,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
BaseSetLastNTError(Status);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
1999-04-14 00:52:19 +00:00
|
|
|
}
|
2000-01-11 17:32:13 +00:00
|
|
|
|
2011-11-07 00:18:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
ReadFileScatter(HANDLE hFile,
|
|
|
|
FILE_SEGMENT_ELEMENT aSegmentArray[],
|
|
|
|
DWORD nNumberOfBytesToRead,
|
|
|
|
LPDWORD lpReserved,
|
|
|
|
LPOVERLAPPED lpOverlapped)
|
|
|
|
{
|
|
|
|
PIO_STATUS_BLOCK pIOStatus;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("(%p %p %u %p)\n", hFile, aSegmentArray, nNumberOfBytesToRead, lpOverlapped);
|
|
|
|
|
|
|
|
Offset.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.HighPart = lpOverlapped->OffsetHigh;
|
|
|
|
pIOStatus = (PIO_STATUS_BLOCK) lpOverlapped;
|
|
|
|
pIOStatus->Status = STATUS_PENDING;
|
|
|
|
pIOStatus->Information = 0;
|
|
|
|
|
|
|
|
Status = NtReadFileScatter(hFile,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
pIOStatus,
|
|
|
|
aSegmentArray,
|
|
|
|
nNumberOfBytesToRead,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
WriteFileGather(HANDLE hFile,
|
|
|
|
FILE_SEGMENT_ELEMENT aSegmentArray[],
|
|
|
|
DWORD nNumberOfBytesToWrite,
|
|
|
|
LPDWORD lpReserved,
|
|
|
|
LPOVERLAPPED lpOverlapped)
|
|
|
|
{
|
|
|
|
PIO_STATUS_BLOCK IOStatus;
|
|
|
|
LARGE_INTEGER Offset;
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
DPRINT("%p %p %u %p\n", hFile, aSegmentArray, nNumberOfBytesToWrite, lpOverlapped);
|
|
|
|
|
|
|
|
Offset.LowPart = lpOverlapped->Offset;
|
|
|
|
Offset.HighPart = lpOverlapped->OffsetHigh;
|
|
|
|
IOStatus = (PIO_STATUS_BLOCK) lpOverlapped;
|
|
|
|
IOStatus->Status = STATUS_PENDING;
|
|
|
|
IOStatus->Information = 0;
|
|
|
|
|
|
|
|
Status = NtWriteFileGather(hFile,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
IOStatus,
|
|
|
|
aSegmentArray,
|
|
|
|
nNumberOfBytesToWrite,
|
|
|
|
&Offset,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastError(RtlNtStatusToDosError(Status));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-01-11 17:32:13 +00:00
|
|
|
/* EOF */
|