mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-10-04 17:09:25 +00:00
NOISSUE Implement status code lookup for Win32
This commit is contained in:
@@ -39,7 +39,7 @@ if (WIN32)
|
|||||||
target_compile_definitions(systeminfo-ntstatus-gen PRIVATE
|
target_compile_definitions(systeminfo-ntstatus-gen PRIVATE
|
||||||
NTSTATUS_PREPROCESSOR_OUT=\"${systeminfo_PREPROCESSOR_OUT}\")
|
NTSTATUS_PREPROCESSOR_OUT=\"${systeminfo_PREPROCESSOR_OUT}\")
|
||||||
|
|
||||||
set(NTSTATUS_GEN_HEADER "${CMAKE_CURRENT_BINARY_DIR}/NtStatsuGen.h")
|
set(NTSTATUS_GEN_HEADER "${CMAKE_CURRENT_BINARY_DIR}/NtStatusGen.h")
|
||||||
set(NTSTATUS_GEN_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/NtStatusGen.cpp")
|
set(NTSTATUS_GEN_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/NtStatusGen.cpp")
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "NtStatsuGen.h"
|
#include "NtStatusGen.h"
|
||||||
|
|
||||||
Sys::KernelInfo Sys::getKernelInfo()
|
Sys::KernelInfo Sys::getKernelInfo()
|
||||||
{
|
{
|
||||||
@@ -59,6 +60,41 @@ Sys::DistributionInfo Sys::getDistributionInfo()
|
|||||||
|
|
||||||
bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &description)
|
bool Sys::lookupSystemStatusCode(uint64_t code, std::string &name, std::string &description)
|
||||||
{
|
{
|
||||||
|
bool hasCodeName = Win32::lookupNtStatusCodeName(code, name);
|
||||||
|
if(!hasCodeName)
|
||||||
|
{
|
||||||
|
name = "unknown status";
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
PSTR messageBuffer = nullptr;
|
||||||
|
HMODULE ntdll = GetModuleHandleA("ntdll.dll");
|
||||||
|
if(!ntdll)
|
||||||
|
{
|
||||||
|
// ???
|
||||||
|
qWarning() << "GetModuleHandleA returned nullptr for ntdll.dll";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto messageSize = FormatMessageA(
|
||||||
|
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_HMODULE,
|
||||||
|
ntdll,
|
||||||
|
code,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
reinterpret_cast<PSTR>(&messageBuffer),
|
||||||
|
0,
|
||||||
|
nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
bool hasDescription = messageSize > 0;
|
||||||
|
if(hasDescription)
|
||||||
|
{
|
||||||
|
description = std::string(messageBuffer, messageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(messageBuffer)
|
||||||
|
{
|
||||||
|
LocalFree(messageBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasCodeName || hasDescription;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user