1
0
Fork 0

DBG: no idea what happened...

This commit is contained in:
Mr. eXoDia 2015-07-13 03:52:33 +02:00
parent d5c7c6f6a0
commit 2374dbb897
1 changed files with 59 additions and 59 deletions

View File

@ -17,65 +17,65 @@ ControlFlowAnalysis::ControlFlowAnalysis(uint base, uint size, bool exceptionDir
memset(modulePath, 0, sizeof(modulePath)); memset(modulePath, 0, sizeof(modulePath));
ModPathFromAddr(_moduleBase, modulePath, ARRAYSIZE(modulePath)); ModPathFromAddr(_moduleBase, modulePath, ARRAYSIZE(modulePath));
HANDLE fileHandle; HANDLE fileHandle;
DWORD fileSize; DWORD fileSize;
HANDLE fileMapHandle; HANDLE fileMapHandle;
ULONG_PTR fileMapVa; ULONG_PTR fileMapVa;
if(StaticFileLoadW( if(StaticFileLoadW(
StringUtils::Utf8ToUtf16(modulePath).c_str(), StringUtils::Utf8ToUtf16(modulePath).c_str(),
UE_ACCESS_READ, UE_ACCESS_READ,
false, false,
&fileHandle, &fileHandle,
&fileSize, &fileSize,
&fileMapHandle, &fileMapHandle,
&fileMapVa)) &fileMapVa))
{ {
// Find a pointer to IMAGE_DIRECTORY_ENTRY_EXCEPTION for later use // Find a pointer to IMAGE_DIRECTORY_ENTRY_EXCEPTION for later use
ULONG_PTR virtualOffset = GetPE32DataFromMappedFile(fileMapVa, IMAGE_DIRECTORY_ENTRY_EXCEPTION, UE_SECTIONVIRTUALOFFSET); ULONG_PTR virtualOffset = GetPE32DataFromMappedFile(fileMapVa, IMAGE_DIRECTORY_ENTRY_EXCEPTION, UE_SECTIONVIRTUALOFFSET);
_functionInfoSize = (uint)GetPE32DataFromMappedFile(fileMapVa, IMAGE_DIRECTORY_ENTRY_EXCEPTION, UE_SECTIONVIRTUALSIZE); _functionInfoSize = (uint)GetPE32DataFromMappedFile(fileMapVa, IMAGE_DIRECTORY_ENTRY_EXCEPTION, UE_SECTIONVIRTUALSIZE);
// Unload the file // Unload the file
StaticFileUnloadW(nullptr, false, fileHandle, fileSize, fileMapHandle, fileMapVa); StaticFileUnloadW(nullptr, false, fileHandle, fileSize, fileMapHandle, fileMapVa);
// Get a copy of the function table // Get a copy of the function table
if(virtualOffset) if(virtualOffset)
{ {
// Read the table into a buffer // Read the table into a buffer
_functionInfoData = emalloc(_functionInfoSize); _functionInfoData = emalloc(_functionInfoSize);
if(_functionInfoData) if(_functionInfoData)
MemRead(virtualOffset + _moduleBase, _functionInfoData, _functionInfoSize); MemRead(virtualOffset + _moduleBase, _functionInfoData, _functionInfoSize);
} }
} }
} }
#endif //_WIN64 #endif //_WIN64
} }
ControlFlowAnalysis::~ControlFlowAnalysis() ControlFlowAnalysis::~ControlFlowAnalysis()
{ {
if(_functionInfoData) if(_functionInfoData)
efree(_functionInfoData); efree(_functionInfoData);
} }
void ControlFlowAnalysis::Analyse() void ControlFlowAnalysis::Analyse()
{ {
dputs("Starting analysis..."); dputs("Starting analysis...");
DWORD ticks = GetTickCount(); DWORD ticks = GetTickCount();
BasicBlockStarts(); BasicBlockStarts();
dprintf("Basic block starts in %ums!\n", GetTickCount() - ticks); dprintf("Basic block starts in %ums!\n", GetTickCount() - ticks);
ticks = GetTickCount(); ticks = GetTickCount();
BasicBlocks(); BasicBlocks();
dprintf("Basic blocks in %ums!\n", GetTickCount() - ticks); dprintf("Basic blocks in %ums!\n", GetTickCount() - ticks);
ticks = GetTickCount(); ticks = GetTickCount();
Functions(); Functions();
dprintf("Functions in %ums!\n", GetTickCount() - ticks); dprintf("Functions in %ums!\n", GetTickCount() - ticks);
dprintf("Analysis finished!\n"); dprintf("Analysis finished!\n");
} }
void ControlFlowAnalysis::SetMarkers() void ControlFlowAnalysis::SetMarkers()
{ {