assembly - Tiny Pe file format program error when running on Windows 7 64-bit -
assembly - Tiny Pe file format program error when running on Windows 7 64-bit -
i'm trying run next assembly code (assembled nasm) in windows 7 ultimate 64-bit.
; tiny.asm bits 32 ; ; mz header ; ; 2 fields matter e_magic , 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 ; ; info directories ; times 16 dd 0, 0 opthdrsize equ $ - opthdr ; ; pe code section ; db ".text", 0, 0, 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 info ; align filealign, db 0 code: ; entry point start: force byte 42 pop eax ret codesize equ $ - code filesize equ $ - $$
code taken from: http://www.phreedom.org/solar/code/tinype/
i create executable using: nasm -f bin -o tiny.exe tiny.asm when i'm trying run tiny.exe, error: application unable start correctly (0xc0000018).
from other hand on windows xp sp3 machine runs flawlessly. thought might wrong?
filealign equ 1 sectalign equ 1
the windows 7 loader not take filealign less 512 , sectionalign less 4096.
edit:
in lite of counter examples, seems alignment limits 4/4.
windows-7 assembly nasm pe
Comments
Post a Comment