[KERNEL32]

- No need to explicitely convert the pointers to PVOID in the NtQueryInformationProcess calls, and do not hardcode the size-of the variable being passed in parameter.
- "Fix" FatalAppExitW: it's only in checked builds that one can continue running the application even after a FatalAppExitW call.

svn path=/trunk/; revision=71793
This commit is contained in:
Hermès Bélusca-Maïto 2016-07-03 13:48:50 +00:00
parent f844461ede
commit 21d2accad3

View file

@ -915,8 +915,8 @@ GetProcessAffinityMask(IN HANDLE hProcess,
/* Query information on the process from the kernel */ /* Query information on the process from the kernel */
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessBasicInformation, ProcessBasicInformation,
(PVOID)&ProcessInfo, &ProcessInfo,
sizeof(PROCESS_BASIC_INFORMATION), sizeof(ProcessInfo),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -1032,7 +1032,7 @@ GetProcessWorkingSetSizeEx(IN HANDLE hProcess,
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessQuotaLimits, ProcessQuotaLimits,
&QuotaLimits, &QuotaLimits,
sizeof(QUOTA_LIMITS_EX), sizeof(QuotaLimits),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -1220,7 +1220,7 @@ GetExitCodeProcess(IN HANDLE hProcess,
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessBasicInformation, ProcessBasicInformation,
&ProcessBasic, &ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION), sizeof(ProcessBasic),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -1251,7 +1251,7 @@ GetProcessId(IN HANDLE Process)
Status = NtQueryInformationProcess(Process, Status = NtQueryInformationProcess(Process,
ProcessBasicInformation, ProcessBasicInformation,
&ProcessBasic, &ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION), sizeof(ProcessBasic),
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -1615,7 +1615,7 @@ FatalAppExitA(UINT uAction,
MessageTextU = &NtCurrentTeb()->StaticUnicodeString; MessageTextU = &NtCurrentTeb()->StaticUnicodeString;
RtlInitAnsiString(&MessageText, (LPSTR)lpMessageText); RtlInitAnsiString(&MessageText, (LPSTR)lpMessageText);
/* Convert to unicode and just exit normally if this failed */ /* Convert to unicode, or just exit normally if this failed */
Status = RtlAnsiStringToUnicodeString(MessageTextU, &MessageText, FALSE); Status = RtlAnsiStringToUnicodeString(MessageTextU, &MessageText, FALSE);
if (!NT_SUCCESS(Status)) ExitProcess(0); if (!NT_SUCCESS(Status)) ExitProcess(0);
@ -1643,11 +1643,18 @@ FatalAppExitW(IN UINT uAction,
1, 1,
1, 1,
(PULONG_PTR)&UnicodeString, (PULONG_PTR)&UnicodeString,
#if DBG
/* On Checked builds, Windows allows the user to cancel the operation */
OptionOkCancel, OptionOkCancel,
#else
OptionOk,
#endif
&Response); &Response);
#if DBG
/* Give the user a chance to abort */ /* Give the user a chance to abort */
if ((NT_SUCCESS(Status)) && (Response == ResponseCancel)) return; if ((NT_SUCCESS(Status)) && (Response == ResponseCancel)) return;
#endif
/* Otherwise kill the process */ /* Otherwise kill the process */
ExitProcess(0); ExitProcess(0);
@ -1661,7 +1668,7 @@ WINAPI
FatalExit(IN int ExitCode) FatalExit(IN int ExitCode)
{ {
#if DBG #if DBG
/* On Checked builds, Windows gives you a nice little debugger UI */ /* On Checked builds, Windows gives the user a nice little debugger UI */
CHAR ch[2]; CHAR ch[2];
DbgPrint("FatalExit...\n"); DbgPrint("FatalExit...\n");
DbgPrint("\n"); DbgPrint("\n");
@ -1701,7 +1708,7 @@ GetPriorityClass(IN HANDLE hProcess)
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessPriorityClass, ProcessPriorityClass,
&PriorityClass, &PriorityClass,
sizeof(PROCESS_PRIORITY_CLASS), sizeof(PriorityClass),
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -1933,7 +1940,7 @@ GetProcessPriorityBoost(IN HANDLE hProcess,
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessPriorityBoost, ProcessPriorityBoost,
&PriorityBoost, &PriorityBoost,
sizeof(ULONG), sizeof(PriorityBoost),
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
@ -1990,7 +1997,7 @@ GetProcessHandleCount(IN HANDLE hProcess,
Status = NtQueryInformationProcess(hProcess, Status = NtQueryInformationProcess(hProcess,
ProcessHandleCount, ProcessHandleCount,
&phc, &phc,
sizeof(ULONG), sizeof(phc),
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {