Fixed some unicode initialization bugs

svn path=/trunk/; revision=1020
This commit is contained in:
Eric Kohl 2000-02-27 18:01:44 +00:00
parent c0ad0d9b02
commit c37b4fd7f1

View file

@ -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 */
@ -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,7 +530,6 @@ 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);
@ -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);
@ -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 */
@ -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 */