- renamed Helper to Global.Helper

- added Global.Helper to the project files
This commit is contained in:
Mr. eXoDia 2014-03-08 20:32:11 +01:00
parent 68a5a4b7a0
commit 6bdbe09afe
10 changed files with 163 additions and 139 deletions

View File

@ -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<stringlen; i++)
{
if (tolower(a[i]) != tolower(b[i]))
return false;
}
return true;
}
}
void* MemAlloc( size_t sz )
{
void* r = malloc(sz);
if(r)
memset(r, 0, sz);
return r;
}
void MemFree( void* mem )
{
free(mem);
}
#include "stdafx.h"
#include "Global.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<stringlen; i++)
{
if (tolower(a[i]) != tolower(b[i]))
return false;
}
return true;
}
}
void* MemAlloc( size_t sz )
{
void* r = malloc(sz);
if(r)
memset(r, 0, sz);
return r;
}
void MemFree( void* mem )
{
free(mem);
}

View File

@ -1,89 +1,98 @@
#ifndef Helper_h__
#define Helper_h__
#include <string>
#include <vector>
/*
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<char> 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 <string>
#include <vector>
/*
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<char> 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__

View File

@ -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)

View File

@ -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);

View File

@ -80,6 +80,8 @@
<Unit filename="Global.Garbage.h" />
<Unit filename="Global.Handle.cpp" />
<Unit filename="Global.Handle.h" />
<Unit filename="Global.Helper.cpp" />
<Unit filename="Global.Helper.h" />
<Unit filename="Global.Injector.cpp" />
<Unit filename="Global.Injector.h" />
<Unit filename="Global.Librarian.cpp" />

View File

@ -226,6 +226,7 @@
<ClCompile Include="Global.Engine.Threading.cpp" />
<ClCompile Include="Global.Garbage.cpp" />
<ClCompile Include="Global.Handle.cpp" />
<ClCompile Include="Global.Helper.cpp" />
<ClCompile Include="Global.Injector.cpp" />
<ClCompile Include="Global.Librarian.cpp" />
<ClCompile Include="Global.Mapping.cpp" />
@ -288,6 +289,7 @@
<ClInclude Include="Global.Engine.Threading.h" />
<ClInclude Include="Global.Garbage.h" />
<ClInclude Include="Global.Handle.h" />
<ClInclude Include="Global.Helper.h" />
<ClInclude Include="Global.Injector.h" />
<ClInclude Include="Global.Librarian.h" />
<ClInclude Include="Global.Mapping.h" />

View File

@ -201,6 +201,9 @@
<ClCompile Include="Global.Engine.Threading.cpp">
<Filter>Source Files\TitanEngine</Filter>
</ClCompile>
<ClCompile Include="Global.Helper.cpp">
<Filter>Source Files\TitanEngine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
@ -284,6 +287,12 @@
<ClInclude Include="Global.Engine.Threading.h">
<Filter>Header Files\TitanEngine</Filter>
</ClInclude>
<ClInclude Include="ntdll.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Global.Helper.h">
<Filter>Header Files\TitanEngine</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="TitanEngine.rc">

View File

@ -118,7 +118,7 @@ extern "C" {
typedef enum {
Decode16Bits = 0, Decode32Bits = 1, Decode64Bits = 2
}
_DecodeType;
_DecodeType;
typedef OFFSET_INTEGER _OffsetType;

View File

@ -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;

View File

@ -17,7 +17,7 @@
#include "aplib.h"
#include "LzmaDec.h"
#include "Helper.h"
#include "Global.Helper.h"
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth