Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Crazy Scripting : WinAPI Listing [New Version]


  • Please log in to reply
21 replies to this topic
SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Newer Version

Posted Image


/*
[color=#225599]  ___  _    _     ___                 _    _             ___                      _
 | . \| |  | |   | __>_ _ ._ _  ___ _| |_ <_> ___ ._ _  | __>__   ___  ___  _ _ _| |_ ___
 | | || |_ | |_  | _>| | || ' |/ | ' | |  | |/ . \| ' | | _> \ \/| . \/ . \| '_> | | <_-<
 |___/|___||___| |_| `___||_|_|\_|_. |_|  |_|\___/|_|_| |___>/\_\|  _/\___/|_|   |_| /__/
                                                                 |_|[/color]
 [color=darkred]AutoHotkey PE Tool :[/color] [color=black]Lists all Exported Functions found in all \System Folder\DLL files.[/color]
 
 [color=black]Author:[/color] [color=indigo]SKAN - Suresh Kumar A N[/color] ( [email protected] )  [color=black]|  CD:20090109 / LM:20100827[/color]

                                                                                        */
#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 ) { ;[color=black]List of Exported Functions[/color] / [color=#AA0000]Comp@t: WIN32_NT +AHK +LA +LW[/color]
; By SKAN www.autohotkey.com/forum/viewtopic.php?p=379086#379086[color=#808080] CD:20100825/LM:20100827[/color]
 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
}

[*:1bybx926]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

[*:1bybx926]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

Posted Image

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.
kWo4Lk1.png

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Thanks a lot, this will help for sure.

godsstigma
  • Members
  • 222 posts
  • Last active: May 13 2011 03:09 AM
  • Joined: 04 Nov 2008
Thanks a million SKAN...

I really appreciate you doing this to help me and everyone else.

Chavez
  • Members
  • 256 posts
  • Last active: Oct 13 2009 01:27 PM
  • Joined: 20 Aug 2008
Nice idea, and it'll really help, but the auto-download part doesn't work, at least not here ;D
-Chavez.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

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.
kWo4Lk1.png

trik
  • Members
  • 1317 posts
  • Last active: Jun 11 2010 11:48 PM
  • Joined: 15 Jul 2007
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. >_>

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

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.
kWo4Lk1.png

mitchi
  • Members
  • 9 posts
  • Last active: Jan 31 2009 06:21 AM
  • Joined: 14 Jun 2008
I get this error when running the script ?

---------------------------
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   
---------------------------



SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
There is no problem with the script. Try copy/paste by blocking the text manually with mouse.

sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008

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:

IfNotExist, WinAPI.txt, UrlDownloadToFile 
, https://ahknet.autohotkey.com/~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:

IfNotExist, WinAPI.txt, UrlDownloadToFile[color=red],[/color]
 https://ahknet.autohotkey.com/~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.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
I hve changed the offending line as:

IfNotExist, WinAPI.txt 
   UrlDownloadToFile, https://ahknet.autohotkey.com/~Skan/Utils/MSDN/WinAPI.txt, WinAPI.txt


danalec
  • Members
  • 225 posts
  • Last active: Oct 03 2014 05:31 PM
  • Joined: 20 Jul 2006
awesome, thanks very much for this tool.
i wonder when you'll release an unified tool, grouping windows constants, winapi etc..

                                  [ profile ]


ribbet.1
  • Members
  • 198 posts
  • Last active: Feb 07 2012 01:21 AM
  • Joined: 20 Feb 2007
WOW!

Drugwash
  • Members
  • 1078 posts
  • Last active: May 24 2016 04:20 PM
  • Joined: 07 Sep 2008
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. 8)

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Update: A newer dynamic version has been posted. Please refer the Title post