From eb4262d8eca9f302693c04b15f8a6bd277c0f49d Mon Sep 17 00:00:00 2001 From: mrexodia Date: Fri, 19 Aug 2016 16:35:53 +0200 Subject: [PATCH] simplification of TitanEngineEmulator --- TitanEngineEmulator/Emulator.h | 37 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/TitanEngineEmulator/Emulator.h b/TitanEngineEmulator/Emulator.h index 0a61df1..9f4590f 100644 --- a/TitanEngineEmulator/Emulator.h +++ b/TitanEngineEmulator/Emulator.h @@ -411,28 +411,10 @@ public: { if (!mProcess) return false; - MemoryType type; - switch (BreakPointType) - { - case UE_MEMORY: - type = MemoryType::Access; - break; - case UE_MEMORY_READ: - type = MemoryType::Read; - break; - case UE_MEMORY_WRITE: - type = MemoryType::Write; - break; - case UE_MEMORY_EXECUTE: - type = MemoryType::Execute; - break; - default: - return false; - } return mProcess->SetMemoryBreakpoint(ptr(MemoryStart), ptr(SizeOfMemory), [bpxCallBack](const BreakpointInfo & info) { (MEMBPCALLBACK(bpxCallBack))((const void*)info.address); - }, type, !RestoreOnHit); + }, memtypeFromTitan(BreakPointType), !RestoreOnHit); } bool RemoveMemoryBPX(ULONG_PTR MemoryStart, SIZE_T SizeOfMemory) @@ -648,6 +630,23 @@ private: //functions } } + static MemoryType memtypeFromTitan(DWORD type) + { + switch (type) + { + case UE_MEMORY: + return MemoryType::Access; + case UE_MEMORY_READ: + return MemoryType::Read; + case UE_MEMORY_WRITE: + return MemoryType::Write; + case UE_MEMORY_EXECUTE: + return MemoryType::Execute; + default: + return MemoryType::Access; + } + } + private: //variables bool mSetDebugPrivilege = false; typedef void(*CUSTOMHANDLER)(const void*);