本程序代码演示怎么遍历导出/输入表.下面是完整源码.
下面是关键代码,如果想要完整源码可以到我的博客上去下载.
地址是: http://blog.csdn.net/chenhui530/
http://blog.csdn.net/chenhui530/archive/2007/12/30/2005399.aspxPublic Function GetImportTable(ByVal strFilePath As String, pImportInfo As ImportInfo) As Boolean
    Dim lngFile As Long
    Dim pNTHeader      As IMAGE_NT_HEADERS
    Dim lngTmp As Long, strTmp As String, lngNextAddr As Long
    Dim i As Integer, j As Integer
    Dim pImport As IMAGE_IMPORT_DESCRIPTOR
    Dim pTunk As IMAGE_THUNK_DATA32, lngTunk As Long
    Dim bytBuffer(129) As Byte
    Dim pDosHear As IMAGE_DOS_HEADER
    Dim pName As IMAGE_IMPORT_BY_NAME
    Dim hMap As Long, hBase As Long, hAddr As Long
    lngFile = CreateFile(ByVal strFilePath, ByVal &H80000000, FILE_SHARE_READ, ByVal 0&, ByVal 3, ByVal 0&, ByVal 0&)
    If (lngFile > 0) Then
        hMap = CreateFileMapping(lngFile, ByVal 0&, PAGE_READONLY, 0, 0, vbNullString)
        If hMap = 0 Then
            Exit Function
        End If
        hBase = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)
        If hBase = 0 Then
            Exit Function
        End If
        CopyMemory pDosHear, ByVal hBase, Len(pDosHear)
        If pDosHear.Magic <> &H5A4D Then
            Exit Function
        End If
        CopyMemory pNTHeader, ByVal hBase + pDosHear.lfanew, Len(pNTHeader)
        If pNTHeader.Signature <> IMAGE_NT_SIGNATURE Then
            Exit Function
        End If
        If pNTHeader.OptionalHeader.DataEntries(1).DataRVA = 0 Then Exit Function
        Do While 1
            hAddr = ImageRvaToVa(ByVal hBase + pDosHear.lfanew, ByVal hBase, pNTHeader.OptionalHeader.DataEntries(1).DataRVA + j * Len(pImport), ByVal 0&)
            CopyMemory pImport, ByVal hAddr, Len(pImport)
            If pImport.FirstThunk = 0 And pImport.Characteristics = 0 Then
                Exit Do
            End If
            hAddr = ImageRvaToVa(ByVal hBase + pDosHear.lfanew, ByVal hBase, pImport.pName, ByVal 0&)
            CopyMemory bytBuffer(0), ByVal hAddr, 130
            strTmp = StrConv(bytBuffer, vbUnicode)
            strTmp = Left(strTmp, InStr(strTmp, Chr(0)) - 1)
            Debug.Print "DLL模块为:" & strTmp
            ReDim Preserve pImportInfo.pDetailInfo(j)
            pImportInfo.pDetailInfo(j).strDllName = strTmp
            i = 0
            Do While 1
                hAddr = ImageRvaToVa(ByVal hBase + pDosHear.lfanew, ByVal hBase, pImport.Characteristics + i * 4, ByVal 0&)
                If hAddr = 0 Then Exit Do
                CopyMemory pTunk, ByVal hAddr, Len(pTunk)
                If pTunk.AddressOfData = 0 Then Exit Do
                hAddr = ImageRvaToVa(ByVal hBase + pDosHear.lfanew, ByVal hBase, pTunk.AddressOfData, ByVal 0&)
                ReDim Preserve pImportInfo.pDetailInfo(j).strFuns(i)
                If hAddr = 0 Then
                    Debug.Print "       ----函数为:"
                    pImportInfo.pDetailInfo(j).strFuns(i) = ""
                Else
                    CopyMemory pName, ByVal hAddr, Len(pName)
                    strTmp = StrConv(pName.pName, vbUnicode)
                    strTmp = Left(strTmp, InStr(strTmp, Chr(0)) - 1)
                    Debug.Print "       ----函数为:" & strTmp
                    pImportInfo.pDetailInfo(j).strFuns(i) = strTmp
                End If
                strTmp = ""
                i = i + 1
            Loop
            j = j + 1
        Loop
    End If
    GetImportTable = True
    UnmapViewOfFile ByVal hBase
    CloseHandle hMap
    CloseHandle lngFile
    GetImportTable = True
End Function