mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
output this module base if abnormal in crashlogs
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
DWORD WINAPI MainThread(LPVOID lpParam)
|
||||
{
|
||||
U::CrashLog.Initialize();
|
||||
U::CrashLog.Initialize(lpParam);
|
||||
|
||||
U::Core.Load();
|
||||
U::Core.Loop();
|
||||
|
||||
@@ -21,6 +21,7 @@ struct Frame_t
|
||||
};
|
||||
|
||||
static PVOID s_pHandle;
|
||||
static LPVOID s_lpParam;
|
||||
static std::unordered_map<LPVOID, bool> s_mAddresses = {};
|
||||
static int s_iExceptions = 0;
|
||||
|
||||
@@ -111,7 +112,10 @@ static LONG APIENTRY ExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
s_mAddresses[ExceptionInfo->ExceptionRecord->ExceptionAddress] = true;
|
||||
|
||||
std::stringstream ssErrorStream;
|
||||
ssErrorStream << std::format("Error: {} (0x{:X}) ({})\n\n", sError, ExceptionInfo->ExceptionRecord->ExceptionCode, ++s_iExceptions);
|
||||
ssErrorStream << std::format("Error: {} (0x{:X}) ({})\n", sError, ExceptionInfo->ExceptionRecord->ExceptionCode, ++s_iExceptions);
|
||||
if (U::Memory.GetOffsetFromBase(s_lpParam))
|
||||
ssErrorStream << std::format("This: {}\n", U::Memory.GetModuleOffset(s_lpParam));
|
||||
ssErrorStream << "\n";
|
||||
|
||||
ssErrorStream << std::format("RIP: {:#x}\n", ExceptionInfo->ContextRecord->Rip);
|
||||
ssErrorStream << std::format("RAX: {:#x}\n", ExceptionInfo->ContextRecord->Rax);
|
||||
@@ -174,9 +178,10 @@ static LONG APIENTRY ExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo)
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void CCrashLog::Initialize()
|
||||
void CCrashLog::Initialize(LPVOID lpParam)
|
||||
{
|
||||
s_pHandle = AddVectoredExceptionHandler(1, ExceptionFilter);
|
||||
s_lpParam = lpParam;
|
||||
}
|
||||
void CCrashLog::Unload()
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
#include "../Macros/Macros.h"
|
||||
#include <Windows.h>
|
||||
|
||||
class CCrashLog
|
||||
{
|
||||
public:
|
||||
void Initialize();
|
||||
void Initialize(LPVOID lpParam = nullptr);
|
||||
void Unload();
|
||||
};
|
||||
|
||||
|
||||
@@ -110,4 +110,14 @@ std::string CMemory::GetModuleOffset(uintptr_t uAddress)
|
||||
return std::format("{}+{:#x}", buffer, uAddress - uBase);
|
||||
|
||||
return std::format("{:#x}+{:#x}", uBase, uAddress - uBase);
|
||||
}
|
||||
|
||||
uintptr_t CMemory::GetOffsetFromBase(uintptr_t uAddress)
|
||||
{
|
||||
HMODULE hModule;
|
||||
if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, LPCSTR(uAddress), &hModule))
|
||||
return -1;
|
||||
|
||||
uintptr_t uBase = uintptr_t(hModule);
|
||||
return uAddress - uBase;
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public:
|
||||
PVOID FindInterface(const char* szModule, const char* szObject);
|
||||
std::string GetModuleOffset(void* pAddress) { return GetModuleOffset(uintptr_t(pAddress)); };
|
||||
std::string GetModuleOffset(uintptr_t uAddress);
|
||||
uintptr_t GetOffsetFromBase(void* pAddress) { return GetOffsetFromBase(uintptr_t(pAddress)); };
|
||||
uintptr_t GetOffsetFromBase(uintptr_t uAddress);
|
||||
|
||||
inline void* GetVirtual(void* p, size_t i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user