forked from demoscene/E-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EAnalyEngine.h
98 lines (78 loc) · 2.1 KB
/
EAnalyEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "stdafx.h"
#pragma once
static DWORD Search_Bin(byte *pSrc, byte *pTrait, int nSrcLen, int nTraitLen) //低配版二进制搜索,用0x90来代替模糊搜索,返回偏移大小
{
if (IsBadReadPtr(pSrc, 4) == TRUE)
{
return 0;
}
int i, j, k;
for (i = 0; i <= (nSrcLen - nTraitLen); i++)
{
if (pSrc[i] == pTrait[0])
{
k = i;
j = 0;
while (j < nTraitLen)
{
k++; j++;
if (pTrait[j] == 0x90)
{
continue;
}
if (pSrc[k] != pTrait[j])
{
break;
}
}
if (j == nTraitLen)
{
return i;
}
}
}
return 0;
}
typedef struct sectionAlloc
{
BYTE* SectionAddr; //申请的内存空间地址
DWORD dwBase; //原始代码区段的基址
DWORD dwSize; //原始代码区段的大小
}*psectionAlloc;
typedef struct _ENTRYINFO // 易语言入口信息
{
DWORD dwMagic; //<- 未知
DWORD dwUnkown1; //+4 未知
DWORD dwUnkown2; //+8 未知
DWORD dwUserCodeStart;//+c 用户代码开始
DWORD dwEString; //+10 字符串 资源 如果没有字符串资源,则为0
DWORD dwEStringSize; //+14 字符串 资源大小 如果没有字符串资源,则为0
DWORD dwEWindow; //+18 创建组件信息 包括窗口、标签等控件
DWORD dwEWindowSize; //+1c 大小
DWORD dwLibNum; //+20 支持库数量
DWORD pLibEntey; //+24 支持库信息入口
DWORD dwApiCount; //+28 Api数量
DWORD pLibName; //+2C 指向库名称
DWORD pApiName; //+30 指向Api名称
}*PEENTRYINFO;
class EAnalysis
{
public:
EAnalysis(ULONG dwVBase, ULONG dwVsize);
~EAnalysis();
BOOL EStaticLibInit(); //静态编译--初始化
BOOL GetUserEntryPoint(); //静态编译--取用户结束地址
UINT FindSection(DWORD addr); //寻找地址是否在区段表中,返回index
UINT AddSection(DWORD addr); //内存拷贝表中增加区段,返回新的index
DWORD Search_BinEx(byte *pSrc, byte *pTrait, int nSrcLen, int nTraitLen);
DWORD O2V(DWORD dwVaddr, UINT index);//origin addr to virtual addr
DWORD V2O(DWORD dwOaddr, UINT index);
DWORD GetPoint(DWORD dwAddr);
DWORD GetOriginPoint(DWORD dwAddr, UINT index);
DWORD dwUsercodeStart; //用户代码的起始地址
DWORD dwUsercodeEnd; //用户代码的结束地址
vector<sectionAlloc> SectionMap; //维护一份内存拷贝表
PEENTRYINFO pEnteyInfo; // entry info
private:
protected:
};