I want to clone ollydbg's functionalities in vb6, so I could write my own tools easier then using it's scripting engine.
I started of with trying to map the memory map's addresses exactly the same way ollydbg does it.
The PE header is at 0x00400000 with Size 0x1000
I assume the 0x00400000 is retrieved like so.
Dim AddressOfPE As Long = NTHEADER.OptionalHeader.ImageBase
Now I want to map the addresses for all the other stuff most importantly .text
.rdata
but I wouldn't mind having them all.
what I tried is this
For u = 0 To UBound(SECTIONSHEADER)
AddressStart = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
Debug.Print "(" & u & ") " & SECTIONSHEADER(u).nameSec & _
" AddressStart = " & Hex(AddressStart) & _
" VirtualAddress = " & Hex(SECTIONSHEADER(u).VirtualAddress) & _
" VirtualSize = " & Hex(SECTIONSHEADER(u).VirtualSize) & _
" SizeOfRawData = " & Hex(SECTIONSHEADER(u).SizeOfRawData)
'Hunt for strings
If SECTIONSHEADER(u).nameSec = ".rdata" Or SECTIONSHEADER(u).nameSec = ".data" Then
MsgBox "a"
End If
AddressEnd = AddressStart + SECTIONSHEADER(u).SizeOfRawData
Debug.Print "(" & u & ") " & SECTIONSHEADER(u).nameSec & _
" AddressEnd(?) = " & Hex(AddressEnd) & _
" OllyAddressEnd(?) = " & Hex(SECTIONSHEADER(u).SizeOfRawData)
Next u
Debug log looks like this
(0) .text AddressStart = 401000 VirtualAddress = 1000 VirtualSize = 1FAB3AD SizeOfRawData = 1FAB400
(0) .text AddressEnd(?) = 23AC400 OllyAddressEnd(?) = 1FAB400
(1) .rdata AddressStart = 23AD000 VirtualAddress = 1FAD000 VirtualSize = 855586 SizeOfRawData = 855600
(1) .rdata AddressEnd(?) = 2C02600 OllyAddressEnd(?) = 855600
(2) .data AddressStart = 2C03000 VirtualAddress = 2803000 VirtualSize = 2D045C4 SizeOfRawData = 1DF000
(2) .data AddressEnd(?) = 2DE2000 OllyAddressEnd(?) = 1DF000
(3) .rsrc AddressStart = 5908000 VirtualAddress = 5508000 VirtualSize = 105CC SizeOfRawData = 10600
(3) .rsrc AddressEnd(?) = 5918600 OllyAddressEnd(?) = 10600
Looking at this image seems I got it all right? but the size addresses are off.