From 07ec166b945703e5a884033d024fb0476ae828a5 Mon Sep 17 00:00:00 2001 From: cw2k <3834079+cw2k@users.noreply.github.com> Date: Tue, 3 Nov 2020 05:37:41 +0100 Subject: [PATCH] ConvertVAtoFileOffsetEx * now returns 0 on error (and not INVALID_VALUE => -1) * implementation for ReturnType In short I just copied that from: https://github.com/x64dbg/GleeBug/blob/c5aed9fcccb9f2161af86cfefe0ef5006e913fc9/StaticEngine/Emulator.h#L507 --- TitanEngineEmulator/Emulator.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/TitanEngineEmulator/Emulator.h b/TitanEngineEmulator/Emulator.h index 67d08ff..9ed8ac9 100644 --- a/TitanEngineEmulator/Emulator.h +++ b/TitanEngineEmulator/Emulator.h @@ -590,7 +590,10 @@ public: __debugbreak(); //return 0; if(!found->second.pe->IsValidPe()) __debugbreak(); //return 0; - return found->second.pe->ConvertRvaToOffset(uint32(AddressToConvert)); + auto offset = found->second.pe->ConvertRvaToOffset(uint32(AddressToConvert)); + if (offset == INVALID_VALUE) + return 0; + return ReturnType ? FileMapVA + offset : offset; } template @@ -1200,4 +1203,4 @@ private: //variables STEPCALLBACK mCbATTACHBREAKPOINT = nullptr; PROCESS_INFORMATION* mAttachProcessInfo = nullptr; wchar_t szDebuggeeName[MAX_PATH] = L""; -}; \ No newline at end of file +};