Kayaker
November 4th, 2000, 17:53
Disassembly of the main exe file shows:
Number of Objects = 0004 (dec), Imagebase = 00400000h
   Object01: CODE     RVA: 00001000 Offset: 00000600 Size: 00000200 Flags: 60000020
   Object02: DATA     RVA: 00002000 Offset: 00000800 Size: 00000000 Flags: C0000040
   Object03: .idata   RVA: 00003000 Offset: 00000800 Size: 00000200 Flags: C0000040
   Object04: .reloc   RVA: 00004000 Offset: 00000A00 Size: 00000200 Flags: 50000040
   
I am going to start the insertion of the .rsrc section at C00 (A00 end of .reloc raw offset + 200 raw size = C00).  Before doing this the Number of Sections in the PE File Header needs to be changed.  I've filled in the values in the Header template with results from PEBrowsePro.
PE File Header
WORD  Machine Type; 0x014C
WORD  Number of Sections; 0x0004 ; change to 05
DWORD  Time/Date Stamp; 0x8D8D2953
DWORD  Pointer To Symbol Table; 0x00000000
DWORD  Number Of Symbols; 0x00000000
WORD  Size Of Optional Header; 0x00E0
WORD Characteristics; 0x818E
In a hex editor the section looks like this:
00000100 5045 0000 4C01 0400 5329 8D8D 0000 0000 PE..L...S)......
00000110 0000 0000                               ....           
So I just changed offset 106 from 04 to 05.
After the File Header comes the Optional Header, which I think we can ignore, then the Section Headers for each of the 4 (soon to become 5) sections.
Using the .reloc section as an example you can use it as a template to fill in values for the .rsrc section
00000270 2E72 656C 6F63 0000 0010 0000 0040 0000 .reloc.......@..
00000280 0002 0000 000A 0000 0000 0000 0000 0000 ................
00000290 0000 0000 4000 0050                     ....@..P        
Section Header 
BYTE   Name[IMAGE_SIZEOF_SHORT_NAME]; = ".reloc  "
DWORD   PhysicalAddress; = unused
DWORD   VirtualSize; = 0x00001000
DWORD   VirtualAddress; = 0x00004000
DWORD   SizeOfRawData; = 0x00000200
DWORD   PointerToRawData; = 0x00000A00
DWORD   PointerToRelocations; = 0x00000000
DWORD   PointerToLinenumbers; = 0x00000000
WORD  NumberOfRelocations; = 0x0000
WORD  NumberOfLinenumbers; = 0x0000
DWORD   Characteristics; = 0x50000040
So at the end of the .reloc section I inserted TEMPORARY values to create a .rsrc Section Header (some of these may be changed):
00000298 2E72 7372 6300 0000 0030 0000 0050 0000 .rsrc....0...P..
000002A8 1617 0000 00C0 0000 0000 0000 0000 0000 ................
000002B8 0000 0000 4000 0040                     ....@..@        
Which now gives PEBrowse results of:
Name                 = ".rsrc   "
Misc                 = 0x00003000 ;Virtual Size - I guessed at 3000 for now
VirtualAddress       = 0x00005000 ;starting at the end of V.Off for .reloc
SizeOfRawData        = 0x00001716 ;size of 3 dumped bin sections (doesn't include Resource Directory Headers!!)
PointerToRawData     = 0x0000C000 ;will begin inserting Resource Headers here
PointerToRelocations = 0x00000000
PointerToLinenumbers = 0x00000000
NumberOfRelocations  = 0x0000
NumberOfLinenumbers  = 0x0000
Characteristics      = 0x40000040 ;standard, might change it
The next step will be to *try* to build up the Resource Directory tree for each of the 3 resources and then actually insert the raw resources.  Adding code to pop up the Dialog boxes is going to be a whole other matter altogether...
Kayaker