mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Fixed some unicode initialization bugs
svn path=/trunk/; revision=1020
This commit is contained in:
parent
c0ad0d9b02
commit
c37b4fd7f1
1 changed files with 63 additions and 74 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: loader.c,v 1.47 2000/02/25 00:32:04 ekohl Exp $
|
/* $Id: loader.c,v 1.48 2000/02/27 18:01:44 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -109,8 +109,7 @@ VOID LdrInitModuleManagement(VOID)
|
||||||
/* Create Modules object directory */
|
/* Create Modules object directory */
|
||||||
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
||||||
*(wcsrchr(NameBuffer, L'\\')) = 0;
|
*(wcsrchr(NameBuffer, L'\\')) = 0;
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&ModuleName,
|
&ModuleName,
|
||||||
0,
|
0,
|
||||||
|
@ -123,8 +122,7 @@ VOID LdrInitModuleManagement(VOID)
|
||||||
/* Add module entry for NTOSKRNL */
|
/* Add module entry for NTOSKRNL */
|
||||||
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
wcscpy(NameBuffer, MODULE_ROOT_NAME);
|
||||||
wcscat(NameBuffer, L"ntoskrnl.exe");
|
wcscat(NameBuffer, L"ntoskrnl.exe");
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
DPRINT("Kernel's Module name is: %wZ\n", &ModuleName);
|
DPRINT("Kernel's Module name is: %wZ\n", &ModuleName);
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for ModuleObject */
|
/* Initialize ObjectAttributes for ModuleObject */
|
||||||
|
@ -142,13 +140,13 @@ VOID LdrInitModuleManagement(VOID)
|
||||||
ObModuleType);
|
ObModuleType);
|
||||||
assert(ModuleObject != NULL);
|
assert(ModuleObject != NULL);
|
||||||
|
|
||||||
InitializeListHead(&ModuleListHead);
|
InitializeListHead(&ModuleListHead);
|
||||||
|
|
||||||
/* Initialize ModuleObject data */
|
/* Initialize ModuleObject data */
|
||||||
ModuleObject->Base = (PVOID) KERNEL_BASE;
|
ModuleObject->Base = (PVOID) KERNEL_BASE;
|
||||||
ModuleObject->Flags = MODULE_FLAG_PE;
|
ModuleObject->Flags = MODULE_FLAG_PE;
|
||||||
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
||||||
ModuleObject->Name = wcsdup(L"ntoskrnl.exe");
|
ModuleObject->Name = wcsdup(L"ntoskrnl.exe");
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) KERNEL_BASE;
|
DosHeader = (PIMAGE_DOS_HEADER) KERNEL_BASE;
|
||||||
ModuleObject->Image.PE.FileHeader =
|
ModuleObject->Image.PE.FileHeader =
|
||||||
(PIMAGE_FILE_HEADER) ((DWORD) ModuleObject->Base +
|
(PIMAGE_FILE_HEADER) ((DWORD) ModuleObject->Base +
|
||||||
|
@ -180,11 +178,7 @@ static VOID LdrLoadAutoConfigDriver (LPWSTR RelativeDriverName)
|
||||||
LdrGetSystemDirectory(TmpFileName, (MAX_PATH * sizeof(WCHAR)));
|
LdrGetSystemDirectory(TmpFileName, (MAX_PATH * sizeof(WCHAR)));
|
||||||
wcscat(TmpFileName, L"\\drivers\\");
|
wcscat(TmpFileName, L"\\drivers\\");
|
||||||
wcscat(TmpFileName, RelativeDriverName);
|
wcscat(TmpFileName, RelativeDriverName);
|
||||||
|
RtlInitUnicodeString (&DriverName, TmpFileName);
|
||||||
DriverName.Buffer = TmpFileName;
|
|
||||||
DriverName.Length = wcslen(TmpFileName) * sizeof (WCHAR);
|
|
||||||
DriverName.MaximumLength = DriverName.Length + sizeof(WCHAR);
|
|
||||||
|
|
||||||
|
|
||||||
Status = LdrLoadDriver(&DriverName);
|
Status = LdrLoadDriver(&DriverName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -351,9 +345,7 @@ LdrLoadModule(PUNICODE_STRING Filename)
|
||||||
{
|
{
|
||||||
wcscat(NameBuffer, Filename->Buffer);
|
wcscat(NameBuffer, Filename->Buffer);
|
||||||
}
|
}
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
|
|
||||||
|
|
||||||
ModuleObject = LdrProcessModule(ModuleLoadBase, &ModuleName);
|
ModuleObject = LdrProcessModule(ModuleLoadBase, &ModuleName);
|
||||||
|
|
||||||
|
@ -423,8 +415,7 @@ LdrOpenModule(PUNICODE_STRING Filename)
|
||||||
{
|
{
|
||||||
wcscat(NameBuffer, Filename->Buffer);
|
wcscat(NameBuffer, Filename->Buffer);
|
||||||
}
|
}
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&ModuleName,
|
&ModuleName,
|
||||||
0,
|
0,
|
||||||
|
@ -539,9 +530,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
|
|
||||||
/* Determine the size of the module */
|
/* Determine the size of the module */
|
||||||
|
DriverSize = PEOptionalHeader->SizeOfImage;
|
||||||
DriverSize = PEOptionalHeader->SizeOfImage;
|
DPRINT("DriverSize %x\n",DriverSize);
|
||||||
DPRINT("DriverSize %x\n",DriverSize);
|
|
||||||
|
|
||||||
/* Allocate a virtual section for the module */
|
/* Allocate a virtual section for the module */
|
||||||
DriverBase = MmAllocateSection(DriverSize);
|
DriverBase = MmAllocateSection(DriverSize);
|
||||||
|
@ -678,8 +668,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
||||||
NameBuffer[Idx + Idx2] = (WCHAR) pName[Idx2];
|
NameBuffer[Idx + Idx2] = (WCHAR) pName[Idx2];
|
||||||
}
|
}
|
||||||
NameBuffer[Idx + Idx2] = 0;
|
NameBuffer[Idx + Idx2] = 0;
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
DPRINT("Import module: %wZ\n", &ModuleName);
|
DPRINT("Import module: %wZ\n", &ModuleName);
|
||||||
|
|
||||||
LibraryModuleObject = LdrLoadModule(&ModuleName);
|
LibraryModuleObject = LdrLoadModule(&ModuleName);
|
||||||
|
@ -729,7 +718,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DbgPrint("Unresolved kernel symbol: %s\n", pName);
|
DbgPrint("Unresolved kernel symbol: %s\n", pName);
|
||||||
}
|
}
|
||||||
ImportAddressList++;
|
ImportAddressList++;
|
||||||
FunctionNameList++;
|
FunctionNameList++;
|
||||||
|
@ -768,8 +757,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
||||||
Idx2++;
|
Idx2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ModuleName.Length = ModuleName.MaximumLength = wcslen(NameBuffer);
|
RtlInitUnicodeString (&ModuleName, NameBuffer);
|
||||||
ModuleName.Buffer = NameBuffer;
|
|
||||||
DbgPrint("Module name is: %wZ\n", &ModuleName);
|
DbgPrint("Module name is: %wZ\n", &ModuleName);
|
||||||
|
|
||||||
/* Initialize ObjectAttributes for ModuleObject */
|
/* Initialize ObjectAttributes for ModuleObject */
|
||||||
|
@ -790,10 +778,10 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
||||||
ModuleObject->Base = DriverBase;
|
ModuleObject->Base = DriverBase;
|
||||||
ModuleObject->Flags = MODULE_FLAG_PE;
|
ModuleObject->Flags = MODULE_FLAG_PE;
|
||||||
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
||||||
ModuleObject->Name = wcsdup(NameBuffer);
|
ModuleObject->Name = wcsdup(NameBuffer);
|
||||||
ModuleObject->EntryPoint = (PVOID) ((DWORD)DriverBase +
|
ModuleObject->EntryPoint = (PVOID) ((DWORD)DriverBase +
|
||||||
PEOptionalHeader->AddressOfEntryPoint);
|
PEOptionalHeader->AddressOfEntryPoint);
|
||||||
ModuleObject->Length = DriverSize;
|
ModuleObject->Length = DriverSize;
|
||||||
DPRINT("entrypoint at %x\n", ModuleObject->EntryPoint);
|
DPRINT("entrypoint at %x\n", ModuleObject->EntryPoint);
|
||||||
|
|
||||||
ModuleObject->Image.PE.FileHeader =
|
ModuleObject->Image.PE.FileHeader =
|
||||||
|
@ -877,10 +865,9 @@ LdrPEGetExportAddress(PMODULE_OBJECT ModuleObject,
|
||||||
if (ExportAddress == 0)
|
if (ExportAddress == 0)
|
||||||
{
|
{
|
||||||
DbgPrint("Export not found for %d:%s\n", Hint, Name != NULL ? Name : "(Ordinal)");
|
DbgPrint("Export not found for %d:%s\n", Hint, Name != NULL ? Name : "(Ordinal)");
|
||||||
for(;;) ;
|
for(;;) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ExportAddress;
|
return ExportAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,3 +891,5 @@ LdrPEGetEnclosingSectionHeader(DWORD RVA,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue