Patch by Pablo Borobia <pablog7@argentina.com>

Correct search path for DLL loading (including directory from which .exe
was loaded).

svn path=/trunk/; revision=9589
This commit is contained in:
Gé van Geldorp 2004-06-02 18:26:58 +00:00
parent 3a1705b0b1
commit 08108f008e
2 changed files with 1077 additions and 1037 deletions

View file

@ -1,4 +1,4 @@
/* $Id: dir.c,v 1.44 2004/01/23 21:16:03 ekohl Exp $ /* $Id: dir.c,v 1.45 2004/06/02 18:26:57 gvg Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -637,16 +637,35 @@ SearchPathW (
DWORD retCode = 0; DWORD retCode = 0;
ULONG pos, len; ULONG pos, len;
PWCHAR EnvironmentBufferW = NULL; PWCHAR EnvironmentBufferW = NULL;
PWCHAR AppPathW = NULL;
WCHAR Buffer; WCHAR Buffer;
//WCHAR drv[3];
DPRINT("SearchPath\n"); DPRINT("SearchPath\n");
if (lpPath == NULL) if (lpPath == NULL)
{ {
AppPathW = (PWCHAR) RtlAllocateHeap(GetProcessHeap(),
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
MAX_PATH * sizeof(WCHAR));
wcscat (AppPathW, NtCurrentPeb()->ProcessParameters->ImagePathName.Buffer);
len = wcslen (AppPathW);
while (len && AppPathW[len - 1] != L'\\')
len--;
if (len) AppPathW[len-1] = L'\0';
len = GetEnvironmentVariableW(L"PATH", &Buffer, 0); len = GetEnvironmentVariableW(L"PATH", &Buffer, 0);
len += 1 + GetCurrentDirectoryW(0, &Buffer); len += 1 + GetCurrentDirectoryW(0, &Buffer);
len += 1 + GetSystemDirectoryW(&Buffer, 0); len += 1 + GetSystemDirectoryW(&Buffer, 0);
len += 1 + GetWindowsDirectoryW(&Buffer, 0); len += 1 + GetWindowsDirectoryW(&Buffer, 0);
len += 1 + wcslen(AppPathW) * sizeof(WCHAR);
EnvironmentBufferW = (PWCHAR) RtlAllocateHeap(GetProcessHeap(), EnvironmentBufferW = (PWCHAR) RtlAllocateHeap(GetProcessHeap(),
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
@ -667,7 +686,16 @@ SearchPathW (
EnvironmentBufferW[pos++] = L';'; EnvironmentBufferW[pos++] = L';';
EnvironmentBufferW[pos] = 0; EnvironmentBufferW[pos] = 0;
pos += GetEnvironmentVariableW(L"PATH", &EnvironmentBufferW[pos], len - pos); pos += GetEnvironmentVariableW(L"PATH", &EnvironmentBufferW[pos], len - pos);
EnvironmentBufferW[pos++] = L';';
EnvironmentBufferW[pos] = 0;
wcscat (EnvironmentBufferW, AppPathW);
RtlFreeHeap (RtlGetProcessHeap (),
0,
AppPathW);
lpPath = EnvironmentBufferW; lpPath = EnvironmentBufferW;
} }
retCode = RtlDosSearchPath_U ((PWCHAR)lpPath, (PWCHAR)lpFileName, (PWCHAR)lpExtension, retCode = RtlDosSearchPath_U ((PWCHAR)lpPath, (PWCHAR)lpFileName, (PWCHAR)lpExtension,

View file

@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.86 2004/05/13 20:30:26 navaraf Exp $ /* $Id: utils.c,v 1.87 2004/06/02 18:26:58 gvg Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -560,19 +560,32 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL,
ULONG ImageSize; ULONG ImageSize;
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status; NTSTATUS Status;
ULONG len;
DPRINT("LdrpMapDllImageFile() called\n"); DPRINT("LdrpMapDllImageFile() called\n");
if (SearchPath == NULL) if (SearchPath == NULL)
{ {
SearchPath = SearchPathBuffer; /* get application running path */
wcscpy (SearchPathBuffer, SharedUserData->NtSystemRoot);
wcscpy (SearchPathBuffer, NtCurrentPeb()->ProcessParameters->ImagePathName.Buffer);
len = wcslen (SearchPathBuffer);
while (len && SearchPathBuffer[len - 1] != L'\\')
len--;
if (len) SearchPathBuffer[len-1] = L'\0';
wcscat (SearchPathBuffer, L";");
wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot);
wcscat (SearchPathBuffer, L"\\system32;"); wcscat (SearchPathBuffer, L"\\system32;");
wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot); wcscat (SearchPathBuffer, SharedUserData->NtSystemRoot);
wcscat (SearchPathBuffer, L";."); wcscat (SearchPathBuffer, L";.");
}
DPRINT("SearchPath %S\n", SearchPath); SearchPath = SearchPathBuffer;
}
if (RtlDosSearchPath_U (SearchPath, if (RtlDosSearchPath_U (SearchPath,
DllName->Buffer, DllName->Buffer,
@ -582,7 +595,6 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL,
NULL) == 0) NULL) == 0)
return STATUS_DLL_NOT_FOUND; return STATUS_DLL_NOT_FOUND;
DPRINT("DosName %S\n", DosName);
if (!RtlDosPathNameToNtPathName_U (DosName, if (!RtlDosPathNameToNtPathName_U (DosName,
&FullNtFileName, &FullNtFileName,