-
-
[原创]软件保护壳技术专题 - 添加新节(练习笔记)
-
发表于:
2010-8-16 23:59
8206
-
[原创]软件保护壳技术专题 - 添加新节(练习笔记)
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
include user32.inc
include macro.asm
includelib kernel32.lib
includelib user32.lib
include comdlg32.inc
includelib comdlg32.lib
.data
szSectionName db '.Alone',0
SecData db 200 dup('A')
.code
include kernel.asm
_OpenExeFile proc
local OFN:OPENFILENAME,szFileNameBuff[MAX_PATH]:BYTE
local Map:MapFileHandle
;以下是打开通用对话框的操作
invoke RtlZeroMemory,addr OFN,sizeof OFN ;初始化结构
invoke RtlZeroMemory,addr szFileNameBuff,MAX_PATH
mov OFN.lStructSize,sizeof OFN
lea eax,szFileNameBuff
mov OFN.lpstrFile,eax
mov OFN.nMaxFile,MAX_PATH
mov OFN.Flags,OFN_PATHMUSTEXIST or OFN_FILEMUSTEXIST
invoke GetOpenFileName,addr OFN ;打开通用对话框
;********************************************
.if eax
invoke _CalcAlign,sizeof SecData,200H ;以200H为对齐方式
invoke _CreatMapFile,addr szFileNameBuff, addr Map,eax;创建一个内存映射文件
mov eax,Map.lpMemory ;简单判断下PE文件有效性
assume eax:ptr IMAGE_DOS_HEADER
.if [eax].e_magic == IMAGE_DOS_SIGNATURE
add eax,[eax].e_lfanew ;到文件头
assume eax:ptr IMAGE_NT_HEADERS
.if [eax].Signature==IMAGE_NT_SIGNATURE
invoke _AddSection,Map.lpMemory,addr szSectionName,sizeof szSectionName,addr SecData,sizeof SecData
invoke MessageBox,NULL,CTXT("添加节成功!"),NULL,NULL
jmp @F
.endif
.endif
invoke MessageBox,NULL,CTXT("不是有效的PE文件!"),NULL,NULL
@@:
invoke _CloseMapFile, addr Map
.endif
ret
_OpenExeFile endp
;OEP
Start:
call _OpenExeFile
invoke ExitProcess,NULL
end Start
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)