-
Notifications
You must be signed in to change notification settings - Fork 5
/
MainWindow.cpp
225 lines (169 loc) · 4.84 KB
/
MainWindow.cpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// MainWindow.cpp : 实现文件
//
/*
MainWindow,分析界面交互的接口
*/
#include "stdafx.h"
#include "E-Debug.h"
#include "afxdialogex.h"
#include "MainWindow.h"
#include <vector>
#include "EAnalyEngine.h"
extern HINSTANCE g_hInstace;
CMainWindow *pMaindlg;
EAnalysis *pEAnalysisEngine;
// CMainWindow 对话框
IMPLEMENT_DYNAMIC(CMainWindow, CDialog)
CMainWindow::CMainWindow(CWnd* pParent /*=NULL*/)
: CDialog(IDD_MainWindow, pParent)
{
}
CMainWindow::~CMainWindow()
{
}
void CMainWindow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB1, m_Tab);
DDX_Control(pDX, IDC_LOG, m_output);
}
BEGIN_MESSAGE_MAP(CMainWindow, CDialog)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CMainWindow::OnTcnSelchangeTab1)
ON_LBN_SELCHANGE(IDC_LOG, &CMainWindow::OnLbnSelchangeLog)
END_MESSAGE_MAP()
// CMainWindow 消息处理程序
BOOL CMainWindow::OnInitDialog() {
CDialog::OnInitDialog();
pMaindlg = this; //得到窗口指针
HICON hIcon = LoadIcon(g_hInstace, MAKEINTRESOURCE(IDI_ICON));
SetIcon(hIcon, FALSE);
SetIcon(hIcon, TRUE);
m_Tab.InsertItem(0, _T("支持库命令"));
m_Tab.InsertItem(1, _T("API命令"));
m_Tab.InsertItem(2, _T("窗口组件"));
ULONG uBase, uSize;
INT nPos;
Getdisassemblerrange(&uBase, &uSize);
outputInfo("->开始分析当前区段.... 分析地址: % 08X 内存大小: % 08X", uBase, uSize);
pEAnalysisEngine = new EAnalysis(uBase,uSize); //初始化内存
if (pEAnalysisEngine->EStaticLibInit()) { //易语言静态编译识别+初始化,识别失败返回false
std::vector<std::string> krnlCmd =
{ "错误回调", "DLL命令", "三方支持库命令", "核心支持库命令",
"读取组件属性", "设置组件属性", "分配内存", "重新分配内存",
"释放内存", "结束", "窗口消息循环", "载入启动窗口", "初始化" };
nPos = outputInfo("-> 用户自写代码段开始 : %08X ", pEAnalysisEngine->dwUsercodeStart);
m_output.SetItemData(nPos, pEAnalysisEngine->dwUsercodeStart);
Insertname(pEAnalysisEngine->dwUsercodeStart, NM_COMMENT, "用户代码段开始");
if (!pEAnalysisEngine->GetUserEntryPoint()) {
pEAnalysisEngine->dwUsercodeEnd = uBase + uSize -1;
nPos = outputInfo("-> 用户自写代码段结束 : %08X ", pEAnalysisEngine->dwUsercodeEnd);
}
else {
nPos = outputInfo("-> 用户自写代码段结束 : %08X ", pEAnalysisEngine->dwUsercodeEnd);
m_output.SetItemData(nPos, pEAnalysisEngine->dwUsercodeEnd);
Insertname(pEAnalysisEngine->dwUsercodeEnd, NM_COMMENT, "易语言程序入口");
}
DWORD dwKrnlEntry = pEAnalysisEngine->pEnteyInfo->dwEString;
if (dwKrnlEntry == 0) {
dwKrnlEntry = pEAnalysisEngine->pEnteyInfo->dwEWindow;
}
DWORD dwPoint;
UINT index = pEAnalysisEngine->FindSection(dwKrnlEntry);
if (index == -1) { //区段有可能被切割,加入新的区段
index = pEAnalysisEngine->AddSection(dwKrnlEntry);
}
for (int i = krnlCmd.size() - 1; i >= 0; i--)
{
dwKrnlEntry -= sizeof(DWORD);
dwPoint = pEAnalysisEngine->GetPoint(pEAnalysisEngine->O2V(dwKrnlEntry,index));
Insertname(dwPoint, NM_LABEL, (char*)krnlCmd[i].c_str());
}
//To do Here,扫描基础特征码
outputInfo("-> 枚举易语言<_krnl_fn_>核心支持命令成功...");
}
else {
outputInfo("-> 该程序有可能不是易语言程序...");
return true;
}
CRect rc;
m_Tab.GetClientRect(&rc);
rc.top += 26;
rc.left += 4;
rc.right -= 6;
rc.bottom -= 6;
m_page1.Create(IDD_PAGE1, &m_Tab);
m_page1.MoveWindow(&rc);
m_page2.Create(IDD_PAGE2, &m_Tab);
m_page2.MoveWindow(&rc);
m_page3.Create(IDD_PAGE3, &m_Tab);
m_page3.MoveWindow(&rc);
m_page1.ShowWindow(true);
return true;
}
void CMainWindow::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)
{
int nCursel = m_Tab.GetCurSel()+1;
switch (nCursel)
{
case 1:
if (IsWindow(m_page1.m_hWnd)) {
m_page1.ShowWindow(true);
}
if (IsWindow(m_page2.m_hWnd)) {
m_page2.ShowWindow(false);
}
if (IsWindow(m_page3.m_hWnd)) {
m_page3.ShowWindow(false);
}
break;
case 2:
if (IsWindow(m_page1.m_hWnd)) {
m_page1.ShowWindow(false);
}
if (IsWindow(m_page2.m_hWnd)) {
m_page2.ShowWindow(true);
}
if (IsWindow(m_page3.m_hWnd)) {
m_page3.ShowWindow(false);
}
break;
case 3:
if (IsWindow(m_page1.m_hWnd)) {
m_page1.ShowWindow(false);
}
if (IsWindow(m_page2.m_hWnd)) {
m_page2.ShowWindow(false);
}
if (IsWindow(m_page3.m_hWnd)) {
m_page3.ShowWindow(true);
}
break;
default:
break;
}
*pResult = 0;
}
int CMainWindow::outputInfo(char *formatText, ...)
{
USES_CONVERSION;
char buf[MAX_PATH] = { 0 };
va_list st;
va_start(st, formatText);
vsprintf_s(buf, formatText, st);
va_end(st);
return m_output.InsertString(-1, A2W(buf));
}
void CMainWindow::OnLbnSelchangeLog()
{
int nCurSel;
DWORD dwItemData;
nCurSel = m_output.GetCurSel();
dwItemData = m_output.GetItemData(nCurSel);
if (dwItemData != 0)
{
Setcpu(NULL, dwItemData, NULL, NULL, CPU_NOFOCUS);
}
}
void ScanCode(byte* pSrc,byte* pTrait,int nStrlen,int nTraitlen ) {
Search_Bin(pSrc,pTrait,nStrlen,nTraitlen);
}