list of dll functions with parameter types for DllCall

Helpful script writing tricks and HowTo's
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

list of dll functions with parameter types for DllCall

20 Apr 2017, 21:09

[Update:]
This list is being maintained here in a function called JEE_TidyDllCallGetList:
DllCall converter/cleaner (e.g. x32 to x64/x32 two-way compatible) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=31365

There is a longer list here, although note: parameters are specified with the correct size, but not necessarily the correct sign (signed/unsigned), unless they are return types, because sign only matters when you read a value.
WinApi
https://hotkeyit.github.io/v2/docs/commands/WinApi.htm

==================================================

See also:
list of handy dll functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=34017

This is a list of dll functions with parameter types, for use with DllCall. More dll functions may be added in future.

One major change that could happen is that more instances of 'Ptr' will be replaced with 'Ptr|IntP' or 'Ptr|Str' etc where appropriate.

The information at MSDN for dll functions and parameters is not always correct, or easy (possible?) to find, hence the presence of the word 'ERROR' in many places.

- Please use with caution.
- *Do not assume that the list is accurate.*
- Do notify of any errors.

I will provide code for generating this list in the near future.

The information is presented in 3 ways:
[dll\function,ReturnType,Type1,Type2,Type3,...][MSDN style]
[dll\function,Type1,Type2,Type3,...,(ReturnType)][AHK style]
[DllCall templates]

Note: GetProcAddress uses AStr.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by jeeswg on 12 Nov 2017, 15:20, edited 3 times in total.
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

21 Apr 2017, 00:59

I think this is a good idea. We could make an intelliSense for DllCalls with this.
However it would be good if you could host it at a different place than this forum e.g. GitHub so that other members can contribute. ( I would probably like to add opengl32.dll )
It would also be very nice if we could provide a little more details e.g. add names for the parameters and a bit of a description and a link to documentation.
Recommends AHK Studio
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

21 Apr 2017, 02:14

Yeah but they are not complete.
I think he implemented about 10% or less of opengls functionality.
Recommends AHK Studio
Helgef
Posts: 2478
Joined: 17 Jul 2016, 01:02
Contact:

Re: list of dll functions with parameter types for DllCall

22 Apr 2017, 17:26

Thanks for sharing jeeswg, I might use this :think:
As mentioned by nnnik, variable names would be nice. The link from guest3456 seems to have quite a few more functions, maybe you can parse that list ;)

Cheers!
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

22 Apr 2017, 20:18

Many thanks for the link, guest3456.

The AHK_H link is a game changer from my perspective, but I'll need to know how the struct information was retrieved (e.g. I download them from MSDN), and how it was confirmed whether a parameter type was signed/unsigned.

The work there is excellent, so credits to HotKeyIt and/or whoever else worked on it. So anybody who worked on it, it would be great to hear from you.

I've had quite a lot to think about, regarding dll functions, just as I thought I'd essentially finished what I set out to do, leaving me like a startled fawn. I'm going to have to 'come out of retirement' again, and come back to dll functions.

- list of parameter types, their sizes (in x64/x32), whether signed/unsigned
--> you can get the sizes using the C++ method ('including' header files where necessary)
--> in HotKeyIt's list, where did the parameter size/type information come from?
--> ... is there information inside the dlls?
--> ... you can get the signed/unsigned property by relying on other lists (bad)
--> ... can you get the signed/unsigned property by checking header files in Visual Studio perhaps?
--> e.g. '.h' files in C:\Program Files (x86)\Windows Kits\8.1
--> complicated, perhaps easier when I confirm certain things: adapting the information to allow things like 'Ptr|IntP' / 'Ptr|Str' / 'Ptr|PtrP'

- list of dlls, their functions, their structs
--> you can use SKAN's function to get a dll's list of functions
--> in HotKeyIt's list, where did the struct information come from?
--> ... downloading htms en masse from MSDN?
--> ... is the information available inside header in the Visual Studio folder?
--> are there errors in some of the structs at MSDN and/or other sources?

[SKAN's function to list a dll's functions]
DllListExports() - List of Function exports of a DLL - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=4563

- parsing structs to extract the parameter type and 'variable name', and know that the rest can be discarded
--> the information from the AHK_H link, gives me all sorts of test data, to check that my parser is perfect
--> ... that will then allow me to focus on being able to retrieve the 'variable names'
--> ... logically, information should be retrieved for every function in a dll

- which dlls to include
--> e.g. we need to handle msvcrt and Gdip functions [EDIT: it appears that gdiplus is in the AHK_H list]
--> I would advocate creating 2 files per dll, an MSDN-style file, and an AHK-style file
--> the dlls in HotKeyIt's list are virtually the same ones I included, I'm not planning to add any more, but people could propose dlls to add

- additional information to include
--> what did nnnik have in mind?
--> ... what functions does opengl32.dll have that you use, are you saying that the AHK_H list only lists 10% of opengl32's functions?
--> ... adding parameter names is fine
--> ... what is 'a bit of description', what other descriptive material beyond parameter types and 'variable names' would you like?
--> ... 'and a link to documentation', an MSDN link for every dll function?

What are the best resources/links available that could assist me to do further work on this topic, including the best list of parameter type names and their AHK equivalents.

Also, is there a difference between LPCVOID/LPVOID/PVOID/VOID* (are they all 'Ptr or PtrP'), and LPBOOL/PBOOL/BOOL* (are they all 'Ptr or IntP')? What is **?

Fundamentally I need to upload 3 things:
- my list of parameter types and their sizes (derived via C++, a massive list)
- confirm the best current list of parameter types and their AHK equivalents (and share my suggested extensions to it, or indeed my own version of it) (also any general non-AHK lists of parameter types and their sizes/signed/unsigned information)
- my functions for parsing dll structs (that I've written) and parsing the AHK_H list (that I'm about to write)

@Helgef, yes, you've pretty much summed up my line of thinking.

Cheers.

==================================================

Information example:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Summary of dll functions I posted cf. the AHK_H list:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



I will do some checks on the AHK_H list, counting the number of functions, and comparing them with the count returned by SKAN's function for listing functions in a dll.
Last edited by jeeswg on 23 Apr 2017, 10:11, edited 1 time in total.
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

23 Apr 2017, 09:03

You need to understand that OpenGL is not opengl32.dll. OpenGL is a specification of function names their received types etc.
Your graphics card vendor then creates an implementation of OpenGL and ships it with your graphics card driver.
If you install a new graphics card driver on Windows it is likely that openGL32.dll will change.
The second thing is that the specification of OpenGL grew and changed over the years. It never changed how functions work though just added new ones and removed old ones.
Not every graphics card supports every OpenGL version. The older the graphics card the more likel it is that will only support older OpenGL versions.
The latest specification is 4.5. You can look it up here.
However if you want backwards compatability you need every OpenGL function from every version. ( That's impossible to do alone )

jeeswg wrote:--> the dlls in HotKeyIt's list are virtually the same ones I included, I'm not planning to add any more, but people could propose dlls to add
You could solve this problem by hosting this list on github since other people could contribute to it. This would allow us to document .dlls that are not on MSDN e.g. Bass.dll SciLexer.dll...

jeeswg wrote:--> ... what is 'a bit of description', what other descriptive material beyond parameter types and 'variable names' would you like?
A one-liner about functionality would be nice. e.g "SubStr allows you to return a part of a string"
jeeswg wrote:--> ... 'and a link to documentation', an MSDN link for every dll function?
Yeah or wherever we find good documentation for that function.
What I pictured when I made those suggestions was a tool for an editor. Do you know what IntelliSense is? It is kind of an auto complete for functions/variables or whatever else you want completed but it also displays you information about the function as you type.
With this sort of document we could create such a tool for DllCalls and built them into AutoHotkeys main editors.
Recommends AHK Studio
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

23 Apr 2017, 09:43

@nnnik
Cheers for the OpenGL clarification, I did check the Wikipedia article, it wasn't very clear what it was.

Yes, I intend to try and get to grips with GitHub for this project. I.e. to start using it for the first time.

Regarding function descriptions and urls. I would advocate separate description/url ini files for each dll. So 4 files per dll: MSDN-style, AHK-style, description, link (url). Allowing more than one url per function, possibly pipe-separated. Although I have no desire to work on any description/link files myself. However, I do plan, completely separately, to create a list of handy dll functions with descriptions.

Yes, IntelliSense would be a good use for this information. Personally I would use hotstrings for certain dlls, and/or a hotkey/menu option that retrieves the dll function within some selected text, and expands it into a DllCall line. I often find IntelliSense slow to use in practice.

Many thanks for your comments.

[EDIT:] I think a 5th file per dll is needed, a raw, horizontal one-line version of the struct for each dll function, basically just like in the AHK_H list.
HotKeyIt
Posts: 1549
Joined: 29 Sep 2013, 18:35
Contact:

Re: list of dll functions with parameter types for DllCall

23 Apr 2017, 17:12

Attached is the definition file I built for a custom scite editor, including the description, I got the functions from various places, msdn, sdk headers...

Also attached user.ahk.api for SciTE4AutoHotkey and AHK_H.

EDIT:
Also note that for DllCall it is not important whether it is signed or unsigned for input parameter, only output parameter matters.
Also WinAPI does only accept pointer for IntP and similar. Using getvar(var:=0) you can retrieve that pointer for a variable to fill it (e.g. QueryPerformanceCounter(getvar(count:=0))). After calling the function you might need to read the parameter using functions like ToInt!
Attachments
user.ahk.zip
(89.4 KiB) Downloaded 92 times
DllCall Definitions.zip
(633.8 KiB) Downloaded 96 times
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

27 Apr 2017, 12:54

Lately I've been thinking about using JSON to encode this information.
Recommends AHK Studio
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

30 Apr 2017, 20:29

I'm planning to get the x64 and x86 parameter size values for the 19486 parameters in:
http://katahiromz.web.fc2.com/win32/winwords.txt

One issue would be: how many/which headers to include, to get as many as possible to work first time. (I'd fill some gaps in later.)

Another issue is that last time I did something similar I believe it clogged the system with the remnants of loads of small files (even though they were deleted and overwritten each time). I don't know if perhaps the AHK File object can overwrite files in a cleaner way. Also, the sheer number made it quite slow.

@nnnik
You can start collecting urls and descriptions if you like. A list of functions with urls that link to MSDN pages that contain the struct definitions would be very useful. Do you have some plans to retrieve urls systematically or do something like repeated Google 'I'm Feeling Lucky' searches? Thanks.
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

01 May 2017, 02:32

We will need to check every function that we add there by hand. I would probably add links then - though we could probably use scripts to automate the searching.
Recommends AHK Studio
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

01 May 2017, 02:50

If you do multiple Google searches, it thinks you're a bot and you have to do CAPTCHA

I used a search url template:
https://social.msdn.microsoft.com/search/en-US?query=MySearchText

And used InStr to find urls that started with this:
https://msdn.microsoft.com/en-us/library/windows/desktop

Although maybe an HTMLFile object could have worked.

I checked the webpage title and/or contents to make sure the page was the right one.

However maybe there are better ways, including using some MSDN indexes. Maybe even some websites that have done some of this already. When I collected information before it was for less than 600 functions, so it wasn't too bad.

Btw if you download all the MSDN pages the disk space can add up surprisingly.
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

01 May 2017, 17:06

@HotKeyIt: Thanks for the link.

[EDIT:] Package This! is a small GUI exe (161 KB) with a treeview of Windows related stuff. It was slow to load, I think it was gathering information from the Internet.

I spent a good amount of time looking through the treeview, but I couldn't find any references to dll functions! If you wouldn't mind, please say a little bit about how you use it. Thanks.

==================================================

I'm having problems getting the parameter types for:
ATLAPI / STDAPI / WINAPI / WINOLEAPI / WSAAPI
I.e. what do you put for ReturnType, is it Int, Ptr or something else?

Sources:
- MSDN
- pinvoke.net (look up a dll function that contains the parameter)
- .h files (manually reading .h files in C:\Program Files (x86)\Windows Kits\8.1) (checking for lines that start with '#define' or 'typedef')
- sizeof in C++ (no matter what .h files I include I can't get these to work with sizeof in C++)
- occasional Stack Overflow pages

Part of the problem is that I'm getting conflicting information.

==================================================

E.g.

[STDAPI is HRESULT]
STDAPI
https://msdn.microsoft.com/library/ms686631(vs.85).aspx
Defines an API function that returns an HRESULT.

[HRESULT is LONG, so STDAPI is LONG (i.e. Int)]
Windows Data Types (Windows)
https://msdn.microsoft.com/en-gb/library/windows/desktop/aa383751(v=vs.85).aspx
typedef LONG HRESULT;

[AccessibleObjectFromPoint returns STDAPI]
AccessibleObjectFromPoint function (Windows)
https://msdn.microsoft.com/en-us/library/windows/desktop/dd317977(v=vs.85).aspx

STDAPI AccessibleObjectFromPoint(
_In_ POINT ptScreen,
_Out_ IAccessible **ppacc,
_Out_ VARIANT *pvarChild
);

[AccessibleObjectFromPoint returns STDAPI which is IntPtr (i.e. INT_PTR i.e. Ptr)]
pinvoke.net: Search Results
[url]http://www.pinvoke.net/search.aspx?search=AccessibleObjectFromPoint&namespace=[All][/url]

IntPtr success = AccessibleObjectFromPoint(pt, out accObj, out varChildID);

==================================================
Last edited by jeeswg on 02 May 2017, 17:13, edited 6 times in total.
User avatar
nnnik
Posts: 2316
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: list of dll functions with parameter types for DllCall

01 May 2017, 17:18

Those are calling conventions, not return types.
https://autohotkey.com/boards/viewtopic ... 567#p32145
Recommends AHK Studio
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

20 May 2017, 09:03

You can use sizeof(DWORD) to find out that the size of DWORD is 4.

But you can do something like typeof or decltype to find out that DWORD is UInt? Cheers.

(C++ didn't have typeof, and decltype(DWORD) didn't work.)

[EDIT:] Another idea would be to write then read a value, to determine if the value was signed/unsigned. But I don't have too much experience with C++, so I wouldn't be sure how to do this.
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

05 Jul 2017, 10:06

As promised I created:
list of handy dll functions - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=34017

Btw when gdiplus.dll is used, which file is actually used, for example, it's not in my system32 folder on Windows 7, it seems to be present on the PC, but in some very obscure folders. Cheers.
User avatar
jeeswg
Posts: 3000
Joined: 19 Dec 2016, 01:58
Location: UK

Re: list of dll functions with parameter types for DllCall

26 Aug 2017, 23:04

DLL NAME TO DLL PATH
I searched in Google for 'gdiplus location' and found this link, which suggested to use LoadLibrary and GetModuleFileName.
where is the GDIPLUS.DLL ? - PowerBASIC Peer Support Community
https://forum.powerbasic.com/forum/jose-s-corner/discussion/51588-where-is-the-gdiplus-dll

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
SKAN
Posts: 310
Joined: 29 Sep 2013, 16:58

Re: list of dll functions with parameter types for DllCall

02 Sep 2017, 06:13

jeeswg wrote:DLL NAME TO DLL PATH


I wouldn't say the following is better.. Its just an another way:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




Edit: Without VarSetCapacity

Code: [Select all] [Download] GeSHi © Codebox Plus

DLL := "gdiplus.dll"

hModule := DllCall( "LoadLibrary", "Str","ImageHlp.dll", "Ptr" )
pLOADED_IMAGE := DllCall("ImageHlp\ImageLoad", "AStr",DLL, "Int",0, "UPtr")
dllPath := StrGet( NumGet(pLOADED_IMAGE+0),"" )
DllCall( "ImageHlp\ImageUnload", "Ptr",pLOADED_IMAGE )
DllCall( "FreeLibrary", "Ptr",hModule )

MsgBox % dllPath

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 4 guests