windows-7 – 在Windows 7 64位上运行时出现Tiny Pe文件格式程序
发布时间:2020-12-14 02:53:54 所属栏目:Windows 来源:网络整理
导读:我正在尝试在 Windows 7 Ultimate 64位中运行以下汇编代码(与Nasm一起组装). ; tiny.asmBITS 32;; MZ header;; The only two fields that matter are e_magic and e_lfanewmzhdr: dw "MZ" ; e_magic dw 0 ; e_cblp UNUSED dw 0 ; e_cp UNUSED dw 0 ; e_crlc
我正在尝试在
Windows 7 Ultimate 64位中运行以下汇编代码(与Nasm一起组装).
; tiny.asm BITS 32 ; ; MZ header ; ; The only two fields that matter are e_magic and e_lfanew mzhdr: dw "MZ" ; e_magic dw 0 ; e_cblp UNUSED dw 0 ; e_cp UNUSED dw 0 ; e_crlc UNUSED dw 0 ; e_cparhdr UNUSED dw 0 ; e_minalloc UNUSED dw 0 ; e_maxalloc UNUSED dw 0 ; e_ss UNUSED dw 0 ; e_sp UNUSED dw 0 ; e_csum UNUSED dw 0 ; e_ip UNUSED dw 0 ; e_cs UNUSED dw 0 ; e_lsarlc UNUSED dw 0 ; e_ovno UNUSED times 4 dw 0 ; e_res UNUSED dw 0 ; e_oemid UNUSED dw 0 ; e_oeminfo UNUSED times 10 dw 0 ; e_res2 UNUSED dd pesig ; e_lfanew ; ; PE signature ; pesig: dd "PE" ; ; PE header ; pehdr: dw 0x014C ; Machine (Intel 386) dw 1 ; NumberOfSections dd 0x4545BE5D ; TimeDateStamp UNUSED dd 0 ; PointerToSymbolTable UNUSED dd 0 ; NumberOfSymbols UNUSED dw opthdrsize ; SizeOfOptionalHeader dw 0x103 ; Characteristics (no relocations,executable,32 bit) ; ; PE optional header ; filealign equ 1 sectalign equ 1 %define round(n,r) (((n+(r-1))/r)*r) opthdr: dw 0x10B ; Magic (PE32) db 8 ; MajorLinkerVersion UNUSED db 0 ; MinorLinkerVersion UNUSED dd round(codesize,filealign) ; SizeOfCode UNUSED dd 0 ; SizeOfInitializedData UNUSED dd 0 ; SizeOfUninitializedData UNUSED dd start ; AddressOfEntryPoint dd code ; BaSEOfCode UNUSED dd round(filesize,sectalign) ; BaSEOfData UNUSED dd 0x400000 ; ImageBase dd sectalign ; SectionAlignment dd filealign ; FileAlignment dw 4 ; MajorOperatingSystemVersion UNUSED dw 0 ; MinorOperatingSystemVersion UNUSED dw 0 ; MajorImageVersion UNUSED dw 0 ; MinorImageVersion UNUSED dw 4 ; MajorSubsystemVersion dw 0 ; MinorSubsystemVersion UNUSED dd 0 ; Win32VersionValue UNUSED dd round(filesize,sectalign) ; SizeOfImage dd round(hdrsize,filealign) ; SizeOfHeaders dd 0 ; CheckSum UNUSED dw 2 ; Subsystem (Win32 GUI) dw 0x400 ; DllCharacteristics UNUSED dd 0x100000 ; SizeOfStackReserve UNUSED dd 0x1000 ; SizeOfStackCommit dd 0x100000 ; SizeOfHeapReserve dd 0x1000 ; SizeOfHeapCommit UNUSED dd 0 ; LoaderFlags UNUSED dd 16 ; NumberOfRvaAndSizes UNUSED ; ; Data directories ; times 16 dd 0,0 opthdrsize equ $- opthdr ; ; PE code section ; db ".text",0 ; Name dd codesize ; VirtualSize dd round(hdrsize,sectalign) ; VirtualAddress dd round(codesize,filealign) ; SizeOfRawData dd code ; PointerToRawData dd 0 ; PointerToRelocations UNUSED dd 0 ; PointerToLinenumbers UNUSED dw 0 ; NumberOfRelocations UNUSED dw 0 ; NumberOfLinenumbers UNUSED dd 0x60000020 ; Characteristics (code,execute,read) UNUSED hdrsize equ $- $$ ; ; PE code section data ; align filealign,db 0 code: ; Entry point start: push byte 42 pop eax ret codesize equ $- code filesize equ $- $$ 代码取自:http://www.phreedom.org/solar/code/tinype/ 我使用以下命令创建可执行文件:nasm -f bin -o tiny.exe tiny.asm 另一方面,Windows XP SP3机器运行完美.知道什么可能是错的吗? 解决方法filealign equ 1 sectalign equ 1 Windows 7加载程序不接受低于512的文件对齐和小于4096的分段符号. 编辑: 根据counter examples,似乎对齐限制为4/4. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- for-loop – DOS Batch FOR循环删除不包含字符串
- Windows – 组策略未在同一个doman上应用或被某些
- Windows调试1.WinDbg基本使用-异常基础知识
- 如何在nuget中创建像Microsoft.AspNetCore.All这
- windows – 在运行spark-shell之前编辑spark-env
- Windows服务移植到linux
- .net – 与Windows兼容的文件系统的文件时间分辨
- 可以多次运行Windows服务(使用不同的设置)吗?
- Windows上的boot2docker – 无法访问暴露的端口
- windows – 一起使用gevent和多处理与子进程通信
热点阅读