Add files via upload

This commit is contained in:
Useful Stuffs
2024-02-11 12:51:01 +01:00
committed by GitHub
commit eac708fbdc
96 changed files with 28373 additions and 0 deletions

20
shared/HResult.c Normal file
View File

@@ -0,0 +1,20 @@
#include <windows.h>
#include "WUErrors.h"
EXTERN_C LPWSTR GetMessageForHresult(HRESULT hr) {
LPWSTR message;
for (int i = 0; WUErrorMessages[i].hr != 0; i++) {
if (WUErrorMessages[i].hr == hr) {
message = (LPWSTR)LocalAlloc(LPTR, 4096 * sizeof(WCHAR));
lstrcpy(message, WUErrorMessages[i].message);
return message;
}
}
if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&message, 0, NULL) == 0) {
message = (LPWSTR)LocalAlloc(LPTR, 1024 * sizeof(WCHAR));
wsprintf(message, L"Error 0x%08x", hr);
}
return message;
}