PE headers in vb.NET?

atlantisx

New member
Joined
Sep 1, 2007
Messages
1
I can get DOS header by doing this
Code:
    Public Structure IMAGEDOSHEADER
        Dim e_magic As Short
        Dim e_cblp As Short
        Dim e_cp As Short
        Dim e_crlc As Short
        Dim e_cparhdr As Short
        Dim e_minalloc As Short
        Dim e_maxalloc As Short
        Dim e_ss As Short
        Dim e_sp As Short
        Dim e_csum As Short
        Dim e_ip As Short
        Dim e_cs As Short
        Dim e_lfarlc As Short
        Dim e_ovno As Short
        <VBFixedArray(3)> Dim e_res() As Short
        Dim e_oemid As Short
        Dim e_oeminfo As Short
        <VBFixedArray(9)> Dim e_res2() As Short
        Dim e_lfanew As Integer
        Public Sub Initialize()
            ReDim e_res(3)
            ReDim e_res2(9)
        End Sub
    End Structure

Private Const MZSIGNATURE As Integer = &H5A4D

    Private sub getvalues(ByVal StrFileName As String)
        Dim rFree As Integer
        Dim IDH As New IMAGEDOSHEADER
        rFree = FreeFile()
        FileOpen(rFree, StrFileName, OpenMode.Binary, OpenAccess.Read)
        FileGet(rFree, IDH)
        If (IDH.e_magic = MZSIGNATURE) Then
        msgbox("file has dos header")
        End If
        FileClose(rFree)
    End Function

But how do I do if I like to get NT optional headers and virtual size of
sections?
 
Back
Top