mirror of https://github.com/x64dbg/TitanEngine
Merge branch 'master' of https://bitbucket.org/mrexodia/titanengine-update
This commit is contained in:
commit
ea2850e6ec
|
|
@ -247,12 +247,13 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//maintain thread list
|
//maintain thread list
|
||||||
int threadcount=hListThread.size();
|
for(unsigned int i = 0; i < hListThread.size(); i++)
|
||||||
for(int i=0; i<threadcount; i++)
|
|
||||||
{
|
{
|
||||||
if(hListThread.at(i).dwThreadId == DBGEvent.dwThreadId) //found the thread to remove
|
if(hListThread.at(i).dwThreadId == DBGEvent.dwThreadId) //found the thread to remove
|
||||||
{
|
{
|
||||||
//TODO: close handle?
|
//TODO: close handle?
|
||||||
|
EngineCloseHandle(hListThread.at(i).hThread);
|
||||||
|
|
||||||
hListThread.erase(hListThread.begin() + i);
|
hListThread.erase(hListThread.begin() + i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -313,8 +314,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
||||||
WideCharToMultiByte(CP_ACP, NULL, NewLibraryData.szLibraryName, -1, szAnsiLibraryName, sizeof szAnsiLibraryName, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, NULL, NewLibraryData.szLibraryName, -1, szAnsiLibraryName, sizeof szAnsiLibraryName, NULL, NULL);
|
||||||
|
|
||||||
//library breakpoint
|
//library breakpoint
|
||||||
int libbpcount=LibrarianData.size();
|
for(int i = LibrarianData.size() - 1; i >= 0; i--)
|
||||||
for(int i=libbpcount-1; i>-1; i--)
|
|
||||||
{
|
{
|
||||||
ptrLibrarianData=&LibrarianData.at(i);
|
ptrLibrarianData=&LibrarianData.at(i);
|
||||||
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
|
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
|
||||||
|
|
@ -378,8 +378,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
||||||
{
|
{
|
||||||
RtlZeroMemory(szAnsiLibraryName, sizeof(szAnsiLibraryName));
|
RtlZeroMemory(szAnsiLibraryName, sizeof(szAnsiLibraryName));
|
||||||
WideCharToMultiByte(CP_ACP, NULL, hLoadedLibData->szLibraryName, -1, szAnsiLibraryName, sizeof szAnsiLibraryName, NULL, NULL);
|
WideCharToMultiByte(CP_ACP, NULL, hLoadedLibData->szLibraryName, -1, szAnsiLibraryName, sizeof szAnsiLibraryName, NULL, NULL);
|
||||||
int libbpcount=LibrarianData.size();
|
|
||||||
for(int i=libbpcount-1; i>-1; i--)
|
for(int i= LibrarianData.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
ptrLibrarianData = &LibrarianData.at(i);
|
ptrLibrarianData = &LibrarianData.at(i);
|
||||||
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
|
if(!lstrcmpiA(ptrLibrarianData->szLibraryName, szAnsiLibraryName))
|
||||||
|
|
@ -405,8 +405,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//maintain library list
|
//maintain library list
|
||||||
int libcount=hListLibrary.size();
|
for(unsigned int i = 0; i < hListLibrary.size(); i++)
|
||||||
for(int i=0; i<libcount; i++)
|
|
||||||
{
|
{
|
||||||
if(hListLibrary.at(i).BaseOfDll == DBGEvent.u.UnloadDll.lpBaseOfDll &&
|
if(hListLibrary.at(i).BaseOfDll == DBGEvent.u.UnloadDll.lpBaseOfDll &&
|
||||||
hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,12 @@ __declspec(dllexport) void* TITCALL StaticDisassembleEx(ULONG_PTR DisassmStart,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void* TITCALL StaticDisassemble(LPVOID DisassmAddress)
|
__declspec(dllexport) void* TITCALL StaticDisassemble(LPVOID DisassmAddress)
|
||||||
{
|
{
|
||||||
return(StaticDisassembleEx((ULONG_PTR)DisassmAddress, DisassmAddress));
|
return StaticDisassembleEx((ULONG_PTR)DisassmAddress, DisassmAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void* TITCALL DisassembleEx(HANDLE hProcess, LPVOID DisassmAddress, bool ReturnInstructionType)
|
__declspec(dllexport) void* TITCALL DisassembleEx(HANDLE hProcess, LPVOID DisassmAddress, bool ReturnInstructionType)
|
||||||
{
|
{
|
||||||
_DecodedInst engineDecodedInstructions[1];
|
_DecodedInst engineDecodedInstructions[1];
|
||||||
|
|
@ -136,14 +138,17 @@ __declspec(dllexport) void* TITCALL DisassembleEx(HANDLE hProcess, LPVOID Disass
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void* TITCALL Disassemble(LPVOID DisassmAddress)
|
__declspec(dllexport) void* TITCALL Disassemble(LPVOID DisassmAddress)
|
||||||
{
|
{
|
||||||
return(DisassembleEx(dbgProcessInformation.hProcess, DisassmAddress, false));
|
return(DisassembleEx(dbgProcessInformation.hProcess, DisassmAddress, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL StaticLengthDisassemble(LPVOID DisassmAddress)
|
__declspec(dllexport) long TITCALL StaticLengthDisassemble(LPVOID DisassmAddress)
|
||||||
{
|
{
|
||||||
return LengthDisassembleEx(GetCurrentProcess(), DisassmAddress);
|
return LengthDisassembleEx(GetCurrentProcess(), DisassmAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL LengthDisassembleEx(HANDLE hProcess, LPVOID DisassmAddress)
|
__declspec(dllexport) long TITCALL LengthDisassembleEx(HANDLE hProcess, LPVOID DisassmAddress)
|
||||||
{
|
{
|
||||||
unsigned int DecodedInstructionsCount = 0;
|
unsigned int DecodedInstructionsCount = 0;
|
||||||
|
|
@ -174,6 +179,7 @@ __declspec(dllexport) long TITCALL LengthDisassembleEx(HANDLE hProcess, LPVOID D
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL LengthDisassemble(LPVOID DisassmAddress)
|
__declspec(dllexport) long TITCALL LengthDisassemble(LPVOID DisassmAddress)
|
||||||
{
|
{
|
||||||
return LengthDisassembleEx(dbgProcessInformation.hProcess, DisassmAddress);
|
return LengthDisassembleEx(dbgProcessInformation.hProcess, DisassmAddress);
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,6 @@ __declspec(dllexport) bool TITCALL DumpProcessEx(DWORD ProcessId, LPVOID ImageBa
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DumpProcessExW(DWORD ProcessId, LPVOID ImageBase, wchar_t* szDumpFileName, ULONG_PTR EntryPoint)
|
__declspec(dllexport) bool TITCALL DumpProcessExW(DWORD ProcessId, LPVOID ImageBase, wchar_t* szDumpFileName, ULONG_PTR EntryPoint)
|
||||||
{
|
{
|
||||||
|
|
||||||
HANDLE hProcess = 0;
|
HANDLE hProcess = 0;
|
||||||
bool ReturnValue = false;
|
bool ReturnValue = false;
|
||||||
|
|
||||||
|
|
@ -298,7 +297,6 @@ __declspec(dllexport) bool TITCALL DumpMemory(HANDLE hProcess, LPVOID MemoryStar
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DumpMemoryW(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName)
|
__declspec(dllexport) bool TITCALL DumpMemoryW(HANDLE hProcess, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
ULONG_PTR ueNumberOfBytesRead = 0;
|
ULONG_PTR ueNumberOfBytesRead = 0;
|
||||||
DWORD uedNumberOfBytesRead = 0;
|
DWORD uedNumberOfBytesRead = 0;
|
||||||
HANDLE hFile = 0;
|
HANDLE hFile = 0;
|
||||||
|
|
@ -356,7 +354,6 @@ __declspec(dllexport) bool TITCALL DumpMemoryEx(DWORD ProcessId, LPVOID MemorySt
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DumpMemoryExW(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName)
|
__declspec(dllexport) bool TITCALL DumpMemoryExW(DWORD ProcessId, LPVOID MemoryStart, ULONG_PTR MemorySize, wchar_t* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
HANDLE hProcess = 0;
|
HANDLE hProcess = 0;
|
||||||
bool ReturnValue = false;
|
bool ReturnValue = false;
|
||||||
|
|
||||||
|
|
@ -388,7 +385,6 @@ __declspec(dllexport) bool TITCALL DumpRegions(HANDLE hProcess, char* szDumpFold
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DumpRegionsW(HANDLE hProcess, wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly)
|
__declspec(dllexport) bool TITCALL DumpRegionsW(HANDLE hProcess, wchar_t* szDumpFolder, bool DumpAboveImageBaseOnly)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
DWORD cbNeeded = NULL;
|
DWORD cbNeeded = NULL;
|
||||||
wchar_t szDumpName[MAX_PATH];
|
wchar_t szDumpName[MAX_PATH];
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
// TitanEngine.Engine.Simplification.functions:
|
// TitanEngine.Engine.Simplification.functions:
|
||||||
__declspec(dllexport) void TITCALL EngineUnpackerInitialize(char* szFileName, char* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack)
|
__declspec(dllexport) void TITCALL EngineUnpackerInitialize(char* szFileName, char* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
wchar_t uniUnpackedFileName[MAX_PATH] = {};
|
wchar_t uniUnpackedFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
|
|
@ -15,7 +14,7 @@ __declspec(dllexport) void TITCALL EngineUnpackerInitialize(char* szFileName, ch
|
||||||
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
||||||
if(szUnpackedFileName == NULL)
|
if(szUnpackedFileName == NULL)
|
||||||
{
|
{
|
||||||
return(EngineUnpackerInitializeW(uniFileName, NULL, DoLogData, DoRealignFile, DoMoveOverlay, EntryCallBack));
|
return EngineUnpackerInitializeW(uniFileName, NULL, DoLogData, DoRealignFile, DoMoveOverlay, EntryCallBack);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -24,9 +23,9 @@ __declspec(dllexport) void TITCALL EngineUnpackerInitialize(char* szFileName, ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL EngineUnpackerInitializeW(wchar_t* szFileName, wchar_t* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack)
|
__declspec(dllexport) void TITCALL EngineUnpackerInitializeW(wchar_t* szFileName, wchar_t* szUnpackedFileName, bool DoLogData, bool DoRealignFile, bool DoMoveOverlay, void* EntryCallBack)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i,j;
|
int i,j;
|
||||||
wchar_t TempBackBuffer[MAX_PATH] = {};
|
wchar_t TempBackBuffer[MAX_PATH] = {};
|
||||||
|
|
||||||
|
|
@ -80,9 +79,9 @@ __declspec(dllexport) void TITCALL EngineUnpackerInitializeW(wchar_t* szFileName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchStart, DWORD SearchSize, void* SearchPattern, DWORD PatternSize, DWORD PatternDelta, ULONG_PTR BreakType, bool SingleBreak, DWORD Parameter1, DWORD Parameter2)
|
__declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchStart, DWORD SearchSize, void* SearchPattern, DWORD PatternSize, DWORD PatternDelta, ULONG_PTR BreakType, bool SingleBreak, DWORD Parameter1, DWORD Parameter2)
|
||||||
{
|
{
|
||||||
|
|
||||||
ULONG_PTR fPatternLocation;
|
ULONG_PTR fPatternLocation;
|
||||||
DWORD fBreakPointType = UE_BREAKPOINT;
|
DWORD fBreakPointType = UE_BREAKPOINT;
|
||||||
UnpackerInformation fUnpackerInformation = {};
|
UnpackerInformation fUnpackerInformation = {};
|
||||||
|
|
@ -98,10 +97,12 @@ __declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchS
|
||||||
SearchStart = (void*)((ULONG_PTR)GetPE32DataW(szEngineUnpackerInputFile, NULL, UE_OEP) + (ULONG_PTR)GetDebuggedFileBaseAddress());
|
SearchStart = (void*)((ULONG_PTR)GetPE32DataW(szEngineUnpackerInputFile, NULL, UE_OEP) + (ULONG_PTR)GetDebuggedFileBaseAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SearchSize == NULL)
|
if(SearchSize == NULL)
|
||||||
{
|
{
|
||||||
SearchSize = 0x1000;
|
SearchSize = 0x1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPatternLocation = (ULONG_PTR)FindEx(pEngineUnpackerProcessHandle->hProcess, SearchStart, SearchSize, SearchPattern, PatternSize, NULL);
|
fPatternLocation = (ULONG_PTR)FindEx(pEngineUnpackerProcessHandle->hProcess, SearchStart, SearchSize, SearchPattern, PatternSize, NULL);
|
||||||
if(fPatternLocation != NULL)
|
if(fPatternLocation != NULL)
|
||||||
{
|
{
|
||||||
|
|
@ -109,11 +110,13 @@ __declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchS
|
||||||
{
|
{
|
||||||
fBreakPointType = UE_SINGLESHOOT;
|
fBreakPointType = UE_SINGLESHOOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPatternLocation = fPatternLocation + (int)PatternDelta;
|
fPatternLocation = fPatternLocation + (int)PatternDelta;
|
||||||
fUnpackerInformation.Parameter1 = Parameter1;
|
fUnpackerInformation.Parameter1 = Parameter1;
|
||||||
fUnpackerInformation.Parameter2 = Parameter2;
|
fUnpackerInformation.Parameter2 = Parameter2;
|
||||||
fUnpackerInformation.SingleBreak = SingleBreak;
|
fUnpackerInformation.SingleBreak = SingleBreak;
|
||||||
fUnpackerInformation.BreakPointAddress = fPatternLocation;
|
fUnpackerInformation.BreakPointAddress = fPatternLocation;
|
||||||
|
|
||||||
if(BreakType == UE_UNPACKER_CONDITION_LOADLIBRARY)
|
if(BreakType == UE_UNPACKER_CONDITION_LOADLIBRARY)
|
||||||
{
|
{
|
||||||
if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyLoadLibraryCallBack))
|
if(SetBPX(fPatternLocation, UE_BREAKPOINT, &EngineSimplifyLoadLibraryCallBack))
|
||||||
|
|
@ -165,15 +168,17 @@ __declspec(dllexport) bool TITCALL EngineUnpackerSetBreakCondition(void* SearchS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL EngineUnpackerSetEntryPointAddress(ULONG_PTR UnpackedEntryPointAddress)
|
__declspec(dllexport) void TITCALL EngineUnpackerSetEntryPointAddress(ULONG_PTR UnpackedEntryPointAddress)
|
||||||
{
|
{
|
||||||
EngineUnpackerOptionUnpackedOEP = UnpackedEntryPointAddress;
|
EngineUnpackerOptionUnpackedOEP = UnpackedEntryPointAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL EngineUnpackerFinalizeUnpacking()
|
__declspec(dllexport) void TITCALL EngineUnpackerFinalizeUnpacking()
|
||||||
{
|
{
|
||||||
|
|
||||||
EngineSimplifyEntryPointCallBack();
|
EngineSimplifyEntryPointCallBack();
|
||||||
EmptyGarbage();
|
EmptyGarbage();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ __declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoW(wchar_t* szLibraryN
|
||||||
static LIBRARY_ITEM_DATAW LibraryInfo;
|
static LIBRARY_ITEM_DATAW LibraryInfo;
|
||||||
memset(&LibraryInfo, 0, sizeof(LIBRARY_ITEM_DATAW));
|
memset(&LibraryInfo, 0, sizeof(LIBRARY_ITEM_DATAW));
|
||||||
|
|
||||||
for(int i = 0; i < hListLibrary.size(); i++)
|
for(unsigned int i = 0; i < hListLibrary.size(); i++)
|
||||||
{
|
{
|
||||||
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE && !lstrcmpiW(hListLibrary.at(i).szLibraryName, szLibraryName))
|
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE && !lstrcmpiW(hListLibrary.at(i).szLibraryName, szLibraryName))
|
||||||
{
|
{
|
||||||
|
|
@ -98,7 +98,7 @@ __declspec(dllexport) void* TITCALL LibrarianGetLibraryInfoExW(void* BaseOfDll)
|
||||||
static LIBRARY_ITEM_DATAW LibraryData;
|
static LIBRARY_ITEM_DATAW LibraryData;
|
||||||
memset(&LibraryData, 0, sizeof(LIBRARY_ITEM_DATAW));
|
memset(&LibraryData, 0, sizeof(LIBRARY_ITEM_DATAW));
|
||||||
|
|
||||||
for(int i = 0; i < hListLibrary.size(); i++)
|
for(unsigned int i = 0; i < hListLibrary.size(); i++)
|
||||||
{
|
{
|
||||||
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE && hListLibrary.at(i).BaseOfDll == BaseOfDll)
|
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE && hListLibrary.at(i).BaseOfDll == BaseOfDll)
|
||||||
{
|
{
|
||||||
|
|
@ -118,9 +118,8 @@ __declspec(dllexport) void TITCALL LibrarianEnumLibraryInfo(void* EnumCallBack)
|
||||||
|
|
||||||
typedef void(TITCALL *fEnumCallBack)(LPVOID fLibraryDetail);
|
typedef void(TITCALL *fEnumCallBack)(LPVOID fLibraryDetail);
|
||||||
fEnumCallBack myEnumCallBack = (fEnumCallBack)EnumCallBack;
|
fEnumCallBack myEnumCallBack = (fEnumCallBack)EnumCallBack;
|
||||||
int libcount = hListLibrary.size();
|
|
||||||
|
|
||||||
for(int i = 0; i < libcount; i++)
|
for(unsigned int i = 0; i < hListLibrary.size(); i++)
|
||||||
{
|
{
|
||||||
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|
@ -151,9 +150,8 @@ __declspec(dllexport) void TITCALL LibrarianEnumLibraryInfoW(void* EnumCallBack)
|
||||||
|
|
||||||
typedef void(TITCALL *fEnumCallBack)(LPVOID fLibraryDetail);
|
typedef void(TITCALL *fEnumCallBack)(LPVOID fLibraryDetail);
|
||||||
fEnumCallBack myEnumCallBack = (fEnumCallBack)EnumCallBack;
|
fEnumCallBack myEnumCallBack = (fEnumCallBack)EnumCallBack;
|
||||||
int libcount = hListLibrary.size();
|
|
||||||
|
|
||||||
for(int i = 0; i < libcount; i++)
|
for(unsigned int i = 0; i < hListLibrary.size(); i++)
|
||||||
{
|
{
|
||||||
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
if(hListLibrary.at(i).hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ __declspec(dllexport) bool TITCALL ExtractSection(char* szFileName, char* szDump
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ExtractSectionW(wchar_t* szFileName, wchar_t* szDumpFileName, DWORD SectionNumber)
|
__declspec(dllexport) bool TITCALL ExtractSectionW(wchar_t* szFileName, wchar_t* szDumpFileName, DWORD SectionNumber)
|
||||||
{
|
{
|
||||||
|
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
PIMAGE_NT_HEADERS32 PEHeader32;
|
PIMAGE_NT_HEADERS32 PEHeader32;
|
||||||
PIMAGE_NT_HEADERS64 PEHeader64;
|
PIMAGE_NT_HEADERS64 PEHeader64;
|
||||||
|
|
@ -127,7 +126,6 @@ __declspec(dllexport) bool TITCALL ExtractSectionW(wchar_t* szFileName, wchar_t*
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ResortFileSections(char* szFileName)
|
__declspec(dllexport) bool TITCALL ResortFileSections(char* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -143,7 +141,6 @@ __declspec(dllexport) bool TITCALL ResortFileSections(char* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ResortFileSectionsW(wchar_t* szFileName)
|
__declspec(dllexport) bool TITCALL ResortFileSectionsW(wchar_t* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
|
|
@ -345,7 +342,6 @@ __declspec(dllexport) bool TITCALL ResortFileSectionsW(wchar_t* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL MakeAllSectionsRWE(char* szFileName)
|
__declspec(dllexport) bool TITCALL MakeAllSectionsRWE(char* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -361,7 +357,6 @@ __declspec(dllexport) bool TITCALL MakeAllSectionsRWE(char* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL MakeAllSectionsRWEW(wchar_t* szFileName)
|
__declspec(dllexport) bool TITCALL MakeAllSectionsRWEW(wchar_t* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t szBackupFile[MAX_PATH] = {};
|
wchar_t szBackupFile[MAX_PATH] = {};
|
||||||
wchar_t szBackupItem[MAX_PATH] = {};
|
wchar_t szBackupItem[MAX_PATH] = {};
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
|
|
@ -501,7 +496,6 @@ __declspec(dllexport) bool TITCALL MakeAllSectionsRWEW(wchar_t* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL AddNewSectionEx(char* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize)
|
__declspec(dllexport) long TITCALL AddNewSectionEx(char* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -511,13 +505,12 @@ __declspec(dllexport) long TITCALL AddNewSectionEx(char* szFileName, char* szSec
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return(NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL AddNewSectionExW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize)
|
__declspec(dllexport) long TITCALL AddNewSectionExW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize, DWORD SectionAttributes, LPVOID SectionContent, DWORD ContentSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
bool OverlayHasBeenRemoved = false;
|
bool OverlayHasBeenRemoved = false;
|
||||||
wchar_t szBackupOverlayFile[MAX_PATH] = {};
|
wchar_t szBackupOverlayFile[MAX_PATH] = {};
|
||||||
wchar_t szBackupFile[MAX_PATH] = {};
|
wchar_t szBackupFile[MAX_PATH] = {};
|
||||||
|
|
@ -876,17 +869,16 @@ __declspec(dllexport) long TITCALL AddNewSectionExW(wchar_t* szFileName, char* s
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL AddNewSection(char* szFileName, char* szSectionName, DWORD SectionSize)
|
__declspec(dllexport) long TITCALL AddNewSection(char* szFileName, char* szSectionName, DWORD SectionSize)
|
||||||
{
|
{
|
||||||
return(AddNewSectionEx(szFileName, szSectionName, SectionSize, NULL, NULL, NULL));
|
return AddNewSectionEx(szFileName, szSectionName, SectionSize, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) long TITCALL AddNewSectionW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize)
|
__declspec(dllexport) long TITCALL AddNewSectionW(wchar_t* szFileName, char* szSectionName, DWORD SectionSize)
|
||||||
{
|
{
|
||||||
return(AddNewSectionExW(szFileName, szSectionName, SectionSize, NULL, NULL, NULL));
|
return AddNewSectionExW(szFileName, szSectionName, SectionSize, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ResizeLastSection(char* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData)
|
__declspec(dllexport) bool TITCALL ResizeLastSection(char* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -902,7 +894,6 @@ __declspec(dllexport) bool TITCALL ResizeLastSection(char* szFileName, DWORD Num
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ResizeLastSectionW(wchar_t* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData)
|
__declspec(dllexport) bool TITCALL ResizeLastSectionW(wchar_t* szFileName, DWORD NumberOfExpandBytes, bool AlignResizeData)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t szBackupFile[MAX_PATH] = {};
|
wchar_t szBackupFile[MAX_PATH] = {};
|
||||||
wchar_t szBackupItem[MAX_PATH] = {};
|
wchar_t szBackupItem[MAX_PATH] = {};
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
|
|
@ -1106,7 +1097,6 @@ __declspec(dllexport) bool TITCALL ResizeLastSectionW(wchar_t* szFileName, DWORD
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DeleteLastSection(char* szFileName)
|
__declspec(dllexport) bool TITCALL DeleteLastSection(char* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -1122,7 +1112,6 @@ __declspec(dllexport) bool TITCALL DeleteLastSection(char* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DeleteLastSectionW(wchar_t* szFileName)
|
__declspec(dllexport) bool TITCALL DeleteLastSectionW(wchar_t* szFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t szBackupFile[MAX_PATH] = {};
|
wchar_t szBackupFile[MAX_PATH] = {};
|
||||||
wchar_t szBackupItem[MAX_PATH] = {};
|
wchar_t szBackupItem[MAX_PATH] = {};
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
|
|
@ -1276,7 +1265,6 @@ __declspec(dllexport) bool TITCALL DeleteLastSectionW(wchar_t* szFileName)
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DeleteLastSectionEx(char* szFileName, DWORD NumberOfSections)
|
__declspec(dllexport) bool TITCALL DeleteLastSectionEx(char* szFileName, DWORD NumberOfSections)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(NumberOfSections > 0)
|
while(NumberOfSections > 0)
|
||||||
{
|
{
|
||||||
DeleteLastSection(szFileName);
|
DeleteLastSection(szFileName);
|
||||||
|
|
@ -1287,7 +1275,6 @@ __declspec(dllexport) bool TITCALL DeleteLastSectionEx(char* szFileName, DWORD N
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL DeleteLastSectionExW(wchar_t* szFileName, DWORD NumberOfSections)
|
__declspec(dllexport) bool TITCALL DeleteLastSectionExW(wchar_t* szFileName, DWORD NumberOfSections)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(NumberOfSections > 0)
|
while(NumberOfSections > 0)
|
||||||
{
|
{
|
||||||
DeleteLastSectionW(szFileName);
|
DeleteLastSectionW(szFileName);
|
||||||
|
|
@ -1298,7 +1285,6 @@ __declspec(dllexport) bool TITCALL DeleteLastSectionExW(wchar_t* szFileName, DWO
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL WipeSection(char* szFileName, int WipeSectionNumber, bool RemovePhysically)
|
__declspec(dllexport) bool TITCALL WipeSection(char* szFileName, int WipeSectionNumber, bool RemovePhysically)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -1311,9 +1297,9 @@ __declspec(dllexport) bool TITCALL WipeSection(char* szFileName, int WipeSection
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL WipeSectionW(wchar_t* szFileName, int WipeSectionNumber, bool RemovePhysically)
|
__declspec(dllexport) bool TITCALL WipeSectionW(wchar_t* szFileName, int WipeSectionNumber, bool RemovePhysically)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t szBackupFile[MAX_PATH] = {};
|
wchar_t szBackupFile[MAX_PATH] = {};
|
||||||
wchar_t szBackupItem[MAX_PATH] = {};
|
wchar_t szBackupItem[MAX_PATH] = {};
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
// TitanEngine.StaticUnpacker.functions:
|
// TitanEngine.StaticUnpacker.functions:
|
||||||
__declspec(dllexport) bool TITCALL StaticFileLoad(char* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA)
|
__declspec(dllexport) bool TITCALL StaticFileLoad(char* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!SimulateLoad)
|
if(!SimulateLoad)
|
||||||
{
|
{
|
||||||
if(MapFileEx(szFileName, DesiredAccess, FileHandle, LoadedSize, FileMap, FileMapVA, NULL))
|
if(MapFileEx(szFileName, DesiredAccess, FileHandle, LoadedSize, FileMap, FileMapVA, NULL))
|
||||||
|
|
@ -24,14 +23,16 @@ __declspec(dllexport) bool TITCALL StaticFileLoad(char* szFileName, DWORD Desire
|
||||||
*LoadedSize = (DWORD)GetPE32DataFromMappedFile(*FileMapVA, NULL, UE_SIZEOFIMAGE);
|
*LoadedSize = (DWORD)GetPE32DataFromMappedFile(*FileMapVA, NULL, UE_SIZEOFIMAGE);
|
||||||
*FileHandle = NULL;
|
*FileHandle = NULL;
|
||||||
*FileMap = NULL;
|
*FileMap = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileLoadW(wchar_t* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA)
|
__declspec(dllexport) bool TITCALL StaticFileLoadW(wchar_t* szFileName, DWORD DesiredAccess, bool SimulateLoad, LPHANDLE FileHandle, LPDWORD LoadedSize, LPHANDLE FileMap, PULONG_PTR FileMapVA)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!SimulateLoad)
|
if(!SimulateLoad)
|
||||||
{
|
{
|
||||||
if(MapFileExW(szFileName, DesiredAccess, FileHandle, LoadedSize, FileMap, FileMapVA, NULL))
|
if(MapFileExW(szFileName, DesiredAccess, FileHandle, LoadedSize, FileMap, FileMapVA, NULL))
|
||||||
|
|
@ -47,14 +48,16 @@ __declspec(dllexport) bool TITCALL StaticFileLoadW(wchar_t* szFileName, DWORD De
|
||||||
*LoadedSize = (DWORD)GetPE32DataFromMappedFile(*FileMapVA, NULL, UE_SIZEOFIMAGE);
|
*LoadedSize = (DWORD)GetPE32DataFromMappedFile(*FileMapVA, NULL, UE_SIZEOFIMAGE);
|
||||||
*FileHandle = NULL;
|
*FileHandle = NULL;
|
||||||
*FileMap = NULL;
|
*FileMap = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileUnload(char* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA)
|
__declspec(dllexport) bool TITCALL StaticFileUnload(char* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
|
|
@ -67,9 +70,9 @@ __declspec(dllexport) bool TITCALL StaticFileUnload(char* szFileName, bool Commi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA)
|
__declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool CommitChanges, HANDLE FileHandle, DWORD LoadedSize, HANDLE FileMap, ULONG_PTR FileMapVA)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD PeHeaderSize;
|
DWORD PeHeaderSize;
|
||||||
PIMAGE_DOS_HEADER DOSHeader;
|
PIMAGE_DOS_HEADER DOSHeader;
|
||||||
PIMAGE_NT_HEADERS32 PEHeader32;
|
PIMAGE_NT_HEADERS32 PEHeader32;
|
||||||
|
|
@ -87,13 +90,14 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
if(FileHandle != NULL && FileMap != NULL)
|
if(FileHandle != NULL && FileMap != NULL)
|
||||||
{
|
{
|
||||||
UnMapFileEx(FileHandle, LoadedSize, FileMap, FileMapVA);
|
UnMapFileEx(FileHandle, LoadedSize, FileMap, FileMapVA);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!CommitChanges)
|
if(!CommitChanges)
|
||||||
{
|
{
|
||||||
return(ResourcerFreeLoadedFile((LPVOID)FileMapVA));
|
return ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -104,6 +108,7 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
{
|
{
|
||||||
PEHeader32 = (PIMAGE_NT_HEADERS32)((ULONG_PTR)DOSHeader + DOSHeader->e_lfanew);
|
PEHeader32 = (PIMAGE_NT_HEADERS32)((ULONG_PTR)DOSHeader + DOSHeader->e_lfanew);
|
||||||
PEHeader64 = (PIMAGE_NT_HEADERS64)((ULONG_PTR)DOSHeader + DOSHeader->e_lfanew);
|
PEHeader64 = (PIMAGE_NT_HEADERS64)((ULONG_PTR)DOSHeader + DOSHeader->e_lfanew);
|
||||||
|
|
||||||
if(PEHeader32->OptionalHeader.Magic == 0x10B)
|
if(PEHeader32->OptionalHeader.Magic == 0x10B)
|
||||||
{
|
{
|
||||||
FileIs64 = false;
|
FileIs64 = false;
|
||||||
|
|
@ -116,22 +121,27 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
{
|
{
|
||||||
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
||||||
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!FileIs64)
|
if(!FileIs64)
|
||||||
{
|
{
|
||||||
PeHeaderSize = PEHeader32->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_SECTION_HEADER) * PEHeader32->FileHeader.NumberOfSections;
|
PeHeaderSize = PEHeader32->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_SECTION_HEADER) * PEHeader32->FileHeader.NumberOfSections;
|
||||||
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PEHeader32 + PEHeader32->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_FILE_HEADER) + 4);
|
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PEHeader32 + PEHeader32->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_FILE_HEADER) + 4);
|
||||||
SectionNumber = PEHeader32->FileHeader.NumberOfSections;
|
SectionNumber = PEHeader32->FileHeader.NumberOfSections;
|
||||||
RtlMoveMemory((LPVOID)myFileMapVA, (LPVOID)FileMapVA, PeHeaderSize);
|
RtlMoveMemory((LPVOID)myFileMapVA, (LPVOID)FileMapVA, PeHeaderSize);
|
||||||
|
|
||||||
while(SectionNumber > 0)
|
while(SectionNumber > 0)
|
||||||
{
|
{
|
||||||
RtlMoveMemory((LPVOID)((ULONG_PTR)myFileMapVA + PESections->PointerToRawData), (LPVOID)(FileMapVA + PESections->VirtualAddress), PESections->SizeOfRawData);
|
RtlMoveMemory((LPVOID)((ULONG_PTR)myFileMapVA + PESections->PointerToRawData), (LPVOID)(FileMapVA + PESections->VirtualAddress), PESections->SizeOfRawData);
|
||||||
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PESections + IMAGE_SIZEOF_SECTION_HEADER);
|
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PESections + IMAGE_SIZEOF_SECTION_HEADER);
|
||||||
SectionNumber--;
|
SectionNumber--;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
||||||
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -140,6 +150,7 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PEHeader64 + PEHeader64->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_FILE_HEADER) + 4);
|
PESections = (PIMAGE_SECTION_HEADER)((ULONG_PTR)PEHeader64 + PEHeader64->FileHeader.SizeOfOptionalHeader + sizeof(IMAGE_FILE_HEADER) + 4);
|
||||||
SectionNumber = PEHeader64->FileHeader.NumberOfSections;
|
SectionNumber = PEHeader64->FileHeader.NumberOfSections;
|
||||||
RtlMoveMemory((LPVOID)myFileMapVA, (LPVOID)FileMapVA, PeHeaderSize);
|
RtlMoveMemory((LPVOID)myFileMapVA, (LPVOID)FileMapVA, PeHeaderSize);
|
||||||
|
|
||||||
while(SectionNumber > 0)
|
while(SectionNumber > 0)
|
||||||
{
|
{
|
||||||
RtlMoveMemory((LPVOID)((ULONG_PTR)myFileMapVA + PESections->PointerToRawData), (LPVOID)(FileMapVA + PESections->VirtualAddress), PESections->SizeOfRawData);
|
RtlMoveMemory((LPVOID)((ULONG_PTR)myFileMapVA + PESections->PointerToRawData), (LPVOID)(FileMapVA + PESections->VirtualAddress), PESections->SizeOfRawData);
|
||||||
|
|
@ -148,6 +159,7 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
}
|
}
|
||||||
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
||||||
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -155,37 +167,41 @@ __declspec(dllexport) bool TITCALL StaticFileUnloadW(wchar_t* szFileName, bool C
|
||||||
{
|
{
|
||||||
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
ResourcerFreeLoadedFile((LPVOID)FileMapVA);
|
||||||
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
UnMapFileEx(myFileHandle, myFileSize, myFileMap, myFileMapVA);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileOpen(char* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh)
|
__declspec(dllexport) bool TITCALL StaticFileOpen(char* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
||||||
return(StaticFileOpenW(uniFileName, DesiredAccess, FileHandle, FileSizeLow, FileSizeHigh));
|
|
||||||
|
return StaticFileOpenW(uniFileName, DesiredAccess, FileHandle, FileSizeLow, FileSizeHigh);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileOpenW(wchar_t* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh)
|
__declspec(dllexport) bool TITCALL StaticFileOpenW(wchar_t* szFileName, DWORD DesiredAccess, LPHANDLE FileHandle, LPDWORD FileSizeLow, LPDWORD FileSizeHigh)
|
||||||
{
|
{
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
*FileHandle = CreateFileW(szFileName, DesiredAccess, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
*FileHandle = CreateFileW(szFileName, DesiredAccess, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
if(FileHandle != INVALID_HANDLE_VALUE)
|
if(FileHandle != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
*FileSizeLow = GetFileSize(*FileHandle, FileSizeHigh);
|
*FileSizeLow = GetFileSize(*FileHandle, FileSizeHigh);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -198,9 +214,9 @@ __declspec(dllexport) bool TITCALL StaticFileOpenW(wchar_t* szFileName, DWORD De
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticFileGetContent(HANDLE FileHandle, DWORD FilePositionLow, LPDWORD FilePositionHigh, void* Buffer, DWORD Size)
|
__declspec(dllexport) bool TITCALL StaticFileGetContent(HANDLE FileHandle, DWORD FilePositionLow, LPDWORD FilePositionHigh, void* Buffer, DWORD Size)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD rfNumberOfBytesRead;
|
DWORD rfNumberOfBytesRead;
|
||||||
|
|
||||||
if(SetFilePointer(FileHandle, FilePositionLow, (PLONG)FilePositionHigh, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
if(SetFilePointer(FileHandle, FilePositionLow, (PLONG)FilePositionHigh, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
||||||
|
|
@ -217,12 +233,15 @@ __declspec(dllexport) bool TITCALL StaticFileGetContent(HANDLE FileHandle, DWORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL StaticFileClose(HANDLE FileHandle)
|
__declspec(dllexport) void TITCALL StaticFileClose(HANDLE FileHandle)
|
||||||
{
|
{
|
||||||
EngineCloseHandle(FileHandle);
|
EngineCloseHandle(FileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL StaticMemoryDecrypt(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey)
|
__declspec(dllexport) void TITCALL StaticMemoryDecrypt(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey)
|
||||||
{
|
{
|
||||||
DWORD LoopCount = NULL;
|
DWORD LoopCount = NULL;
|
||||||
|
|
@ -326,9 +345,9 @@ __declspec(dllexport) void TITCALL StaticMemoryDecrypt(LPVOID MemoryStart, DWORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL StaticMemoryDecryptEx(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionKeySize, void* DecryptionCallBack)
|
__declspec(dllexport) void TITCALL StaticMemoryDecryptEx(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionKeySize, void* DecryptionCallBack)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD LoopCount = NULL;
|
DWORD LoopCount = NULL;
|
||||||
typedef bool(TITCALL *fStaticCallBack)(void* sMemoryStart, int sKeySize);
|
typedef bool(TITCALL *fStaticCallBack)(void* sMemoryStart, int sKeySize);
|
||||||
fStaticCallBack myStaticCallBack = (fStaticCallBack)DecryptionCallBack;
|
fStaticCallBack myStaticCallBack = (fStaticCallBack)DecryptionCallBack;
|
||||||
|
|
@ -354,9 +373,9 @@ __declspec(dllexport) void TITCALL StaticMemoryDecryptEx(LPVOID MemoryStart, DWO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL StaticMemoryDecryptSpecial(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionKeySize, DWORD SpecDecryptionType, void* DecryptionCallBack)
|
__declspec(dllexport) void TITCALL StaticMemoryDecryptSpecial(LPVOID MemoryStart, DWORD MemorySize, DWORD DecryptionKeySize, DWORD SpecDecryptionType, void* DecryptionCallBack)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD LoopCount = NULL;
|
DWORD LoopCount = NULL;
|
||||||
typedef bool(TITCALL *fStaticCallBack)(void* sMemoryStart, int sKeySize);
|
typedef bool(TITCALL *fStaticCallBack)(void* sMemoryStart, int sKeySize);
|
||||||
fStaticCallBack myStaticCallBack = (fStaticCallBack)DecryptionCallBack;
|
fStaticCallBack myStaticCallBack = (fStaticCallBack)DecryptionCallBack;
|
||||||
|
|
@ -381,6 +400,7 @@ __declspec(dllexport) void TITCALL StaticMemoryDecryptSpecial(LPVOID MemoryStart
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SpecDecryptionType == UE_STATIC_DECRYPTOR_BACKWARD)
|
if(SpecDecryptionType == UE_STATIC_DECRYPTOR_BACKWARD)
|
||||||
{
|
{
|
||||||
MemoryStart = (LPVOID)((ULONG_PTR)MemoryStart - DecryptionKeySize);
|
MemoryStart = (LPVOID)((ULONG_PTR)MemoryStart - DecryptionKeySize);
|
||||||
|
|
@ -389,13 +409,14 @@ __declspec(dllexport) void TITCALL StaticMemoryDecryptSpecial(LPVOID MemoryStart
|
||||||
{
|
{
|
||||||
MemoryStart = (LPVOID)((ULONG_PTR)MemoryStart + DecryptionKeySize);
|
MemoryStart = (LPVOID)((ULONG_PTR)MemoryStart + DecryptionKeySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopCount--;
|
LoopCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void TITCALL StaticSectionDecrypt(ULONG_PTR FileMapVA, DWORD SectionNumber, bool SimulateLoad, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey)
|
__declspec(dllexport) void TITCALL StaticSectionDecrypt(ULONG_PTR FileMapVA, DWORD SectionNumber, bool SimulateLoad, DWORD DecryptionType, DWORD DecryptionKeySize, ULONG_PTR DecryptionKey)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!SimulateLoad)
|
if(!SimulateLoad)
|
||||||
{
|
{
|
||||||
StaticMemoryDecrypt((LPVOID)((ULONG_PTR)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWOFFSET) + FileMapVA), (DWORD)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWSIZE), DecryptionType, DecryptionKeySize, DecryptionKey);
|
StaticMemoryDecrypt((LPVOID)((ULONG_PTR)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWOFFSET) + FileMapVA), (DWORD)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWSIZE), DecryptionType, DecryptionKeySize, DecryptionKey);
|
||||||
|
|
@ -405,6 +426,7 @@ __declspec(dllexport) void TITCALL StaticSectionDecrypt(ULONG_PTR FileMapVA, DWO
|
||||||
StaticMemoryDecrypt((LPVOID)((ULONG_PTR)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONVIRTUALOFFSET) + FileMapVA), (DWORD)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWSIZE), DecryptionType, DecryptionKeySize, DecryptionKey);
|
StaticMemoryDecrypt((LPVOID)((ULONG_PTR)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONVIRTUALOFFSET) + FileMapVA), (DWORD)GetPE32DataFromMappedFile(FileMapVA, SectionNumber, UE_SECTIONRAWSIZE), DecryptionType, DecryptionKeySize, DecryptionKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticMemoryDecompress(void* Source, DWORD SourceSize, void* Destination, DWORD DestinationSize, int Algorithm)
|
__declspec(dllexport) bool TITCALL StaticMemoryDecompress(void* Source, DWORD SourceSize, void* Destination, DWORD DestinationSize, int Algorithm)
|
||||||
{
|
{
|
||||||
if(!Source || !Destination)
|
if(!Source || !Destination)
|
||||||
|
|
@ -431,11 +453,12 @@ __declspec(dllexport) bool TITCALL StaticMemoryDecompress(void* Source, DWORD So
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopy(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, char* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopy(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, char* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szDumpFileName != NULL)
|
if(szDumpFileName != NULL)
|
||||||
|
|
@ -448,9 +471,9 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopy(HANDLE hFile, ULONG_PTR F
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, wchar_t* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR FileMapVA, ULONG_PTR VitualAddressToCopy, DWORD Size, bool AddressIsRVA, wchar_t* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD SizeToRead;
|
DWORD SizeToRead;
|
||||||
HANDLE hReadFile;
|
HANDLE hReadFile;
|
||||||
HANDLE hWriteFile;
|
HANDLE hWriteFile;
|
||||||
|
|
@ -472,8 +495,8 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR
|
||||||
{
|
{
|
||||||
AddressToCopy = (ULONG_PTR)ConvertVAtoFileOffset(FileMapVA, VitualAddressToCopy, false);
|
AddressToCopy = (ULONG_PTR)ConvertVAtoFileOffset(FileMapVA, VitualAddressToCopy, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SetFilePointer(hReadFile, (long)AddressToCopy, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
if(SetFilePointer(hReadFile, (long)AddressToCopy, NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
EngineCreatePathForFileW(szDumpFileName);
|
EngineCreatePathForFileW(szDumpFileName);
|
||||||
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
@ -521,20 +544,22 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyW(HANDLE hFile, ULONG_PTR
|
||||||
Size = NULL;
|
Size = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
EngineCloseHandle(hWriteFile);
|
EngineCloseHandle(hWriteFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, char* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, char* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szDumpFileName != NULL)
|
if(szDumpFileName != NULL)
|
||||||
|
|
@ -547,9 +572,9 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx(HANDLE hFile, DWORD Raw
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, wchar_t* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD RawAddressToCopy, DWORD Size, wchar_t* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD SizeToRead;
|
DWORD SizeToRead;
|
||||||
HANDLE hReadFile;
|
HANDLE hReadFile;
|
||||||
HANDLE hWriteFile;
|
HANDLE hWriteFile;
|
||||||
|
|
@ -559,7 +584,6 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD Ra
|
||||||
if(DuplicateHandle(GetCurrentProcess(), hFile, GetCurrentProcess(), &hReadFile, NULL, false, DUPLICATE_SAME_ACCESS))
|
if(DuplicateHandle(GetCurrentProcess(), hFile, GetCurrentProcess(), &hReadFile, NULL, false, DUPLICATE_SAME_ACCESS))
|
||||||
{
|
{
|
||||||
if(SetFilePointer(hReadFile, (long)(RawAddressToCopy), NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
if(SetFilePointer(hReadFile, (long)(RawAddressToCopy), NULL, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
EngineCreatePathForFileW(szDumpFileName);
|
EngineCreatePathForFileW(szDumpFileName);
|
||||||
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
@ -607,34 +631,38 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyExW(HANDLE hFile, DWORD Ra
|
||||||
Size = 0;
|
Size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
EngineCloseHandle(hWriteFile);
|
EngineCloseHandle(hWriteFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, char* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, char* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szDumpFileName != NULL)
|
if(szDumpFileName != NULL)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_ACP, NULL, szDumpFileName, lstrlenA(szDumpFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
MultiByteToWideChar(CP_ACP, NULL, szDumpFileName, lstrlenA(szDumpFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
||||||
return(StaticRawMemoryCopyEx64W(hFile, RawAddressToCopy, Size, uniFileName));
|
|
||||||
|
return StaticRawMemoryCopyEx64W(hFile, RawAddressToCopy, Size, uniFileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, wchar_t* szDumpFileName)
|
__declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD64 RawAddressToCopy, DWORD64 Size, wchar_t* szDumpFileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
DWORD SizeToRead;
|
DWORD SizeToRead;
|
||||||
HANDLE hReadFile;
|
HANDLE hReadFile;
|
||||||
HANDLE hWriteFile;
|
HANDLE hWriteFile;
|
||||||
|
|
@ -648,7 +676,6 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD6
|
||||||
FilePosLow = (DWORD)RawAddressToCopy;
|
FilePosLow = (DWORD)RawAddressToCopy;
|
||||||
RtlMoveMemory(&FilePosHigh, (void*)((ULONG_PTR)(&RawAddressToCopy) + 4), 4);
|
RtlMoveMemory(&FilePosHigh, (void*)((ULONG_PTR)(&RawAddressToCopy) + 4), 4);
|
||||||
if(SetFilePointer(hReadFile, FilePosLow, &FilePosHigh, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
if(SetFilePointer(hReadFile, FilePosLow, &FilePosHigh, FILE_BEGIN) != INVALID_SET_FILE_POINTER)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
EngineCreatePathForFileW(szDumpFileName);
|
EngineCreatePathForFileW(szDumpFileName);
|
||||||
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
hWriteFile = CreateFileW(szDumpFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
@ -681,6 +708,7 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD6
|
||||||
{
|
{
|
||||||
WriteFile(hWriteFile, ueCopyBuffer, rfNumberOfBytesRead, &rfNumberOfBytesRead, NULL);
|
WriteFile(hWriteFile, ueCopyBuffer, rfNumberOfBytesRead, &rfNumberOfBytesRead, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeToRead = (DWORD)Size;
|
SizeToRead = (DWORD)Size;
|
||||||
Size = NULL;
|
Size = NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -696,19 +724,22 @@ __declspec(dllexport) bool TITCALL StaticRawMemoryCopyEx64W(HANDLE hFile, DWORD6
|
||||||
Size = NULL;
|
Size = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
EngineCloseHandle(hWriteFile);
|
EngineCloseHandle(hWriteFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
EngineCloseHandle(hReadFile);
|
EngineCloseHandle(hReadFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD SizeOfMemory, void* HashDigest, bool OutputString, int Algorithm)
|
__declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD SizeOfMemory, void* HashDigest, bool OutputString, int Algorithm)
|
||||||
{
|
{
|
||||||
|
|
||||||
#define MD5LEN 16
|
#define MD5LEN 16
|
||||||
#define SHA1LEN 20
|
#define SHA1LEN 20
|
||||||
#define HASH_MAX_LENGTH 20
|
#define HASH_MAX_LENGTH 20
|
||||||
|
|
@ -741,6 +772,7 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
if(!CryptCreateHash(hProv, hashAlgo, NULL, NULL, &hHash))
|
if(!CryptCreateHash(hProv, hashAlgo, NULL, NULL, &hHash))
|
||||||
{
|
{
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -749,6 +781,7 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -759,6 +792,7 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -767,6 +801,7 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
rgbHash[1] = _byteswap_ulong(rgbHash[1]);
|
rgbHash[1] = _byteswap_ulong(rgbHash[1]);
|
||||||
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
||||||
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
if(OutputString)
|
if(OutputString)
|
||||||
|
|
@ -782,10 +817,13 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -796,6 +834,7 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -820,10 +859,13 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -840,28 +882,31 @@ __declspec(dllexport) bool TITCALL StaticHashMemory(void* MemoryToHash, DWORD Si
|
||||||
{
|
{
|
||||||
RtlMoveMemory(HashDigest, &crc32, sizeof crc32);
|
RtlMoveMemory(HashDigest, &crc32, sizeof crc32);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticHashFile(char* szFileName, char* HashDigest, bool OutputString, int Algorithm)
|
__declspec(dllexport) bool TITCALL StaticHashFile(char* szFileName, char* HashDigest, bool OutputString, int Algorithm)
|
||||||
{
|
{
|
||||||
|
|
||||||
wchar_t uniFileName[MAX_PATH] = {};
|
wchar_t uniFileName[MAX_PATH] = {};
|
||||||
|
|
||||||
if(szFileName != NULL)
|
if(szFileName != NULL)
|
||||||
{
|
{
|
||||||
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
MultiByteToWideChar(CP_ACP, NULL, szFileName, lstrlenA(szFileName)+1, uniFileName, sizeof(uniFileName)/(sizeof(uniFileName[0])));
|
||||||
return(StaticHashFileW(uniFileName, HashDigest, OutputString, Algorithm));
|
|
||||||
|
return StaticHashFileW(uniFileName, HashDigest, OutputString, Algorithm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* HashDigest, bool OutputString, int Algorithm)
|
__declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* HashDigest, bool OutputString, int Algorithm)
|
||||||
{
|
{
|
||||||
|
|
||||||
#define MD5LEN 16
|
#define MD5LEN 16
|
||||||
#define SHA1LEN 20
|
#define SHA1LEN 20
|
||||||
#define HASH_MAX_LENGTH 20
|
#define HASH_MAX_LENGTH 20
|
||||||
|
|
@ -889,6 +934,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
|
if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET))
|
||||||
{
|
{
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -904,6 +950,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
{
|
{
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while(bResult)
|
while(bResult)
|
||||||
|
|
@ -921,6 +968,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -929,6 +977,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(Algorithm == UE_STATIC_HASH_MD5)
|
if(Algorithm == UE_STATIC_HASH_MD5)
|
||||||
|
|
@ -939,6 +988,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -947,6 +997,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
rgbHash[1] = _byteswap_ulong(rgbHash[1]);
|
rgbHash[1] = _byteswap_ulong(rgbHash[1]);
|
||||||
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
||||||
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
if(OutputString)
|
if(OutputString)
|
||||||
|
|
@ -963,11 +1014,13 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -979,6 +1032,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -988,6 +1042,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
rgbHash[2] = _byteswap_ulong(rgbHash[2]);
|
||||||
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
rgbHash[3] = _byteswap_ulong(rgbHash[3]);
|
||||||
rgbHash[4] = _byteswap_ulong(rgbHash[4]);
|
rgbHash[4] = _byteswap_ulong(rgbHash[4]);
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
if(OutputString)
|
if(OutputString)
|
||||||
|
|
@ -1004,11 +1059,13 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CryptDestroyHash(hHash);
|
CryptDestroyHash(hHash);
|
||||||
CryptReleaseContext(hProv, NULL);
|
CryptReleaseContext(hProv, NULL);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1025,6 +1082,7 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineCrc32PartialCRC(&crc32, (unsigned char*)&rgbFile[0], cbRead);
|
EngineCrc32PartialCRC(&crc32, (unsigned char*)&rgbFile[0], cbRead);
|
||||||
}
|
}
|
||||||
crc32 = crc32 ^ 0xFFFFFFFF;
|
crc32 = crc32 ^ 0xFFFFFFFF;
|
||||||
|
|
@ -1036,9 +1094,13 @@ __declspec(dllexport) bool TITCALL StaticHashFileW(wchar_t* szFileName, char* Ha
|
||||||
{
|
{
|
||||||
RtlMoveMemory(HashDigest, &crc32, sizeof crc32);
|
RtlMoveMemory(HashDigest, &crc32, sizeof crc32);
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +243,7 @@ __declspec(dllexport) long long TITCALL ThreaderGetOpenHandleForThread(DWORD Thr
|
||||||
|
|
||||||
__declspec(dllexport) bool TITCALL ThreaderIsExceptionInMainThread()
|
__declspec(dllexport) bool TITCALL ThreaderIsExceptionInMainThread()
|
||||||
{
|
{
|
||||||
LPDEBUG_EVENT myDBGEvent;
|
LPDEBUG_EVENT myDBGEvent = (LPDEBUG_EVENT)GetDebugData();
|
||||||
myDBGEvent = (LPDEBUG_EVENT)GetDebugData();
|
|
||||||
return (myDBGEvent->dwThreadId == dbgProcessInformation.dwThreadId);
|
return (myDBGEvent->dwThreadId == dbgProcessInformation.dwThreadId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ __declspec(dllexport) void* TITCALL TranslateNativeName(char* szNativeName)
|
||||||
}
|
}
|
||||||
szDeviceName[0]++;
|
szDeviceName[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(szDeviceCOMName[3] <= 0x39)
|
while(szDeviceCOMName[3] <= 0x39)
|
||||||
{
|
{
|
||||||
RtlZeroMemory(TranslatedName, 0x1000);
|
RtlZeroMemory(TranslatedName, 0x1000);
|
||||||
|
|
@ -43,8 +44,10 @@ __declspec(dllexport) void* TITCALL TranslateNativeName(char* szNativeName)
|
||||||
}
|
}
|
||||||
szDeviceCOMName[3]++;
|
szDeviceCOMName[3]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualFree(TranslatedName, NULL, MEM_RELEASE);
|
VirtualFree(TranslatedName, NULL, MEM_RELEASE);
|
||||||
return(NULL);
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(dllexport) void* TITCALL TranslateNativeNameW(wchar_t* szNativeName)
|
__declspec(dllexport) void* TITCALL TranslateNativeNameW(wchar_t* szNativeName)
|
||||||
|
|
@ -71,6 +74,7 @@ __declspec(dllexport) void* TITCALL TranslateNativeNameW(wchar_t* szNativeName)
|
||||||
}
|
}
|
||||||
szDeviceName[0]++;
|
szDeviceName[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(szDeviceCOMName[3] <= 0x39)
|
while(szDeviceCOMName[3] <= 0x39)
|
||||||
{
|
{
|
||||||
RtlZeroMemory(TranslatedName, 0x1000);
|
RtlZeroMemory(TranslatedName, 0x1000);
|
||||||
|
|
@ -88,6 +92,8 @@ __declspec(dllexport) void* TITCALL TranslateNativeNameW(wchar_t* szNativeName)
|
||||||
}
|
}
|
||||||
szDeviceCOMName[3]++;
|
szDeviceCOMName[3]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualFree(TranslatedName, NULL, MEM_RELEASE);
|
VirtualFree(TranslatedName, NULL, MEM_RELEASE);
|
||||||
return(NULL);
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue