-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNoname1.txt
98 lines (75 loc) · 2.06 KB
/
Noname1.txt
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
;判断是否是PE文件
_LoadIsPEFile proc hWnd
local @hFile,@hMapFile,@ImageBase,@dwFileSize,@lpMemory
; 打开文件并建立文件 Mapping,判断是不是PE格式文件
invoke CreateFile,offset szFileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
.if eax != INVALID_HANDLE_VALUE
mov @hFile,eax
invoke GetFileSize,eax,NULL
mov @dwFileSize,eax
.if eax
invoke CreateFileMapping,@hFile,NULL,PAGE_READONLY,0,0,NULL
.if eax
mov @hMapFile,eax
invoke MapViewOfFile,eax,FILE_MAP_READ,0,0,0
.if eax
mov @lpMemory,eax
; 检测 PE 文件是否有效
mov esi,@lpMemory
assume esi:ptr IMAGE_DOS_HEADER
.if [esi].e_magic != IMAGE_DOS_SIGNATURE
jmp _ErrFormat
.endif
add esi,[esi].e_lfanew
assume esi:ptr IMAGE_NT_HEADERS
.if [esi].Signature != IMAGE_NT_SIGNATURE
jmp _ErrFormat
.endif
xor eax,eax
inc eax
jmp _ErrorExit
_ErrFormat:
invoke MessageBox,hWnd,addr szErrFormat,NULL,MB_OK
xor eax,eax
_ErrorExit:
.endif
.endif
.endif
.else
invoke MessageBox,0,OFFSET szOpenFileErrorMsg,0,MB_OK
.endif
@@:
ret
_LoadIsPEFile endp
.elseif ax == IDD_MENU_PACK
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
.elseif ax == IDD_MENU_ABOUT
invoke DialogBoxParam,hInstance,IDD_DIALOG_ABOUT,hWnd,offset _ProcDlgAbout,NULL
.elseif ax == IDD_MENU_EXIT
invoke EndDialog,hWnd,NULL
mov eax,wParam
.if ax == IDD_MENU_OPEN
invoke _OpenFile,hWnd
.elseif ax == IDD_MENU_PACK
invoke MessageBox,NULL,offset szText,offset szCaption,MB_OK
.elseif ax == IDD_MENU_ABOUT
invoke DialogBoxParam,hInstance,IDD_DIALOG_ABOUT,hWnd,offset _ProcDlgAbout,NULL
.elseif ax == IDD_MENU_EXIT
invoke EndDialog,hWnd,NULL
.endif
_ProcDlgAbout PROC hDlg,wMsg,wParam,lParam
mov eax,wMsg
cmp eax,WM_CLOSE
jz _closeabout
cmp eax,WM_COMMAND
jz _command
xor eax,eax
ret
_command:
mov eax,wParam
cmp ax,IDOK
jz _closeabout
_closeabout:
invoke EndDialog,hDlg,0
ret
_ProcDlgAbout endp