ReactOS  0.4.12-dev-919-gfc3b8d5
rw.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for rw.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 DEBUG_CHANNEL (kernel32file)
 
BOOL WINAPI WriteFile (IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
 
BOOL WINAPI ReadFile (IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
 
VOID WINAPI ApcRoutine (PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
 
BOOL WINAPI WriteFileEx (IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
BOOL WINAPI ReadFileEx (IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead OPTIONAL, IN LPOVERLAPPED lpOverlapped, IN LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
BOOL WINAPI ReadFileScatter (HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], DWORD nNumberOfBytesToRead, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
 
BOOL WINAPI WriteFileGather (HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file rw.c.

Function Documentation

◆ ApcRoutine()

VOID WINAPI ApcRoutine ( PVOID  ApcContext,
PIO_STATUS_BLOCK  IoStatusBlock,
ULONG  Reserved 
)

Definition at line 243 of file rw.c.

246 {
247  DWORD dwErrorCode;
248  LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine =
250 
252  lpCompletionRoutine(dwErrorCode,
255 }
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:719
unsigned long DWORD
Definition: ntddk_ex.h:95
void(CALLBACK * LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD, DWORD, LPOVERLAPPED)
Definition: winbase.h:1404
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by ReadFileEx(), and WriteFileEx().

◆ DEBUG_CHANNEL()

DEBUG_CHANNEL ( kernel32file  )

◆ ReadFile()

BOOL WINAPI ReadFile ( IN HANDLE  hFile,
IN LPVOID  lpBuffer,
IN DWORD  nNumberOfBytesToRead,
OUT LPDWORD lpNumberOfBytesRead  OPTIONAL,
IN LPOVERLAPPED lpOverlapped  OPTIONAL 
)

Definition at line 123 of file rw.c.

128 {
130 
131  TRACE("ReadFile(hFile %p)\n", hFile);
132 
133  if (lpNumberOfBytesRead != NULL) *lpNumberOfBytesRead = 0;
134 
136 
137  if (IsConsoleHandle(hFile))
138  {
139  if (ReadConsoleA(hFile,
140  lpBuffer,
141  nNumberOfBytesToRead,
142  lpNumberOfBytesRead,
143  NULL))
144  {
145  DWORD dwMode;
146  GetConsoleMode(hFile, &dwMode);
147  if ((dwMode & ENABLE_PROCESSED_INPUT) && *(PCHAR)lpBuffer == 0x1a)
148  {
149  /* EOF character entered; simulate end-of-file */
150  *lpNumberOfBytesRead = 0;
151  }
152  return TRUE;
153  }
154  return FALSE;
155  }
156 
157  if (lpOverlapped != NULL)
158  {
161 
162  Offset.u.LowPart = lpOverlapped->Offset;
163  Offset.u.HighPart = lpOverlapped->OffsetHigh;
164  lpOverlapped->Internal = STATUS_PENDING;
165  ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
166 
168  lpOverlapped->hEvent,
169  NULL,
170  ApcContext,
172  lpBuffer,
173  nNumberOfBytesToRead,
174  &Offset,
175  NULL);
176 
177  /* return FALSE in case of failure and pending operations! */
179  {
180  if (Status == STATUS_END_OF_FILE && lpNumberOfBytesRead != NULL)
181  *lpNumberOfBytesRead = 0;
182 
184  return FALSE;
185  }
186 
187  if (lpNumberOfBytesRead != NULL)
188  *lpNumberOfBytesRead = lpOverlapped->InternalHigh;
189  }
190  else
191  {
193 
195  NULL,
196  NULL,
197  NULL,
198  &Iosb,
199  lpBuffer,
200  nNumberOfBytesToRead,
201  NULL,
202  NULL);
203 
204  /* Wait in case operation is pending */
205  if (Status == STATUS_PENDING)
206  {
208  if (NT_SUCCESS(Status)) Status = Iosb.Status;
209  }
210 
211  if (Status == STATUS_END_OF_FILE)
212  {
213  /*
214  * lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
215  * check that case either and crashes (only after the operation
216  * completed).
217  */
218  *lpNumberOfBytesRead = 0;
219  return TRUE;
220  }
221 
222  if (NT_SUCCESS(Status))
223  {
224  /*
225  * lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
226  * check that case either and crashes (only after the operation
227  * completed).
228  */
229  *lpNumberOfBytesRead = Iosb.Information;
230  }
231  else
232  {
234  return FALSE;
235  }
236  }
237 
238  TRACE("ReadFile() succeeded\n");
239  return TRUE;
240 }
signed char * PCHAR
Definition: retypes.h:7
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:719
#define TRUE
Definition: types.h:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
LONG NTSTATUS
Definition: precomp.h:26
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
#define STATUS_END_OF_FILE
Definition: shellext.h:62
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define TRACE(s)
Definition: solgame.cpp:4
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL)
Definition: readwrite.c:1197
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
#define ULONG_PTR
Definition: config.h:101
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by _chm_fetch_bytes(), _fgets(), _hread(), _overlapped_read_async(), _overlapped_read_sync(), _RunRemoteTest(), _tiffReadProc(), add_cabinet_storage(), BatchFile2Mem(), cabinet_read(), cfgets(), check_binary_file_data(), check_bom(), check_file_matches(), check_version(), CheckTestFile(), ClientSideInstallW(), ClipboardReadMemoryBlock(), cmd_type(), CmosInitialize(), compare_file2(), compare_file_(), compare_file_data(), compare_files(), compare_mf_disk_bits(), compare_pf_data(), compareFiles(), ConInString(), copy(), create_stream(), create_stream_on_file(), CRYPT_GetObjectFromFile(), CRYPT_ReadBlobFromFile(), CryptCATAdminCalcHashFromFileHandle(), CryptCATOpen(), CryptSIPRetrieveSubjectGuid(), d3dx_include_from_file_open(), detect_compression_type(), DllMain(), BtrfsRecv::do_recv(), doChild(), DoImport(), DoOpenFile(), DosReadFile(), CShellCommandSetValue::Execute(), exercizeServer(), ExtractZipImage(), ExtractZipInfo(), fci_read(), fdi_read(), file_has_content(), file_matches(), file_matches_data(), ATL::CRegObject::file_register(), file_register(), FileAsyncReader_Request(), FileAsyncReader_SyncRead(), FileGetString(), FileLoadByHandle(), FileLockBytesImpl_ReadAt(), FileProtocol_Read(), FindEntryInHosts(), FNREAD(), FTP_SendData(), getpass(), GetProtoGetNextEnt(), HANDLE_CustomType21_22(), ImageAddCertificate(), ImageEnumerateCertificates(), ImageGetCertificateData(), ImageGetCertificateHeader(), IMAGEHLP_GetCertificateOffset(), IMAGEHLP_GetNTHeaders(), ImageRemoveCertificate(), inf_load(), InitFont(), InstanceThread(), InternalGetBinaryType(), InternalIsOS2OrOldWin(), IStream_fnRead(), load_blackbox(), load_profile(), load_script(), load_ttf_name_id(), LoadCodePageData(), LoadDIBImage(), CJournaledTestList::LoadJournalFile(), LoadTextFileToEdit(), LocalmonReadPort(), LocalReadPrinter(), mailslot_test(), MailSlotReader(), main(), MF_ReadMetaFile(), MountHDD(), msi_read_text_archive(), named_pipe_client_func(), NLS_ReadFile(), NSP_GetServiceByNameHeapAllocW(), OLECONVERT_WriteOLE20ToBuffer(), open_file_test(), open_wav(), OpenColorProfileW(), overlapped_server(), pipe_thread(), pipeClient(), PipeReadThread(), pipeServer(), PipeThreadProc(), print_something(), process_stabs(), PROFILE_Load(), ProtocolStream_Read(), r_verify_inifile(), CPipe::Read(), read_file(), read_file_data(), read_file_to_bstr(), read_file_wrapper(), read_i(), read_pipe(), read_utf8(), ReadAndHandleOutput(), ReadClipboardFile(), ReadCommand(), ReadDisk(), ReadFromConsole(), ReadFromPipeThread(), ReadJobShadowFile(), ReadLines(), ReadRdpFile(), TNetwork::ReadString(), ReadText(), ReadUrlCacheEntryStream(), ReadVolumeSector(), RECORD_StreamFromFile(), BtrfsContextMenu::reflink_copy(), reflink_copy2(), replace(), RetrieveQuote(), RPC_GetLocalClassObject(), rpcThreadMain(), Rs232ReadByteWin32(), RunBookmarkEditor(), sc_cb_read(), ScmControlService(), ScmSendStartCommand(), ScmWaitForServiceConnect(), ScServiceDispatcher(), CHttpClient::SendFile(), sendmail_extended_mapi(), serverThreadMain1(), serverThreadMain2(), serverThreadMain3(), serverThreadMain4(), shgfi_get_exe_type(), SOFTPUB_HashPEFile(), StgIsStorageFile(), stream_in(), tcp_recv(), telProcessConsole(), test_CloseHandle(), Test_CommandLine(), test_Console(), test_CopyFile2(), test_CopyFileA(), test_create_typelib_lcid(), test_CreateFileA(), test_CreateNamedPipe(), test_CreatePipe(), test_DisconnectNamedPipe(), test_file_access(), test_file_security(), test_filter_graph(), test_ImpersonateNamedPipeClient(), test_iocp_fileio(), test_LoopbackRead(), test_LZCopy(), test_msiexport(), test_null_device(), test_offset_in_overlapped_structure(), test_OpenFileById(), test_overlapped_transport(), test_read_device(), test_read_write(), test_ReadConsole(), test_ReadFile(), test_readfileex_pending(), test_readonlyfile_cab(), test_ReadTimeOut(), test_RealizationInfo(), test_riff_write(), test_save(), test_write_watch(), test_WriteLine(), textstream_read(), UDFPhReadSynchronous(), VfdOpenImage(), VfdSaveImage(), win32_read_file_func(), WINTRUST_GetSignedMsgFromCabFile(), WINTRUST_GetSignedMsgFromCatFile(), wmain(), XCOPY_DoCopy(), and XCOPY_ProcessDestParm().

◆ ReadFileEx()

BOOL WINAPI ReadFileEx ( IN HANDLE  hFile,
IN LPVOID  lpBuffer,
IN DWORD nNumberOfBytesToRead  OPTIONAL,
IN LPOVERLAPPED  lpOverlapped,
IN LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 299 of file rw.c.

304 {
307 
308  Offset.u.LowPart = lpOverlapped->Offset;
309  Offset.u.HighPart = lpOverlapped->OffsetHigh;
310  lpOverlapped->Internal = STATUS_PENDING;
311 
313  NULL,
314  ApcRoutine,
315  lpCompletionRoutine,
317  lpBuffer,
318  nNumberOfBytesToRead,
319  &Offset,
320  NULL);
321 
322  if (!NT_SUCCESS(Status))
323  {
325  return FALSE;
326  }
327 
328  return TRUE;
329 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
VOID WINAPI ApcRoutine(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
Definition: rw.c:243
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)

Referenced by pipeserver(), ReadPipeCompletion(), serverThreadMain5(), test_async_file_errors(), test_readfileex_pending(), and WdmAudCommitWaveBufferByLegacy().

◆ ReadFileScatter()

BOOL WINAPI ReadFileScatter ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToRead,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)

Definition at line 337 of file rw.c.

342 {
343  PIO_STATUS_BLOCK pIOStatus;
346 
347  DPRINT("(%p %p %u %p)\n", hFile, aSegmentArray, nNumberOfBytesToRead, lpOverlapped);
348 
349  Offset.LowPart = lpOverlapped->Offset;
350  Offset.HighPart = lpOverlapped->OffsetHigh;
351  pIOStatus = (PIO_STATUS_BLOCK) lpOverlapped;
352  pIOStatus->Status = STATUS_PENDING;
353  pIOStatus->Information = 0;
354 
356  NULL,
357  NULL,
358  NULL,
359  pIOStatus,
360  aSegmentArray,
361  nNumberOfBytesToRead,
362  &Offset,
363  NULL);
364 
365  if (!NT_SUCCESS(Status))
366  {
368  return FALSE;
369  }
370 
371  return TRUE;
372 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtReadFileScatter(IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK UserIoStatusBlock, IN FILE_SEGMENT_ELEMENT BufferDescription [], IN ULONG BufferLength, IN PLARGE_INTEGER ByteOffset, IN PULONG Key OPTIONAL)
Definition: iofunc.c:2901
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define SetLastError(x)
Definition: compat.h:409
struct _IO_STATUS_BLOCK * PIO_STATUS_BLOCK
Definition: change.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90

Referenced by test_WriteFileGather().

◆ WriteFile()

BOOL WINAPI WriteFile ( IN HANDLE  hFile,
IN LPCVOID  lpBuffer,
IN DWORD nNumberOfBytesToWrite  OPTIONAL,
OUT LPDWORD  lpNumberOfBytesWritten,
IN LPOVERLAPPED lpOverlapped  OPTIONAL 
)

Definition at line 24 of file rw.c.

29 {
31 
32  TRACE("WriteFile(hFile %p)\n", hFile);
33 
34  if (lpNumberOfBytesWritten != NULL) *lpNumberOfBytesWritten = 0;
35 
37 
39  {
40  return WriteConsoleA(hFile,
41  lpBuffer,
43  lpNumberOfBytesWritten,
44  lpOverlapped);
45  }
46 
47  if (lpOverlapped != NULL)
48  {
51 
52  Offset.u.LowPart = lpOverlapped->Offset;
53  Offset.u.HighPart = lpOverlapped->OffsetHigh;
54  lpOverlapped->Internal = STATUS_PENDING;
55  ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
56 
58  lpOverlapped->hEvent,
59  NULL,
60  ApcContext,
62  (PVOID)lpBuffer,
64  &Offset,
65  NULL);
66 
67  /* return FALSE in case of failure and pending operations! */
69  {
71  return FALSE;
72  }
73 
74  if (lpNumberOfBytesWritten != NULL)
75  *lpNumberOfBytesWritten = lpOverlapped->InternalHigh;
76  }
77  else
78  {
80 
82  NULL,
83  NULL,
84  NULL,
85  &Iosb,
86  (PVOID)lpBuffer,
88  NULL,
89  NULL);
90 
91  /* Wait in case operation is pending */
92  if (Status == STATUS_PENDING)
93  {
95  if (NT_SUCCESS(Status)) Status = Iosb.Status;
96  }
97 
98  if (NT_SUCCESS(Status))
99  {
100  /*
101  * lpNumberOfBytesWritten must not be NULL here, in fact Win doesn't
102  * check that case either and crashes (only after the operation
103  * completed).
104  */
105  *lpNumberOfBytesWritten = Iosb.Information;
106  }
107  else
108  {
110  return FALSE;
111  }
112  }
113 
114  TRACE("WriteFile() succeeded\n");
115  return TRUE;
116 }
_In_opt_ HANDLE _In_opt_ PIO_APC_ROUTINE _In_opt_ PVOID ApcContext
Definition: iofuncs.h:719
#define TRUE
Definition: types.h:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LONG NTSTATUS
Definition: precomp.h:26
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleA(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved)
Definition: readwrite.c:1470
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define TRACE(s)
Definition: solgame.cpp:4
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IsConsoleHandle(h)
Definition: console.h:14
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
#define ULONG_PTR
Definition: config.h:101
_In_ HANDLE _In_ DWORD nNumberOfBytesToWrite
Definition: mswsock.h:90
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)

Referenced by __report_error(), _hwrite(), _overlapped_write_async(), _overlapped_write_sync(), _putch(), _RunRemoteTest(), _tiffWriteProc(), _write(), _wsopen_s(), append_file(), ata_bblk(), BackupBootSector(), BestFit_CreateFile(), BestFit_Write(), build_exe(), cabinet_write(), child_process(), ClipboardWriteMemory(), CloseEnhMetaFile(), BtrfsRecv::cmd_setxattr(), cmd_type(), BtrfsRecv::cmd_write(), CmosCleanup(), ConErrPrintf(), ConOutPuts(), ConWrite(), copy(), CopyEnhMetaFileA(), CopyEnhMetaFileW(), CopyMetaFileW(), create_and_write_file(), create_assembly(), create_avi_file(), create_bitmap(), create_cache_entry(), create_cache_file(), create_cdf_file(), create_chm(), create_fake_dll(), create_file(), create_file_data(), create_ico_file(), create_inf_file(), create_manifest_file(), create_source_file(), create_source_fileA(), create_source_fileW(), create_temp_binary(), create_temp_file(), create_test_dll(), create_test_dll_sections(), create_test_file(), create_testfontfile(), create_textstream(), create_tmp_ini_file(), create_xml_file(), CreateEnhMetaFileW(), CreateMetaFileW(), CNewMenu::CreateNewItem(), CreateTestFile(), createTestFile(), CRYPT_CacheURL(), CRYPT_FileOutputFunc(), CRYPT_SavePKCSToFile(), doChild(), DoEntry(), DoExport(), DoFileSave(), DoSaveFile(), DosWriteFile(), DoWriteFile(), dump_memory_info(), dump_system_info(), DumpMemoryRaw(), DumpMemoryTxt(), EMFDRV_WriteRecord(), EnumThreadProc(), CShellCommandValue::Execute(), exercizeServer(), ExtCabCallback(), CZipExtract::Extract(), extract2(), extract_one(), extract_resource(), ExtractTTFFile(), fci_write(), fdi_write(), FileLockBytesImpl_WriteAt(), FNWRITE(), FormatOutput(), FTP_RetrieveFileData(), FTPFILE_ReadFile(), Generate(), GetAndSendInputThread(), getpass(), ICreateTypeLib2_fnSaveAllChanges(), IDirectXFileImpl_CreateEnumObject(), IDirectXFileImpl_RegisterTemplates(), ImageAddCertificate(), IMAGEHLP_RecalculateChecksum(), IMAGEHLP_SetSecurityDirOffset(), ImageRemoveCertificate(), inf_open_file_content(), initFileFromData(), InitLogging(), InstallDevice(), InstanceThread(), IStream_fnWrite(), ITERATE_PublishIcon(), load_resource(), load_v6_module(), local_server_thread(), LocalmonWritePort(), LocalWritePrinter(), LogToFile(), mailslot_test(), MailSlotWriter(), main(), make_tmp_file(), makeFile(), MFDRV_CloseMetaFile(), MFDRV_WriteRecord(), msi_export_field(), msi_export_forcecodepage(), msi_export_record(), msi_export_stream(), msi_export_summaryinformation(), MSI_ProcessMessageVerbatim(), myprintf(), named_pipe_client_func(), OLECONVERT_GetOLE20FromOLE10(), open_file_test(), output_header(), output_string(), output_writeconsole(), OutputResult(), TANSIParser::ParseBuffer(), PersistFile_Save(), PipeSend(), print_string(), printit(), process_stabs(), PROFILE_WriteLine(), PROFILE_WriteMarker(), pSetupDebugPrint(), read_http_stream(), read_pipe_test(), RecycleBin5_Create(), BtrfsContextMenu::reflink_copy(), reflink_copy2(), RemoveFile(), replace(), Rs232Thread(), Rs232WriteByteWin32(), WriterThread::Run(), run_cmd(), run_script(), save_base64(), save_blackbox(), save_der(), save_persistent_cookie(), save_pfx(), save_profile(), save_prop(), SaveServicesToFile(), SaveTextFileFromEdit(), sc_cb_write(), ScConnectControlPipe(), ScmControlService(), ScmSendStartCommand(), ScServiceDispatcher(), send_msg(), send_subvol(), CJournaledTestList::SerializeIntoJournal(), serverThreadMain1(), serverThreadMain2(), serverThreadMain3(), serverThreadMain4(), SetupLogErrorA(), stream_out(), taskkill_vprintfW(), tcp_send(), TerminateShell(), test_AtlAxCreateControl(), test_ax_win(), test_bind_image_ex(), test_cache_read(), test_calchash(), test_catalog_properties(), test_CloseHandle(), test_completion(), test_Console(), test_CopyFile2(), test_CopyFileA(), test_create_catalog_file(), test_create_db_imp(), test_create_exe_imp(), test_create_file_imp(), test_create_ne_imp(), test_CreateFile(), test_CreateNamedPipe(), test_CreatePipe(), test_CryptCATAdminAddRemoveCatalog(), test_dib_bits_access(), test_DisconnectNamedPipe(), test_domdoc(), test_ExitProcess(), test_file_access(), test_file_completion_information(), test_file_contents(), test_file_protocol(), test_FileSecurity(), test_filesourcefilter(), test_FindFirstChangeNotification(), test_FlushFileBuffers(), test_get_digest_stream(), test_get_inf_class(), test_get_osfhandle(), test_GetFileInformationByHandleEx(), test_http_cache(), test_image_load(), test_ImpersonateNamedPipeClient(), test_import_resolution(), test_int_widths(), test_iocp_callback(), test_iocp_fileio(), test_ITextDocument_Open(), test_LoadIconWithScaleDown(), test_LoadImageFile(), test_LocalizedNames(), test_LockFile(), test_LoopbackRead(), test_LZCopy(), test_LZRead(), test_mhtml_protocol_binding(), test_monochrome_icon(), test_MoveFileA(), test_NtMapViewOfSection(), test_null_device(), test_offset_in_overlapped_structure(), test_OleLoadPicturePath(), test_openbackup(), test_OpenFileById(), test_overlapped(), test_profile_delete_on_close(), test_profile_existing(), test_profile_refresh(), test_profile_sections(), test_profile_sections_names(), test_profile_string(), test_query_recyclebin(), test_read_write(), test_ReadFile(), test_readfileex_pending(), test_readonlyfile(), test_readonlyfile_cab(), test_ReplaceFileA(), test_ResolveDelayLoadedAPI(), test_saxreader(), test_saxreader_encoding(), test_section_access(), Test_SectionContents(), test_SetFileValidData(), test_sip(), test_sip_create_indirect_data(), test_SIPRetrieveSubjectGUID(), test_textstream(), test_TransformWithLoadingLocalFile(), Test_Truncate(), test_WaitRx(), test_waittxempty(), test_wintrust_digest(), test_write_watch(), textstream_writecrlf(), textstream_writestr(), BtrfsSend::Thread(), CDownloadManager::ThreadFunc(), transfer_file_http(), translateinfstringex_test(), UDFPhWriteSynchronous(), unpack_avi_file(), CJournaledTestList::UpdateJournal(), VfdCreateImageFile(), VfdFormatMedia(), VfdOpenImage(), VfdSaveImage(), win32_write_file_func(), WINETEST_PRINTF_ATTR(), WMSFT_write_segment(), CPipe::Write(), Write(), write_bitmap(), write_buffer_to_file(), write_file(), write_inifile(), write_manifest(), write_raw_file(), write_tmp_file(), write_to_file(), write_typelib(), write_wav(), writeat(), WriteClipboardFile(), WriteDisk(), WriteEncodedText(), CJournaledTestList::WriteInitialJournalFile(), WriteJobShadowFile(), WritePrinter(), WriteRdpFile(), WriteSdbFile(), TNetwork::WriteString(), WriteToLog(), WriteToPipeThread(), WriteVolumeSector(), wWinMain(), and XCOPY_wprintf().

◆ WriteFileEx()

BOOL WINAPI WriteFileEx ( IN HANDLE  hFile,
IN LPCVOID  lpBuffer,
IN DWORD nNumberOfBytesToWrite  OPTIONAL,
IN LPOVERLAPPED  lpOverlapped,
IN LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Definition at line 262 of file rw.c.

267 {
270 
271  Offset.u.LowPart = lpOverlapped->Offset;
272  Offset.u.HighPart = lpOverlapped->OffsetHigh;
273  lpOverlapped->Internal = STATUS_PENDING;
274 
276  NULL,
277  ApcRoutine,
278  lpCompletionRoutine,
280  (PVOID)lpBuffer,
282  &Offset,
283  NULL);
284 
285  if (!NT_SUCCESS(Status))
286  {
288  return FALSE;
289  }
290 
291  return TRUE;
292 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
VOID WINAPI ApcRoutine(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved)
Definition: rw.c:243
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSYSAPI NTSTATUS NTAPI NtWriteFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID WriteBuffer, IN ULONG WriteBufferLength, IN PLARGE_INTEGER FileOffset OPTIONAL, IN PULONG LockOperationKey OPTIONAL)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
_In_ HANDLE _In_ DWORD nNumberOfBytesToWrite
Definition: mswsock.h:90

Referenced by ReadPipeCompletion(), serverThreadMain5(), test_readfileex_pending(), WdmAudCommitWaveBufferByLegacy(), WriteFileEx_Committer(), and WriteFileEx_Remixer().

◆ WriteFileGather()

BOOL WINAPI WriteFileGather ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)

Definition at line 379 of file rw.c.

384 {
385  PIO_STATUS_BLOCK IOStatus;
388 
389  DPRINT("%p %p %u %p\n", hFile, aSegmentArray, nNumberOfBytesToWrite, lpOverlapped);
390 
391  Offset.LowPart = lpOverlapped->Offset;
392  Offset.HighPart = lpOverlapped->OffsetHigh;
393  IOStatus = (PIO_STATUS_BLOCK) lpOverlapped;
394  IOStatus->Status = STATUS_PENDING;
395  IOStatus->Information = 0;
396 
398  NULL,
399  NULL,
400  NULL,
401  IOStatus,
402  aSegmentArray,
404  &Offset,
405  NULL);
406 
407  if (!NT_SUCCESS(Status))
408  {
410  return FALSE;
411  }
412 
413  return TRUE;
414 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define SetLastError(x)
Definition: compat.h:409
struct _IO_STATUS_BLOCK * PIO_STATUS_BLOCK
Definition: change.c:34
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED lpOverlapped
Definition: mswsock.h:90
NTSTATUS NTAPI NtWriteFileGather(IN HANDLE FileHandle, IN HANDLE Event OPTIONAL, IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL, IN PVOID UserApcContext OPTIONAL, OUT PIO_STATUS_BLOCK UserIoStatusBlock, IN FILE_SEGMENT_ELEMENT BufferDescription [], IN ULONG BufferLength, IN PLARGE_INTEGER ByteOffset, IN PULONG Key OPTIONAL)
Definition: iofunc.c:3957
_In_ HANDLE _In_ DWORD nNumberOfBytesToWrite
Definition: mswsock.h:90

Referenced by test_WriteFileGather().