/* * pe_start.s Header file and DOS stub for PE executable. * * Author: Max Feoktistov * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Compile * command: as pe_start.s -o pe_start.o * ld pehd -oformat=binary -Tbin.djl -o a.bin */ //as pe_start.s -o pe_start.o //ld pe_start.s -oformat=binary -Tbin.djl -o pe.bin .text .=0 .globl start start: .byte 0x4D,0x5A .word 0x90,0x1,0,4,0,0xFFFF,0,0x1FF,0,0,0,0x40,0,0,0,0 .org 0x3C,0 .long NewExe .code16 BegCode16: pushw %cs popw %ds movb $9,%ah movw $(DosMsg - BegCode16 + 0x100) ,%dx int $0x21 movb $0x4c,%ah int $0x21 DosMsg: .ascii "Sorry, for Win32... :(" .byte 0xA,0xD,0x24,0 .code32 .align 4 NewExe: .long 0x4550 .word 0x14C,1 ;//CPU Type,Num of Objects .long 0,0,0 ;//Time/Date Stamp,Pointer to COFF table,COFF table size .word ObjectTable-Magic,0x203 ;//NT Header Size,Flags Magic: .word 0x10B,0x102 ;//Magic,Link Major,Link Minor CodeSize: .long 0x400,0x400,0x400 ;//Size of Code,Size of Init Data,Size of UnInit Data .long 0,0x0,0x0,0x400000,0x1000,512 ;//Entry point RVA, ;//Base of Code,Base of Data,Image Base,Object Align,File Align .word 1,0xB,0,0,4,0 ;//OS Major,OS Minor,USER Major,USER Minor, ;//SubSys Major,SubSys Minor .long 0,0x400,0x200,0 ;//Reserved,Image Size,Header Size,File CheckSum .word 2,0 ;//SubSytem,DLL Flags .long 0x10000,0x1000,0x80000,0x1000,0 ;//Stack Reserve Size, ;//Stack Commit Size,Heap Reserve Size,Heap Comit Size,Loader Flags .long 0x10,0,0 ;//Num of RVA and Sizes,Export Table RVA,Export Data Size .long 0,0x28,0, 0,0,0, 0,0,0, 0,0,0, 0,0 ;//Import Table RVA,Import Data Size,Resource Table RVA, ;//Resource Data Size,Exception Table RVA,Exception Data Size, ;//Security Table RVA,Security Data Size,Fix Up's Table RVA ;//Fix Up's Data Size,Debug Table RVA,Debug Data Size ;//Image Description RVA,Description Data Size .long 0,0,0,0, 0,0,0, 0,0 ;//Machine Specific RVA,Machnine Data Size,TLS RVA,TLS Data Size ;//Load Config RVA,Load Config Data Size,Reserved ;//IAT RVA,IAT Data Size .org 0x168,0 ObjectTable: .ascii "Feokt.\x00\x00" ;// Object Name .long 0x800,0,0x400 ;// Virtual Size,Section RVA,Physical Size .long 0x400,0,0,0 ;// Physical Offset,Reserved .long 0xF2501040 ;// Object Flags