Tuesday, 27 September 2011 12:27
The one to rule them all:
This is a function I pulled from the Autohotkey forums submitted by SKAN which lists all the functions for a specified Dynamic Link Library (DLL) along with an inputbox for convenience:
InputBox, FunctionToDo, DLL File, Enter the name of the DLL file you want to (suffix with .dll):,,500,120,,,,,shell32.dll
If not ErrorLevel {
ThisData:=PE_FunctionExports( FunctionToDo )
IfExist, %A_Temp%\delete_me.txt
FileDelete, %A_Temp%\delete_me.txt
FileAppend, %ThisData%, %A_Temp%\delete_me.txt
RunWait, %A_Temp%\delete_me.txt
}
PE_FunctionExports( PEFile ) {
; Lists Exported Functions/ Comp@t: WIN32_NT +AHK +LA +LW
;By SKAN www.autohotkey.com/forum/viewtopic.php?p=379086#379086 CD:20100824/LM:20100825
VarSetCapacity( $LI,48,0 ), DllCall( "ImageHlp\MapAndLoad", A_IsUnicode ? "AStr" : "Str",PEFile, Int,0, UInt,&$LI, Int,1, Int,1 )
nPtr := DllCall( "ImageHlp\ImageRvaToVa", UInt,Numget( $LI,12 ), UInt,Numget( $LI,08 ), UInt, NumGet( ( P := DllCall( "ImageHlp\ImageDirectoryEntryToData", UInt, NumGet( $LI,8 ), Int,0, UShort,0, UIntP,nSz )) + 12 ), UInt,0 )
VarSetCapacity( Var,1024,0 ), VarSetCapacity( List,10240,0 )
IfEqual,nPtr,0, Return SubStr( DllCall( "ImageHlp\UnMapAndLoad", UInt,&$LI ), 0,0 )
Loop % NumGet( P+24 ) + 1
A_IsUnicode ? Var := DllCall( "MulDiv", Int,nPtr, Int,1, Int,1, AStr ) : DllCall( "lstrcpy", Str,Var, UInt,nPtr ), nPtr := nPtr+StrLen( Var )+1, List .= "`n" Var, A_Index=1 ? Omit := StrLen( Var )+2 : StringTrimLeft, List, List, %Omit%
DllCall( "ImageHlp\UnMapAndLoad", UInt,&$LI )
Return List
}
ExitApp
Examples of DllCall'ing:
// get number of network card interfaces
DllCall("iphlpapi\GetNumberOfInterfaces", "UintP", nIf)
MsgBox % nIf
...
// get current process ID
ProcessID := DllCall("GetCurrentProcessId")
| < Prev | Next > |
|---|


