PCHAR Options,
PCHAR SystemPath,
PCHAR BootPath,
- WORD VersionToBoot)
+ USHORT VersionToBoot)
{
/* Examples of correct options and paths */
//CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
strcpy(SystemRoot, &SystemPath[PathSeparator]);
strcat(SystemRoot, "\\");
- DbgPrint((DPRINT_WINDOWS, "ArcBoot: %s\n", ArcBoot));
- DbgPrint((DPRINT_WINDOWS, "SystemRoot: %s\n", SystemRoot));
- DbgPrint((DPRINT_WINDOWS, "Options: %s\n", Options));
+ DPRINTM(DPRINT_WINDOWS, "ArcBoot: %s\n", ArcBoot);
+ DPRINTM(DPRINT_WINDOWS, "SystemRoot: %s\n", SystemRoot);
+ DPRINTM(DPRINT_WINDOWS, "Options: %s\n", Options);
/* Fill Arc BootDevice */
LoaderBlock->ArcBootDeviceName = MmHeapAlloc(strlen(ArcBoot)+1);
*(DriverNamePos+1) = 0;
}
- DbgPrint((DPRINT_WINDOWS, "DriverPath: %s, DllName: %s, LPB %p\n", DriverPath, DllName, LoaderBlock));
+ DPRINTM(DPRINT_WINDOWS, "DriverPath: %s, DllName: %s, LPB %p\n", DriverPath, DllName, LoaderBlock);
// Check if driver is already loaded
Status = WinLdrAllocateDataTableEntry(LoaderBlock, DllName, DllName, DriverBase, DriverDTE);
if (!Status)
{
- DbgPrint((DPRINT_WINDOWS, "WinLdrAllocateDataTableEntry() failed\n"));
+ DPRINTM(DPRINT_WINDOWS, "WinLdrAllocateDataTableEntry() failed\n");
return FALSE;
}
Status = WinLdrScanImportDescriptorTable(LoaderBlock, FullPath, *DriverDTE);
if (!Status)
{
- DbgPrint((DPRINT_WINDOWS, "WinLdrScanImportDescriptorTable() failed for %s\n",
- FullPath));
+ DPRINTM(DPRINT_WINDOWS, "WinLdrScanImportDescriptorTable() failed for %s\n",
+ FullPath);
return FALSE;
}
while (NextBd != &LoaderBlock->BootDriverListHead)
{
- BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, ListEntry);
+ BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
- DbgPrint((DPRINT_WINDOWS, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
- BootDriver->DataTableEntry, &BootDriver->RegistryPath));
+ DPRINTM(DPRINT_WINDOWS, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
+ BootDriver->LdrEntry, &BootDriver->RegistryPath);
// Paths are relative (FIXME: Are they always relative?)
// Load it
Status = WinLdrLoadDeviceDriver(LoaderBlock, BootPath, &BootDriver->FilePath,
- 0, &BootDriver->DataTableEntry);
+ 0, &BootDriver->LdrEntry);
// If loading failed - cry loudly
//FIXME: Maybe remove it from the list and try to continue?
// Convert the RegistryPath and DTE addresses to VA since we are not going to use it anymore
BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
- BootDriver->DataTableEntry = PaToVa(BootDriver->DataTableEntry);
+ BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
- NextBd = BootDriver->ListEntry.Flink;
+ NextBd = BootDriver->Link.Flink;
}
return TRUE;
PVOID WinLdrLoadModule(PCSTR ModuleName, ULONG *Size,
TYPE_OF_MEMORY MemoryType)
{
- PFILE FileHandle;\r
- PVOID PhysicalBase;\r
- ULONG FileSize;\r
- BOOLEAN Status;\r
-\r
- //CHAR ProgressString[256];\r
-\r
- /* Inform user we are loading files */\r
- //sprintf(ProgressString, "Loading %s...", FileName);\r
- //UiDrawProgressBarCenter(1, 100, ProgressString);\r
-\r
- DbgPrint((DPRINT_WINDOWS, "Loading module %s\n", ModuleName));\r
- *Size = 0;\r
-\r
- /* Open the image file */\r
- FileHandle = FsOpenFile(ModuleName);\r
-\r
- if (FileHandle == NULL)\r
- {\r
- /* In case of errors, we just return, without complaining to the user */\r
- return NULL;\r
- }\r
-\r
- /* Get this file's size */\r
- FileSize = FsGetFileSize(FileHandle);\r
- *Size = FileSize;\r
-\r
- /* Allocate memory */\r
- PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);\r
- if (PhysicalBase == NULL)\r
- {\r
- FsCloseFile(FileHandle);\r
- return NULL;\r
- }\r
-\r
- /* Load whole file */\r
- Status = FsReadFile(FileHandle, FileSize, NULL, PhysicalBase);\r
- if (!Status)\r
- {\r
- FsCloseFile(FileHandle);\r
- return NULL;\r
- }\r
-\r
- DbgPrint((DPRINT_WINDOWS, "Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize));\r
-\r
- /* We are done with the file - close it */\r
- FsCloseFile(FileHandle);\r
-\r
- return PhysicalBase;\r
+ PFILE FileHandle;
+ PVOID PhysicalBase;
+ ULONG FileSize;
+ BOOLEAN Status;
+
+ //CHAR ProgressString[256];
+
+ /* Inform user we are loading files */
+ //sprintf(ProgressString, "Loading %s...", FileName);
+ //UiDrawProgressBarCenter(1, 100, ProgressString);
+
+ DPRINTM(DPRINT_WINDOWS, "Loading module %s\n", ModuleName);
+ *Size = 0;
+
+ /* Open the image file */
+ FileHandle = FsOpenFile(ModuleName);
+
+ if (FileHandle == NULL)
+ {
+ /* In case of errors, we just return, without complaining to the user */
+ return NULL;
+ }
+
+ /* Get this file's size */
+ FileSize = FsGetFileSize(FileHandle);
+ *Size = FileSize;
+
+ /* Allocate memory */
+ PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
+ if (PhysicalBase == NULL)
+ {
+ FsCloseFile(FileHandle);
+ return NULL;
+ }
+
+ /* Load whole file */
+ Status = FsReadFile(FileHandle, FileSize, NULL, PhysicalBase);
+ if (!Status)
+ {
+ FsCloseFile(FileHandle);
+ return NULL;
+ }
+
+ DPRINTM(DPRINT_WINDOWS, "Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
+
+ /* We are done with the file - close it */
+ FsCloseFile(FileHandle);
+
+ return PhysicalBase;
}
VOID
-LoadAndBootWindows(PCSTR OperatingSystemName, WORD OperatingSystemVersion)
+LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
{
CHAR MsgBuffer[256];
CHAR SystemPath[512], SearchPath[512];
BootPath[strlen(BootPath)] != '\\')
strcat(BootPath, "\\");
- DbgPrint((DPRINT_WINDOWS,"SystemRoot: '%s'\n", BootPath));
+ DPRINTM(DPRINT_WINDOWS,"SystemRoot: '%s'\n", BootPath);
/* Allocate and minimalistic-initialize LPB */
AllocateAndInitLPB(&LoaderBlock);
strcpy(FileName, BootPath);
strcat(FileName, "SYSTEM32\\NTOSKRNL.EXE");
Status = WinLdrLoadImage(FileName, LoaderSystemCode, &NtosBase);
- DbgPrint((DPRINT_WINDOWS, "Ntos loaded with status %d at %p\n", Status, NtosBase));
+ DPRINTM(DPRINT_WINDOWS, "Ntos loaded with status %d at %p\n", Status, NtosBase);
/* Load HAL */
strcpy(FileName, BootPath);
strcat(FileName, "SYSTEM32\\HAL.DLL");
Status = WinLdrLoadImage(FileName, LoaderHalCode, &HalBase);
- DbgPrint((DPRINT_WINDOWS, "HAL loaded with status %d at %p\n", Status, HalBase));
+ DPRINTM(DPRINT_WINDOWS, "HAL loaded with status %d at %p\n", Status, HalBase);
/* Load kernel-debugger support dll */
if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
strcpy(FileName, BootPath);
strcat(FileName, "SYSTEM32\\KDCOM.DLL");
Status = WinLdrLoadImage(FileName, LoaderBootDriver, &KdComBase);
- DbgPrint((DPRINT_WINDOWS, "KdCom loaded with status %d at %p\n", Status, KdComBase));
+ DPRINTM(DPRINT_WINDOWS, "KdCom loaded with status %d at %p\n", Status, KdComBase);
}
/* Allocate data table entries for above-loaded modules */
/* Load Hive, and then NLS data, OEM font, and prepare boot drivers list */
Status = WinLdrLoadAndScanSystemHive(LoaderBlock, BootPath);
- DbgPrint((DPRINT_WINDOWS, "SYSTEM hive loaded and scanned with status %d\n", Status));
+ DPRINTM(DPRINT_WINDOWS, "SYSTEM hive loaded and scanned with status %d\n", Status);
/* Load boot drivers */
Status = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
- DbgPrint((DPRINT_WINDOWS, "Boot drivers loaded with status %d\n", Status));
+ DPRINTM(DPRINT_WINDOWS, "Boot drivers loaded with status %d\n", Status);
/* Alloc PCR, TSS, do magic things with the GDT/IDT */
WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage);
/* Save final value of LoaderPagesSpanned */
LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
- DbgPrint((DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
- KiSystemStartup, LoaderBlockVA));
+ DPRINTM(DPRINT_WINDOWS, "Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
+ KiSystemStartup, LoaderBlockVA);
WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
WinLdrpDumpBootDriver(LoaderBlockVA);
{
MemoryDescriptor = CONTAINING_RECORD(NextMd, MEMORY_ALLOCATION_DESCRIPTOR, ListEntry);
- DbgPrint((DPRINT_WINDOWS, "BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
- MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType));
+ DPRINTM(DPRINT_WINDOWS, "BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
+ MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
NextMd = MemoryDescriptor->ListEntry.Flink;
}
while (NextBd != &LoaderBlock->BootDriverListHead)
{
- BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, ListEntry);
+ BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
- DbgPrint((DPRINT_WINDOWS, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
- BootDriver->DataTableEntry, &BootDriver->RegistryPath));
+ DPRINTM(DPRINT_WINDOWS, "BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
+ BootDriver->LdrEntry, &BootDriver->RegistryPath);
- NextBd = BootDriver->ListEntry.Flink;
+ NextBd = BootDriver->Link.Flink;
}
}
{
ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
- DbgPrint((DPRINT_WINDOWS, "ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
- ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature));
+ DPRINTM(DPRINT_WINDOWS, "ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
+ ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
NextBd = ArcDisk->ListEntry.Flink;
}