Just for helping people :
read carefully the source code ... and adapt it ....
Code: Select all
;
; Attempt to list a DLL content 2.pb
; By fweil 20040514
;
Global NewList DumpString.s()
#Main_Window = 0
Global ProgramName.s, Directory_SDK.s, Dir_SDK.s
DebugLevel 2
Procedure AddToolTip(Handle, Text.s) ; This replaces the GadgetToolTip procedure of PureBasic giving a higher quality tooltip for gadgets. API based.
hToolTip = CreateWindowEx_(0, "tooltips_class32", "", $D0000000 | #TTS_BALLOON, 0, 0, 0, 0, WindowID(#Main_Window), 0, GetModuleHandle_(0), 0) ; Tooltip window creation
SendMessage_(hToolTip, #RB_SETTEXTCOLOR - 1, $C0FFFF, 0) ; Foreground color tooltip : Don't know why #RB_SETTEXTCOLOR - 1 !
SendMessage_(hToolTip, #RB_SETBKCOLOR, $400000, 0) ; Background color tooltip
SendMessage_(hToolTip, #RB_SIZETORECT + 1, 0, 180) ; Maximum width of tooltip : Don't know why #RB_SIZETORECT + 1 !
Button.TOOLINFO\cbSize = SizeOf(TOOLINFO) ; Structure information fulfillment
Button\uFlags = #TTF_IDISHWND | #TTF_SUBCLASS ; Indicates that the uId member is the window handle to the tool. If this flag is not set, uId is the identifier of the tool. | Indicates that the tooltip control should subclass the tool's window to intercept messages, such as WM_MOUSEMOVE. If not set, you need to use the TTM_RELAYEVENT message to forward messages to the tooltip control. For a list of messages that a tooltip control processes, see TTM_RELAYEVENT.
Button\hWnd = Handle
Button\uId = Handle
Button\lpszText = @Text
SendMessage_(hToolTip, #RB_SETBARINFO, 0, Button) ; Send structure content to the tooltip window.
EndProcedure
Procedure ParseDLL(DLLName.s)
ClearList(DumpString())
If DLLName <> ""
BatchFileName.s = "ParseDLL_" + GetFilePart(DLLName) + ".bat"
OutputFileName.s = "ParseDLL_" + GetFilePart(DLLName) + ".pdl"
ProgramParameters.s = " " + DLLName + " > " + OutputFileName
If CreateFile(0, BatchFileName)
Debug ProgramName + " " + ProgramParameters, 2
WriteStringN(0, ProgramName + " " + ProgramParameters)
CloseFile(0)
EndIf
RunProgram(BatchFileName, "", "", 1 | 2)
DeleteFile(BatchFileName)
LengthToRead = FileSize(DLLName)
*Buffer = AllocateMemory(LengthToRead)
If ReadFile(0, DLLName)
ReadData(0, *Buffer, LengthToRead)
CloseFile(0)
EndIf
Debug LengthToRead
Debug DLLName
Debug "********* HexDump header *********", 2
StepLength = 32
Limit = $3FFF
For i = 0 To Limit
Addr.s = Hex(i)
While Len(Addr) < 4
Addr = "0" + Addr
Wend
a$ = Addr + " | "
b$ = ""
For j = i To i + StepLength - 1
If j > LengthToRead
Break 2
EndIf
Byte.b = PeekB(*Buffer + j)
Cod.s = Hex(Byte & $FF)
While Len(Cod) < 2
Cod = "0" + Cod
Wend
a$ = a$ + Cod + " "
If Byte < 32
b$ = b$ + " "
Else
b$ = b$ + Chr(Byte)
EndIf
Next
a$ = a$ + " - " + b$
Debug a$, 2
a$ = ""
i + StepLength - 1
Next
If a$ <> ""
Debug a$, 2
EndIf
Debug "********* HexDump footer *********", 2
StepLength = 32
Limit = LengthToRead
For i = Limit - $1000 To Limit
Addr.s = Hex(i)
While Len(Addr) < 4
Addr = "0" + Addr
Wend
a$ = Addr + " | "
b$ = ""
For j = i To i + StepLength - 1
If j > LengthToRead
Break 2
EndIf
Byte.b = PeekB(*Buffer + j)
Cod.s = Hex(Byte & $FF)
While Len(Cod) < 2
Cod = "0" + Cod
Wend
a$ = a$ + Cod + " "
If Byte < 32
b$ = b$ + " "
Else
b$ = b$ + Chr(Byte)
EndIf
Next
a$ = a$ + " - " + b$
Debug a$, 2
a$ = ""
i + StepLength - 1
Next
If a$ <> ""
Debug a$, 2
EndIf
If ReadFile(0, OutputFileName)
i = 1
Repeat
a$ = Trim(ReadString(0))
While FindString(a$, " ", 1)
a$ = ReplaceString(a$, " ", " ")
Wend
If a$ <> ""
AddElement(DumpString())
DumpString() = a$
Debug Str(i) + " - " + Chr(34) + a$ + Chr(34), 3
i + 1
EndIf
Until Eof(0)
CloseFile(0)
DeleteFile(OutputFileName)
EndIf
EndIf
EndProcedure
;
;
;
CurrentDirectory.s = Space(255)
GetCurrentDirectory_(255, @CurrentDirectory)
Directory_SDK = "C:\Program Files\Microsoft SDK\Bin\Win64\"
Dir_SDK = Space(255)
GetShortPathName_(Directory_SDK, Dir_SDK, 255)
ProgramName = Dir_SDK + "Dumpbin.exe /EXPORTS"
#Gadget_ExplorerTree = 14
#Gadget_ExplorerCombo = 15
#Gadget_ExplorerList = 16
#Gadget_ListIcon = 17
#Gadget_Button = 18
#Escape = 99
Quit.l = #False
WindowXSize.l = 800
WindowYSize.l = 600
CurrentDirectory.s = Space(255)
GetCurrentDirectory_(255, CurrentDirectory)
If OpenWindow(#Main_Window, 0, 0, WindowXSize, WindowYSize, "My Explorer", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
AddKeyboardShortcut(#Main_Window, #PB_Shortcut_Escape, #Escape)
hExplorerTreeGadget = ExplorerTreeGadget(#Gadget_ExplorerTree, 0, 0, WindowXsize / 4, WindowYSize / 3, CurrentDirectory + "\*.*", #PB_Explorer_NoFiles | #PB_Explorer_AlwaysShowSelection)
AddToolTip(hExplorerTreeGadget, "Directories explorer")
hExplorerListGadget = ExplorerListGadget(#Gadget_ExplorerList, WindowXsize / 4, 0, 3 * WindowXSize / 4, WindowYSize / 3, CurrentDirectory + "\*.dll", #PB_Explorer_NoParentFolder | #PB_Explorer_AlwaysShowSelection)
AddToolTip(hExplorerListGadget, "Files explorer")
hListIconGadget = ListIconGadget(#Gadget_ListIcon, 0, WindowYSize / 3 + 30, WindowXSize, 2 * WindowYSize / 3 - 30, "ordinal", 40)
AddToolTip(hListIconGadget, "Exports list")
hButtonGadget = ButtonGadget(#Gadget_Button, 0, WindowYSize / 3 + 5, 60, 20, "Button")
GadgetToolTip(#Gadget_Button, "Button")
AddToolTip(hButtonGadget, "Button")
AddGadgetColumn(#Gadget_ListIcon, 1, "hint", 40)
AddGadgetColumn(#Gadget_ListIcon, 2, "RVA", 80)
AddGadgetColumn(#Gadget_ListIcon, 3, "name", 480)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = #True
Case #PB_Event_Menu
Select EventMenu()
Case #Escape
Quit = #True
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #Gadget_ExplorerTree
Debug Str(GetGadgetState(#Gadget_ExplorerTree)) + " " + GetGadgetText(#Gadget_ExplorerTree), 3
SetGadgetText(#Gadget_ExplorerList, GetGadgetText(#Gadget_ExplorerTree))
Case #Gadget_ExplorerList
Debug Str(GetGadgetState(#Gadget_ExplorerList)) + " " + GetGadgetText(#Gadget_ExplorerList) + " " + GetGadgetItemText(#Gadget_ExplorerList, GetGadgetState(#Gadget_ExplorerList), 0), 3
EventType = EventType()
Select EventType
Case #PB_EventType_LeftDoubleClick
ThisName.s = GetGadgetText(#Gadget_ExplorerTree) + GetGadgetItemText(#Gadget_ExplorerList, GetGadgetState(#Gadget_ExplorerList), 0)
If LCase(GetExtensionPart(ThisName)) = "dll"
DLLName.s = Space(255)
GetShortPathName_(ThisName, DLLName, 255)
Debug "Calling DLL parser with " + ThisName, 1
Debug "----------", 1
ParseDLL(DLLName)
NumberOfFunctions = 0
NumberOfNames = 0
;
; While CountGadgetItems(#Gadget_ListIcon) > 0
; RemoveGadgetItem(#Gadget_ListIcon, CountGadgetItems(#Gadget_ListIcon) - 1)
; Wend
;
FreeGadget(#Gadget_ListIcon)
hListIconGadget = ListIconGadget(#Gadget_ListIcon, 0, WindowYSize / 3 + 30, WindowXSize, 2 * WindowYSize / 3 - 30, "ordinal", 40)
AddToolTip(hListIconGadget, "Exports list")
AddGadgetColumn(#Gadget_ListIcon, 1, "hint", 40)
AddGadgetColumn(#Gadget_ListIcon, 2, "RVA", 80)
AddGadgetColumn(#Gadget_ListIcon, 3, "name", 480)
SelectElement(DumpString(), 9)
If FindString(DumpString(), "number of functions", 1)
NumberOfFunctions = Val(DumpString())
EndIf
SelectElement(DumpString(), 10)
If FindString(DumpString(), "number of names", 1)
NumberOfNames = Val(DumpString())
EndIf
Debug Str(NumberOfFunctions) + " functions and " + Str(NumberOfNames) + " names found", 1
If NumberOfFunctions Or NumberOfNames
SelectElement(DumpString(), 8)
Debug DumpString(), 1
Debug "----------", 2
For i = 12 To NumberOfNames + 11
SelectElement(DumpString(), i)
; Debug Str(i) + " : " + Str(i) + " : " + DumpString(), 2
AddGadgetItem(#Gadget_ListIcon, -1, ReplaceString(DumpString(), " ", Chr(10)))
Next
EndIf
Debug "==========", 1
Else
Debug ThisName, 3
EndIf
Case #PB_EventType_Change
If GetGadgetText(#Gadget_ExplorerTree) <> GetGadgetText(#Gadget_ExplorerList)
SetGadgetText(#Gadget_ExplorerTree, GetGadgetText(#Gadget_ExplorerList))
EndIf
EndSelect
EndSelect
Case #WM_SIZE
WindowXSize = WindowWidth(#Main_Window)
WindowYSize = WindowHeight(#Main_Window)
ResizeGadget(#Gadget_ExplorerTree, 0, 0, WindowXsize / 4, WindowYSize / 3)
ResizeGadget(#Gadget_ExplorerList, WindowXsize / 4, 0, 3 * WindowXSize / 4, WindowYSize / 3)
ResizeGadget(#Gadget_ListIcon, 0, WindowYSize / 3 + 30, WindowXSize, 2 * WindowYSize / 3 - 30)
ResizeGadget(#Gadget_Button, 0, WindowYSize / 3 + 5, 60, 20)
EndSelect
Until Quit
EndIf
End