Skip to main content
added 170 characters in body
Source Link
SSpoke
  • 759
  • 1
  • 7
  • 19

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long
Dim StartAddress as Long
Dim EndAddresss as Long   

AddressOfPE = NTHEADER.OptionalHeader.ImageBase

For u = 0 To UBound(SECTIONSHEADER)
    StartAddress = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    EndAddresss = AddressOfPE + RoundUp((SECTIONSHEADER(u).VirtualAddress + SECTIONSHEADER(u).VirtualSize), NtHeader.OptionalHeader.SectionAlignment) - 1

    If offset >= StartAddress And offset <= EndAddresss Then
        RawFileOffsetToCheck = offset - StartAddress  + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u


Public Function RoundUp(V, M) As Long
    If (V Mod M) = 0 Then
        RoundUp = V
    Else
        RoundUp = ((V \ M) + 1) * M
    End If
End Function

Debug outputs exactly like ollydbg view

.text  401000 23ACFFF
.rdata 23AD000 2C02FFF
.data  2C03000 5907FFF
.rsrc  5908000 5918FFF

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long
Dim StartAddress as Long
Dim EndAddresss as Long   

AddressOfPE = NTHEADER.OptionalHeader.ImageBase

For u = 0 To UBound(SECTIONSHEADER)
    StartAddress = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    EndAddresss = RoundUp((SECTIONSHEADER(u).VirtualAddress + SECTIONSHEADER(u).VirtualSize), NtHeader.OptionalHeader.SectionAlignment) - 1

    If offset >= StartAddress And offset <= EndAddresss Then
        RawFileOffsetToCheck = offset - StartAddress  + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u


Public Function RoundUp(V, M) As Long
    If (V Mod M) = 0 Then
        RoundUp = V
    Else
        RoundUp = ((V \ M) + 1) * M
    End If
End Function

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long
Dim StartAddress as Long
Dim EndAddresss as Long   

AddressOfPE = NTHEADER.OptionalHeader.ImageBase

For u = 0 To UBound(SECTIONSHEADER)
    StartAddress = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    EndAddresss = AddressOfPE + RoundUp((SECTIONSHEADER(u).VirtualAddress + SECTIONSHEADER(u).VirtualSize), NtHeader.OptionalHeader.SectionAlignment) - 1

    If offset >= StartAddress And offset <= EndAddresss Then
        RawFileOffsetToCheck = offset - StartAddress  + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u


Public Function RoundUp(V, M) As Long
    If (V Mod M) = 0 Then
        RoundUp = V
    Else
        RoundUp = ((V \ M) + 1) * M
    End If
End Function

Debug outputs exactly like ollydbg view

.text  401000 23ACFFF
.rdata 23AD000 2C02FFF
.data  2C03000 5907FFF
.rsrc  5908000 5918FFF
fixed, much cleaner now
Source Link
SSpoke
  • 759
  • 1
  • 7
  • 19

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long

 
AddressOfPE = NTHEADER.OptionalHeader.ImageBase
 
Dim StartAddresses()StartAddress Asas Long
Dim EndAddressess()EndAddresss Asas Long

ReDim StartAddresses(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]
ReDim EndAddressess(UBound(SECTIONSHEADER)) 'holds 4 atm [.text,
AddressOfPE .rdata,= NTHEADER.data, OptionalHeader.rsrc]
ImageBase
'Preloop to calculate proper EndAddresses for the StartAddresses
For u = 0 To UBound(SECTIONSHEADER)
    StartAddresses(u)StartAddress = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    IfEndAddresss = RoundUp((SECTIONSHEADER(u).VirtualAddress >+ 0SECTIONSHEADER(u).VirtualSize), Then
NtHeader.OptionalHeader.SectionAlignment) - 1

    If offset 'Fill>= inStartAddress previousAnd EndAddressoffset from<= theEndAddresss StartAddressThen
 gathered before.
      RawFileOffsetToCheck = EndAddressess(uoffset - 1)StartAddress = (StartAddresses+ SECTIONSHEADER(u) - 1).PointerToRawData
    End If
    If u ='Hunt UBound(SECTIONSHEADER)for Thenstrings
        'No idea how to fill in last EndAddress so I just use VirtualSize
   'TODO: Use the STUFF here.. EndAddressess(u)pretty =easy StartAddresses(u)since +we SECTIONSHEADER(u).VirtualSize
get the file offset Endhere If[RawFileOffsetToCheck]
Next u

For
Public uFunction =RoundUp(V, 0M) ToAs UBound(SECTIONSHEADER)Long
    If offset >= StartAddresses(u)V AndMod offsetM) <== EndAddressess(u)0 Then
        RawFileOffsetToCheckRoundUp = offset - StartAddresses(u) + SECTIONSHEADER(u).PointerToRawDataV
    End IfElse
    'Hunt for strings
    'TODO: UseRoundUp the= STUFF((V here..\ prettyM) easy+ since1) we* getM
 the file offset hereEnd [RawFileOffsetToCheck]If
NextEnd uFunction

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long

 
AddressOfPE = NTHEADER.OptionalHeader.ImageBase
 
Dim StartAddresses() As Long
Dim EndAddressess() As Long

ReDim StartAddresses(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]
ReDim EndAddressess(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]

'Preloop to calculate proper EndAddresses for the StartAddresses
For u = 0 To UBound(SECTIONSHEADER)
    StartAddresses(u) = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    If u > 0 Then
        'Fill in previous EndAddress from the StartAddress gathered before.
        EndAddressess(u - 1) = (StartAddresses(u) - 1)
    End If
    If u = UBound(SECTIONSHEADER) Then
        'No idea how to fill in last EndAddress so I just use VirtualSize
        EndAddressess(u) = StartAddresses(u) + SECTIONSHEADER(u).VirtualSize
    End If
Next u

For u = 0 To UBound(SECTIONSHEADER)
    If offset >= StartAddresses(u) And offset <= EndAddressess(u) Then
        RawFileOffsetToCheck = offset - StartAddresses(u) + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long
Dim StartAddress as Long
Dim EndAddresss as Long   

AddressOfPE = NTHEADER.OptionalHeader.ImageBase

For u = 0 To UBound(SECTIONSHEADER)
    StartAddress = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    EndAddresss = RoundUp((SECTIONSHEADER(u).VirtualAddress + SECTIONSHEADER(u).VirtualSize), NtHeader.OptionalHeader.SectionAlignment) - 1

    If offset >= StartAddress And offset <= EndAddresss Then
        RawFileOffsetToCheck = offset - StartAddress  + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u


Public Function RoundUp(V, M) As Long
    If (V Mod M) = 0 Then
        RoundUp = V
    Else
        RoundUp = ((V \ M) + 1) * M
    End If
End Function
added 1371 characters in body
Source Link
SSpoke
  • 759
  • 1
  • 7
  • 19

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long


AddressOfPE = NTHEADER.OptionalHeader.ImageBase
 
Dim StartAddresses() As Long
Dim EndAddressess() As Long

ReDim StartAddresses(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]
ReDim EndAddressess(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]

'Preloop to calculate proper EndAddresses for the StartAddresses
For u = 0 To UBound(SECTIONSHEADER)
    StartAddresses(u) = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    If u > 0 Then
        'Fill in previous EndAddress from the StartAddress gathered before.
        EndAddressess(u - 1) = (StartAddresses(u) - 1)
    End If
    If u = UBound(SECTIONSHEADER) Then
        'No idea how to fill in last EndAddress so I just use VirtualSize
        EndAddressess(u) = StartAddresses(u) + SECTIONSHEADER(u).VirtualSize
    End If
Next u

For u = 0 To UBound(SECTIONSHEADER)
    If offset >= StartAddresses(u) And offset <= EndAddressess(u) Then
        RawFileOffsetToCheck = offset - StartAddresses(u) + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved

Dang I solved it, I thought you had to add the previous section size to create new section address but it doesn't work like that.

Still got a little bug where VirtualSize is smaller then OllyDbg's Memory Map Sizes for that section, but it seems SizeOfRawData is more accurate sometimes?

But I guess I could fix this by taking the previous StartAddress for each section and subtracting one from it to get the End Size.

I guess I could mark this solved.

Dim AddressOfPE As Long
Dim RawFileOffsetToCheck As Long


AddressOfPE = NTHEADER.OptionalHeader.ImageBase
 
Dim StartAddresses() As Long
Dim EndAddressess() As Long

ReDim StartAddresses(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]
ReDim EndAddressess(UBound(SECTIONSHEADER)) 'holds 4 atm [.text, .rdata, .data, .rsrc]

'Preloop to calculate proper EndAddresses for the StartAddresses
For u = 0 To UBound(SECTIONSHEADER)
    StartAddresses(u) = AddressOfPE + SECTIONSHEADER(u).VirtualAddress
    If u > 0 Then
        'Fill in previous EndAddress from the StartAddress gathered before.
        EndAddressess(u - 1) = (StartAddresses(u) - 1)
    End If
    If u = UBound(SECTIONSHEADER) Then
        'No idea how to fill in last EndAddress so I just use VirtualSize
        EndAddressess(u) = StartAddresses(u) + SECTIONSHEADER(u).VirtualSize
    End If
Next u

For u = 0 To UBound(SECTIONSHEADER)
    If offset >= StartAddresses(u) And offset <= EndAddressess(u) Then
        RawFileOffsetToCheck = offset - StartAddresses(u) + SECTIONSHEADER(u).PointerToRawData
    End If
    'Hunt for strings
    'TODO: Use the STUFF here.. pretty easy since we get the file offset here [RawFileOffsetToCheck]
Next u
added 170 characters in body
Source Link
SSpoke
  • 759
  • 1
  • 7
  • 19
Loading
Post Undeleted by SSpoke
Post Deleted by SSpoke
Source Link
SSpoke
  • 759
  • 1
  • 7
  • 19
Loading