[KERNEL32]

- Remove unneeded old commented code chunks.
- ConDllInitialize can set the current console locale for new threads,...
- ... and it can do its own cleaning.

svn path=/branches/condrv_restructure/; revision=64098
This commit is contained in:
Hermès Bélusca-Maïto 2014-09-09 21:24:44 +00:00
parent cfe6d0b69f
commit 2eeef60fe6
7 changed files with 73 additions and 171 deletions

View file

@ -3,8 +3,8 @@
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: dll/win32/kernel32/client/console/console.c * FILE: dll/win32/kernel32/client/console/console.c
* PURPOSE: Win32 server console functions * PURPOSE: Win32 server console functions
* PROGRAMMERS: James Tabor * PROGRAMMERS: James Tabor <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net>
* <jimtabor@adsl-64-217-116-74.dsl.hstntx.swbell.net> * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
*/ */
/* INCLUDES *******************************************************************/ /* INCLUDES *******************************************************************/
@ -1316,6 +1316,7 @@ AllocConsole(VOID)
/* Initialize Console Ctrl Handling */ /* Initialize Console Ctrl Handling */
InitializeCtrlHandling(); InitializeCtrlHandling();
/* Sets the current console locale for this thread */
SetTEBLangID(lcid); SetTEBLangID(lcid);
} }
@ -2578,6 +2579,7 @@ AttachConsole(DWORD dwProcessId)
/* Initialize Console Ctrl Handling */ /* Initialize Console Ctrl Handling */
InitializeCtrlHandling(); InitializeCtrlHandling();
/* Sets the current console locale for this thread */
SetTEBLangID(lcid); SetTEBLangID(lcid);
} }

View file

@ -25,30 +25,6 @@ IntStringSize(LPCVOID String,
ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR); ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR);
return (Size + 3) & ~3; return (Size + 3) & ~3;
} }
/* Copy a string to a capture buffer */
static VOID
IntCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer,
LPCVOID String,
BOOL Unicode,
PUNICODE_STRING RequestString)
{
ULONG Size;
if (Unicode)
{
Size = wcslen(String) * sizeof(WCHAR);
CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)String, Size, (PVOID *)&RequestString->Buffer);
}
else
{
Size = strlen(String);
CsrAllocateMessagePointer(CaptureBuffer, Size * sizeof(WCHAR), (PVOID *)&RequestString->Buffer);
Size = MultiByteToWideChar(CP_ACP, 0, String, Size, RequestString->Buffer, Size * sizeof(WCHAR))
* sizeof(WCHAR);
}
RequestString->Length = RequestString->MaximumLength = (USHORT)Size;
}
#endif #endif
static VOID static VOID
@ -80,8 +56,6 @@ IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOLEAN bUnicode)
return; return;
} }
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
// &ExpungeCommandHistoryRequest->ExeName);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
ExpungeCommandHistoryRequest->ExeLength, ExpungeCommandHistoryRequest->ExeLength,
@ -131,14 +105,11 @@ IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName
return 0; return 0;
} }
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
// &GetCommandHistoryRequest->ExeName);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
GetCommandHistoryRequest->ExeLength, GetCommandHistoryRequest->ExeLength,
(PVOID)&GetCommandHistoryRequest->ExeName); (PVOID)&GetCommandHistoryRequest->ExeName);
// CsrAllocateMessagePointer(CaptureBuffer, HistoryLength,
CsrAllocateMessagePointer(CaptureBuffer, GetCommandHistoryRequest->HistoryLength, CsrAllocateMessagePointer(CaptureBuffer, GetCommandHistoryRequest->HistoryLength,
(PVOID*)&GetCommandHistoryRequest->History); (PVOID*)&GetCommandHistoryRequest->History);
@ -192,8 +163,6 @@ IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
return 0; return 0;
} }
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
// &GetCommandHistoryLengthRequest->ExeName);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
GetCommandHistoryLengthRequest->ExeLength, GetCommandHistoryLengthRequest->ExeLength,
@ -248,8 +217,6 @@ IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
return FALSE; return FALSE;
} }
// IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode,
// &SetHistoryNumberCommandsRequest->ExeName);
CsrCaptureMessageBuffer(CaptureBuffer, CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)lpExeName, (PVOID)lpExeName,
SetHistoryNumberCommandsRequest->ExeLength, SetHistoryNumberCommandsRequest->ExeLength,

View file

@ -26,7 +26,7 @@ BOOLEAN ConsoleInitialized = FALSE;
extern HANDLE InputWaitHandle; extern HANDLE InputWaitHandle;
static HMODULE ConsoleLibrary = NULL; static HMODULE ConsoleApplet = NULL;
static BOOL AlreadyDisplayingProps = FALSE; static BOOL AlreadyDisplayingProps = FALSE;
static const PWSTR DefaultConsoleTitle = L"ReactOS Console"; static const PWSTR DefaultConsoleTitle = L"ReactOS Console";
@ -60,14 +60,14 @@ PropDialogHandler(IN LPVOID lpThreadParameter)
AlreadyDisplayingProps = TRUE; AlreadyDisplayingProps = TRUE;
/* Load the Control Applet if needed */ /* Load the Control Applet if needed */
if (ConsoleLibrary == NULL) if (ConsoleApplet == NULL)
{ {
WCHAR szBuffer[MAX_PATH]; WCHAR szBuffer[MAX_PATH];
GetSystemDirectoryW(szBuffer, MAX_PATH); GetSystemDirectoryW(szBuffer, MAX_PATH);
wcscat(szBuffer, L"\\console.dll"); wcscat(szBuffer, L"\\console.dll");
ConsoleLibrary = LoadLibraryW(szBuffer); ConsoleApplet = LoadLibraryW(szBuffer);
if (ConsoleLibrary == NULL) if (ConsoleApplet == NULL)
{ {
DPRINT1("Failed to load console.dll\n"); DPRINT1("Failed to load console.dll\n");
Status = STATUS_UNSUCCESSFUL; Status = STATUS_UNSUCCESSFUL;
@ -76,7 +76,7 @@ PropDialogHandler(IN LPVOID lpThreadParameter)
} }
/* Load its main function */ /* Load its main function */
CPLFunc = (APPLET_PROC)GetProcAddress(ConsoleLibrary, "CPlApplet"); CPLFunc = (APPLET_PROC)GetProcAddress(ConsoleApplet, "CPlApplet");
if (CPLFunc == NULL) if (CPLFunc == NULL)
{ {
DPRINT1("Error: Console.dll misses CPlApplet export\n"); DPRINT1("Error: Console.dll misses CPlApplet export\n");
@ -261,7 +261,7 @@ SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
/* We got the handles, let's set them */ /* We got the handles, let's set them */
Parameters->ConsoleHandle = ConsoleStartInfo->ConsoleHandle; Parameters->ConsoleHandle = ConsoleStartInfo->ConsoleHandle;
if (!(ConsoleStartInfo->dwStartupFlags & STARTF_USESTDHANDLES)) if ((ConsoleStartInfo->dwStartupFlags & STARTF_USESTDHANDLES) == 0)
{ {
Parameters->StandardInput = ConsoleStartInfo->InputHandle; Parameters->StandardInput = ConsoleStartInfo->InputHandle;
Parameters->StandardOutput = ConsoleStartInfo->OutputHandle; Parameters->StandardOutput = ConsoleStartInfo->OutputHandle;
@ -345,11 +345,24 @@ ConDllInitialize(IN ULONG Reason,
if (Reason != DLL_PROCESS_ATTACH) if (Reason != DLL_PROCESS_ATTACH)
{ {
if (Reason != DLL_THREAD_ATTACH || !IsConsoleApp()) if ((Reason == DLL_THREAD_ATTACH) && IsConsoleApp())
return TRUE; {
/* Sets the current console locale for the new thread */
SetTEBLangID(lcid);
}
else if (Reason == DLL_PROCESS_DETACH)
{
/* Free our resources */
if (ConsoleInitialized == TRUE)
{
if (ConsoleApplet) FreeLibrary(ConsoleApplet);
// Reason == DLL_THREAD_ATTACH and IsConsoleApp; ConsoleInitialized = FALSE;
goto Exit; RtlDeleteCriticalSection(&ConsoleLock);
}
}
return TRUE;
} }
DPRINT("ConDllInitialize for: %wZ\n" DPRINT("ConDllInitialize for: %wZ\n"
@ -509,7 +522,8 @@ ConDllInitialize(IN ULONG Reason,
SetUpHandles(&ConnectInfo.ConsoleStartInfo); SetUpHandles(&ConnectInfo.ConsoleStartInfo);
InputWaitHandle = ConnectInfo.ConsoleStartInfo.InputWaitHandle; InputWaitHandle = ConnectInfo.ConsoleStartInfo.InputWaitHandle;
Exit:
/* Sets the current console locale for this thread */
SetTEBLangID(lcid); SetTEBLangID(lcid);
} }
@ -522,19 +536,4 @@ Exit:
return TRUE; return TRUE;
} }
VOID
WINAPI
BasepUninitConsole(VOID)
{
/* Delete our critical section if we were initialized */
if (ConsoleInitialized == TRUE)
{
if (ConsoleLibrary) FreeLibrary(ConsoleLibrary);
ConsoleInitialized = FALSE;
RtlDeleteCriticalSection(&ConsoleLock);
}
}
/* EOF */ /* EOF */

View file

@ -163,7 +163,7 @@ IntReadConsole(IN HANDLE hConsoleInput,
} }
_SEH2_END; _SEH2_END;
/* Check for sanity */ /* FIXME: Check for sanity */
/* /*
if (!NT_SUCCESS(Status) && pInputControl) if (!NT_SUCCESS(Status) && pInputControl)
{ {
@ -1167,9 +1167,7 @@ IntFillConsoleOutputCode(IN HANDLE hConsoleOutput,
* Read functions * * Read functions *
******************/ ******************/
/*-------------------------------------------------------------- /*
* ReadConsoleW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1189,9 +1187,7 @@ ReadConsoleW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1211,9 +1207,7 @@ ReadConsoleA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* PeekConsoleInputW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1232,9 +1226,7 @@ PeekConsoleInputW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* PeekConsoleInputA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1253,9 +1245,7 @@ PeekConsoleInputA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleInputW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1274,9 +1264,7 @@ ReadConsoleInputW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleInputA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1295,9 +1283,7 @@ ReadConsoleInputA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleInputExW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1317,9 +1303,7 @@ ReadConsoleInputExW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleInputExA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1339,9 +1323,7 @@ ReadConsoleInputExA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleOutputW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1361,9 +1343,7 @@ ReadConsoleOutputW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleOutputA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1383,9 +1363,7 @@ ReadConsoleOutputA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleOutputCharacterW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1405,9 +1383,7 @@ ReadConsoleOutputCharacterW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleOutputCharacterA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1427,9 +1403,7 @@ ReadConsoleOutputCharacterA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* ReadConsoleOutputAttribute
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1453,9 +1427,7 @@ ReadConsoleOutputAttribute(IN HANDLE hConsoleOutput,
* Write functions * * Write functions *
*******************/ *******************/
/*-------------------------------------------------------------- /*
* WriteConsoleW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1475,9 +1447,7 @@ WriteConsoleW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1497,9 +1467,7 @@ WriteConsoleA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleInputW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1518,9 +1486,7 @@ WriteConsoleInputW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleInputA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1539,9 +1505,7 @@ WriteConsoleInputA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleInputVDMW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1560,9 +1524,7 @@ WriteConsoleInputVDMW(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleInputVDMA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1581,9 +1543,7 @@ WriteConsoleInputVDMA(IN HANDLE hConsoleInput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleOutputW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1603,9 +1563,7 @@ WriteConsoleOutputW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleOutputA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1625,9 +1583,7 @@ WriteConsoleOutputA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleOutputCharacterW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1647,9 +1603,7 @@ WriteConsoleOutputCharacterW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleOutputCharacterA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1669,9 +1623,7 @@ WriteConsoleOutputCharacterA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* WriteConsoleOutputAttribute
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1691,9 +1643,7 @@ WriteConsoleOutputAttribute(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* FillConsoleOutputCharacterW
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1715,9 +1665,7 @@ FillConsoleOutputCharacterW(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* FillConsoleOutputCharacterA
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -1739,9 +1687,7 @@ FillConsoleOutputCharacterA(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* FillConsoleOutputAttribute
*
* @implemented * @implemented
*/ */
BOOL BOOL

View file

@ -18,9 +18,7 @@
#if _WIN32_WINNT >= 0x600 #if _WIN32_WINNT >= 0x600
/*-------------------------------------------------------------- /*
* GetConsoleHistoryInfo
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -55,9 +53,7 @@ GetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo)
} }
/*-------------------------------------------------------------- /*
* SetConsoleHistoryInfo
*
* @implemented * @implemented
*/ */
BOOL BOOL
@ -92,9 +88,7 @@ SetConsoleHistoryInfo(IN PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo)
} }
/*-------------------------------------------------------------- /*
* GetConsoleOriginalTitleW
*
* @unimplemented * @unimplemented
*/ */
DWORD DWORD
@ -108,9 +102,7 @@ GetConsoleOriginalTitleW(OUT LPWSTR lpConsoleTitle,
} }
/*-------------------------------------------------------------- /*
* GetConsoleOriginalTitleA
*
* @unimplemented * @unimplemented
*/ */
DWORD DWORD
@ -124,9 +116,7 @@ GetConsoleOriginalTitleA(OUT LPSTR lpConsoleTitle,
} }
/*-------------------------------------------------------------- /*
* GetConsoleScreenBufferInfoEx
*
* @unimplemented * @unimplemented
*/ */
BOOL BOOL
@ -140,9 +130,7 @@ GetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* SetConsoleScreenBufferInfoEx
*
* @unimplemented * @unimplemented
*/ */
BOOL BOOL
@ -156,9 +144,7 @@ SetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput,
} }
/*-------------------------------------------------------------- /*
* GetCurrentConsoleFontEx
*
* @unimplemented * @unimplemented
*/ */
BOOL BOOL

View file

@ -219,18 +219,24 @@ DllMain(HANDLE hDll,
{ {
if (DllInitialized == TRUE) if (DllInitialized == TRUE)
{ {
/* Uninitialize console support */
ConDllInitialize(dwReason, NULL);
/* Insert more dll detach stuff here! */ /* Insert more dll detach stuff here! */
NlsUninit(); NlsUninit();
/* Uninitialize console support */
BasepUninitConsole();
/* Delete DLL critical section */ /* Delete DLL critical section */
RtlDeleteCriticalSection(&BaseDllDirectoryLock); RtlDeleteCriticalSection(&BaseDllDirectoryLock);
} }
break; break;
} }
case DLL_THREAD_ATTACH:
{
/* ConDllInitialize sets the current console locale for the new thread */
return ConDllInitialize(dwReason, NULL);
}
default: default:
break; break;
} }

View file

@ -26,10 +26,6 @@ WINAPI
ConDllInitialize(IN ULONG Reason, ConDllInitialize(IN ULONG Reason,
IN PWSTR SessionDir); IN PWSTR SessionDir);
VOID
WINAPI
BasepUninitConsole(VOID);
VOID VOID
InitializeCtrlHandling(VOID); InitializeCtrlHandling(VOID);