Author: ion
Date: Mon Oct 9 03:46:26 2006
New Revision: 24462
URL:
http://svn.reactos.org/svn/reactos?rev=24462&view=rev
Log:
- 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.
Modified:
trunk/reactos/include/ddk/winddk.h
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
trunk/reactos/ntoskrnl/io/iomgr/iomgr.c
Modified: trunk/reactos/include/ddk/winddk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=2…
==============================================================================
--- trunk/reactos/include/ddk/winddk.h (original)
+++ trunk/reactos/include/ddk/winddk.h Mon Oct 9 03:46:26 2006
@@ -6275,6 +6275,17 @@
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
NTSTATUS
NTAPI
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=244…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c (original)
+++ trunk/reactos/ntoskrnl/ex/init.c Mon Oct 9 03:46:26 2006
@@ -929,17 +929,11 @@
/* Enter the kernel debugger before starting up the boot drivers */
if (KdDebuggerEnabled && KdpEarlyBreak) DbgBreakPoint();
- /* Setup Drivers and Root Device Node */
- IoInit2(FALSE);
+ /* Initialize the I/O Subsystem */
+ if (!IoInitSystem(KeLoaderBlock)) KeBugCheck(IO1_INITIALIZATION_FAILED);
/* Display the boot screen image if not disabled */
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 */
KeI386VdmInitialize();
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h Mon Oct 9 03:46:26 2006
@@ -575,6 +575,12 @@
OUT PANSI_STRING NtBootPath
);
+BOOLEAN
+NTAPI
+IoInitSystem(
+ IN PLOADER_PARAMETER_BLOCK LoaderBlock
+);
+
//
// Device/Volume Routines
//
Modified: trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ntoskrnl.h Mon Oct 9 03:46:26 2006
@@ -61,8 +61,6 @@
*/
VOID MmInitSystem(ULONG Phase, PLOADER_PARAMETER_BLOCK LoaderBlock, ULONG
LastKernelAddress);
VOID IoInit(VOID);
-VOID IoInit2(BOOLEAN BootLog);
-VOID NTAPI IoInit3(VOID);
BOOLEAN NTAPI ObInit(VOID);
VOID NTAPI CmInitSystem1(VOID);
VOID NTAPI CmInitHives(BOOLEAN SetupBoot);
Modified: trunk/reactos/ntoskrnl/io/iomgr/iomgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iomgr.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr/iomgr.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr/iomgr.c Mon Oct 9 03:46:26 2006
@@ -60,8 +60,6 @@
#pragma alloc_text(INIT, IoInitShutdownNotification)
#pragma alloc_text(INIT, IopInitLookasideLists)
#pragma alloc_text(INIT, IoInit)
-#pragma alloc_text(INIT, IoInit2)
-#pragma alloc_text(INIT, IoInit3)
#endif
/* INIT FUNCTIONS ************************************************************/
@@ -395,103 +393,96 @@
PnpInit();
}
-VOID
+BOOLEAN
INIT_FUNCTION
-IoInit2(BOOLEAN BootLog)
+NTAPI
+IoInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
{
- PDEVICE_NODE DeviceNode;
- PDRIVER_OBJECT DriverObject;
- LDR_DATA_TABLE_ENTRY ModuleObject;
- NTSTATUS Status;
-
- PnpInit2();
-
- IoCreateDriverList();
-
- KeInitializeSpinLock (&IoStatisticsLock);
-
- /* Initialize raw filesystem driver */
-
- /* Use IopRootDeviceNode for now */
- Status = IopCreateDeviceNode(IopRootDeviceNode,
- NULL,
- &DeviceNode);
- if (!NT_SUCCESS(Status))
+ PDEVICE_NODE DeviceNode;
+ PDRIVER_OBJECT DriverObject;
+ LDR_DATA_TABLE_ENTRY ModuleObject;
+ NTSTATUS Status;
+ CHAR Buffer[256];
+ ANSI_STRING NtBootPath, RootString;
+
+ RtlInitEmptyAnsiString(&NtBootPath, Buffer, sizeof(Buffer));
+
+ PnpInit2();
+
+ IoCreateDriverList();
+
+ KeInitializeSpinLock (&IoStatisticsLock);
+
+ /* Initialize raw filesystem driver */
+
+ /* Use IopRootDeviceNode for now */
+ Status = IopCreateDeviceNode(IopRootDeviceNode, NULL, &DeviceNode);
+ if (!NT_SUCCESS(Status))
{
- CPRINT("IopCreateDeviceNode() failed with status (%x)\n", Status);
- return;
+ CPRINT("IopCreateDeviceNode() failed with status (%x)\n", Status);
+ return FALSE;
}
- ModuleObject.DllBase = NULL;
- ModuleObject.SizeOfImage = 0;
- ModuleObject.EntryPoint = RawFsDriverEntry;
-
- Status = IopInitializeDriverModule(
- DeviceNode,
- &ModuleObject,
- &DeviceNode->ServiceName,
- TRUE,
- &DriverObject);
- if (!NT_SUCCESS(Status))
+ ModuleObject.DllBase = NULL;
+ ModuleObject.SizeOfImage = 0;
+ ModuleObject.EntryPoint = RawFsDriverEntry;
+
+ Status = IopInitializeDriverModule(DeviceNode,
+ &ModuleObject,
+ &DeviceNode->ServiceName,
+ TRUE,
+ &DriverObject);
+ if (!NT_SUCCESS(Status))
{
- IopFreeDeviceNode(DeviceNode);
- CPRINT("IopInitializeDriver() failed with status (%x)\n", Status);
- return;
+ IopFreeDeviceNode(DeviceNode);
+ CPRINT("IopInitializeDriver() failed with status (%x)\n", Status);
+ return FALSE;
}
- Status = IopInitializeDevice(DeviceNode, DriverObject);
- if (!NT_SUCCESS(Status))
+ Status = IopInitializeDevice(DeviceNode, DriverObject);
+ if (!NT_SUCCESS(Status))
{
- IopFreeDeviceNode(DeviceNode);
- CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
- return;
+ IopFreeDeviceNode(DeviceNode);
+ CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
+ return FALSE;
}
- Status = IopStartDevice(DeviceNode);
- if (!NT_SUCCESS(Status))
+ Status = IopStartDevice(DeviceNode);
+ if (!NT_SUCCESS(Status))
{
- IopFreeDeviceNode(DeviceNode);
- CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
- return;
+ IopFreeDeviceNode(DeviceNode);
+ CPRINT("IopInitializeDevice() failed with status (%x)\n", Status);
+ return FALSE;
}
- /*
- * Initialize PnP root releations
- */
- IoSynchronousInvalidateDeviceRelations(
- IopRootDeviceNode->PhysicalDeviceObject,
- BusRelations);
-
- /* Start boot logging */
- IopInitBootLog(BootLog);
+ /*
+ * Initialize PnP root releations
+ */
+ IoSynchronousInvalidateDeviceRelations(IopRootDeviceNode->
+ PhysicalDeviceObject,
+ BusRelations);
/* Load boot start drivers */
IopInitializeBootDrivers();
/* Call back drivers that asked for */
IopReinitializeBootDrivers();
-}
-
-VOID
-NTAPI
-INIT_FUNCTION
-IoInit3(VOID)
-{
- NTSTATUS Status;
- ANSI_STRING NtBootPath, RootString;
/* Create ARC names for boot devices */
- IopCreateArcNames(KeLoaderBlock);
+ IopCreateArcNames(LoaderBlock);
/* Read KDB Data */
KdbInit();
/* 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 */
IopInitializePnpServices(IopRootDeviceNode, FALSE);
+ /* Load the System DLL and its Entrypoints */
+ if (!NT_SUCCESS(PsLocateSystemDll())) return FALSE;
+
/* Load system start drivers */
IopInitializeSystemDrivers();
@@ -502,7 +493,8 @@
IopReinitializeDrivers();
/* 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 */
RootString.MaximumLength = NtSystemRoot.MaximumLength / sizeof(WCHAR);
@@ -513,17 +505,20 @@
/* Convert the path into the ANSI_STRING */
Status = RtlUnicodeStringToAnsiString(&RootString, &NtSystemRoot, FALSE);
- if (!NT_SUCCESS(Status)) return;
+ if (!NT_SUCCESS(Status)) return FALSE;
/* Assign drive letters */
- IoAssignDriveLetters(KeLoaderBlock,
+ IoAssignDriveLetters(LoaderBlock,
&NtBootPath,
RootString.Buffer,
&RootString);
/* Update system root */
Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &RootString, FALSE);
- if (!NT_SUCCESS(Status)) return;
+ if (!NT_SUCCESS(Status)) return FALSE;
+
+ /* Return success */
+ return TRUE;
}
/* EOF */