-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPESectionHeader.cpp
More file actions
136 lines (111 loc) · 3.33 KB
/
PESectionHeader.cpp
File metadata and controls
136 lines (111 loc) · 3.33 KB
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
// PESectionHeader.cpp: implementation of the PESectionHeader class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PESectionHeader.h"
//////////////////////////////////////////////////////////////////////
// CONSTruction/Destruction
//////////////////////////////////////////////////////////////////////
_IMAGE_SECTION_HEADER *lpSectionHeader ;
static PESectionHeader sectionHeaderOpt;
static DWORD number;
BOOL CALLBACK SectionViewProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
sectionHeaderOpt.SetSectionInfoDlg(hwndDlg, lpSectionHeader, number);
break;
}
case WM_CLOSE:
{
EndDialog(hwndDlg,0);
break;
}
}
return FALSE;
}
PESectionHeader::PESectionHeader()
{
}
PESectionHeader::~PESectionHeader()
{
}
void PESectionHeader::ShowSectionView(HINSTANCE hInstance, HWND hwndDlg, CONST _IMAGE_SECTION_HEADER *lpSection, DWORD numberOfSections)
{
lpSectionHeader = (_IMAGE_SECTION_HEADER *)lpSection;
number = numberOfSections;
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_SECTION_VIEW), hwndDlg, SectionViewProc);
}
void PESectionHeader::SetSectionInfoDlg(HWND hwndDlg, CONST _IMAGE_SECTION_HEADER *lpSectionHeader, DWORD numberOfSections)
{
_IMAGE_SECTION_HEADER* section = (_IMAGE_SECTION_HEADER*)lpSectionHeader;
TCHAR szBuffer[9 * 4096] = {0};
TCHAR Name[0x9] = {0};
int len = 0;
CHAR* sectionContent[0xA] = {
"Name:\t\t\t",
"VirtualSize:\t\t",
"VirtualAddress:\t\t",
"SizeOfRawData:\t\t",
"PointerToRawData:\t\t",
"PointerToRelocations:\t",
"PointerToLinenumbers:\t",
"NumberOfRelocations:\t",
"NumberOfLinenumbers:\t",
"Characteristics:\t\t", };
for(DWORD i = 0; i < numberOfSections; i++)
{
memset(Name, 0, 0x9);
//½ÚÃû
memcpy(Name, section->Name, 0x8);
len += sprintf(szBuffer + len,"%s%s\r\n",
sectionContent[0], Name
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[1], section->Misc.VirtualSize
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[2], section->VirtualAddress
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[3], section->SizeOfRawData
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[4], section->PointerToRawData
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[5], section->PointerToRelocations
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[6], section->PointerToLinenumbers
);
len += sprintf(szBuffer + len ,"%s%04x\r\n",
sectionContent[7], section->NumberOfRelocations
);
len += sprintf(szBuffer + len ,"%s%04x\r\n",
sectionContent[8], section->NumberOfLinenumbers
);
len += sprintf(szBuffer + len ,"%s%08x\r\n",
sectionContent[9], section->Characteristics
);
len += sprintf(szBuffer + len ,"%s\r\n", "--------------------------------------"
);
section++;
}
//,
// sectionContent[2], sectionHeader.VirtualAddress
SendDlgItemMessage(hwndDlg,
IDC_TEST,
WM_SETTEXT,
0,
(DWORD)szBuffer);
HDC hdc = ::GetDC(hwndDlg);
::TextOutA(hdc,0,0,"Îı¾ÄÚÈÝ",strlen("Îı¾ÄÚÈÝ"));
}