59 pUnicodeString->Length = pUnicodeString->MaximumLength;
111 if (SizeOfAllUnicodeStrings)
112 *SizeOfAllUnicodeStrings = 0;
115 for (nParam = 0; nParam <
Message->NumberOfParameters; ++nParam)
120 if (
Message->UnicodeStringParameterMask & (1 << nParam))
130 sizeof(ParamStringU),
135 DPRINT1(
"NtReadVirtualMemory(Message->Parameters) failed, Status 0x%lx, skipping.\n",
Status);
161 DPRINT1(
"NtReadVirtualMemory(ParamStringU) failed, Status 0x%lx, skipping.\n",
Status);
168 DPRINT(
"ParamString = \'%wZ\'\n", &TempStringU);
197 DPRINT1(
"RtlUnicodeStringToAnsiString() failed, Status 0x%lx, skipping.\n",
Status);
214 if (SizeOfAllUnicodeStrings)
215 *SizeOfAllUnicodeStrings =
Size;
227 for (nParam = 0; nParam <
Message->NumberOfParameters; ++nParam)
230 if ((
Message->UnicodeStringParameterMask & (1 << nParam)) && (
Parameters[nParam] != 0))
255 RtlInitEmptyUnicodeString(ClientFileNameU,
NULL, 0);
261 sizeof(ClientBasicInfo),
295 sizeof(ClientDllBase),
301 ClientFileNameU->MaximumLength =
ModuleData.BaseDllName.MaximumLength;
304 ClientFileNameU->MaximumLength);
305 if (!ClientFileNameU->Buffer)
307 RtlInitEmptyUnicodeString(ClientFileNameU,
NULL, 0);
313 ClientFileNameU->Buffer,
314 ClientFileNameU->MaximumLength,
318 RtlFreeHeap(RtlGetProcessHeap(), 0, ClientFileNameU->Buffer);
319 RtlInitEmptyUnicodeString(ClientFileNameU,
NULL, 0);
323 ClientFileNameU->Length = (
USHORT)(
wcslen(ClientFileNameU->Buffer) *
sizeof(
WCHAR));
324 DPRINT(
"ClientFileNameU = \'%wZ\'\n", &ClientFileNameU);
343 &FormatU, &TempStringU)))
350 DPRINT1(
"Cannot allocate memory for UnicodeString, use original buffer.\n");
375 static const PCWSTR pszUnknownHardError =
376 L"Unknown Hard Error 0x%08lx\n"
377 L"Parameters: 0x%p 0x%p 0x%p 0x%p";
378 static const PCWSTR pszExceptionHardError =
379 L"Exception processing message 0x%08lx\n"
380 L"Parameters: 0x%p 0x%p 0x%p 0x%p";
389 UNICODE_STRING WindowTitleU, FileNameU, TempStringU, FormatU, Format2U;
404 DPRINT1(
"NtOpenProcess failed with status 0x%08lx, possibly SYSTEM process.\n",
Status);
412 TextStringU->Length = 0;
415 CaptionStringU->Length = 0;
439 if (
Message->UnicodeStringParameterMask & 0x1)
441 if (
Message->UnicodeStringParameterMask & 0x2)
445 if (
Message->NumberOfParameters >= 4)
455 switch (
Message->ValidResponseOptions)
527 if (MessageResource->
Flags)
547 RtlInitEmptyUnicodeString(&FormatU,
NULL, 0);
560 for (TempStringU.
Length = 0;
588 RtlInitEmptyUnicodeString(&WindowTitleU,
L"", 0);
598 cszBuffer *=
sizeof(
WCHAR);
604 RtlInitEmptyUnicodeString(&WindowTitleU, pszBuffer, (
USHORT)cszBuffer);
617 if (CaptionStringU->MaximumLength < cszBuffer)
626 DPRINT1(
"Cannot allocate memory for CaptionStringU, use original buffer.\n");
630 RtlInitEmptyUnicodeString(CaptionStringU, pszBuffer, (
USHORT)cszBuffer);
633 CaptionStringU->Length = 0;
638 CaptionStringU->MaximumLength,
640 &WindowTitleU, &FileNameU, &TempStringU);
641 CaptionStringU->Length = (
USHORT)(
wcslen(CaptionStringU->Buffer) *
sizeof(
WCHAR));
668 if (MessageResource->
Flags)
685 CopyParameters[0] = CopyParameters[1];
686 CopyParameters[1] = CopyParameters[3];
687 if (CopyParameters[2])
696 CopyParameters[0] = CopyParameters[1];
697 CopyParameters[1] = CopyParameters[3];
702 CopyParameters[2] = CopyParameters[1];
703 CopyParameters[1] = CopyParameters[0];
705 pszBuffer = Format2U.
Buffer;
706 if (!
_wcsnicmp(pszBuffer,
L"{EXCEPTION}", 11))
717 CopyParameters[0] = (
ULONG_PTR)pszBuffer;
722 CopyParameters[0] = (
ULONG_PTR)
L"unknown software exception";
729 CopyParameters[2] = CopyParameters[1];
730 CopyParameters[1] = CopyParameters[0];
731 CopyParameters[0] = (
ULONG_PTR)
L"unknown software exception";
752 cszBuffer *=
sizeof(
WCHAR);
757 CopyParameters[0], CopyParameters[1],
758 CopyParameters[2], CopyParameters[3]);
759 cszBuffer *=
sizeof(
WCHAR);
785 cszBuffer *=
sizeof(
WCHAR);
791 if (TextStringU->MaximumLength < cszBuffer)
800 DPRINT1(
"Cannot allocate memory for TextStringU, use original buffer.\n");
804 RtlInitEmptyUnicodeString(TextStringU, pszBuffer, (
USHORT)cszBuffer);
807 TextStringU->Length = 0;
814 pszBuffer = TextStringU->Buffer;
815 cszBuffer = TextStringU->MaximumLength;
829 &pszBuffer, &cszBuffer,
832 CopyParameters[0], CopyParameters[1],
833 CopyParameters[2], CopyParameters[3]);
842 &pszBuffer, &cszBuffer,
850 &pszBuffer, &cszBuffer,
861 DPRINT1(
"Exception 0x%08lx occurred while building hard-error message, fall back to default message.\n",
865 TextStringU->MaximumLength,
866 pszExceptionHardError,
939 ULONG ShellErrorMode;
949 ShellErrorMode =
GetRegInt(
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Windows",
950 L"ShellErrorMode", 0);
953 if (ShellErrorMode != 1)
965 cbTitleLen = CaptionStringU->Length +
sizeof(
UNICODE_NULL);
968 dwSize += cbTextLen + cbTitleLen;
974 DPRINT1(
"Failed to allocate balloon data\n");
983 pdata->MessageOffset =
pdata->TitleOffset + cbTitleLen;
986 RtlStringCbCopyNW(pCaption, cbTitleLen, CaptionStringU->Buffer, CaptionStringU->Length);
994 CopyData.lpData =
pdata;
1014 ULONG MessageBoxResponse;
1016 DPRINT(
"Text = '%S', Caption = '%S', Type = 0x%lx\n",
1017 TextStringU->Buffer, CaptionStringU->Buffer,
Type);
1021 TextStringU->Buffer,
1022 CaptionStringU->Buffer,
1026 switch (MessageBoxResponse)
1058 DPRINT1(
"ElfRegisterEventSourceW failed with Status 0x%08lx\n",
Status);
1075 DPRINT1(
"ElfReportEventW failed with Status 0x%08lx\n",
Status);
1090 WCHAR LocalTextBuffer[256];
1091 WCHAR LocalCaptionBuffer[256];
1103 DPRINT1(
"Invalid NumberOfParameters = %d\n",
Message->NumberOfParameters);
1108 DPRINT1(
"Unknown ValidResponseOptions = %d\n",
Message->ValidResponseOptions);
1113 if (
Message->NumberOfParameters < 3)
1115 DPRINT1(
"Invalid NumberOfParameters = %d for STATUS_SERVICE_NOTIFICATION\n",
1128 DPRINT1(
"Failed to set thread desktop!\n");
1136 RtlInitEmptyUnicodeString(&TextU, LocalTextBuffer,
sizeof(LocalTextBuffer));
1137 RtlInitEmptyUnicodeString(&CaptionU, LocalCaptionBuffer,
sizeof(LocalCaptionBuffer));
1146 ErrorMode =
GetRegInt(
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Windows",
1178 if (TextU.
Buffer != LocalTextBuffer)
1180 if (CaptionU.
Buffer != LocalCaptionBuffer)
1192 LCID CurrentUserLCID = 0;
1198 DPRINT1(
"NtQueryDefaultLocale failed with Status = 0x%08lx\n",
Status);
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
_Inout_ PIRP _In_ NTSTATUS ExceptionCode
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
NTSTATUS NTAPI ElfDeregisterEventSource(IN HANDLE hEventLog)
NTSTATUS NTAPI ElfReportEventW(IN HANDLE hEventLog, IN USHORT EventType, IN USHORT EventCategory, IN ULONG EventID, IN PSID UserSID, IN USHORT NumStrings, IN ULONG DataSize, IN PUNICODE_STRING *Strings, IN PVOID Data, IN USHORT Flags, IN OUT PULONG RecordNumber, IN OUT PULONG TimeWritten)
NTSTATUS NTAPI ElfRegisterEventSourceW(IN PUNICODE_STRING UNCServerNameU, IN PUNICODE_STRING SourceNameU, OUT PHANDLE phEventLog)
static const WCHAR Strings[]
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
static const WCHAR Message[]
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define STATUS_SEVERITY_WARNING
#define STATUS_SEVERITY_ERROR
#define STATUS_SEVERITY_INFORMATIONAL
#define STATUS_SEVERITY_SUCCESS
DWORD FormatString(DWORD dwFlags, HINSTANCE hInstance, DWORD dwStringId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, va_list *Arguments)
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
VOID RtlLoadUnicodeString(IN HINSTANCE hInstance OPTIONAL, IN UINT uID, OUT PUNICODE_STRING pUnicodeString, IN PCWSTR pDefaultString)
static VOID UserpCaptureStringParameters(OUT PULONG_PTR Parameters, OUT PULONG SizeOfAllUnicodeStrings, IN PHARDERROR_MSG Message, IN HANDLE hProcess OPTIONAL)
LANGID g_CurrentUserLangId
int WINAPI MessageBoxTimeoutW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType, WORD wLanguageId, DWORD dwTime)
int __cdecl _scwprintf(const wchar_t *format,...)
UNICODE_STRING g_SuccessU
static NTSTATUS UserpGetClientFileName(OUT PUNICODE_STRING ClientFileNameU, IN HANDLE hProcess)
static BOOL UserpShowInformationBalloon(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU, IN UINT Type, IN PHARDERROR_MSG Message)
static VOID UserpFormatMessages(IN OUT PUNICODE_STRING TextStringU, IN OUT PUNICODE_STRING CaptionStringU, OUT PUINT pdwType, OUT PULONG pdwTimeout, IN PHARDERROR_MSG Message)
static HARDERROR_RESPONSE UserpMessageBox(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU, IN UINT Type, IN ULONG Timeout)
static VOID UserpLogHardError(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU)
UNICODE_STRING g_WarningU
static VOID UserpDuplicateParamStringToUnicodeString(IN OUT PUNICODE_STRING UnicodeString, IN PCWSTR ParamString)
VOID NTAPI UserServerHardError(IN PCSR_THREAD ThreadData, IN PHARDERROR_MSG Message)
UNICODE_STRING g_InformationU
UNICODE_STRING g_OKTerminateU
UNICODE_STRING g_SystemProcessU
UNICODE_STRING g_CancelDebugU
static ULONG GetRegInt(IN PCWSTR KeyName, IN PCWSTR ValueName, IN ULONG DefaultValue)
static VOID UserpFreeStringParameters(IN OUT PULONG_PTR Parameters, IN PHARDERROR_MSG Message)
VOID UserInitHardErrorsCache(VOID)
_Check_return_ _CRTIMP int __cdecl _vscwprintf(_In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define PROCESS_QUERY_INFORMATION
NTSTATUS NTAPI NtUserSetInformationThread(IN HANDLE ThreadHandle, IN USERTHREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
@ UserThreadRestoreDesktop
@ UserThreadUseActiveDesktop
#define OBJ_CASE_INSENSITIVE
@ ProcessBasicInformation
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
#define EXCEPTION_EXECUTE_HANDLER
LIST_ENTRY * ModuleListHead
_In_ BOOL _In_ HANDLE hProcess
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define InitializeObjectAttributes(p, n, a, r, s)
static PROTOCOLDATA * pdata
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
#define MAXIMUM_HARDERROR_PARAMETERS
@ OptionCancelTryContinue
enum _HARDERROR_RESPONSE HARDERROR_RESPONSE
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
@ KeyValuePartialInformation
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
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)
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define MAKELCID(lgid, srtid)
_In_ ULONG _In_ ULONG _In_ ULONG Length
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
#define STATUS_UNHANDLED_EXCEPTION
#define STATUS_ACCESS_VIOLATION
#define STATUS_IN_PAGE_ERROR
#define STATUS_LOG_HARD_ERROR
#define STATUS_SERVICE_NOTIFICATION
NTSTRSAFEVAPI RtlStringCbPrintfExW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _Outptr_opt_result_bytebuffer_(*pcbRemaining) NTSTRSAFE_PWSTR *ppszDestEnd, _Out_opt_ size_t *pcbRemaining, _In_ STRSAFE_DWORD dwFlags, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define LANGIDFROMLCID(l)
#define SUBLANG_ENGLISH_US
PULONG MinorVersion OPTIONAL
base of all file and directory entries
struct _LIST_ENTRY * Flink
UCHAR Text[ANYSIZE_ARRAY]
LIST_ENTRY InLoadOrderModuleList
#define RTL_CONSTANT_STRING(s)
#define RtlCopyMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_UNSUCCESSFUL
HWND WINAPI GetTaskmanWindow(VOID)
struct _BALLOON_HARD_ERROR_DATA BALLOON_HARD_ERROR_DATA
#define MB_CANCELTRYCONTINUE
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG _Out_ PULONG ResultLength
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
BOOL CALLBACK FindTopLevelWnd(IN HWND hWnd, IN LPARAM lParam)
HINSTANCE UserServerDllInstance
#define IDS_SEVERITY_INFORMATIONAL
#define IDS_SEVERITY_WARNING
#define IDS_SEVERITY_SUCCESS
#define IDS_SYSTEM_PROCESS
#define IDS_OK_TERMINATE_PROGRAM
#define IDS_SEVERITY_ERROR
#define IDS_CANCEL_DEBUG_PROGRAM
DWORD WINAPI GetLastError(void)
#define EVENTLOG_INFORMATION_TYPE
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
UINT WINAPI RegisterWindowMessageW(_In_ LPCWSTR)
#define MB_ABORTRETRYIGNORE
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define MB_ICONINFORMATION
BOOL WINAPI EnumThreadWindows(_In_ DWORD, _In_ WNDENUMPROC, _In_ LPARAM)
#define RtlUnicodeStringToAnsiSize(String)
#define NtCurrentThread()