Author: fireball
Date: Thu May 6 12:50:26 2010
New Revision: 47113
URL:
http://svn.reactos.org/svn/reactos?rev=47113&view=rev
Log:
[KERNEL32]
- Code committed in revision 846 was lazily initializing command line options with a first
call to GetCommandLine. However, this is not really thread-safe. Move initialization to
DLL_PROCESS_ATTACH, where it should actually happen.
See issue #5347 for more details.
Modified:
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/dll/win32/kernel32/misc/dllmain.c
trunk/reactos/dll/win32/kernel32/process/cmdline.c
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Thu May 6 12:50:26
2010
@@ -190,3 +190,7 @@
LPWSTR
GetDllLoadPath(LPCWSTR lpModule);
+
+VOID
+WINAPI
+InitCommandLines(VOID);
Modified: trunk/reactos/dll/win32/kernel32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/dl…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] Thu May 6 12:50:26 2010
@@ -330,6 +330,9 @@
wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer);
wcscat(SystemDirectory.Buffer, L"\\System32");
+ /* Initialize command line */
+ InitCommandLines();
+
/* Open object base directory */
Status = OpenBaseDirectory(&hBaseDir);
if (!NT_SUCCESS(Status))
Modified: trunk/reactos/dll/win32/kernel32/process/cmdline.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/process…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/process/cmdline.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/process/cmdline.c [iso-8859-1] Thu May 6 12:50:26
2010
@@ -27,19 +27,17 @@
/* FUNCTIONS ****************************************************************/
-static
VOID
+WINAPI
InitCommandLines(VOID)
{
PRTL_USER_PROCESS_PARAMETERS Params;
- /* FIXME - not thread-safe! */
-
- // get command line
+ /* get command line */
Params = NtCurrentPeb()->ProcessParameters;
RtlNormalizeProcessParams (Params);
- // initialize command line buffers
+ /* initialize command line buffers */
CommandLineStringW.Length = Params->CommandLine.Length;
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
@@ -80,13 +78,7 @@
WINAPI
GetCommandLineA(VOID)
{
- if (bCommandLineInitialized == FALSE)
- {
- InitCommandLines();
- }
-
DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
-
return CommandLineStringA.Buffer;
}
@@ -98,13 +90,7 @@
WINAPI
GetCommandLineW(VOID)
{
- if (bCommandLineInitialized == FALSE)
- {
- InitCommandLines();
- }
-
DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
-
return CommandLineStringW.Buffer;
}