 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Thu Jan 08, 2009 9:45 pm Post subject: Crazy Scripting : WinAPI Listing [New Version] |
|
|
Newer Version
| Code: | /*
___ _ _ ___ _ _ ___ _
| . \| | | | | __>_ _ ._ _ ___ _| |_ <_> ___ ._ _ | __>__ ___ ___ _ _ _| |_ ___
| | || |_ | |_ | _>| | || ' |/ | ' | | | |/ . \| ' | | _> \ \/| . \/ . \| '_> | | <_-<
|___/|___||___| |_| `___||_|_|\_|_. |_| |_|\___/|_|_| |___>/\_\| _/\___/|_| |_| /__/
|_|
AutoHotkey PE Tool : Lists all Exported Functions found in all \System Folder\DLL files.
Author: SKAN - Suresh Kumar A N ( arian.suresh@gmail.com ) | CD:20090109 / LM:20100827
*/
#SingleInstance, Force
SetBatchLines -1
Sps := " "
VarSetCapacity( A_SysDir,520 ), DllCall( "GetSystemDirectory", Str,A_SysDir, UInt,260 )
TrayTip, Function Exports - Viewer, Scanning %A_sysDir%
Loop %A_SysDir%\*.dll
If ( Funx := PE_FunctionExports( A_LoopFileLongPath ) )
&& ( File := SubStr(A_LoopFileName,1,StrLen(A_LoopFileName)-4 ) )
Loop, Parse, Funx, `n
If InStr( A_LoopField, "@" ) || ! A_LoopField
Continue
Else Data .= SubStr( File . Sps, 1,16 ) A_LoopField "`n"
StringReplace, Data, Data, `n, `n, UseErrorLevel
TotalFunctions := ErrorLevel
StringTrimRight, Data, Data, 1
Sort, Data, P17 D`n
Gui, Font, s10, Arial
Gui, Add, Edit, w439 h20 -E0x200 UpperCase hWndhEdit cAA1010 Border vQuery gSTimer
SendMessage, 0xD3, 0x1,5,, ahk_id %hEdit%
Gui, Add, ListView, Yp+19 R15 w439 -E0x200 +Border gDClick, Function|Library
LV_ModifyCol( 1, "290" ), LV_ModifyCol( 2, "125" )
TrayTip, Function Exports - Viewer, Loading List of Functions
Loop, Parse, Data, `n
LV_Add( "", SubStr(A_LoopField,17 ), SubStr( A_LoopField,1,16) )
TrayTip
Gui, Show,, Function Exports: %TotalFunctions% in [ %A_SysDir% ]
Return ; // end of auto-execute function //
GuiClose:
Exitapp
sTimer:
SetTimer, FunctionSearch, -250
Return
FunctionSearch:
Critical
GuiControlGet, Query
LV_Delete()
If ( Query="" ) {
Loop, Parse, Data, `n
LV_Add( "", SubStr(A_LoopField,17 ), SubStr( A_LoopField,1,16) )
Return
} StringReplace, Query, Query, +, +, UseErrorLevel
SearchItems := ErrorLevel+1
Loop, Parse, Data, `n
{ Line := A_LoopField, Result := 0
Loop, Parse, Query, +
Result := InStr( Line,A_LoopField,0,17 ) ? Result+1 : Result
If ( Result = SearchItems )
LV_Add( "", SubStr(A_LoopField,17 ), SubStr( A_LoopField,1,16) )
} Return
DClick:
IfNotEqual, A_GuiEvent, DoubleClick, Return
GotoURL:
Critical
Row := LV_GetNext( 0, "Focused" ), LV_GetText( Func,Row,1 )
If ( SubStr(Func,0) == "A" || SubStr(Func,0) == "W" )
StringTrimRight, Func, Func, 1
URL1 := "http://www.google.com/search?hl=en&q=" Func
. "+Function+site:microsoft.com&btnI=I'm+Feeling+Lucky"
URL2 := "http://www.google.com/search?hl=en&q=" Func "&btnI=I'm+Feeling+Lucky"
If GetKeyState( "LControl", "P" )
Run, %Url2%,,Max
Else Run, %Url1%,,Max
Return
PE_FunctionExports( PEFile ) { ;List of Exported Functions / Comp@t: WIN32_NT +AHK +LA +LW
; By SKAN www.autohotkey.com/forum/viewtopic.php?p=379086#379086 CD:20100825/LM:20100827
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
} |
- Double-click on a row should take you directly to the relevant page on MSDN, provided the function is documented.
The above uses 'site-specific' Google I'm Feeling Lucky feature on microsoft.com
- Left control + Double-click on a row does a open Google I'm Feeling Lucky search.
The above is useful in cases where documentation is available from a third party.
For example: RtlComputeCrc32() is documented at winehq.org but not available in MSDN
Previous Version
Just a vague try in building a useful API function list, please refer: Index of .dll files
Download WinAPI.ahk
The scripts requires WinAPI.txt 183.06 KiB, which will be auto-downloaded with first run and whenever missing.
Run the script and double-click on a function name to open the relevant MSDN link. However, be informed that these links have been collected by running a bot in google, and so I cannot assure every link is correct. If you find a wrong link, double-click again with Left-Control Key down to do a Google search on microsoft.com for the particular function. The correct result should be in first few entries. _________________ URLGet - Internet Explorer based Downloader
Last edited by SKAN on Thu Aug 26, 2010 7:00 pm; edited 8 times in total |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
godsstigma
Joined: 04 Nov 2008 Posts: 222 Location: Memphis, TN
|
Posted: Thu Jan 08, 2009 10:54 pm Post subject: |
|
|
Thanks a million SKAN...
I really appreciate you doing this to help me and everyone else. |
|
| Back to top |
|
 |
Chavez
Joined: 20 Aug 2008 Posts: 256
|
Posted: Fri Jan 09, 2009 7:47 am Post subject: |
|
|
Nice idea, and it'll really help, but the auto-download part doesn't work, at least not here ;D _________________ -Chavez. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Jan 10, 2009 10:06 am Post subject: |
|
|
| Chavez wrote: | | but the auto-download part doesn't work |
It works fine for me.
AutoHotkey.net might have been busy or maybe you have to check your firewall settings. _________________ URLGet - Internet Explorer based Downloader |
|
| Back to top |
|
 |
trik
Joined: 15 Jul 2007 Posts: 1320
|
Posted: Sat Jan 10, 2009 2:40 pm Post subject: |
|
|
Wow, another excellent piece of coding. But I must know; where on earth do you find the time to make these mass lists? _________________ Religion is false. >_> |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sun Jan 11, 2009 7:58 am Post subject: |
|
|
| Trikster wrote: | | where on earth do you find the time to make these mass lists? |
I just use AHK Bots, but in this case, I needed a lot of patience. Google is very sensitive in detecting bots and it took me many weeks to acquire this information. Even with 3 second sleep, it randomly detected my bot and refused to cooperate. I had to disable cookies and turn on/off my ADSL modem many times to switch IP address. _________________ URLGet - Internet Explorer based Downloader |
|
| Back to top |
|
 |
mitchi
Joined: 14 Jun 2008 Posts: 9
|
Posted: Fri Jan 16, 2009 6:42 pm Post subject: |
|
|
I get this error when running the script ?
| Code: | ---------------------------
api.ahk
---------------------------
Error: "URLDownloadToFile" requires at least 2 parameters.
Specifically: UrlDownloadToFile
Line#
002: SetBatchLines,-1
003: SetWorkingDir,%A_ScriptDir%
---> 004: IfNotExist,WinAPI.txt
The program will exit.
---------------------------
OK
---------------------------
|
|
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Fri Jan 16, 2009 7:24 pm Post subject: |
|
|
| There is no problem with the script. Try copy/paste by blocking the text manually with mouse. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Sat Jan 17, 2009 9:05 am Post subject: |
|
|
| SKAN wrote: | | There is no problem with the script. |
Actually, I had the same problem after I copied the script but I was pretty sure I could see where it was coming from. Here's what gets copied from your script on line 4:
| Code: | IfNotExist, WinAPI.txt, UrlDownloadToFile
, http://www.autohotkey.net/~Skan/Utils/MSDN/WinAPI.txt, WinAPI.txt |
The URL will have to overflow to the next line but the comma following UrlDownloadToFile should not, it should remain on line 4:
| Code: | IfNotExist, WinAPI.txt, UrlDownloadToFile,
http://www.autohotkey.net/~Skan/Utils/MSDN/WinAPI.txt, WinAPI.txt |
Once I corrected that everything worked fine. Of course I'm using Notepad as my editor, you might be using something different that fits that line correctly where Notepad cannot. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Sat Jan 17, 2009 11:47 am Post subject: |
|
|
I hve changed the offending line as:
| Code: | IfNotExist, WinAPI.txt
UrlDownloadToFile, http://www.autohotkey.net/~Skan/Utils/MSDN/WinAPI.txt, WinAPI.txt |
|
|
| Back to top |
|
 |
k3ph
Joined: 20 Jul 2006 Posts: 223
|
Posted: Fri Feb 13, 2009 5:42 am Post subject: |
|
|
awesome, thanks very much for this tool.
i wonder when you'll release an unified tool, grouping windows constants, winapi etc.. _________________ [ profile | ahk.net | ahk.talk ] |
|
| Back to top |
|
 |
ribbet.1
Joined: 20 Feb 2007 Posts: 197 Location: D.C.
|
Posted: Fri Sep 25, 2009 4:27 am Post subject: |
|
|
| WOW! |
|
| Back to top |
|
 |
Drugwash
Joined: 07 Sep 2008 Posts: 921 Location: Ploiesti, RO
|
Posted: Sat Sep 26, 2009 12:43 pm Post subject: |
|
|
Quite useful script, thank you! I could think of one possible addition that would however require a great amount of work and most likely processing time: check against the libraries in the current OS and only list the existing libraries that match the searched function.
The Google / MSDN goto is a most welcome function.  |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Thu Aug 26, 2010 6:53 pm Post subject: |
|
|
| Update: A newer dynamic version has been posted. Please refer the Title post |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|