mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 18:03:33 +00:00
- Add RtlInitEmptyAnsiString to DDK.
- Fix a pretty bad stack/memory corruption bug related to IoReassignSystemRoot. - Combine IoInit2 and IoInit3 into IoInitSystem, and make it return a BOOLEAN, and handle error with the appropriate IO1_INIT_FAILED bugcheck. Will combine IoInit1 soon. svn path=/trunk/; revision=24462
This commit is contained in:
parent
2b1ade4723
commit
b772538a22
5 changed files with 80 additions and 76 deletions
|
@ -6275,6 +6275,17 @@ RtlInitEmptyUnicodeString(OUT PUNICODE_STRING UnicodeString,
|
||||||
UnicodeString->Buffer = Buffer;
|
UnicodeString->Buffer = Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FORCEINLINE
|
||||||
|
VOID
|
||||||
|
RtlInitEmptyAnsiString(OUT PANSI_STRING AnsiString,
|
||||||
|
IN PCHAR Buffer,
|
||||||
|
IN USHORT BufferSize)
|
||||||
|
{
|
||||||
|
AnsiString->Length = 0;
|
||||||
|
AnsiString->MaximumLength = BufferSize;
|
||||||
|
AnsiString->Buffer = Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
|
|
|
@ -929,18 +929,12 @@ ExPhase2Init(PVOID Context)
|
||||||
/* Enter the kernel debugger before starting up the boot drivers */
|
/* Enter the kernel debugger before starting up the boot drivers */
|
||||||
if (KdDebuggerEnabled && KdpEarlyBreak) DbgBreakPoint();
|
if (KdDebuggerEnabled && KdpEarlyBreak) DbgBreakPoint();
|
||||||
|
|
||||||
/* Setup Drivers and Root Device Node */
|
/* Initialize the I/O Subsystem */
|
||||||
IoInit2(FALSE);
|
if (!IoInitSystem(KeLoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED);
|
||||||
|
|
||||||
/* Display the boot screen image if not disabled */
|
/* Display the boot screen image if not disabled */
|
||||||
if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
|
if (!NoGuiBoot) InbvEnableBootDriver(TRUE);
|
||||||
|
|
||||||
/* Create ARC Names, SystemRoot SymLink, Load Drivers and Assign Letters */
|
|
||||||
IoInit3();
|
|
||||||
|
|
||||||
/* Load the System DLL and its Entrypoints */
|
|
||||||
PsLocateSystemDll();
|
|
||||||
|
|
||||||
/* Initialize VDM support */
|
/* Initialize VDM support */
|
||||||
KeI386VdmInitialize();
|
KeI386VdmInitialize();
|
||||||
|
|
||||||
|
|
|
@ -575,6 +575,12 @@ IopReassignSystemRoot(
|
||||||
OUT PANSI_STRING NtBootPath
|
OUT PANSI_STRING NtBootPath
|
||||||
);
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
IoInitSystem(
|
||||||
|
IN PLOADER_PARAMETER_BLOCK LoaderBlock
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Device/Volume Routines
|
// Device/Volume Routines
|
||||||
//
|
//
|
||||||
|
|
|
@ -61,8 +61,6 @@ typedef struct __DESCRIPTOR
|
||||||
*/
|
*/
|
||||||
VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKernelAddress);
|
VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG LastKernelAddress);
|
||||||
VOID IoInit(VOID);
|
VOID IoInit(VOID);
|
||||||
VOID IoInit2(BOOLEAN BootLog);
|
|
||||||
VOID NTAPI IoInit3(VOID);
|
|
||||||
BOOLEAN NTAPI ObInit(VOID);
|
BOOLEAN NTAPI ObInit(VOID);
|
||||||
VOID NTAPI CmInitSystem1(VOID);
|
VOID NTAPI CmInitSystem1(VOID);
|
||||||
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
|
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
|
||||||
|
|
|
@ -60,8 +60,6 @@ VOID INIT_FUNCTION IopInitLookasideLists(VOID);
|
||||||
#pragma alloc_text(INIT, IoInitShutdownNotification)
|
#pragma alloc_text(INIT, IoInitShutdownNotification)
|
||||||
#pragma alloc_text(INIT, IopInitLookasideLists)
|
#pragma alloc_text(INIT, IopInitLookasideLists)
|
||||||
#pragma alloc_text(INIT, IoInit)
|
#pragma alloc_text(INIT, IoInit)
|
||||||
#pragma alloc_text(INIT, IoInit2)
|
|
||||||
#pragma alloc_text(INIT, IoInit3)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* INIT FUNCTIONS ************************************************************/
|
/* INIT FUNCTIONS ************************************************************/
|
||||||
|
@ -395,14 +393,19 @@ IoInit (VOID)
|
||||||
PnpInit();
|
PnpInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
BOOLEAN
|
||||||
INIT_FUNCTION
|
INIT_FUNCTION
|
||||||
IoInit2(BOOLEAN BootLog)
|
NTAPI
|
||||||
|
IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
{
|
||||||
PDEVICE_NODE DeviceNode;
|
PDEVICE_NODE DeviceNode;
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
LDR_DATA_TABLE_ENTRY ModuleObject;
|
LDR_DATA_TABLE_ENTRY ModuleObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
CHAR Buffer[256];
|
||||||
|
ANSI_STRING NtBootPath, RootString;
|
||||||
|
|
||||||
|
RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
|
||||||
|
|
||||||
PnpInit2();
|
PnpInit2();
|
||||||
|
|
||||||
|
@ -413,21 +416,18 @@ IoInit2(BOOLEAN BootLog)
|
||||||
/* Initialize raw filesystem driver */
|
/* Initialize raw filesystem driver */
|
||||||
|
|
||||||
/* Use IopRootDeviceNode for now */
|
/* Use IopRootDeviceNode for now */
|
||||||
Status = IopCreateDeviceNode(IopRootDeviceNode,
|
Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
|
||||||
NULL,
|
|
||||||
&DeviceNode);
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
CPRINT("IopCreateDeviceNode() failed with status (%x)\n", Status);
|
CPRINT("IopCreateDeviceNode() failed with status (%x)\n", Status);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleObject.DllBase = NULL;
|
ModuleObject.DllBase = NULL;
|
||||||
ModuleObject.SizeOfImage = 0;
|
ModuleObject.SizeOfImage = 0;
|
||||||
ModuleObject.EntryPoint = RawFsDriverEntry;
|
ModuleObject.EntryPoint = RawFsDriverEntry;
|
||||||
|
|
||||||
Status = IopInitializeDriverModule(
|
Status = IopInitializeDriverModule(DeviceNode,
|
||||||
DeviceNode,
|
|
||||||
&ModuleObject,
|
&ModuleObject,
|
||||||
&DeviceNode->ServiceName,
|
&DeviceNode->ServiceName,
|
||||||
TRUE,
|
TRUE,
|
||||||
|
@ -436,7 +436,7 @@ IoInit2(BOOLEAN BootLog)
|
||||||
{
|
{
|
||||||
IopFreeDeviceNode(DeviceNode);
|
IopFreeDeviceNode(DeviceNode);
|
||||||
CPRINT("IopInitializeDriver() failed with status (%x)\n", Status);
|
CPRINT("IopInitializeDriver() failed with status (%x)\n", Status);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
Status = IopInitializeDevice(DeviceNode, DriverObject);
|
||||||
|
@ -444,7 +444,7 @@ IoInit2(BOOLEAN BootLog)
|
||||||
{
|
{
|
||||||
IopFreeDeviceNode(DeviceNode);
|
IopFreeDeviceNode(DeviceNode);
|
||||||
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = IopStartDevice(DeviceNode);
|
Status = IopStartDevice(DeviceNode);
|
||||||
|
@ -452,46 +452,37 @@ IoInit2(BOOLEAN BootLog)
|
||||||
{
|
{
|
||||||
IopFreeDeviceNode(DeviceNode);
|
IopFreeDeviceNode(DeviceNode);
|
||||||
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize PnP root releations
|
* Initialize PnP root releations
|
||||||
*/
|
*/
|
||||||
IoSynchronousInvalidateDeviceRelations(
|
IoSynchronousInvalidateDeviceRelations(IopRootDeviceNode->
|
||||||
IopRootDeviceNode->PhysicalDeviceObject,
|
PhysicalDeviceObject,
|
||||||
BusRelations);
|
BusRelations);
|
||||||
|
|
||||||
/* Start boot logging */
|
|
||||||
IopInitBootLog(BootLog);
|
|
||||||
|
|
||||||
/* Load boot start drivers */
|
/* Load boot start drivers */
|
||||||
IopInitializeBootDrivers();
|
IopInitializeBootDrivers();
|
||||||
|
|
||||||
/* Call back drivers that asked for */
|
/* Call back drivers that asked for */
|
||||||
IopReinitializeBootDrivers();
|
IopReinitializeBootDrivers();
|
||||||
}
|
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
INIT_FUNCTION
|
|
||||||
IoInit3(VOID)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
ANSI_STRING NtBootPath, RootString;
|
|
||||||
|
|
||||||
/* Create ARC names for boot devices */
|
/* Create ARC names for boot devices */
|
||||||
IopCreateArcNames(KeLoaderBlock);
|
IopCreateArcNames(LoaderBlock);
|
||||||
|
|
||||||
/* Read KDB Data */
|
/* Read KDB Data */
|
||||||
KdbInit();
|
KdbInit();
|
||||||
|
|
||||||
/* I/O is now setup for disk access, so phase 3 */
|
/* I/O is now setup for disk access, so phase 3 */
|
||||||
KdInitSystem(3, KeLoaderBlock);
|
KdInitSystem(3, LoaderBlock);
|
||||||
|
|
||||||
/* Load services for devices found by PnP manager */
|
/* Load services for devices found by PnP manager */
|
||||||
IopInitializePnpServices(IopRootDeviceNode, FALSE);
|
IopInitializePnpServices(IopRootDeviceNode, FALSE);
|
||||||
|
|
||||||
|
/* Load the System DLL and its Entrypoints */
|
||||||
|
if (!NT_SUCCESS(PsLocateSystemDll())) return FALSE;
|
||||||
|
|
||||||
/* Load system start drivers */
|
/* Load system start drivers */
|
||||||
IopInitializeSystemDrivers();
|
IopInitializeSystemDrivers();
|
||||||
|
|
||||||
|
@ -502,7 +493,8 @@ IoInit3(VOID)
|
||||||
IopReinitializeDrivers();
|
IopReinitializeDrivers();
|
||||||
|
|
||||||
/* Convert SystemRoot from ARC to NT path */
|
/* Convert SystemRoot from ARC to NT path */
|
||||||
IopReassignSystemRoot(KeLoaderBlock, &NtBootPath);
|
Status = IopReassignSystemRoot(LoaderBlock, &NtBootPath);
|
||||||
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
/* Set the ANSI_STRING for the root path */
|
/* Set the ANSI_STRING for the root path */
|
||||||
RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
|
RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
|
||||||
|
@ -513,17 +505,20 @@ IoInit3(VOID)
|
||||||
|
|
||||||
/* Convert the path into the ANSI_STRING */
|
/* Convert the path into the ANSI_STRING */
|
||||||
Status = RtlUnicodeStringToAnsiString(&RootString, &NtSystemRoot, FALSE);
|
Status = RtlUnicodeStringToAnsiString(&RootString, &NtSystemRoot, FALSE);
|
||||||
if (!NT_SUCCESS(Status)) return;
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
/* Assign drive letters */
|
/* Assign drive letters */
|
||||||
IoAssignDriveLetters(KeLoaderBlock,
|
IoAssignDriveLetters(LoaderBlock,
|
||||||
&NtBootPath,
|
&NtBootPath,
|
||||||
RootString.Buffer,
|
RootString.Buffer,
|
||||||
&RootString);
|
&RootString);
|
||||||
|
|
||||||
/* Update system root */
|
/* Update system root */
|
||||||
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE);
|
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE);
|
||||||
if (!NT_SUCCESS(Status)) return;
|
if (!NT_SUCCESS(Status)) return FALSE;
|
||||||
|
|
||||||
|
/* Return success */
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue