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.

[![enter image description here][1]][1]

The PE header is at 0x00400000 with Size 0x00001000

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

    Dim LastAddress As Long
    'Dim AddressOfPE As Long
    AddressOfPE = NTHEADER.OptionalHeader.ImageBase
    LastAddress = AddressOfPE
    
        For u = 0 To UBound(SECTIONSHEADER)
            LastAddress = LastAddress + SECTIONSHEADER(u).VirtualAddress
            Debug.Print "(" & u & ") " & SECTIONSHEADER(u).nameSec & " Last Address = " & Hex(LastAddress) & " VirtualAddress = " & SECTIONSHEADER(u).VirtualAddress & " VirtualSize = " & SECTIONSHEADER(u).VirtualSize
            'Hunt for strings
            If SECTIONSHEADER(u).nameSec = ".rdata" Or SECTIONSHEADER(u).nameSec = ".data" Then
                MsgBox "a"
            End If
            LastAddress = LastAddress + SECTIONSHEADER(u).VirtualSize
            Debug.Print "(" & u & ") " & SECTIONSHEADER(u).nameSec & " Last Address = " & Hex(LastAddress) & " VirtualAddress = " & SECTIONSHEADER(u).VirtualAddress & " VirtualSize = " & SECTIONSHEADER(u).VirtualSize
        Next u


Debug log looks like this

    (0) .text  Last Address = 401000 VirtualAddress = 4096 VirtualSize = 33207213
    (0) .text  Last Address = 23AC3AD VirtualAddress = 4096 VirtualSize = 33207213
    (1) .rdata Last Address = 43593AD VirtualAddress = 33214464 VirtualSize = 8738182
    (1) .rdata Last Address = 4BAE933 VirtualAddress = 33214464 VirtualSize = 8738182
    (2) .data  Last Address = 73B1933 VirtualAddress = 41955328 VirtualSize = 47203780
    (2) .data  Last Address = A0B5EF7 VirtualAddress = 41955328 VirtualSize = 47203780
    (3) .rsrc  Last Address = F5BDEF7 VirtualAddress = 89161728 VirtualSize = 67020
    (3) .rsrc  Last Address = F5CE4C3 VirtualAddress = 89161728 VirtualSize = 67020


  [1]: https://i.sstatic.net/luaQO.png