[ros-diffs] [fireball] 51197: [KERNEL32] - Rename global vars to some better names (some of the names seen in Windows 2003 asserts and text messages). - Add BaseDefaultPath initialization, which will be needed...
fireball at svn.reactos.org
fireball at svn.reactos.org
Tue Mar 29 21:48:13 UTC 2011
Author: fireball
Date: Tue Mar 29 21:48:13 2011
New Revision: 51197
URL: http://svn.reactos.org/svn/reactos?rev=51197&view=rev
Log:
[KERNEL32]
- Rename global vars to some better names (some of the names seen in Windows 2003 asserts and text messages).
- Add BaseDefaultPath initialization, which will be needed but the new kernel32/ldr code, which is in turn required by the new ntdll/ldr code.
- Add some beginnings of BasepGetDllPath(), but it returns NULL anyway now so no change in execution.
Modified:
trunk/reactos/dll/win32/kernel32/file/curdir.c
trunk/reactos/dll/win32/kernel32/file/dir.c
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/dll/win32/kernel32/misc/console.c
trunk/reactos/dll/win32/kernel32/misc/dllmain.c
trunk/reactos/dll/win32/kernel32/process/procsup.c
Modified: trunk/reactos/dll/win32/kernel32/file/curdir.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/curdir.c?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/curdir.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/curdir.c [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -28,6 +28,8 @@
UNICODE_STRING SystemDirectory;
UNICODE_STRING WindowsDirectory;
+UNICODE_STRING BaseDefaultPathAppend;
+UNICODE_STRING BaseDefaultPath;
/* FUNCTIONS *****************************************************************/
Modified: trunk/reactos/dll/win32/kernel32/file/dir.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/file/dir.c?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/file/dir.c [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -20,7 +20,7 @@
#include <debug.h>
DEBUG_CHANNEL(kernel32file);
-UNICODE_STRING DllDirectory = {0, 0, NULL};
+UNICODE_STRING BaseDllDirectory = {0, 0, NULL};
/* FUNCTIONS *****************************************************************/
@@ -1079,35 +1079,35 @@
RtlInitUnicodeString(&PathName, lpPathName);
- RtlEnterCriticalSection(&DllLock);
+ RtlEnterCriticalSection(&BaseDllDirectoryLock);
if(PathName.Length > 0)
{
- if(PathName.Length + sizeof(WCHAR) <= DllDirectory.MaximumLength)
- {
- RtlCopyUnicodeString(&DllDirectory, &PathName);
+ if(PathName.Length + sizeof(WCHAR) <= BaseDllDirectory.MaximumLength)
+ {
+ RtlCopyUnicodeString(&BaseDllDirectory, &PathName);
}
else
{
- RtlFreeUnicodeString(&DllDirectory);
- if(!(DllDirectory.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(),
- 0,
- PathName.Length + sizeof(WCHAR))))
+ RtlFreeUnicodeString(&BaseDllDirectory);
+ if(!(BaseDllDirectory.Buffer = (PWSTR)RtlAllocateHeap(RtlGetProcessHeap(),
+ 0,
+ PathName.Length + sizeof(WCHAR))))
{
- RtlLeaveCriticalSection(&DllLock);
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
- DllDirectory.Length = 0;
- DllDirectory.MaximumLength = PathName.Length + sizeof(WCHAR);
-
- RtlCopyUnicodeString(&DllDirectory, &PathName);
+ BaseDllDirectory.Length = 0;
+ BaseDllDirectory.MaximumLength = PathName.Length + sizeof(WCHAR);
+
+ RtlCopyUnicodeString(&BaseDllDirectory, &PathName);
}
}
else
{
- RtlFreeUnicodeString(&DllDirectory);
+ RtlFreeUnicodeString(&BaseDllDirectory);
}
- RtlLeaveCriticalSection(&DllLock);
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
return TRUE;
}
@@ -1144,10 +1144,10 @@
{
DWORD Ret;
- RtlEnterCriticalSection(&DllLock);
+ RtlEnterCriticalSection(&BaseDllDirectoryLock);
if(nBufferLength > 0)
{
- Ret = DllDirectory.Length / sizeof(WCHAR);
+ Ret = BaseDllDirectory.Length / sizeof(WCHAR);
if(Ret > nBufferLength - 1)
{
Ret = nBufferLength - 1;
@@ -1155,16 +1155,16 @@
if(Ret > 0)
{
- RtlCopyMemory(lpBuffer, DllDirectory.Buffer, Ret * sizeof(WCHAR));
+ RtlCopyMemory(lpBuffer, BaseDllDirectory.Buffer, Ret * sizeof(WCHAR));
}
lpBuffer[Ret] = L'\0';
}
else
{
/* include termination character, even if the string is empty! */
- Ret = (DllDirectory.Length / sizeof(WCHAR)) + 1;
+ Ret = (BaseDllDirectory.Length / sizeof(WCHAR)) + 1;
}
- RtlLeaveCriticalSection(&DllLock);
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
return Ret;
}
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include/kernel32.h?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -91,9 +91,9 @@
extern HANDLE hBaseDir;
extern HMODULE hCurrentModule;
-extern RTL_CRITICAL_SECTION DllLock;
-
-extern UNICODE_STRING DllDirectory;
+extern RTL_CRITICAL_SECTION BaseDllDirectoryLock;
+
+extern UNICODE_STRING BaseDllDirectory;
extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
@@ -211,6 +211,12 @@
OUT PHANDLE hSection,
IN PUNICODE_STRING ApplicationName);
+LPWSTR
+WINAPI
+BasepGetDllPath(LPWSTR FullPath,
+ PVOID Environment);
+
+
PCODEPAGE_ENTRY FASTCALL
IntGetCodePageEntry(UINT CodePage);
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/console.c?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -3524,7 +3524,7 @@
{
BOOL Ret;
- RtlEnterCriticalSection(&DllLock);
+ RtlEnterCriticalSection(&BaseDllDirectoryLock);
if (Add)
{
Ret = AddConsoleCtrlHandler(HandlerRoutine);
@@ -3534,7 +3534,7 @@
Ret = RemoveConsoleCtrlHandler(HandlerRoutine);
}
- RtlLeaveCriticalSection(&DllLock);
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
return(Ret);
}
Modified: trunk/reactos/dll/win32/kernel32/misc/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/dllmain.c?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -5,6 +5,7 @@
* FILE: lib/kernel32/misc/dllmain.c
* PURPOSE: Initialization
* PROGRAMMER: Ariadne ( ariadne at xs4all.nl)
+ * Aleksey Bragin (aleksey at reactos.org)
* UPDATE HISTORY:
* Created 01/11/98
*/
@@ -20,6 +21,10 @@
extern UNICODE_STRING SystemDirectory;
extern UNICODE_STRING WindowsDirectory;
+extern UNICODE_STRING BaseDefaultPath;
+extern UNICODE_STRING BaseDefaultPathAppend;
+
+WCHAR BaseDefaultPathBuffer[6140];
HANDLE hProcessHeap = NULL;
HMODULE hCurrentModule = NULL;
@@ -36,7 +41,7 @@
LPVOID lpReserved);
/* Critical section for various kernel32 data structures */
-RTL_CRITICAL_SECTION DllLock;
+RTL_CRITICAL_SECTION BaseDllDirectoryLock;
RTL_CRITICAL_SECTION ConsoleLock;
extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event);
@@ -275,6 +280,9 @@
/* Don't bother us for each thread */
LdrDisableThreadCalloutsForDll((PVOID)hDll);
+ /* Initialize default path to NULL */
+ RtlInitUnicodeString(&BaseDefaultPath, NULL);
+
/* Setup the right Object Directory path */
if (!SessionId)
{
@@ -332,10 +340,24 @@
SystemDirectory.MaximumLength);
if(SystemDirectory.Buffer == NULL)
{
+ DPRINT1("Failure allocating SystemDirectory buffer\n");
return FALSE;
}
wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer);
wcscat(SystemDirectory.Buffer, L"\\System32");
+
+ /* Construct the default path (using the static buffer) */
+ _snwprintf(BaseDefaultPathBuffer, sizeof(BaseDefaultPathBuffer) / sizeof(WCHAR),
+ L".;%wZ;%wZ\\system;%wZ;", &SystemDirectory, &WindowsDirectory, &WindowsDirectory);
+
+ BaseDefaultPath.Buffer = BaseDefaultPathBuffer;
+ BaseDefaultPath.Length = wcslen(BaseDefaultPathBuffer) * sizeof(WCHAR);
+ BaseDefaultPath.MaximumLength = sizeof(BaseDefaultPathBuffer);
+
+ /* Use remaining part of the default path buffer for the append path */
+ BaseDefaultPathAppend.Buffer = (PWSTR)((ULONG_PTR)BaseDefaultPathBuffer + BaseDefaultPath.Length);
+ BaseDefaultPathAppend.Length = 0;
+ BaseDefaultPathAppend.MaximumLength = BaseDefaultPath.MaximumLength - BaseDefaultPath.Length;
/* Initialize command line */
InitCommandLines();
@@ -349,7 +371,7 @@
}
/* Initialize the DLL critical section */
- RtlInitializeCriticalSection(&DllLock);
+ RtlInitializeCriticalSection(&BaseDllDirectoryLock);
/* Initialize the National Language Support routines */
if (!NlsInit())
@@ -395,7 +417,7 @@
ConsoleInitialized = FALSE;
RtlDeleteCriticalSection (&ConsoleLock);
}
- RtlDeleteCriticalSection (&DllLock);
+ RtlDeleteCriticalSection (&BaseDllDirectoryLock);
/* Close object base directory */
NtClose(hBaseDir);
Modified: trunk/reactos/dll/win32/kernel32/process/procsup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process/procsup.c?rev=51197&r1=51196&r2=51197&view=diff
==============================================================================
--- trunk/reactos/dll/win32/kernel32/process/procsup.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/process/procsup.c [iso-8859-1] Tue Mar 29 21:48:13 2011
@@ -13,6 +13,9 @@
#define NDEBUG
#include <debug.h>
+
+UNICODE_STRING BasePathVariableName = RTL_CONSTANT_STRING(L"PATH");
+UNICODE_STRING BaseDefaultPath;
#define CMD_STRING L"cmd /c "
@@ -354,11 +357,44 @@
LPWSTR
WINAPI
+BasepGetProcessPath(DWORD Reserved,
+ LPWSTR FullPath,
+ PVOID Environment)
+{
+ return NULL;
+}
+
+LPWSTR
+WINAPI
BasepGetDllPath(LPWSTR FullPath,
PVOID Environment)
{
- /* FIXME: Not yet implemented */
- return NULL;
+ LPWSTR DllPath = NULL;
+
+ /* Acquire DLL directory lock */
+ RtlEnterCriticalSection(&BaseDllDirectoryLock);
+
+ /* Check if we have a base dll directory */
+ if (BaseDllDirectory.Buffer)
+ {
+ /* Then get process path */
+ DllPath = BasepGetProcessPath(0, FullPath, Environment);
+
+ /* Release DLL directory lock */
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
+
+ /* Return dll path */
+ return DllPath;
+ }
+
+ /* Release DLL directory lock */
+ RtlLeaveCriticalSection(&BaseDllDirectoryLock);
+
+ /* There is no base DLL directory */
+ UNIMPLEMENTED;
+
+ /* Return dll path */
+ return DllPath;
}
VOID
More information about the Ros-diffs
mailing list