1
0
Fork 0

DBG: NTSTATUS codes

This commit is contained in:
mrexodia 2016-09-04 01:08:19 +02:00
parent 08332377db
commit 184621c1e5
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
5 changed files with 2043 additions and 9 deletions

2007
bin/ntstatusdb.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#include "value.h"
#include "console.h"
std::unordered_map<unsigned int, String> ErrorNames;
static std::unordered_map<unsigned int, String> ErrorNames;
bool ErrorCodeInit(const String & errorFile)
{

View File

@ -4,15 +4,16 @@
#include "value.h"
#include "console.h"
std::unordered_map<unsigned int, String> ExceptionNames;
static std::unordered_map<unsigned int, String> ExceptionNames;
static std::unordered_map<unsigned int, String> NtStatusNames;
bool ExceptionCodeInit(const String & exceptionFile)
bool UniversalCodeInit(const String & file, std::unordered_map<unsigned int, String> & names)
{
ExceptionNames.clear();
names.clear();
std::vector<String> lines;
if(!FileHelper::ReadAllLines(exceptionFile, lines))
if(!FileHelper::ReadAllLines(file, lines))
return false;
auto parseLine = [](const String & line)
auto parseLine = [&names](const String & line)
{
auto split = StringUtils::Split(line, ' ');
if(int(split.size()) < 2)
@ -26,7 +27,7 @@ bool ExceptionCodeInit(const String & exceptionFile)
dprintf(QT_TRANSLATE_NOOP("DBG", "Failed to convert number \"%s\"\n"), split[0].c_str());
return false;
}
ExceptionNames.insert({ (unsigned int)code, split[1] });
names.insert({ (unsigned int)code, split[1] });
return true;
};
auto result = true;
@ -36,10 +37,28 @@ bool ExceptionCodeInit(const String & exceptionFile)
return result;
}
bool ExceptionCodeInit(const String & exceptionFile)
{
return UniversalCodeInit(exceptionFile, ExceptionNames);
}
String ExceptionCodeToName(unsigned int ExceptionCode)
{
if(ExceptionNames.find(ExceptionCode) == ExceptionNames.end())
return "";
return NtStatusCodeToName(ExceptionCode); //try NTSTATUS codes next
return ExceptionNames[ExceptionCode];
}
}
bool NtStatusCodeInit(const String & ntStatusFile)
{
return UniversalCodeInit(ntStatusFile, NtStatusNames);
}
String NtStatusCodeToName(unsigned NtStatusCode)
{
if(NtStatusNames.find(NtStatusCode) == NtStatusNames.end())
return "";
return NtStatusNames[NtStatusCode];
}

View File

@ -7,5 +7,7 @@
bool ExceptionCodeInit(const String & exceptionFile);
String ExceptionCodeToName(unsigned int ExceptionCode);
bool NtStatusCodeInit(const String & ntStatusFile);
String NtStatusCodeToName(unsigned int NtStatusCode);
#endif // _EXCEPTION_H

View File

@ -503,6 +503,12 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
else
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to load exception codes..."));
// Load NTSTATUS codes
if(NtStatusCodeInit(StringUtils::sprintf("%s\\..\\ntstatusdb.txt", dir)))
dputs(QT_TRANSLATE_NOOP("DBG", "NTSTATUS codes database loaded!"));
else
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to load NTSTATUS codes..."));
// Create database directory in the local debugger folder
DbSetPath(StringUtils::sprintf("%s\\db", dir).c_str(), nullptr);