flat assembler
Message board for the users of flat assembler.

Index > Windows > Building .rsrc and resources manually

Author
Thread Post new topic Reply to topic
snify



Joined: 02 Dec 2004
Posts: 39
snify
hello, i'm using the folowing code to create exe manually, but i don't know how to add resource section with icon (without a macro). help someone? Neutral

Code:
DOS_Header:
   .e_magic     dw 'MZ'   ;IMAGE_DOS_SIGNATURE
   .e_cblp      dw 0x0080
   .e_cp        dw 0x0001
   .e_crlc      dw 0x0000
   .e_cparhdr   dw 0x0004
   .e_minalloc  dw 0x0010
   .e_maxalloc  dw 0xFFFF
   .e_ss        dw 0x0000
   .e_sp        dw 0x0140
   .e_csum      dw 0x0000
   .e_ip        dw 0x0000
   .e_cs        dw 0x0000
   .e_lfarlc    dw 0x0040
   .e_ovno      dw 0x0000
   .e_res       rw 4
   .e_oemid     dw 0x0000
   .e_oeminfo   dw 0x0000
   .e_res2      rw 10
   .e_lfanew    dd PE_header  ;PE header Offset

DOS_Stub:
 org 0
 use16
   push cs
   pop ds
   mov dx,msg
   mov ah,9h
   int 21h
   mov ax,4C01h
   int 21h
   msg:
   db 'win32 app!',13,10,'$'
 org $+DOS_Stub

rb 0x80 - $   ;$ equal to curent offset

Parameters:
NS = 1         ;NumberOfSections
BA = 0x400000  ;Base Address
SA = 0x1000    ;SectionAlignment
FA = 0x0200    ;FileAlignment

%% = BA+SA

PE_header:
   .Signature                   dd 'PE'
   FileHeader:
     .Machine                   dw 0x014C                  ;i386
     .NumberOfSections          dw NS
     .TimeDateStamp             dd %t
     .PointerToSymbolTable      dd 0
     .NumberOfSymbols           dd 0
     .SizeOfOptionalHeader      dw SectionTable-OptionalHeader
     .Characteristics           dw 0x818F                ;
   OptionalHeader:                             ;OptionalHeader has 31 fields
     .Magic                     dw 0x010B                  ;PE32
     .MajorLinkerVersion        db 1                   ;1.51
     .MinerLinkerVersion        db 51
     .SizeOfCode                dd 0
     .SizeOfInitializedData     dd 0
     .SizeOfUnInitializedData   dd 0
     .AddressOfEntryPoint       dd CodeSection
     .BaseOfCode                dd 0
     .BaseOfData                dd 0
     .ImageBase                 dd BA
     .SectionAlignment          dd SA
     .FileAlignment             dd FA
     .MajorOSVersion            dw 1                 ;1.0
     .MinorOSVersion            dw 0
     .MajorImageVersion         dw 0                  ;0.0
     .MinorImageVersion         dw 0
     .MajorSubSystemVerion      dw 4             ;4.0
     .MinorSubSystemVerion      dw 0
     .Win32VersionValue         dd 0             ;Reserved
     .SizeOfImage               dd 1500h;SA*(NS+1)          ;16384 bytes
     .SizeOfHeaders             dd SizeOfHeaders
     .CheckSum                  dd 0x6B94
     .SubSystem                 dw 2             ;Win32 GUI
     .DllCharacteristics        dw 0
     .SizeOfStackReserve        dd 0x1000
     .SizeOfStackCommit         dd 0x1000
     .SizeOfHeapReserve         dd 0x10000
     .SizeOfHeapRCommit         dd 0
     .LoaderFlags               dd 0                   ;Obsolete
     .NumberOfDataDirectories   dd 16

     Data_Directories:
       .Export_Table            dd 0,0        ; Rva,Size
       .Import_Table            dd 0,0    ; Rva,Size
       .Resource_Table          dd 0,0             ; Rva,Size
       .Exception_Table         dd 0,0  ; Rva,Size
       .Certificate_Table       dd 0,0  ; Rva,Size
       .Relocation_Table        dd 0,0  ; Rva,Size
       .Debug_Data              dd 0,0  ; Rva,Size
       .Architecture            dd 0,0  ; Rva,Size
       .Global_PTR              dd 0,0  ; Rva,Size
       .TLS_Table               dd 0,0  ; Rva,Size
       .Load_Config_Table       dd 0,0  ; Rva,Size
       .BoundImportTable        dd 0,0  ; Rva,Size
       .ImportAddressTable      dd 0,0  ; Rva,Size
       .DelayImportDescriptor   dd 0,0  ; Rva,Size
       .COMplusRuntimeHeader    dd 0,0  ; Rva,Size
       .Reserved                dd 0,0  ; Rva,Size

SectionTable:
  Section1:
    .Name                       dq '.code'
    .VirtualSize                dd 0x500;1C
    .VirtualAddress             dd CodeSection
    .SizeOfRawData              dd 1000;SizeOfCode
    .PointerToRawData           dd PointerToCode
    .PointerToRelocations       dd 0
    .PointerToLinenumbers       dd 0
    .NumberOfRelocations        dw 0
    .NumberOfLinenumbers        dw 0
    .Characteristics            dd 0xE0000060 ;0x60000020        ;CODE+MEM_READ+MEM_EXECUTE


SizeOfHeaders = 0x200
rb SizeOfHeaders - $
RawData:

PointerToCode:
org  SA
CodeSection:
repeat 1000
ret
end repeat

SizeOfCode = $-CodeSection
                                         
    
Post 15 Aug 2006, 23:24
View user's profile Send private message Visit poster's website Reply with quote
snify



Joined: 02 Dec 2004
Posts: 39
snify
huh nobody?
Post 25 Aug 2006, 18:18
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
study FASM resource macros
Post 26 Aug 2006, 08:50
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.