在masm下编译一个较小的PE文件

来源:互联网 发布:python 频域分析 编辑:程序博客网 时间:2024/05/29 18:30

前言

写一段masm32汇编程序
link要使用masm32自带的link(改名或指定全路径)
使用link编译选项 /MERGE, 合并的段名用Winhex或PE分析工具来看.

代码片段

echo offrem file buildcmd.batrem brief build projetcall clearcmd.batMl32.exe /c /coff hw.asmif errorlevel 1 goto TheEndrem 用masm的link才会编译出2k以下的PE文件Link32.exe /subsystem:windows /MERGE:.rdata=.text hw.objif errorlevel 1 goto TheEndecho project build success !hw.exegoto TheEndAll:TheEndpause:TheEndAll
; file hw.asm; brief 测试程序.386.model flat, stdcalloption casemap:none; 系统头文件与库include windows.incinclude Kernel32.incincludelib Kernel32.libinclude User32.incincludelib User32.lib; 数据段.const    g_constSzTitle db "t", 0    g_constSz_Msg db "m", 0; 代码段    .codestart:    invoke MessageBoxA, NULL, offset g_constSz_Msg, offset g_constSzTitle, MB_OK    invoke ExitProcess, 0    retend start
0 0
原创粉丝点击