ReactOS 0.4.16-dev-297-gc569aee
utils.h File Reference

Go to the source code of this file.

Functions

VOID FileClose (IN HANDLE FileHandle)
 
HANDLE FileOpen (IN PCSTR FileName, OUT PULONG FileSize OPTIONAL)
 
BOOLEAN FileLoadByHandle (IN HANDLE FileHandle, IN PVOID Location, IN ULONG FileSize, OUT PULONG BytesRead)
 

Function Documentation

◆ FileClose()

VOID FileClose ( IN HANDLE  FileHandle)

Definition at line 21 of file utils.c.

22{
24}
#define CloseHandle
Definition: compat.h:739
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231

Referenced by DemLoadNTDOSKernel(), DosInitialize(), FileOpen(), LoadBios(), LoadRom(), MountDisk(), OpenRomFile(), and UnmountDisk().

◆ FileLoadByHandle()

BOOLEAN FileLoadByHandle ( IN HANDLE  FileHandle,
IN PVOID  Location,
IN ULONG  FileSize,
OUT PULONG  BytesRead 
)

Definition at line 69 of file utils.c.

73{
75
76 /* Attempt to load the file into memory */
77 SetLastError(0); // For debugging purposes
79 Location, // REAL_TO_PHYS(LocationRealPtr),
82 NULL);
83 DPRINT1("File loading %s ; GetLastError() = %u\n", Success ? "succeeded" : "failed", GetLastError());
84
85 return Success;
86}
unsigned char BOOLEAN
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetLastError(x)
Definition: compat.h:752
@ Success
Definition: eventcreate.c:712
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by DemLoadNTDOSKernel(), DosInitialize(), and LoadRomFileByHandle().

◆ FileOpen()

HANDLE FileOpen ( IN PCSTR  FileName,
OUT PULONG FileSize  OPTIONAL 
)

Definition at line 27 of file utils.c.

29{
31 ULONG ulFileSize;
32
33 /* Open the file */
34 SetLastError(0); // For debugging purposes
38 NULL,
41 NULL);
42 DPRINT1("File '%s' opening %s ; GetLastError() = %u\n",
43 FileName, hFile != INVALID_HANDLE_VALUE ? "succeeded" : "failed", GetLastError());
44
45 /* If we failed, bail out */
46 if (hFile == INVALID_HANDLE_VALUE) return NULL;
47
48 /* OK, we have a handle to the file */
49
50 /*
51 * Retrieve the size of the file. In NTVDM we will handle files
52 * of maximum 1Mb so we can largely use GetFileSize only.
53 */
54 ulFileSize = GetFileSize(hFile, NULL);
55 if (ulFileSize == INVALID_FILE_SIZE && GetLastError() != ERROR_SUCCESS)
56 {
57 /* We failed, bail out */
58 DPRINT1("Error when retrieving file size, or size too large (%d)\n", ulFileSize);
60 return NULL;
61 }
62
63 /* Success, return file handle and size if needed */
64 if (FileSize) *FileSize = ulFileSize;
65 return hFile;
66}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define OPEN_EXISTING
Definition: compat.h:775
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
_In_ HANDLE hFile
Definition: mswsock.h:90
VOID FileClose(IN HANDLE FileHandle)
Definition: utils.c:21
uint32_t ULONG
Definition: typedefs.h:59
#define INVALID_FILE_SIZE
Definition: winbase.h:574

Referenced by DemLoadNTDOSKernel(), DosInitialize(), and OpenRomFile().