1
0
Fork 0

DBG: Analysis typedef changes

This commit is contained in:
Nukem 2015-06-30 00:53:44 -04:00
parent 76a92c3e44
commit 576b58e7c3
8 changed files with 23 additions and 28 deletions

View File

@ -16,8 +16,8 @@ enum BasicBlockFlags : uint
struct BasicBlock struct BasicBlock
{ {
uint VirtualStart; // Inclusive byte uint VirtualStart; // Inclusive
uint VirtualEnd; // Exclusive byte uint VirtualEnd; // Exclusive
uint Flags; uint Flags;
uint Target; uint Target;
@ -40,4 +40,6 @@ struct BasicBlock
{ {
return VirtualStart == b.VirtualStart; return VirtualStart == b.VirtualStart;
} }
}; };
typedef std::vector<BasicBlock> BBlockArray;

View File

@ -1,8 +1,8 @@
#include "AnalysisPass.h" #include "AnalysisPass.h"
#include "CodeFollowPass.h" #include "CodeFollowPass.h"
CodeFollowPass::CodeFollowPass(uint VirtualStart, uint VirtualEnd) CodeFollowPass::CodeFollowPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks)
: AnalysisPass(VirtualStart, VirtualEnd) : AnalysisPass(VirtualStart, VirtualEnd, MainBlocks)
{ {
} }

View File

@ -7,7 +7,7 @@
class CodeFollowPass : public AnalysisPass class CodeFollowPass : public AnalysisPass
{ {
public: public:
CodeFollowPass(uint VirtualStart, uint VirtualEnd); CodeFollowPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks);
virtual ~CodeFollowPass(); virtual ~CodeFollowPass();
virtual bool Analyse() override; virtual bool Analyse() override;

View File

@ -1,7 +1,7 @@
#include "FunctionPass.h" #include "FunctionPass.h"
FunctionPass::FunctionPass(uint VirtualStart, uint VirtualEnd) FunctionPass::FunctionPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks)
: AnalysisPass(VirtualStart, VirtualEnd) : AnalysisPass(VirtualStart, VirtualEnd, MainBlocks)
{ {
} }

View File

@ -6,7 +6,7 @@
class FunctionPass : public AnalysisPass class FunctionPass : public AnalysisPass
{ {
public: public:
FunctionPass(uint VirtualStart, uint VirtualEnd); FunctionPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks);
virtual ~FunctionPass(); virtual ~FunctionPass();
virtual bool Analyse() override; virtual bool Analyse() override;

View File

@ -1,15 +1,21 @@
#pragma once #pragma once
#include <vector>
#include <thread>
#include "AnalysisPass.h" #include "AnalysisPass.h"
#include "BasicBlock.h" #include "BasicBlock.h"
class Int3CoagulatorPass : public AnalysisPass class Int3CoagulatorPass : public AnalysisPass
{ {
public: public:
Int3CoagulatorPass(uint VirtualStart, uint VirtualEnd); Int3CoagulatorPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks);
virtual ~Int3CoagulatorPass(); virtual ~Int3CoagulatorPass();
virtual bool Analyse() override; virtual bool Analyse() override;
virtual const char* GetName() override;
private: private:
void AnalysisWorker(uint Start, uint End, std::vector<BasicBlock>* Blocks);
}; };

View File

@ -10,15 +10,15 @@
class LinearPass : public AnalysisPass class LinearPass : public AnalysisPass
{ {
public: public:
LinearPass(uint VirtualStart, uint VirtualEnd); LinearPass(uint VirtualStart, uint VirtualEnd, BBlockArray & MainBlocks);
virtual ~LinearPass(); virtual ~LinearPass();
virtual bool Analyse() override; virtual bool Analyse() override;
virtual std::vector<BasicBlock> & GetModifiedBlocks() override;
virtual const char* GetName() override;
private: private:
uint m_MaximumThreads; uint m_MaximumThreads;
std::vector<BasicBlock> m_InitialBlocks;
void AnalysisWorker(uint Start, uint End, std::vector<BasicBlock>* Blocks); void AnalysisWorker(uint Start, uint End, std::vector<BasicBlock>* Blocks);
BasicBlock* CreateBlockWorker(std::vector<BasicBlock>* Blocks, uint Start, uint End, bool Call, bool Jmp, bool Ret, bool Intr); BasicBlock* CreateBlockWorker(std::vector<BasicBlock>* Blocks, uint Start, uint End, bool Call, bool Jmp, bool Ret, bool Intr);

View File

@ -24,23 +24,10 @@ const unsigned char* FunctionAnalysis::TranslateAddress(uint addr)
return (addr >= _base && addr < _base + _size) ? _data + (addr - _base) : nullptr; return (addr >= _base && addr < _base + _size) ? _data + (addr - _base) : nullptr;
} }
void Derp(uint _base);
void FunctionAnalysis::Analyse() void FunctionAnalysis::Analyse()
{ {
dputs("Starting analysis..."); Derp(_base);
DWORD ticks = GetTickCount();
uint modBase = ModBaseFromAddr(_base);
uint modSize = ModSizeFromAddr(_base);
LinearPass* pass = new LinearPass(modBase, modBase + modSize);
pass->Analyse();
/*
PopulateReferences();
dprintf("%u called functions populated\n", _functions.size());
AnalyseFunctions();
*/
dprintf("Analysis finished in %ums!\n", GetTickCount() - ticks);
} }
void FunctionAnalysis::SetMarkers() void FunctionAnalysis::SetMarkers()