Code: Select all
#NoEnv
#SingleInstance Force
#NoTrayIcon
SetBatchLines -1
Global WinVersion := RtlGetVersion()
Folder := "C:\Windows\System32"
FileLV := "shell32.dll"
Menu, Tray, Icon, imageres.dll, 63
Menu, FileMenu, Add, % "&Open...`tCtrl+O", MenuOpen
Menu, FileMenu, Add
Menu, FileMenu, Add, % "E&xit`tAlt+F4", MenuClose
Menu, MenuBar, Add, % "&File", :FileMenu
Menu, EditMenu, Add, % "Copy`tCtrl+C", MenuCopy
Menu, EditMenu, Add, % "Select All`tCtrl+A", MenuSelect
Menu, MenuBar, Add, % "&Edit", :EditMenu
Menu, HelpMenu, Add, % "&About`tF1", MenuAbout
Menu, MenuBar, Add, % "&Help", :HelpMenu
Gui, +hWndhMainGUI +Resize +MinSize655x200
Gui, Margin, 7, 7
Gui, Color, F1F5FB
Gui, Font, s9, Segoe UI
Gui, Menu, MenuBar
Gui, Add, ListView, xm ym w750 h400 vMyLV hWndhMyLV +LV0x14000, % "#|Ordinal|Function|Entry Point"
LV_ModifyCol(1, "Integer 40"), LV_ModifyCol(2, 60), LV_ModifyCol(3, 225), LV_ModifyCol(4, 100)
If (WinVersion >= 0x0600)
SetWindowTheme(hMyLV)
Gui, Add, ListView, x500 ym w200 h400 vList hwndList +LV0x14000 gFile, % "Files"
If (WinVersion >= 0x0600)
SetWindowTheme(List)
Gui, Add, Edit, xm y+7 w230 h23 +0x2000000 hWndhMyEdit gLV_Search vEdit
If (WinVersion >= 0x0600)
EM_SETCUEBANNER(hMyEdit, "Enter search here")
Gui, Add, Text, x+400 yp w260 h23 +0x202 hWndhCounter vText, Loading Startup Functions from: %FileLV%...
Gui, Show, AutoSize, % "Dll Functions"
SetFocus(hMyEdit)
HideFocusBorder(hMainGUI)
Loop, %Folder%\*.dll
LV_Add("", A_LoopFileName)
GoSub, MenuOpen
Return
GuiContextMenu:
If !(InStr(A_GuiControl, "MyLV"))
Return
If (A_GuiControl = "MyLV") && (LV_GetNext() > 0) {
Menu, ContextMenu, Add, % "Copy`tCtrl+C", ContextCopy
Menu, ContextMenu, Add, % "Select All`tCtrl+A", ContextSelect
Menu, ContextMenu, Show, % A_GuiX, % A_GuiY
}
Return
GuiSize:
GuiControl, Move, MyLV, % "w" A_GuiWidth - 220 " h" A_GuiHeight - 40
GuiControl, Move, List, % "h" A_GuiHeight - 40 " x" A_GuiWidth - 205
GuiControl, MoveDraw, Edit, % "w" A_GuiWidth / 3 " y" A_GuiHeight - 30
GuiControl, MoveDraw, Text, % "x" A_GuiWidth - 270 " y" A_GuiHeight - 30
Return
File:
If (A_GuiEvent = "DoubleClick") {
Gui, ListView, List
RowNumber := 0
RowNumber := LV_GetNext(RowNumber, "Focused")
LV_GetText(FileItemLV, RowNumber, 1)
FileLV := Folder "\" FileItemLV
GoTo MenuOpen
}
Return
MenuSelect:
ContextSelect:
LV_Modify(0, "Select")
Return
MenuCopy:
ContextCopy:
If (A_GuiEvent = "DoubleClick") {
ColNum := LVM_SUBITEMHITTEST(hMyLV)
ControlGet, List, List, Selected Col%ColNum%, SysListView321, % "ahk_id " hMainGUI
Clipboard := List
} Else {
ColNum := LVM_SUBITEMHITTEST(hMyLV)
ControlGet, List, List, Selected Col%ColNum%, SysListView321, % "ahk_id " hMainGUI
Clipboard := List
}
Return
MenuClose:
GuiClose:
GuiEscape:
ExitApp
GuiDropFiles:
LV_Delete()
GuiControl,, % hCounter, % "Loading Functions..."
loop, parse, A_GuiEvent, `n
{
SplitPath, A_LoopField,,, ext
If (ext = "dll")
SelectedFile := A_LoopField
else
MsgBox % "The selected file is not a valid DLL file. Please select a valid DLL file and try again."
break
}
DllLibrary := DllExport(SelectedFile), index := 0
for k, v in DllLibrary
LV_Add("", ++index, v.Ordinal, v.Function, v.EntryPoint)
GuiControl,, % hCounter, % LV_GetCount() " Functions"
SetFocus(hMyEdit), SetWindowText(hMainGUI, "Dll Functions [ " SelectedFile " ]")
Return
MenuOpen:
Gui, ListView, MyLV
LV_Delete()
GuiControl,, % hCounter, % "Loading Functions..."
If (!FileLV) {
FileSelectFile, OutputVar, 3, % A_WinDir "\System32", % "Open", % "Dynamic-link library (*.dll)"
If (ErrorLevel)
Return
DllLibrary := DllExport(OutputVar), index := 0
for k, v in DllLibrary
LV_Add("", ++index, v.Ordinal, v.Function, v.EntryPoint)
GuiControl,, % hCounter, % "Loaded " LV_GetCount() " Functions"
SetFocus(hMyEdit), SetWindowText(hMainGUI, "Dll Functions [ " OutputVar " ]")
} Else If (FileLV) {
DllLibrary := DllExport(FileLV), index := 0
for k, v in DllLibrary
LV_Add("", ++index, v.Ordinal, v.Function, v.EntryPoint)
GuiControl,, % hCounter, % "Loaded " LV_GetCount() " Functions"
SetFocus(hMyEdit), SetWindowText(hMainGUI, "Dll Functions [ " FileLV " ]")
}
FileLV := ""
Return
LV_Search:
GuiControlGet, OutputVarEdit,, % hMyEdit
LV_Delete(), index := 0
for k, v in DllLibrary
If (InStr(v.Function, OutputVarEdit)) || (InStr(v.EntryPoint, OutputVarEdit))
LV_Add("", ++index, v.Ordinal, v.Function, v.EntryPoint)
GuiControl,, % hCounter, % LV_GetCount() " Functions"
SetFocus(hMyEdit)
Return
MenuAbout:
Thread, Priority, 10
Gui, About:+LastFound -MinimizeBox +Owner1
Gui, About:Add, Text, x30 y20 w190 h80,
(
Contributing
- thanks Bentschi for LoadLibrary()
- thanks SKAN for DllListExports()
- thanks 'just me' for some hints
- thanks Algumist for his gui ideas
)
Gui, About:Add, Button, x70 y120 w75 h23 gClose, Close
DllCall("SetParent", "uint", WinExist(), "uint", 99ID)
Gui, About:Show, w225 h155, About
Return
Close:
AboutGuiClose:
Gui, About:Destroy
Return
RtlGetVersion()
{
static RTL_OSV_EX, init := NumPut(VarSetCapacity(RTL_OSV_EX, A_IsUnicode ? 284 : 156, 0), RTL_OSV_EX, "uint")
If (DllCall("ntdll\RtlGetVersion", "ptr", &RTL_OSV_EX) != 0)
throw Exception("RtlGetVersion failed", -1)
Return ((NumGet(RTL_OSV_EX, 4, "uint") << 8) | NumGet(RTL_OSV_EX, 8, "uint"))
}
EM_SETCUEBANNER(handle, string, hideonfocus := true)
{
static EM_SETCUEBANNER := 0x1501
If !(DllCall("user32\SendMessage", "ptr", handle, "uint", EM_SETCUEBANNER, "int", hideonfocus, "str", string, "int"))
throw Exception("EM_SETCUEBANNER failed", -1)
Return true
}
SetWindowTheme(handle)
{
If (HRESULT := DllCall("uxtheme\SetWindowTheme", "ptr", handle, "wstr", "Explorer", "ptr", 0) != 0)
throw Exception("SetWindowTheme failed: " HRESULT, -1)
Return true
}
SetFocus(handle)
{
If !(DllCall("user32\SetFocus", "ptr", handle, "ptr"))
throw Exception("SetFocus failed: " A_LastError, -1)
Return true
}
SetWindowText(handle, string)
{
If !(DllCall("user32\SetWindowText", "ptr", handle, "str", string))
throw Exception("SetWindowText failed: " A_LastError, -1)
Return true
}
LVM_SUBITEMHITTEST(handle) ; by 'just me'
{
VarSetCapacity(POINT, 8, 0)
DllCall("user32\GetCursorPos", "ptr", &POINT)
DllCall("user32\ScreenToClient", "ptr", handle, "ptr", &POINT)
VarSetCapacity(LVHITTESTINFO, 24, 0)
NumPut(NumGet(POINT, 0, "int"), LVHITTESTINFO, 0, "int"), NumPut(NumGet(POINT, 4, "int"), LVHITTESTINFO, 4, "int")
If (DllCall("user32\SendMessage", "ptr", handle, "uint", 0x1039, "ptr", 0, "ptr", &LVHITTESTINFO) = -1)
Return 0
Return NumGet(LVHITTESTINFO, 16, "Int") + 1
}
HideFocusBorder(wParam, lParam := "", Msg := "", handle := "") ; by 'just me'
{
static Affected := []
static WM_UPDATEUISTATE := 0x0128
static SET_HIDEFOCUS := 0x00010001 ; UIS_SET << 16 | UISF_HIDEFOCUS
static init := OnMessage(WM_UPDATEUISTATE, Func("HideFocusBorder"))
If (Msg = WM_UPDATEUISTATE) {
If (wParam = SET_HIDEFOCUS)
Affected[handle] := true
else If Affected[handle]
DllCall("user32\PostMessage", "ptr", handle, "uint", WM_UPDATEUISTATE, "ptr", SET_HIDEFOCUS, "ptr", 0)
}
else If (DllCall("IsWindow", "ptr", wParam, "uint"))
DllCall("user32\PostMessage", "ptr", wParam, "uint", WM_UPDATEUISTATE, "ptr", SET_HIDEFOCUS, "ptr", 0)
}
; INCLUDES ======================================================================================================================
DllExport(FileName) ; by SKAN (modified by jNizM + 'just me')
{
if !(hModule := DllCall("LoadLibrary", "str", FileName, "ptr"))
throw Exception("Couldn't load " FileName, -1)
if !(IMAGE_EXPORT_DIRECTORY := DllCall("imagehlp\ImageDirectoryEntryToData", "ptr", hModule, "int", true, "ushort", 0, "uint*", size, "ptr"))
throw Exception("ImageDirectoryEntryToData failed: " A_LastError, -1)
SectionStart := IMAGE_EXPORT_DIRECTORY - hModule, SectionEnd := SectionStart + size
OrdinalBase := NumGet(IMAGE_EXPORT_DIRECTORY + 0x10, "uint")
NumberOfNames := NumGet(IMAGE_EXPORT_DIRECTORY + 0x18, "uint")
AddressOfFunctions := NumGet(IMAGE_EXPORT_DIRECTORY + 0x1c, "uint") + hModule
AddressOfNames := NumGet(IMAGE_EXPORT_DIRECTORY + 0x20, "uint") + hModule
AddressOfNameOrdinals := NumGet(IMAGE_EXPORT_DIRECTORY + 0x24, "uint") + hModule
IMAGE := {}
loop % NumberOfNames
{
IMAGE[A_Index, "Function"] := StrGet(hModule + NumGet(AddressOfNames + ((A_Index - 1) * 4), "uint"), "cp0")
IMAGE[A_Index, "Ordinal"] := (o := NumGet(AddressOfNameOrdinals + ((A_Index - 1) * 2), "ushort")) + OrdinalBase
Address := NumGet(AddressOfFunctions + (o * 4), "uint")
IMAGE[A_Index, "EntryPoint"] := ((Address > SectionStart) && (Address < SectionEnd)) ? StrGet(hModule + Address, "cp0") : Format("{:#08x}", Address)
}
return IMAGE, DllCall("FreeLibrary", "ptr", hModule)
}