ReactOS 0.4.17-dev-116-ga4b6fe9
init.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/kernel32/client/console/init.c
5 * PURPOSE: Console API Client Initialization
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Aleksey Bragin (aleksey@reactos.org)
8 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9 */
10
11/* INCLUDES *******************************************************************/
12
13#include <k32.h>
14
15// For Control Panel Applet
16#include <cpl.h>
17
18#define NDEBUG
19#include <debug.h>
20
21
22/* GLOBALS ********************************************************************/
23
27static volatile LONG g_bConsoleIMEStartingUp = FALSE; // We use interlock, so LONG
28
29static const PWSTR DefaultConsoleTitle = L"ReactOS Console";
30
31/* FUNCTIONS ******************************************************************/
32
35PropDialogHandler(IN LPVOID lpThreadParameter)
36{
37 // NOTE: lpThreadParameter corresponds to the client shared section handle.
38
40 HMODULE hConsoleApplet = NULL;
42 static BOOL AlreadyDisplayingProps = FALSE;
43 WCHAR szBuffer[MAX_PATH];
44
45 /*
46 * Do not launch more than once the console property dialog applet,
47 * or (albeit less probable), if we are not initialized.
48 */
49 if (!ConsoleInitialized || AlreadyDisplayingProps)
50 {
51 /* Close the associated client shared section handle if needed */
52 if (lpThreadParameter)
53 CloseHandle((HANDLE)lpThreadParameter);
54
56 }
57
58 AlreadyDisplayingProps = TRUE;
59
60 /* Load the control applet */
62 wcscat(szBuffer, L"\\console.dll");
63 hConsoleApplet = LoadLibraryW(szBuffer);
64 if (hConsoleApplet == NULL)
65 {
66 DPRINT1("Failed to load console.dll\n");
68 goto Quit;
69 }
70
71 /* Load its main function */
72 CPlApplet = (APPLET_PROC)GetProcAddress(hConsoleApplet, "CPlApplet");
73 if (CPlApplet == NULL)
74 {
75 DPRINT1("Error: console.dll misses CPlApplet export\n");
77 goto Quit;
78 }
79
80 /* Initialize the applet */
81 if (CPlApplet(NULL, CPL_INIT, 0, 0) == FALSE)
82 {
83 DPRINT1("Error: failed to initialize console.dll\n");
85 goto Quit;
86 }
87
88 /* Check the count */
89 if (CPlApplet(NULL, CPL_GETCOUNT, 0, 0) != 1)
90 {
91 DPRINT1("Error: console.dll returned unexpected CPL count\n");
93 goto Quit;
94 }
95
96 /*
97 * Start the applet. For Windows compatibility purposes we need
98 * to pass the client shared section handle (lpThreadParameter)
99 * via the hWnd parameter of the CPlApplet function.
100 */
101 CPlApplet((HWND)lpThreadParameter, CPL_DBLCLK, 0, 0);
102
103 /* We have finished */
104 CPlApplet(NULL, CPL_EXIT, 0, 0);
105
106Quit:
107 if (hConsoleApplet) FreeLibrary(hConsoleApplet);
108 AlreadyDisplayingProps = FALSE;
109 return Status;
110}
111
112
113static INT
115 LPCWSTR lpszKeyword)
116{
117 DPRINT("ParseShellInfo is UNIMPLEMENTED\n");
118 return 0;
119}
120
121
122/*
123 * NOTE:
124 * The "LPDWORD Length" parameters point on input to the maximum size of
125 * the buffers that can hold data (if != 0), and on output they hold the
126 * real size of the data. If "Length" are == 0 on input, then on output
127 * they receive the full size of the data.
128 * The "LPWSTR* lpTitle" parameter has a double meaning:
129 * - when "CaptureTitle" is TRUE, data is copied to the buffer pointed
130 * by the pointer (*lpTitle).
131 * - when "CaptureTitle" is FALSE, "*lpTitle" is set to the address of
132 * the source data.
133 */
134VOID
136 IN OUT LPDWORD pTitleLength,
138 IN OUT LPDWORD pDesktopLength,
139 IN OUT LPWSTR* lpDesktop OPTIONAL,
140 IN OUT PCONSOLE_START_INFO ConsoleStartInfo)
141{
144
145 /* Initialize the fields */
146
147 ConsoleStartInfo->IconIndex = 0;
148 ConsoleStartInfo->hIcon = NULL;
149 ConsoleStartInfo->hIconSm = NULL;
150 ConsoleStartInfo->dwStartupFlags = Parameters->WindowFlags;
151 ConsoleStartInfo->nFont = 0;
152 ConsoleStartInfo->nInputBufferSize = 0;
153 ConsoleStartInfo->uCodePage = GetOEMCP();
154
155 if (lpTitle)
156 {
158
159 /* If we don't have any title, use the default one */
160 if (Parameters->WindowTitle.Buffer == NULL)
161 {
163 Length = lstrlenW(DefaultConsoleTitle) * sizeof(WCHAR); // sizeof(DefaultConsoleTitle);
164 }
165 else
166 {
167 Title = Parameters->WindowTitle.Buffer;
168 Length = Parameters->WindowTitle.Length;
169 }
170
171 /* Retrieve the needed buffer size */
172 Length += sizeof(WCHAR);
173 if (*pTitleLength > 0) Length = min(Length, *pTitleLength);
174 *pTitleLength = Length;
175
176 /* Capture the data if needed, or, return a pointer to it */
177 if (CaptureTitle)
178 {
179 /*
180 * Length is always >= sizeof(WCHAR). Copy everything but the
181 * possible trailing NULL character, and then NULL-terminate.
182 */
183 Length -= sizeof(WCHAR);
185 (*lpTitle)[Length / sizeof(WCHAR)] = UNICODE_NULL;
186 }
187 else
188 {
189 *lpTitle = Title;
190 }
191 }
192 else
193 {
194 *pTitleLength = 0;
195 }
196
197 if (lpDesktop && Parameters->DesktopInfo.Buffer && *Parameters->DesktopInfo.Buffer)
198 {
199 /* Retrieve the needed buffer size */
200 Length = Parameters->DesktopInfo.Length + sizeof(WCHAR);
201 if (*pDesktopLength > 0) Length = min(Length, *pDesktopLength);
202 *pDesktopLength = Length;
203
204 /* Return a pointer to the data */
205 *lpDesktop = Parameters->DesktopInfo.Buffer;
206 }
207 else
208 {
209 *pDesktopLength = 0;
210 if (lpDesktop) *lpDesktop = NULL;
211 }
212
213 if (Parameters->WindowFlags & STARTF_USEFILLATTRIBUTE)
214 {
215 ConsoleStartInfo->wFillAttribute = (WORD)Parameters->FillAttribute;
216 }
217 if (Parameters->WindowFlags & STARTF_USECOUNTCHARS)
218 {
219 ConsoleStartInfo->dwScreenBufferSize.X = (SHORT)Parameters->CountCharsX;
220 ConsoleStartInfo->dwScreenBufferSize.Y = (SHORT)Parameters->CountCharsY;
221 }
222 if (Parameters->WindowFlags & STARTF_USESHOWWINDOW)
223 {
224 ConsoleStartInfo->wShowWindow = (WORD)Parameters->ShowWindowFlags;
225 }
226 if (Parameters->WindowFlags & STARTF_USEPOSITION)
227 {
228 ConsoleStartInfo->dwWindowOrigin.X = (SHORT)Parameters->StartingX;
229 ConsoleStartInfo->dwWindowOrigin.Y = (SHORT)Parameters->StartingY;
230 }
231 if (Parameters->WindowFlags & STARTF_USESIZE)
232 {
233 ConsoleStartInfo->dwWindowSize.X = (SHORT)Parameters->CountX;
234 ConsoleStartInfo->dwWindowSize.Y = (SHORT)Parameters->CountY;
235 }
236
237 /* Get shell information (ShellInfo.Buffer is NULL-terminated) */
238 if (Parameters->ShellInfo.Buffer != NULL)
239 {
240 ConsoleStartInfo->IconIndex = ParseShellInfo(Parameters->ShellInfo.Buffer, L"dde.");
241
242 if ((Parameters->WindowFlags & STARTF_USEHOTKEY) == 0)
243 ConsoleStartInfo->dwHotKey = ParseShellInfo(Parameters->ShellInfo.Buffer, L"hotkey.");
244 else
245 ConsoleStartInfo->dwHotKey = HandleToUlong(Parameters->StandardInput);
246 }
247}
248
249
250VOID
252{
254
255 if (ConsoleStartInfo->dwStartupFlags & STARTF_USEHOTKEY)
256 {
257 Parameters->WindowFlags &= ~STARTF_USEHOTKEY;
258 }
259 if (ConsoleStartInfo->dwStartupFlags & STARTF_SHELLPRIVATE)
260 {
261 Parameters->WindowFlags &= ~STARTF_SHELLPRIVATE;
262 }
263
264 /* We got the handles, let's set them */
265 Parameters->ConsoleHandle = ConsoleStartInfo->ConsoleHandle;
266
267 if ((ConsoleStartInfo->dwStartupFlags & STARTF_USESTDHANDLES) == 0)
268 {
269 Parameters->StandardInput = ConsoleStartInfo->InputHandle;
270 Parameters->StandardOutput = ConsoleStartInfo->OutputHandle;
271 Parameters->StandardError = ConsoleStartInfo->ErrorHandle;
272 }
273}
274
275
276static BOOLEAN
278{
282}
283
284
285static BOOLEAN
287 IN PCONSRV_API_CONNECTINFO ConnectInfo,
288 OUT PBOOLEAN InServerProcess)
289{
291 ULONG ConnectInfoSize = sizeof(*ConnectInfo);
292
293 ASSERT(SessionDir);
294
295 /* Connect to the Console Server */
296 DPRINT("Connecting to the Console Server...\n");
297 Status = CsrClientConnectToServer(SessionDir,
299 ConnectInfo,
300 &ConnectInfoSize,
301 InServerProcess);
302 if (!NT_SUCCESS(Status))
303 {
304 DPRINT1("Failed to connect to the Console Server (Status %lx)\n", Status);
305 return FALSE;
306 }
307
308 /* Nothing to do for server-to-server */
309 if (*InServerProcess) return TRUE;
310
311 /* Nothing to do if this is not a console app */
312 if (!ConnectInfo->IsConsoleApp) return TRUE;
313
314 /* Wait for the connection to finish */
315 // Is ConnectInfo->ConsoleStartInfo.InitEvents aligned on handle boundary ????
317 ConnectInfo->ConsoleStartInfo.InitEvents,
318 WaitAny, FALSE, NULL);
319 if (!NT_SUCCESS(Status))
320 {
322 return FALSE;
323 }
324
325 NtClose(ConnectInfo->ConsoleStartInfo.InitEvents[INIT_SUCCESS]);
326 NtClose(ConnectInfo->ConsoleStartInfo.InitEvents[INIT_FAILURE]);
327 if (Status != INIT_SUCCESS)
328 {
329 NtCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
330 return FALSE;
331 }
332
333 return TRUE;
334}
335
336/* Query registry value */
337static NTSTATUS
340 _In_ PCWSTR pszValueName,
341 _Out_ PVOID pvValue,
342 _In_ ULONG cbValue)
343{
345 ULONG cbInfo, cbResult;
347 UNICODE_STRING valueName;
349
352 pInfo = HeapAlloc(hProcessHeap, 0, cbInfo);
353 if (!pInfo)
354 return STATUS_NO_MEMORY;
355
356 RtlInitUnicodeString(&valueName, pszValueName);
357
359 pInfo, cbInfo, &cbResult);
360 if (NT_SUCCESS(status))
361 {
362 const ULONG cbCopy = min(pInfo->DataLength, cbValue);
363 RtlCopyMemory(pvValue, pInfo->Data, cbCopy);
364
365 /* SECURITY: Avoid buffer overrun */
366 if (pInfo->Type == REG_SZ && cbValue >= sizeof(UNICODE_NULL))
367 ((PWCHAR)pvValue)[cbValue / sizeof(WCHAR) - 1] = UNICODE_NULL;
368 }
369
370 HeapFree(hProcessHeap, 0, pInfo);
371 return status;
372}
373
374/* Quote a path string if necessary */
375static NTSTATUS
377 _Inout_updates_z_(cchPathMax) PWSTR pszPath,
378 _In_ UINT cchPathMax)
379{
380 size_t cchLen;
381
382 if (!wcschr(pszPath, L' '))
383 return STATUS_SUCCESS;
384
385 cchLen = wcslen(pszPath) + 1;
386 if (cchLen + 2 > cchPathMax) /* for 2 quotes */
388
389 RtlMoveMemory(pszPath + 1, pszPath, cchLen * sizeof(WCHAR));
390 pszPath[0] = L'"';
391 pszPath[cchLen] = L'"';
392 pszPath[cchLen + 1] = UNICODE_NULL;
393 return STATUS_SUCCESS;
394}
395
396/* Reject bad relative paths */
398{
399 /* Replace '/' with '\\' to detect the bad paths easily */
400 INT ich;
401 for (ich = 0; pszPath[ich]; ++ich)
402 {
403 if (pszPath[ich] == L'/')
404 pszPath[ich] = L'\\';
405 }
406
407 /* Avoid path traversal */
408 return (memcmp(pszPath, L"..\\", 3 * sizeof(WCHAR)) && !wcsstr(pszPath, L"\\..\\"));
409}
410
411/* Build the conime.exe command line */
412static VOID
414 _Out_ PWSTR pszBuffer,
416{
417 UINT cchSysDir;
418 HANDLE hKey;
419 UNICODE_STRING keyName;
422 WCHAR szValue[MAX_PATH];
423 static const PCWSTR ConsoleKey =
424 L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Console";
425
426 cchSysDir = GetSystemDirectoryW(pszBuffer, cchBuffer);
427 if (cchSysDir > 0 && cchSysDir < cchBuffer - 1)
428 {
429 RtlStringCchCatW(pszBuffer, cchBuffer, L"\\");
430 cchSysDir = (UINT)wcslen(pszBuffer);
431 }
432 else
433 {
434 *pszBuffer = UNICODE_NULL;
435 cchSysDir = 0;
436 }
437
438 /* Open registry key */
439 RtlInitUnicodeString(&keyName, ConsoleKey);
442 if (NT_SUCCESS(status))
443 {
444 /* Query "ConsoleIME" value */
445 status = IntRegQueryValue(hKey, L"ConsoleIME", szValue, sizeof(szValue));
446 NtClose(hKey);
447 if (NT_SUCCESS(status))
448 {
449 /* Malicious relative paths should be rejected (ReactOS-only) */
450 if (szValue[0] && IntIsSafeRelativePath(szValue))
451 {
452 /* Append value to pszBuffer */
453 status = RtlStringCchCatW(pszBuffer, cchBuffer, szValue);
454 if (NT_SUCCESS(status))
455 {
456 /* Quote the path if necessary (ReactOS-only). Avoid path traversal */
458 if (NT_SUCCESS(status))
459 {
460 DPRINT("ConsoleIME: '%S'\n", pszBuffer);
461 return; /* Success */
462 }
463 }
464 /* It failed. Let's try the default path */
465 pszBuffer[cchSysDir] = UNICODE_NULL;
466 }
467 }
468 }
469 else
470 {
471 DPRINT1("Opening registry failed: 0x%08X\n", status);
472 }
473
474 RtlStringCchCatW(pszBuffer, cchBuffer, L"conime.exe");
475
476 /* Quote the path if necessary (ReactOS-only). Avoid path traversal */
478 if (!NT_SUCCESS(status))
479 RtlStringCchCopyW(pszBuffer, cchBuffer, L"conime.exe"); /* Use filename only */
480}
481
487DWORD
488WINAPI
490{
491 HANDLE hStartUpEvent;
492 DWORD dwError;
493 WCHAR szCommandLine[2 * MAX_PATH];
496 DWORD dwCreationFlags;
497
499
501 return STATUS_UNSUCCESSFUL; /* NOTE: There's confusion between error codes and NTSTATUS */
502
503 hStartUpEvent = CreateEventW(NULL, FALSE, FALSE, L"ConsoleIME_StartUp_Event");
504 dwError = GetLastError();
505 if (dwError == ERROR_ALREADY_EXISTS)
506 {
507 CloseHandle(hStartUpEvent);
508 hStartUpEvent = NULL;
509 }
510 if (!hStartUpEvent)
511 {
513 return ERROR_SUCCESS;
514 }
515
516 RtlZeroMemory(&si, sizeof(si));
517 si.cb = sizeof(si);
518 si.lpDesktop = NtCurrentPeb()->ProcessParameters->DesktopInfo.Buffer;
519 si.dwFlags = STARTF_FORCEONFEEDBACK;
520
521 /* Let's create a conime.exe process */
522 GetConsoleIMECommandLine(szCommandLine, _countof(szCommandLine));
525 if (CreateProcessW(NULL, szCommandLine, NULL, NULL, FALSE, dwCreationFlags,
526 NULL, NULL, &si, &pi))
527 {
528 /* Wait 10 seconds for conime.exe to start up */
529 const DWORD dwWait = WaitForSingleObject(hStartUpEvent, 10 * 1000);
530 if (dwWait == WAIT_TIMEOUT)
534 dwError = ERROR_SUCCESS;
535 }
536 else
537 {
538 dwError = GetLastError();
539 DPRINT1("'%S' startup failed: 0x%08X\n", szCommandLine, dwError);
540 }
541
542 CloseHandle(hStartUpEvent);
543
545 return dwError;
546}
547
549WINAPI
551 IN PWSTR SessionDir)
552{
555 BOOLEAN InServerProcess = FALSE;
556 CONSRV_API_CONNECTINFO ConnectInfo;
557
559 {
561 {
562 /* Sync the new thread's LangId with the console's one */
563 SetTEBLangID();
564 }
565 else if (Reason == DLL_PROCESS_DETACH)
566 {
567 /* Free our resources */
569 {
572 }
573 }
574
575 return TRUE;
576 }
577
578 DPRINT("ConDllInitialize for: %wZ\n"
579 "Our current console handles are: 0x%p, 0x%p, 0x%p 0x%p\n",
580 &Parameters->ImagePathName,
581 Parameters->ConsoleHandle,
582 Parameters->StandardInput,
583 Parameters->StandardOutput,
584 Parameters->StandardError);
585
586 /* Initialize our global console DLL lock */
588 if (!NT_SUCCESS(Status)) return FALSE;
590
591 /* Show by default the console window when applicable */
592 ConnectInfo.IsWindowVisible = TRUE;
593 /* If this is a console app, a console will be created/opened */
594 ConnectInfo.IsConsoleApp = IsConsoleApp();
595
596 /* Do nothing if this is not a console app... */
597 if (!ConnectInfo.IsConsoleApp)
598 {
599 DPRINT("Image is not a console application\n");
600 }
601
602 /*
603 * Handle the special flags given to us by BasePushProcessParameters.
604 */
605 if (Parameters->ConsoleHandle == HANDLE_DETACHED_PROCESS)
606 {
607 /* No console to create */
608 DPRINT("No console to create\n");
609 /*
610 * The new process does not inherit its parent's console and cannot
611 * attach to the console of its parent. The new process can call the
612 * AllocConsole function at a later time to create a console.
613 */
614 Parameters->ConsoleHandle = NULL; // Do not inherit the parent's console.
615 ConnectInfo.IsConsoleApp = FALSE; // Do not create any console.
616 }
617 else if (Parameters->ConsoleHandle == HANDLE_CREATE_NEW_CONSOLE)
618 {
619 /* We'll get the real one soon */
620 DPRINT("Creating a new separate console\n");
621 /*
622 * The new process has a new console, instead of inheriting
623 * its parent's console.
624 */
625 Parameters->ConsoleHandle = NULL; // Do not inherit the parent's console.
626 }
627 else if (Parameters->ConsoleHandle == HANDLE_CREATE_NO_WINDOW)
628 {
629 /* We'll get the real one soon */
630 DPRINT("Creating a new invisible console\n");
631 /*
632 * The process is a console application that is being run
633 * without a console window. Therefore, the console handle
634 * for the application is not set.
635 */
636 Parameters->ConsoleHandle = NULL; // Do not inherit the parent's console.
637 ConnectInfo.IsWindowVisible = FALSE; // A console is created but is not shown to the user.
638 }
639 else
640 {
641 DPRINT("Using existing console: 0x%p\n", Parameters->ConsoleHandle);
642 }
643
644 /* Do nothing if this is not a console app... */
645 if (!ConnectInfo.IsConsoleApp)
646 {
647 /* Do not inherit the parent's console if we are not a console app */
648 Parameters->ConsoleHandle = NULL;
649 }
650
651 /* Now use the proper console handle */
652 ConnectInfo.ConsoleStartInfo.ConsoleHandle = Parameters->ConsoleHandle;
653
654 /* Initialize the console dispatchers */
656 ConnectInfo.PropRoutine = PropDialogHandler;
657 ConnectInfo.ImeRoutine = ConsoleIMERoutine;
658
659 /* Set up the console properties */
660 if (ConnectInfo.IsConsoleApp && Parameters->ConsoleHandle == NULL)
661 {
662 /*
663 * We can set up the console properties only if we create a new one
664 * (we do not inherit it from our parent).
665 */
666
667 LPWSTR ConsoleTitle = ConnectInfo.ConsoleTitle;
668
669 ConnectInfo.TitleLength = sizeof(ConnectInfo.ConsoleTitle);
670 ConnectInfo.DesktopLength = 0; // SetUpConsoleInfo will give us the real length.
671
673 &ConnectInfo.TitleLength,
674 &ConsoleTitle,
675 &ConnectInfo.DesktopLength,
676 &ConnectInfo.Desktop,
677 &ConnectInfo.ConsoleStartInfo);
678 DPRINT("ConsoleTitle = '%S' - Desktop = '%S'\n",
679 ConsoleTitle, ConnectInfo.Desktop);
680 }
681 else
682 {
683 ConnectInfo.TitleLength = 0;
684 ConnectInfo.DesktopLength = 0;
685 }
686
687 /* Initialize the Input EXE name */
688 if (ConnectInfo.IsConsoleApp)
689 {
690 LPWSTR CurDir = ConnectInfo.CurDir;
691 LPWSTR AppName = ConnectInfo.AppName;
692
693 InitExeName();
694
695 ConnectInfo.CurDirLength = sizeof(ConnectInfo.CurDir);
696 ConnectInfo.AppNameLength = sizeof(ConnectInfo.AppName);
697
699 &ConnectInfo.CurDirLength,
700 &CurDir,
701 &ConnectInfo.AppNameLength,
702 &AppName);
703 DPRINT("CurDir = '%S' - AppName = '%S'\n",
704 CurDir, AppName);
705 }
706 else
707 {
708 ConnectInfo.CurDirLength = 0;
709 ConnectInfo.AppNameLength = 0;
710 }
711
712 /*
713 * Initialize Console Ctrl Handling, that needs to be supported by
714 * all applications, especially because it is used at shutdown.
715 */
717
718 /* Connect to the Console Server */
719 if (!ConnectConsole(SessionDir,
720 &ConnectInfo,
721 &InServerProcess))
722 {
723 // DPRINT1("Failed to connect to the Console Server (Status %lx)\n", Status);
724 return FALSE;
725 }
726
727 /* If we are not doing server-to-server init and if this is a console app... */
728 if (!InServerProcess && ConnectInfo.IsConsoleApp)
729 {
730 /* ... set the handles that we got */
731 if (Parameters->ConsoleHandle == NULL)
732 SetUpHandles(&ConnectInfo.ConsoleStartInfo);
733
735
736 /* Sync the current thread's LangId with the console's one */
737 SetTEBLangID();
738 }
739
740 DPRINT("Console setup: 0x%p, 0x%p, 0x%p, 0x%p\n",
741 Parameters->ConsoleHandle,
742 Parameters->StandardInput,
743 Parameters->StandardOutput,
744 Parameters->StandardError);
745
746 return TRUE;
747}
748
749/* EOF */
#define NtCurrentPeb()
Definition: FLS.c:22
unsigned char BOOLEAN
Definition: actypes.h:127
#define InterlockedExchange
Definition: armddk.h:54
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define HandleToUlong(h)
Definition: basetsd.h:73
@ MAX_INIT_EVENTS
Definition: conmsg.h:165
@ INIT_SUCCESS
Definition: conmsg.h:163
@ INIT_FAILURE
Definition: conmsg.h:164
#define CONSRV_SERVERDLL_INDEX
Definition: conmsg.h:15
LONG(APIENTRY * APPLET_PROC)(HWND, UINT, LPARAM, LPARAM)
Definition: cpl.h:23
#define CPL_DBLCLK
Definition: cpl.h:16
#define CPL_INIT
Definition: cpl.h:12
#define CPL_EXIT
Definition: cpl.h:18
#define CPL_GETCOUNT
Definition: cpl.h:13
TCHAR lpTitle[80]
Definition: ctm.c:69
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
PIMAGE_NT_HEADERS WINAPI ImageNtHeader(_In_ PVOID)
#define WAIT_TIMEOUT
Definition: dderror.h:14
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
static const WCHAR Title[]
Definition: oid.c:1259
#define CloseHandle
Definition: compat.h:739
#define wcschr
Definition: compat.h:17
#define GetProcessHeap()
Definition: compat.h:736
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define FreeLibrary(x)
Definition: compat.h:748
#define RtlImageNtHeader
Definition: compat.h:806
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define LoadLibraryW(x)
Definition: compat.h:747
#define lstrlenW
Definition: compat.h:750
static DWORD cchBuffer
Definition: fusion.c:85
VOID InitExeName(VOID)
Definition: console.c:216
DWORD WINAPI ConsoleControlDispatcher(IN LPVOID lpThreadParameter)
Definition: console.c:89
VOID SetTEBLangID(VOID)
Internal helper function used to synchronize the current thread's language ID with the one from the c...
Definition: console.c:3177
VOID InitializeCtrlHandling(VOID)
Definition: console.c:204
VOID SetUpAppName(IN BOOLEAN CaptureStrings, IN OUT LPDWORD CurDirLength, IN OUT LPWSTR *CurDir, IN OUT LPDWORD AppNameLength, IN OUT LPWSTR *AppName)
Definition: console.c:264
static INT ParseShellInfo(LPCWSTR lpszShellInfo, LPCWSTR lpszKeyword)
Definition: init.c:114
static const PWSTR DefaultConsoleTitle
Definition: init.c:29
DWORD WINAPI PropDialogHandler(IN LPVOID lpThreadParameter)
Definition: init.c:35
VOID SetUpConsoleInfo(IN BOOLEAN CaptureTitle, IN OUT LPDWORD pTitleLength, IN OUT LPWSTR *lpTitle OPTIONAL, IN OUT LPDWORD pDesktopLength, IN OUT LPWSTR *lpDesktop OPTIONAL, IN OUT PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:135
static NTSTATUS IntPathQuoteSpacesW(_Inout_updates_z_(cchPathMax) PWSTR pszPath, _In_ UINT cchPathMax)
Definition: init.c:376
RTL_CRITICAL_SECTION ConsoleLock
Definition: init.c:24
static NTSTATUS IntRegQueryValue(_In_ HANDLE hKey, _In_ PCWSTR pszValueName, _Out_ PVOID pvValue, _In_ ULONG cbValue)
Definition: init.c:338
static BOOL IntIsSafeRelativePath(_Inout_z_ PWSTR pszPath)
Definition: init.c:397
static BOOLEAN ConnectConsole(IN PWSTR SessionDir, IN PCONSRV_API_CONNECTINFO ConnectInfo, OUT PBOOLEAN InServerProcess)
Definition: init.c:286
DWORD WINAPI ConsoleIMERoutine(_In_ PVOID unused)
This function is called from winsrv.dll, in the context of the console application,...
Definition: init.c:489
HANDLE InputWaitHandle
Definition: console.c:38
BOOLEAN WINAPI ConDllInitialize(IN ULONG Reason, IN PWSTR SessionDir)
Definition: init.c:550
static volatile LONG g_bConsoleIMEStartingUp
Definition: init.c:27
VOID SetUpHandles(IN PCONSOLE_START_INFO ConsoleStartInfo)
Definition: init.c:251
static VOID GetConsoleIMECommandLine(_Out_ PWSTR pszBuffer, _In_ UINT cchBuffer)
Definition: init.c:413
static BOOLEAN IsConsoleApp(VOID)
Definition: init.c:277
BOOLEAN ConsoleInitialized
Definition: init.c:25
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2232
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4442
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1376
#define HANDLE_CREATE_NEW_CONSOLE
Definition: console.h:14
#define HANDLE_CREATE_NO_WINDOW
Definition: console.h:15
#define HANDLE_DETACHED_PROCESS
Definition: console.h:13
UINT WINAPI GetOEMCP(void)
Definition: locale.c:2062
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_ACRTIMP wchar_t *__cdecl wcsstr(const wchar_t *, const wchar_t *)
Definition: wcs.c:2993
#define L(x)
Definition: resources.c:13
HANDLE hProcessHeap
Definition: explorer.cpp:25
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
#define InterlockedCompareExchange
Definition: interlocked.h:119
#define REG_SZ
Definition: layer.c:22
#define ASSERT(a)
Definition: mode.c:44
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
static PROCESS_INFORMATION pi
Definition: debugger.c:2303
static SYSTEM_INFO si
Definition: virtual.c:39
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
WORD unused[29]
Definition: crypt.c:1298
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define _Inout_updates_z_(s)
Definition: no_sal2.h:186
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _Inout_z_
Definition: no_sal2.h:166
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
@ KeyValuePartialInformation
Definition: nt_native.h:1185
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
@ WaitAny
#define IMAGE_SUBSYSTEM_WINDOWS_CUI
Definition: ntimage.h:438
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:127
NTSTRSAFEAPI RtlStringCchCatW(_Inout_updates_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:601
NTSTATUS NTAPI NtWaitForMultipleObjects(IN ULONG ObjectCount, IN PHANDLE HandleArray, IN WAIT_TYPE WaitType, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:46
#define STARTF_USEHOTKEY
Definition: pch.h:41
short WCHAR
Definition: pedump.c:58
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:167
NTSTATUS NTAPI CsrClientConnectToServer(_In_ PCWSTR ObjectDirectory, _In_ ULONG ServerId, _In_ PVOID ConnectionInfo, _Inout_ PULONG ConnectionInfoSize, _Out_ PBOOLEAN ServerToServerCall)
Definition: connect.c:196
wcscat
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define DPRINT
Definition: sndvol32.h:73
#define _countof(array)
Definition: sndvol32.h:70
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
HANDLE InputWaitHandle
Definition: conmsg.h:171
HANDLE ConsoleHandle
Definition: conmsg.h:170
BOOLEAN IsWindowVisible
Definition: conmsg.h:189
WCHAR ConsoleTitle[MAX_PATH+1]
Definition: conmsg.h:198
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:194
LPTHREAD_START_ROUTINE ImeRoutine
Definition: conmsg.h:195
WCHAR AppName[128]
Definition: conmsg.h:204
WCHAR CurDir[MAX_PATH+1]
Definition: conmsg.h:206
CONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:186
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:193
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
Definition: cookie.c:202
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * PBOOLEAN
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869
#define NORMAL_PRIORITY_CLASS
Definition: winbase.h:185
#define STARTF_USEPOSITION
Definition: winbase.h:470
#define CREATE_BREAKAWAY_FROM_JOB
Definition: winbase.h:213
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define STARTF_USESHOWWINDOW
Definition: winbase.h:468
#define STARTF_USECOUNTCHARS
Definition: winbase.h:471
#define STARTF_USEFILLATTRIBUTE
Definition: winbase.h:472
#define CREATE_DEFAULT_ERROR_MODE
Definition: winbase.h:215
#define CREATE_NEW_PROCESS_GROUP
Definition: winbase.h:189
#define STARTF_USESTDHANDLES
Definition: winbase.h:476
#define STARTF_FORCEONFEEDBACK
Definition: winbase.h:474
#define STARTF_USESIZE
Definition: winbase.h:469
#define WINAPI
Definition: msvc.h:6