ReactOS 0.4.15-dev-7659-ga55345b
bootcode.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _BOOTCODE
 

Macros

#define SECTORSIZE   512
 

Typedefs

typedef struct _BOOTCODE BOOTCODE
 
typedef struct _BOOTCODEPBOOTCODE
 

Functions

NTSTATUS ReadBootCodeByHandle (IN OUT PBOOTCODE BootCodeInfo, IN HANDLE FileHandle, IN ULONG Length OPTIONAL)
 
NTSTATUS ReadBootCodeFromFile (IN OUT PBOOTCODE BootCodeInfo, IN PUNICODE_STRING FilePath, IN ULONG Length OPTIONAL)
 
VOID FreeBootCode (IN OUT PBOOTCODE BootCodeInfo)
 

Macro Definition Documentation

◆ SECTORSIZE

#define SECTORSIZE   512

Definition at line 13 of file bootcode.h.

Typedef Documentation

◆ BOOTCODE

◆ PBOOTCODE

Function Documentation

◆ FreeBootCode()

VOID FreeBootCode ( IN OUT PBOOTCODE  BootCodeInfo)

Definition at line 104 of file bootcode.c.

106{
107 ASSERT(BootCodeInfo);
108
109 /* Update the bootcode information */
110 if (BootCodeInfo->BootCode)
111 RtlFreeHeap(ProcessHeap, 0, BootCodeInfo->BootCode);
112 BootCodeInfo->BootCode = NULL;
113 BootCodeInfo->Length = 0;
114}
HANDLE ProcessHeap
Definition: servman.c:15
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define NULL
Definition: types.h:112
#define ASSERT(a)
Definition: mode.c:44

Referenced by InstallBtrfsBootCode(), InstallFat32BootCode(), InstallFatBootCode(), InstallMbrBootCode(), InstallNtfsBootCode(), IsThereAValidBootSector(), and SaveBootSector().

◆ ReadBootCodeByHandle()

NTSTATUS ReadBootCodeByHandle ( IN OUT PBOOTCODE  BootCodeInfo,
IN HANDLE  FileHandle,
IN ULONG Length  OPTIONAL 
)

Definition at line 21 of file bootcode.c.

25{
27 PVOID BootCode;
30
31 ASSERT(BootCodeInfo);
32
33 /* Normalize the bootcode length */
34 if (Length == 0 || Length == (ULONG)-1)
36
37 /* Allocate a buffer for the bootcode */
39 if (BootCode == NULL)
41
42 /* Read the bootcode from the file into the buffer */
43 FileOffset.QuadPart = 0ULL;
45 NULL,
46 NULL,
47 NULL,
49 BootCode,
50 Length,
52 NULL);
53 if (!NT_SUCCESS(Status))
54 {
55 RtlFreeHeap(ProcessHeap, 0, BootCode);
56 return Status;
57 }
58
59 /* Update the bootcode information */
60 if (BootCodeInfo->BootCode)
61 RtlFreeHeap(ProcessHeap, 0, BootCodeInfo->BootCode);
62 BootCodeInfo->BootCode = BootCode;
63 BootCodeInfo->Length = Length;
64
65 return STATUS_SUCCESS;
66}
LONG NTSTATUS
Definition: precomp.h:26
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define SECTORSIZE
Definition: bootcode.h:13
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
Status
Definition: gdiplustypes.h:25
#define ULL(a, b)
Definition: format_msg.c:27
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_SUCCESS
Definition: shellext.h:65
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)
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by InstallFat32BootCode(), InstallFatBootCode(), InstallMbrBootCode(), InstallNtfsBootCode(), and ReadBootCodeFromFile().

◆ ReadBootCodeFromFile()

NTSTATUS ReadBootCodeFromFile ( IN OUT PBOOTCODE  BootCodeInfo,
IN PUNICODE_STRING  FilePath,
IN ULONG Length  OPTIONAL 
)

Definition at line 69 of file bootcode.c.

73{
78
79 ASSERT(BootCodeInfo);
80
81 /* Open the file */
85 NULL,
86 NULL);
91 FILE_SHARE_READ | FILE_SHARE_WRITE, // Is FILE_SHARE_WRITE necessary?
93 if (!NT_SUCCESS(Status))
94 return Status;
95
97
98 /* Close the file and return */
100 return Status;
101}
PCWSTR FilePath
NTSTATUS ReadBootCodeByHandle(IN OUT PBOOTCODE BootCodeInfo, IN HANDLE FileHandle, IN ULONG Length OPTIONAL)
Definition: bootcode.c:21
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3952
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402

Referenced by InstallBtrfsBootCode(), InstallFat32BootCode(), InstallFatBootCode(), InstallMbrBootCode(), InstallNtfsBootCode(), IsThereAValidBootSector(), and SaveBootSector().