forked from JoneyYang/PE-TOOLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialog_directory.c
150 lines (122 loc) · 4.16 KB
/
dialog_directory.c
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
#include "dialog_directory.h"
#include "dialog_detail.h"
#include "dialog_section.h"
#include "dialog_pe.h"
BOOL CALLBACK DialogDirectoryProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
BOOL result = TRUE;
switch (uMsg)
{
case WM_INITDIALOG:
g_hwndDialogDirectory = hwndDlg;
// 对话框初始化消息
InitDialogDirectory();
break;
case WM_CLOSE:
// 处理窗口关闭消息
DestroyWindow(hwndDlg);
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_BUTTON_DIRECTORYQUIT:
SendMessage(hwndDlg, WM_CLOSE, NULL, NULL);
break;
case IDC_BUTTON_DIRECTORY_SECTIONS:
// 弹出节表窗
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_SECTIONS), hwndDlg, DialogProcSections);
break;
case IDC_BUTTON_DIR_EXPORT:
g_dwShowID = IDC_BUTTON_DIR_EXPORT;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
case IDC_BUTTON_DIR_IMPORT:
g_dwShowID = IDC_BUTTON_DIR_IMPORT;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
case IDC_BUTTON_DIR_RESOURCE:
g_dwShowID = IDC_BUTTON_DIR_RESOURCE;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
case IDC_BUTTON_DIR_RELOCAL:
g_dwShowID = IDC_BUTTON_DIR_RELOCAL;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
case IDC_BUTTON_DIR_BOUNDIMPORT:
g_dwShowID = IDC_BUTTON_DIR_BOUNDIMPORT;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
case IDC_BUTTON_DIR_IAT:
g_dwShowID = IDC_BUTTON_DIR_IAT;
CreateDialog(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_DETAIL), hwndDlg, DialogProcDetail);
break;
default:
result = FALSE;
break;
}
break;
default:
result = FALSE;
break;
}
return result;
}
void InitDialogDirectory()
{
// RVA列所有EDIT控件ID. 按PE结构的DATA_DIRECTORY_ENTRY排序
DWORD rvaIds[16] =
{
IDC_EDIT_DIR_EXPORTRVA,
IDC_EDIT_DIR_IMPORTRVA,
IDC_EDIT_DIR_RESOURCERVA,
IDC_EDIT_DIR_EXCEPTIONRVA,
IDC_EDIT_DIR_SECURITYRVA,
IDC_EDIT_DIR_RELOCATIONRVA,
IDC_EDIT_DIR_DEBUGRVA,
IDC_EDIT_DIR_COPYRIGHTRVA,
IDC_EDIT_DIR_GLOBALPTRRVA,
IDC_EDIT_DIR_TLSRVA,
IDC_EDIT_DIR_LOADCONFIGRVA,
IDC_EDIT_DIR_BOUNDIMPORTRVA,
IDC_EDIT_DIR_IATRVA,
IDC_EDIT_DIR_DELAYIMPORTRVA,
IDC_EDIT_DIR_COMRVA,
IDC_EDIT_DIR_RESERVEDRVA
};
// SIZE列所有EDIT控件ID. 按PE结构的DATA_DIRECTORY_ENTRY排序
DWORD sizeIds[16] =
{
IDC_EDIT_DIR_EXPORTSIZE,
IDC_EDIT_DIR_IMPORTSIZE,
IDC_EDIT_DIR_RESOURCESIZE,
IDC_EDIT_DIR_EXCEPTIONSIZE,
IDC_EDIT_DIR_SECURITYSIZE,
IDC_EDIT_DIR_RELOCATIONSIZE,
IDC_EDIT_DIR_DEBUGSIZE,
IDC_EDIT_DIR_COPYRIGHTSIZA,
IDC_EDIT_DIR_GLOBALPTRSIZE,
IDC_EDIT_DIR_TLSSIZE,
IDC_EDIT_DIR_LOADCONFIGSIZE,
IDC_EDIT_DIR_BOUNDIMPORTSIZE,
IDC_EDIT_DIR_IATSIZE,
IDC_EDIT_DIR_DELAYIMPORTSIZE,
IDC_EDIT_DIR_COMSIZE,
IDC_EDIT_DIR_RESERVEDSIZE,
};
HWND hwndEditRva;
HWND hwndEditSize;
TCHAR buffer[16];
// 遍历所有目录表
for (int row = 0; row < 16; row++)
{
PIMAGE_DATA_DIRECTORY p_DataDirectory = GetDataDirectory(g_pFileBuffer, row);
// 填充VirtualAddress控件
wsprintf(buffer, TEXT("%p"), p_DataDirectory->VirtualAddress);
hwndEditRva = GetDlgItem(g_hwndDialogDirectory, rvaIds[row]);
SetWindowText(hwndEditRva, buffer);
// 填充Size控件
wsprintf(buffer, TEXT("%p"), p_DataDirectory->Size);
hwndEditSize = GetDlgItem(g_hwndDialogDirectory, sizeIds[row]);
SetWindowText(hwndEditSize, buffer);
}
}