forked from Noice2k/NsisDecompiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNsisDecompilerDlg.cpp
274 lines (213 loc) · 7.54 KB
/
NsisDecompilerDlg.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
// NsisDecompilerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "NsisDecompiler.h"
#include "NsisDecompilerDlg.h"
#include "afxdialogex.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CNsisDecompilerDlg dialog
CNsisDecompilerDlg::CNsisDecompilerDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CNsisDecompilerDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CNsisDecompilerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST2, m_SourceCode);
DDX_Control(pDX, IDC_LIST3, m_Stack);
DDX_Control(pDX, IDC_LIST4, m_Variables);
DDX_Control(pDX, IDC_LIST5, m_CallSteck);
}
BEGIN_MESSAGE_MAP(CNsisDecompilerDlg, CDialogEx)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, &CNsisDecompilerDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDOK, &CNsisDecompilerDlg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CNsisDecompilerDlg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON2, &CNsisDecompilerDlg::OnBnClickedButton2)
END_MESSAGE_MAP()
// CNsisDecompilerDlg message handlers
BOOL CNsisDecompilerDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
HICON h1 = LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON1));
HICON h2 = LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON2));
m_ImageList.Create(16,16,ILC_COLOR24,0,0);
m_ImageList.Add(h1);
m_ImageList.Add(h2);
m_lastitem = -1;
// m_SourceCode.SetImageList(&m_ImageList,LVSIL_STATE);
m_SourceCode.SetImageList(&m_ImageList,LVSIL_SMALL);
//m_SourceCode.SetImageList(&m_ImageList,LVSIL_NORMAL);
// TODO: Add extra initialization here
m_SourceCode.SetExtendedStyle(m_SourceCode.GetExtendedStyle() |LVS_EX_FULLROWSELECT|LVS_EX_SIMPLESELECT);
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CNsisDecompilerDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CNsisDecompilerDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
/************************************************************************/
// start decompile file
/************************************************************************/
void CNsisDecompilerDlg::OnBnClickedButton1()
{
//_nsisFile.LoadDump("D:\\ConduitInstaller\\spinstaller_s_exe\\spinstaller_s.EOF");
//_nsisFile.LoadDump("D:\\ConduitInstaller\\spinstaller_s_exe\\1.zip");
//_nsisFile.LoadExeDump("D:\\ConduitInstaller\\spinstaller_s_exe\\spinstaller.exe");
//_nsisFile.LoadExeDump("D:\\ConduitInstaller\\spinstaller_s_exe\\spnocrc.exe");
//_nsisFile.LoadExeDump("D:\\ConduitInstaller\\spinstaller_s_exe\\FPSetup.exe");
//_nsisFile.LoadExeDump("D:\\NSIS_uni\\test.exe");
//_nsisFile.LoadExeDump("D:\\Downloads\\Modding\\GTA\\SA-MP\\sa-mp-0.2X-u1-install.exe");
//_nsisFile.LoadExeDump("D:\\Downloads\\Modding\\GTA\\SA-MP\\sa-mp-0.2X-u1_2-install.exe");
_nsisFile.LoadExeDump("D:\\Downloads\\Modding\\GTA\\SA-MP\\sa-mp-0.3.7-R5-1-install.exe");
#define DIRECTORY "D:\\VirtualBox VMs\\Shared\\sampcvs037R4\\sampcvs\\main\\New folder\\"
//_nsisFile.LoadExeDump(DIRECTORY "best.exe");
//_nsisFile.LoadExeDump(DIRECTORY "bzip2.exe");
//_nsisFile.LoadExeDump(DIRECTORY "bzip2-solid.exe");
//_nsisFile.LoadExeDump(DIRECTORY "default.exe");
//_nsisFile.LoadExeDump(DIRECTORY "lzma.exe");
//_nsisFile.LoadExeDump(DIRECTORY "lzma-solid.exe");
//_nsisFile.LoadExeDump(DIRECTORY "zlib.exe");
//_nsisFile.LoadExeDump(DIRECTORY "zlib-solid.exe");
//_nsisFile.LoadExeDump(DIRECTORY "lzma-9.exe");
_nsisFile.ProcessingHeader();
//_nsisFile.DumpFiles("d:\\ConduitInstaller\\_dump");
// _nsisFile.SaveExeDump("D:\\ConduitInstaller\\spinstaller_s_exe\\spnocrc_t.exe");
//_nsisFile.LoadExeDump("D:\\ConduitInstaller\\_dump\\0002.dll");
//_nsisFile.SaveExeDump("D:\\ConduitInstaller\\_dump\\0002t.dll");
_nsisEmulator.file = &_nsisFile;
_nsisEmulator._source_code_view = &m_SourceCode;
_nsisEmulator._variables_vew = &m_Variables;
_nsisEmulator._stack_view = &m_Stack;
_nsisEmulator._call_stack_view = &m_CallSteck;
_nsisEmulator.Init();
_nsisEmulator.Execute();
}
void CNsisDecompilerDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CDialogEx::OnOK();
}
void CNsisDecompilerDlg::OnBnClickedCancel()
{
// TODO: Add your control notification handler code here
CDialogEx::OnCancel();
}
void CNsisDecompilerDlg::OnBnClickedButton2()
{
_nsisEmulator._breakByStep = true;
}
void CNsisDecompilerDlg::ShowVariables()
{
for (int i = 0;i < _nsisFile._global_vars._max_var_count;i++)
{
m_Variables.SetItemText(i,1,_nsisFile._global_vars.GetVarValue(i).c_str());
}
}
void CNsisDecompilerDlg::ShowStack()
{
m_Stack.DeleteAllItems();
m_Stack.InsertColumn(0,"id",LVCFMT_LEFT,50);
m_Stack.InsertColumn(1,"value",LVCFMT_LEFT,450);
CString num;
for (unsigned i = 0x00;i< _nsisEmulator._stack.size();i++)
{
num.Format("%4.4i",i);
m_Stack.InsertItem(i,num,0);
m_Stack.SetItemText(i,1,_nsisEmulator._stack[i].c_str());
}
}
void CNsisDecompilerDlg::ShowCallStack()
{
m_CallSteck.DeleteAllItems();
m_CallSteck.InsertColumn(0,"id",LVCFMT_LEFT,50);
m_CallSteck.InsertColumn(1,"value",LVCFMT_LEFT,450);
CString num;
for (unsigned i = 0x00;i< _nsisEmulator._function_call_stack.size();i++)
{
num.Format("%4.4i",i);
m_CallSteck.InsertItem(i,num,0);
m_CallSteck.SetItemText(i,1,_nsisEmulator._function_call_stack[i].c_str());
}
}
LRESULT CNsisDecompilerDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_USER+100)
{
/* POSITION pos = m_SourceCode.GetFirstSelectedItemPosition();
while( pos >0)
{
int index = m_SourceCode.GetNextSelectedItem( pos );
m_SourceCode.SetItemState(index, 0, LVS_SHOWSELALWAYS|LVS_SINGLESEL);
}
*/
if ((-1 != m_lastitem) && (m_lastitem != wParam))
{
m_SourceCode.SetItem(m_lastitem,0,LVIF_IMAGE,NULL,0,0,0,NULL,0);
}
m_lastitem = wParam;
m_SourceCode.SetItem(m_lastitem,0,LVIF_IMAGE,NULL,1,0,0,NULL,0);
int top = m_SourceCode.GetTopIndex();
int bottom = top + m_SourceCode.GetCountPerPage();
CRect rt;
m_SourceCode.GetItemRect(0,&rt,LVIR_BOUNDS);
CSize size;
if (m_lastitem < top)
{
size.cy = rt.Height()*(m_lastitem - top);
m_SourceCode.Scroll(size);
}
if (m_lastitem > bottom)
{
size.cy = rt.Height()*(m_lastitem - top);
m_SourceCode.Scroll(size/*(m_lastitem - top)*0x10000*/);
}
ShowVariables();
ShowStack();
ShowCallStack();
/*
int nLast = n + m_myListCtrl.GetCountPerPage();
for (; n < nLast; n++)
{
m_myListCtrl.SetItemState(n, LVIS_SELECTED, LVIS_SELECTED);
ASSERT(m_myListCtrl.GetItemState(n, LVIS_SELECTED) == LVIS_SELECTED);
}
*/
return true;
}
return CDialogEx::DefWindowProc(message, wParam, lParam);
}