diff --git a/TitanEngine/Helper.cpp b/TitanEngine/Global.Helper.cpp similarity index 90% rename from TitanEngine/Helper.cpp rename to TitanEngine/Global.Helper.cpp index 823349d..58ffe06 100644 --- a/TitanEngine/Helper.cpp +++ b/TitanEngine/Global.Helper.cpp @@ -1,40 +1,40 @@ -#include "stdafx.h" -#include "Helper.h" - - - -bool IsStrEqual( const char* const a, const char* const b, bool considercase/*=true*/ ) -{ - const int stringlen = std::strlen(a); - if(stringlen != std::strlen(b)) - return false; //cheap - - if(considercase) - { - //plain old strcmp - return std::strcmp(a, b)==0; - } - else - { - for(int i=0; i -#include - -/* -Compares two strings -a : string 1 -b : string 2 -considercase : casesensitivity -*/ -bool IsStrEqual(const char* const a, const char* const b, bool considercase=true); - -/* -A basic dynamic buffer, exception free. -*/ -class DynBuf -{ -public: - DynBuf(size_t sz=0) - { - Allocate(sz); - } - typedef std::vector DynBufVec; - - void* Allocate(size_t sz) - { - void* r=NULL; - try - { - if(Size() < sz) - mem.resize(sz); - if(Size()) - r = GetPtr(); - if(r && sz) - memset(r, 0, sz); - } - catch(...) - { - } - - return r; - } - void* GetPtr() - { - if(Size()) - return &mem.front(); //in c++11: .data() - return NULL; - } - void Free() - { - mem.clear(); - } - DynBufVec& GetVector() {return mem;} - const DynBufVec& GetVector() const {return mem;} - size_t Size() const {return mem.size();} - - -protected: - char& operator[](std::size_t idx) - { - return mem[idx]; - }; - const char& operator[](std::size_t idx) const - { - return mem[idx]; - }; - - DynBufVec mem; -}; - - -//Unused malloc/free wrappers - -/* -malloc wrapper -*/ -void* MemAlloc(size_t sz); - -/* -free wrapper -*/ -void MemFree(void* mem); - - - -#endif // Helper_h__ - +#ifndef Helper_h__ +#define Helper_h__ + +#include +#include + +/* +Compares two strings +a : string 1 +b : string 2 +considercase : casesensitivity +*/ +bool IsStrEqual(const char* const a, const char* const b, bool considercase=true); + +/* +A basic dynamic buffer, exception free. +*/ +class DynBuf +{ +public: + DynBuf(size_t sz=0) + { + Allocate(sz); + } + typedef std::vector DynBufVec; + + void* Allocate(size_t sz) + { + void* r=NULL; + try + { + if(Size() < sz) + mem.resize(sz); + if(Size()) + r = GetPtr(); + if(r && sz) + memset(r, 0, sz); + } + catch(...) + { + } + + return r; + } + void* GetPtr() + { + if(Size()) + return &mem.front(); //in c++11: .data() + return NULL; + } + void Free() + { + mem.clear(); + } + DynBufVec& GetVector() + { + return mem; + } + const DynBufVec& GetVector() const + { + return mem; + } + size_t Size() const + { + return mem.size(); + } + + +protected: + char& operator[](std::size_t idx) + { + return mem[idx]; + }; + const char& operator[](std::size_t idx) const + { + return mem[idx]; + }; + + DynBufVec mem; +}; + + +//Unused malloc/free wrappers + +/* +malloc wrapper +*/ +void* MemAlloc(size_t sz); + +/* +free wrapper +*/ +void MemFree(void* mem); + + + +#endif // Helper_h__ + diff --git a/TitanEngine/TitanEngine.Debugger.Helper.cpp b/TitanEngine/TitanEngine.Debugger.Helper.cpp index 3668d9e..65b142c 100644 --- a/TitanEngine/TitanEngine.Debugger.Helper.cpp +++ b/TitanEngine/TitanEngine.Debugger.Helper.cpp @@ -292,7 +292,7 @@ __declspec(dllexport) long long TITCALL GetJumpDestinationEx(HANDLE hProcess, UL } else if(CompareMemory->DataByte[0] == 0x0F && CompareMemory->DataByte[1] >= 0x81 && CompareMemory->DataByte[1] <= 0x8F && CurrentInstructionSize == 4) { - ReadMemData = 0; + ReadMemData = 0; RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)ReadMemory + 2), 2); TargetedAddress = ReadMemData + InstructionAddress + CurrentInstructionSize; } @@ -321,7 +321,7 @@ __declspec(dllexport) long long TITCALL GetJumpDestinationEx(HANDLE hProcess, UL } else if(CompareMemory->DataByte[0] == 0xFF && CompareMemory->DataByte[1] != 0x64 && CompareMemory->DataByte[1] >= 0x60 && CompareMemory->DataByte[1] <= 0x67 && CurrentInstructionSize == 3) { - ReadMemData = 0; + ReadMemData = 0; RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)ReadMemory + 2), 1); TargetedAddress = ReadMemData; if(CompareMemory->DataByte[1] == 0x60) @@ -427,7 +427,7 @@ __declspec(dllexport) long long TITCALL GetJumpDestinationEx(HANDLE hProcess, UL } else if(CompareMemory->DataByte[0] == 0x0F && CompareMemory->DataByte[1] >= 0x81 && CompareMemory->DataByte[1] <= 0x8F && CurrentInstructionSize == 4) { - ReadMemData = 0; + ReadMemData = 0; RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)InstructionAddress + 2), 2); TargetedAddress = ReadMemData + InstructionAddress + CurrentInstructionSize; } @@ -456,7 +456,7 @@ __declspec(dllexport) long long TITCALL GetJumpDestinationEx(HANDLE hProcess, UL } else if(CompareMemory->DataByte[0] == 0xFF && CompareMemory->DataByte[1] != 0x64 && CompareMemory->DataByte[1] >= 0x60 && CompareMemory->DataByte[1] <= 0x67 && CurrentInstructionSize == 3) { - ReadMemData = 0; + ReadMemData = 0; RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)InstructionAddress + 2), 1); TargetedAddress = ReadMemData; if(CompareMemory->DataByte[1] == 0x60) diff --git a/TitanEngine/TitanEngine.Handler.cpp b/TitanEngine/TitanEngine.Handler.cpp index b6ee0fc..10fd5c7 100644 --- a/TitanEngine/TitanEngine.Handler.cpp +++ b/TitanEngine/TitanEngine.Handler.cpp @@ -130,7 +130,7 @@ __declspec(dllexport) void* TITCALL HandlerGetHandleName(HANDLE hProcess, DWORD TotalHandleCount--; } - if(!NameFound) + if(!NameFound) { VirtualFree(HandleFullName, NULL, MEM_RELEASE); return(NULL); @@ -200,7 +200,7 @@ __declspec(dllexport) void* TITCALL HandlerGetHandleNameW(HANDLE hProcess, DWORD TotalHandleCount--; } - if(!NameFound) + if(!NameFound) { VirtualFree(HandleFullName, NULL, MEM_RELEASE); return(NULL); diff --git a/TitanEngine/TitanEngine.cbp b/TitanEngine/TitanEngine.cbp index 8e8f10b..91d3c6c 100644 --- a/TitanEngine/TitanEngine.cbp +++ b/TitanEngine/TitanEngine.cbp @@ -80,6 +80,8 @@ + + diff --git a/TitanEngine/TitanEngine.vcxproj b/TitanEngine/TitanEngine.vcxproj index 1ab3633..d6d0f0f 100644 --- a/TitanEngine/TitanEngine.vcxproj +++ b/TitanEngine/TitanEngine.vcxproj @@ -226,6 +226,7 @@ + @@ -288,6 +289,7 @@ + diff --git a/TitanEngine/TitanEngine.vcxproj.filters b/TitanEngine/TitanEngine.vcxproj.filters index f480f26..fead0ab 100644 --- a/TitanEngine/TitanEngine.vcxproj.filters +++ b/TitanEngine/TitanEngine.vcxproj.filters @@ -201,6 +201,9 @@ Source Files\TitanEngine + + Source Files\TitanEngine + @@ -284,6 +287,12 @@ Header Files\TitanEngine + + Header Files + + + Header Files\TitanEngine + diff --git a/TitanEngine/distorm.h b/TitanEngine/distorm.h index bbc2c51..de2e086 100644 --- a/TitanEngine/distorm.h +++ b/TitanEngine/distorm.h @@ -118,7 +118,7 @@ extern "C" { typedef enum { Decode16Bits = 0, Decode32Bits = 1, Decode64Bits = 2 } - _DecodeType; +_DecodeType; typedef OFFSET_INTEGER _OffsetType; diff --git a/TitanEngine/ntdll.h b/TitanEngine/ntdll.h index fde91dd..7ce981f 100644 --- a/TitanEngine/ntdll.h +++ b/TitanEngine/ntdll.h @@ -11,7 +11,8 @@ typedef LONG NTSTATUS; typedef LONG KPRIORITY; -typedef struct _CLIENT_ID { +typedef struct _CLIENT_ID +{ HANDLE UniqueProcess; HANDLE UniqueThread; } CLIENT_ID, *PCLIENT_ID; @@ -53,7 +54,8 @@ typedef struct _PROCESS_BASIC_INFORMATION } PROCESS_BASIC_INFORMATION; typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION; -typedef struct _THREAD_BASIC_INFORMATION { +typedef struct _THREAD_BASIC_INFORMATION +{ NTSTATUS ExitStatus; PVOID TebBaseAddress; CLIENT_ID ClientId; diff --git a/TitanEngine/stdafx.h b/TitanEngine/stdafx.h index 734fab9..6a4a909 100644 --- a/TitanEngine/stdafx.h +++ b/TitanEngine/stdafx.h @@ -17,7 +17,7 @@ #include "aplib.h" #include "LzmaDec.h" -#include "Helper.h" +#include "Global.Helper.h" #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth