mirror of
https://github.com/reactos/reactos.git
synced 2024-08-30 15:18:33 +00:00
[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. svn path=/trunk/; revision=47113
This commit is contained in:
parent
c47421927e
commit
a2464ecca7
|
@ -190,3 +190,7 @@ IntGetCodePageEntry(UINT CodePage);
|
||||||
|
|
||||||
LPWSTR
|
LPWSTR
|
||||||
GetDllLoadPath(LPCWSTR lpModule);
|
GetDllLoadPath(LPCWSTR lpModule);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
WINAPI
|
||||||
|
InitCommandLines(VOID);
|
||||||
|
|
|
@ -330,6 +330,9 @@ DllMain(HANDLE hDll,
|
||||||
wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer);
|
wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer);
|
||||||
wcscat(SystemDirectory.Buffer, L"\\System32");
|
wcscat(SystemDirectory.Buffer, L"\\System32");
|
||||||
|
|
||||||
|
/* Initialize command line */
|
||||||
|
InitCommandLines();
|
||||||
|
|
||||||
/* Open object base directory */
|
/* Open object base directory */
|
||||||
Status = OpenBaseDirectory(&hBaseDir);
|
Status = OpenBaseDirectory(&hBaseDir);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -27,19 +27,17 @@ static BOOL bCommandLineInitialized = FALSE;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
static
|
|
||||||
VOID
|
VOID
|
||||||
|
WINAPI
|
||||||
InitCommandLines(VOID)
|
InitCommandLines(VOID)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS Params;
|
PRTL_USER_PROCESS_PARAMETERS Params;
|
||||||
|
|
||||||
/* FIXME - not thread-safe! */
|
/* get command line */
|
||||||
|
|
||||||
// get command line
|
|
||||||
Params = NtCurrentPeb()->ProcessParameters;
|
Params = NtCurrentPeb()->ProcessParameters;
|
||||||
RtlNormalizeProcessParams (Params);
|
RtlNormalizeProcessParams (Params);
|
||||||
|
|
||||||
// initialize command line buffers
|
/* initialize command line buffers */
|
||||||
CommandLineStringW.Length = Params->CommandLine.Length;
|
CommandLineStringW.Length = Params->CommandLine.Length;
|
||||||
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
|
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
|
||||||
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
|
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
|
||||||
|
@ -80,13 +78,7 @@ LPSTR
|
||||||
WINAPI
|
WINAPI
|
||||||
GetCommandLineA(VOID)
|
GetCommandLineA(VOID)
|
||||||
{
|
{
|
||||||
if (bCommandLineInitialized == FALSE)
|
|
||||||
{
|
|
||||||
InitCommandLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
|
DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
|
||||||
|
|
||||||
return CommandLineStringA.Buffer;
|
return CommandLineStringA.Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,13 +90,7 @@ LPWSTR
|
||||||
WINAPI
|
WINAPI
|
||||||
GetCommandLineW(VOID)
|
GetCommandLineW(VOID)
|
||||||
{
|
{
|
||||||
if (bCommandLineInitialized == FALSE)
|
|
||||||
{
|
|
||||||
InitCommandLines();
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
|
DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
|
||||||
|
|
||||||
return CommandLineStringW.Buffer;
|
return CommandLineStringW.Buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue