mirror of https://github.com/x64dbg/TitanEngine
- renamed Helper to Global.Helper
- added Global.Helper to the project files
This commit is contained in:
parent
68a5a4b7a0
commit
6bdbe09afe
|
|
@ -1,40 +1,40 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Helper.h"
|
#include "Global.Helper.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool IsStrEqual( const char* const a, const char* const b, bool considercase/*=true*/ )
|
bool IsStrEqual( const char* const a, const char* const b, bool considercase/*=true*/ )
|
||||||
{
|
{
|
||||||
const int stringlen = std::strlen(a);
|
const int stringlen = std::strlen(a);
|
||||||
if(stringlen != std::strlen(b))
|
if(stringlen != std::strlen(b))
|
||||||
return false; //cheap
|
return false; //cheap
|
||||||
|
|
||||||
if(considercase)
|
if(considercase)
|
||||||
{
|
{
|
||||||
//plain old strcmp
|
//plain old strcmp
|
||||||
return std::strcmp(a, b)==0;
|
return std::strcmp(a, b)==0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int i=0; i<stringlen; i++)
|
for(int i=0; i<stringlen; i++)
|
||||||
{
|
{
|
||||||
if (tolower(a[i]) != tolower(b[i]))
|
if (tolower(a[i]) != tolower(b[i]))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void* MemAlloc( size_t sz )
|
void* MemAlloc( size_t sz )
|
||||||
{
|
{
|
||||||
void* r = malloc(sz);
|
void* r = malloc(sz);
|
||||||
if(r)
|
if(r)
|
||||||
memset(r, 0, sz);
|
memset(r, 0, sz);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemFree( void* mem )
|
void MemFree( void* mem )
|
||||||
{
|
{
|
||||||
free(mem);
|
free(mem);
|
||||||
}
|
}
|
||||||
|
|
@ -1,89 +1,98 @@
|
||||||
#ifndef Helper_h__
|
#ifndef Helper_h__
|
||||||
#define Helper_h__
|
#define Helper_h__
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Compares two strings
|
Compares two strings
|
||||||
a : string 1
|
a : string 1
|
||||||
b : string 2
|
b : string 2
|
||||||
considercase : casesensitivity
|
considercase : casesensitivity
|
||||||
*/
|
*/
|
||||||
bool IsStrEqual(const char* const a, const char* const b, bool considercase=true);
|
bool IsStrEqual(const char* const a, const char* const b, bool considercase=true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A basic dynamic buffer, exception free.
|
A basic dynamic buffer, exception free.
|
||||||
*/
|
*/
|
||||||
class DynBuf
|
class DynBuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynBuf(size_t sz=0)
|
DynBuf(size_t sz=0)
|
||||||
{
|
{
|
||||||
Allocate(sz);
|
Allocate(sz);
|
||||||
}
|
}
|
||||||
typedef std::vector<char> DynBufVec;
|
typedef std::vector<char> DynBufVec;
|
||||||
|
|
||||||
void* Allocate(size_t sz)
|
void* Allocate(size_t sz)
|
||||||
{
|
{
|
||||||
void* r=NULL;
|
void* r=NULL;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(Size() < sz)
|
if(Size() < sz)
|
||||||
mem.resize(sz);
|
mem.resize(sz);
|
||||||
if(Size())
|
if(Size())
|
||||||
r = GetPtr();
|
r = GetPtr();
|
||||||
if(r && sz)
|
if(r && sz)
|
||||||
memset(r, 0, sz);
|
memset(r, 0, sz);
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
void* GetPtr()
|
void* GetPtr()
|
||||||
{
|
{
|
||||||
if(Size())
|
if(Size())
|
||||||
return &mem.front(); //in c++11: .data()
|
return &mem.front(); //in c++11: .data()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
void Free()
|
void Free()
|
||||||
{
|
{
|
||||||
mem.clear();
|
mem.clear();
|
||||||
}
|
}
|
||||||
DynBufVec& GetVector() {return mem;}
|
DynBufVec& GetVector()
|
||||||
const DynBufVec& GetVector() const {return mem;}
|
{
|
||||||
size_t Size() const {return mem.size();}
|
return mem;
|
||||||
|
}
|
||||||
|
const DynBufVec& GetVector() const
|
||||||
protected:
|
{
|
||||||
char& operator[](std::size_t idx)
|
return mem;
|
||||||
{
|
}
|
||||||
return mem[idx];
|
size_t Size() const
|
||||||
};
|
{
|
||||||
const char& operator[](std::size_t idx) const
|
return mem.size();
|
||||||
{
|
}
|
||||||
return mem[idx];
|
|
||||||
};
|
|
||||||
|
protected:
|
||||||
DynBufVec mem;
|
char& operator[](std::size_t idx)
|
||||||
};
|
{
|
||||||
|
return mem[idx];
|
||||||
|
};
|
||||||
//Unused malloc/free wrappers
|
const char& operator[](std::size_t idx) const
|
||||||
|
{
|
||||||
/*
|
return mem[idx];
|
||||||
malloc wrapper
|
};
|
||||||
*/
|
|
||||||
void* MemAlloc(size_t sz);
|
DynBufVec mem;
|
||||||
|
};
|
||||||
/*
|
|
||||||
free wrapper
|
|
||||||
*/
|
//Unused malloc/free wrappers
|
||||||
void MemFree(void* mem);
|
|
||||||
|
/*
|
||||||
|
malloc wrapper
|
||||||
|
*/
|
||||||
#endif // Helper_h__
|
void* MemAlloc(size_t sz);
|
||||||
|
|
||||||
|
/*
|
||||||
|
free wrapper
|
||||||
|
*/
|
||||||
|
void MemFree(void* mem);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Helper_h__
|
||||||
|
|
||||||
|
|
@ -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)
|
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);
|
RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)ReadMemory + 2), 2);
|
||||||
TargetedAddress = ReadMemData + InstructionAddress + CurrentInstructionSize;
|
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)
|
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);
|
RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)ReadMemory + 2), 1);
|
||||||
TargetedAddress = ReadMemData;
|
TargetedAddress = ReadMemData;
|
||||||
if(CompareMemory->DataByte[1] == 0x60)
|
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)
|
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);
|
RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)InstructionAddress + 2), 2);
|
||||||
TargetedAddress = ReadMemData + InstructionAddress + CurrentInstructionSize;
|
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)
|
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);
|
RtlMoveMemory(&ReadMemData, (LPVOID)((ULONG_PTR)InstructionAddress + 2), 1);
|
||||||
TargetedAddress = ReadMemData;
|
TargetedAddress = ReadMemData;
|
||||||
if(CompareMemory->DataByte[1] == 0x60)
|
if(CompareMemory->DataByte[1] == 0x60)
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ __declspec(dllexport) void* TITCALL HandlerGetHandleName(HANDLE hProcess, DWORD
|
||||||
TotalHandleCount--;
|
TotalHandleCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NameFound)
|
if(!NameFound)
|
||||||
{
|
{
|
||||||
VirtualFree(HandleFullName, NULL, MEM_RELEASE);
|
VirtualFree(HandleFullName, NULL, MEM_RELEASE);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
@ -200,7 +200,7 @@ __declspec(dllexport) void* TITCALL HandlerGetHandleNameW(HANDLE hProcess, DWORD
|
||||||
TotalHandleCount--;
|
TotalHandleCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NameFound)
|
if(!NameFound)
|
||||||
{
|
{
|
||||||
VirtualFree(HandleFullName, NULL, MEM_RELEASE);
|
VirtualFree(HandleFullName, NULL, MEM_RELEASE);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@
|
||||||
<Unit filename="Global.Garbage.h" />
|
<Unit filename="Global.Garbage.h" />
|
||||||
<Unit filename="Global.Handle.cpp" />
|
<Unit filename="Global.Handle.cpp" />
|
||||||
<Unit filename="Global.Handle.h" />
|
<Unit filename="Global.Handle.h" />
|
||||||
|
<Unit filename="Global.Helper.cpp" />
|
||||||
|
<Unit filename="Global.Helper.h" />
|
||||||
<Unit filename="Global.Injector.cpp" />
|
<Unit filename="Global.Injector.cpp" />
|
||||||
<Unit filename="Global.Injector.h" />
|
<Unit filename="Global.Injector.h" />
|
||||||
<Unit filename="Global.Librarian.cpp" />
|
<Unit filename="Global.Librarian.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -226,6 +226,7 @@
|
||||||
<ClCompile Include="Global.Engine.Threading.cpp" />
|
<ClCompile Include="Global.Engine.Threading.cpp" />
|
||||||
<ClCompile Include="Global.Garbage.cpp" />
|
<ClCompile Include="Global.Garbage.cpp" />
|
||||||
<ClCompile Include="Global.Handle.cpp" />
|
<ClCompile Include="Global.Handle.cpp" />
|
||||||
|
<ClCompile Include="Global.Helper.cpp" />
|
||||||
<ClCompile Include="Global.Injector.cpp" />
|
<ClCompile Include="Global.Injector.cpp" />
|
||||||
<ClCompile Include="Global.Librarian.cpp" />
|
<ClCompile Include="Global.Librarian.cpp" />
|
||||||
<ClCompile Include="Global.Mapping.cpp" />
|
<ClCompile Include="Global.Mapping.cpp" />
|
||||||
|
|
@ -288,6 +289,7 @@
|
||||||
<ClInclude Include="Global.Engine.Threading.h" />
|
<ClInclude Include="Global.Engine.Threading.h" />
|
||||||
<ClInclude Include="Global.Garbage.h" />
|
<ClInclude Include="Global.Garbage.h" />
|
||||||
<ClInclude Include="Global.Handle.h" />
|
<ClInclude Include="Global.Handle.h" />
|
||||||
|
<ClInclude Include="Global.Helper.h" />
|
||||||
<ClInclude Include="Global.Injector.h" />
|
<ClInclude Include="Global.Injector.h" />
|
||||||
<ClInclude Include="Global.Librarian.h" />
|
<ClInclude Include="Global.Librarian.h" />
|
||||||
<ClInclude Include="Global.Mapping.h" />
|
<ClInclude Include="Global.Mapping.h" />
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,9 @@
|
||||||
<ClCompile Include="Global.Engine.Threading.cpp">
|
<ClCompile Include="Global.Engine.Threading.cpp">
|
||||||
<Filter>Source Files\TitanEngine</Filter>
|
<Filter>Source Files\TitanEngine</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Global.Helper.cpp">
|
||||||
|
<Filter>Source Files\TitanEngine</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="resource.h">
|
<ClInclude Include="resource.h">
|
||||||
|
|
@ -284,6 +287,12 @@
|
||||||
<ClInclude Include="Global.Engine.Threading.h">
|
<ClInclude Include="Global.Engine.Threading.h">
|
||||||
<Filter>Header Files\TitanEngine</Filter>
|
<Filter>Header Files\TitanEngine</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="ntdll.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Global.Helper.h">
|
||||||
|
<Filter>Header Files\TitanEngine</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="TitanEngine.rc">
|
<ResourceCompile Include="TitanEngine.rc">
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ extern "C" {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
Decode16Bits = 0, Decode32Bits = 1, Decode64Bits = 2
|
Decode16Bits = 0, Decode32Bits = 1, Decode64Bits = 2
|
||||||
}
|
}
|
||||||
_DecodeType;
|
_DecodeType;
|
||||||
|
|
||||||
typedef OFFSET_INTEGER _OffsetType;
|
typedef OFFSET_INTEGER _OffsetType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@
|
||||||
typedef LONG NTSTATUS;
|
typedef LONG NTSTATUS;
|
||||||
typedef LONG KPRIORITY;
|
typedef LONG KPRIORITY;
|
||||||
|
|
||||||
typedef struct _CLIENT_ID {
|
typedef struct _CLIENT_ID
|
||||||
|
{
|
||||||
HANDLE UniqueProcess;
|
HANDLE UniqueProcess;
|
||||||
HANDLE UniqueThread;
|
HANDLE UniqueThread;
|
||||||
} CLIENT_ID, *PCLIENT_ID;
|
} CLIENT_ID, *PCLIENT_ID;
|
||||||
|
|
@ -53,7 +54,8 @@ typedef struct _PROCESS_BASIC_INFORMATION
|
||||||
} PROCESS_BASIC_INFORMATION;
|
} PROCESS_BASIC_INFORMATION;
|
||||||
typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION;
|
typedef PROCESS_BASIC_INFORMATION *PPROCESS_BASIC_INFORMATION;
|
||||||
|
|
||||||
typedef struct _THREAD_BASIC_INFORMATION {
|
typedef struct _THREAD_BASIC_INFORMATION
|
||||||
|
{
|
||||||
NTSTATUS ExitStatus;
|
NTSTATUS ExitStatus;
|
||||||
PVOID TebBaseAddress;
|
PVOID TebBaseAddress;
|
||||||
CLIENT_ID ClientId;
|
CLIENT_ID ClientId;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
#include "aplib.h"
|
#include "aplib.h"
|
||||||
#include "LzmaDec.h"
|
#include "LzmaDec.h"
|
||||||
|
|
||||||
#include "Helper.h"
|
#include "Global.Helper.h"
|
||||||
|
|
||||||
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
|
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue