2006-06-15 04:19:30 +00:00
|
|
|
#ifndef _MIPSANALYSIS_H_
|
|
|
|
#define _MIPSANALYSIS_H_
|
|
|
|
|
|
|
|
#include "Types.h"
|
2006-10-12 06:16:48 +00:00
|
|
|
#include <map>
|
2012-05-21 06:31:50 +00:00
|
|
|
#include <vector>
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
class CMIPS;
|
|
|
|
|
|
|
|
class CMIPSAnalysis
|
|
|
|
{
|
|
|
|
public:
|
2006-10-12 06:16:48 +00:00
|
|
|
struct SUBROUTINE
|
|
|
|
{
|
|
|
|
uint32 nStart;
|
|
|
|
uint32 nEnd;
|
|
|
|
uint32 nStackAllocStart;
|
|
|
|
uint32 nStackAllocEnd;
|
|
|
|
uint32 nStackSize;
|
|
|
|
uint32 nReturnAddrPos;
|
|
|
|
};
|
|
|
|
|
2012-05-21 06:31:50 +00:00
|
|
|
struct CALLSTACKITEM
|
|
|
|
{
|
|
|
|
uint32 function;
|
|
|
|
uint32 caller;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<CALLSTACKITEM> CallStackItemArray;
|
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
CMIPSAnalysis(CMIPS*);
|
|
|
|
~CMIPSAnalysis();
|
2012-05-21 06:31:50 +00:00
|
|
|
void Analyse(uint32, uint32, uint32 = -1);
|
2012-04-01 00:47:39 +00:00
|
|
|
const SUBROUTINE* FindSubroutine(uint32) const;
|
2006-06-15 04:19:30 +00:00
|
|
|
void Clear();
|
2012-04-01 00:47:39 +00:00
|
|
|
|
2012-05-21 06:31:50 +00:00
|
|
|
static CallStackItemArray GetCallStack(CMIPS*, uint32 pc, uint32 sp, uint32 ra);
|
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
private:
|
2012-04-01 00:47:39 +00:00
|
|
|
typedef std::map<uint32, SUBROUTINE, std::greater<uint32>> SubroutineList;
|
2006-10-12 06:16:48 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
void InsertSubroutine(uint32, uint32, uint32, uint32, uint32, uint32);
|
2012-04-01 00:47:39 +00:00
|
|
|
void ChangeSubroutineStart(uint32, uint32);
|
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
CMIPS* m_pCtx;
|
2012-04-01 00:47:39 +00:00
|
|
|
SubroutineList m_subroutines;
|
2006-06-15 04:19:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|