C++: DllCall: get parameter types/sizes

Discuss other programming languages besides AutoHotkey
User avatar
jeeswg
Posts: 2930
Joined: 19 Dec 2016, 01:58
Location: UK

C++: DllCall: get parameter types/sizes

04 Nov 2017, 17:46

- Using the list of dlls and functions here:
WinApi
https://hotkeyit.github.io/v2/docs/commands/WinApi.htm
I created a list of all the raw parameter descriptions for each dll function, and removed the duplicates to give 7686 unique parameter names.
- I then attempted to create a struct definition based on each of these parameters and retrieve the size of them of in C++, the x64 and x32 sizes.
- I obtained all of the uppercase words and kept including .h files, and adding custom definitions, until all of them were defined.
- I pasted in definitions for all the structs, and tried multiple times to compile the script, retrieving a list of lines that had errors and commenting out those lines until the script compiled. I had to comment out about 10% of the struct definitions.

I used this AutoHotkey code to generate the list of structs.

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



I used this AutoHotkey code to generate a list of parameters and sizes based on the information already in Winapi.htm. I wanted to use the Winapi.htm information, and my C++ list, to help me check that my lists of dll functions and their parameter sizes/types were correct.

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



Every item generated by the script had a maximum size of 8 bytes or fewer. With these 7 exceptions.

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

_In_ CLSID clsid=16:16
_In_ const SYSTEMTIME lpSysTime=16:16
_In_ CRYPT_PKCS8_IMPORT_PARAMS sPrivateKeyAndParams=48:24
_In_ STGMEDIUM pmedium=24:12
_In_ VARIANT varFileName=24:16
_Out_ STGMEDIUM pmedium=24:12
WCHAR name[LF_FACESIZE]=64:64


To retrieve the output from the C++ script:

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

User avatar
jeeswg
Posts: 2930
Joined: 19 Dec 2016, 01:58
Location: UK

Re: C++: DllCall: get parameter types/sizes

04 Nov 2017, 18:31

Here is the C++ code I used, although with only 10 of the 7686 structs, so that it can fit in a post. I'm quite new to C++, so this the best I could come up with. I would welcome any comments or ideas for improving it.

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


Here's the full script:
Attachments
dll function parameters get sizes.zip
(111.62 KiB) Downloaded 5 times
HotKeyIt
Posts: 1549
Joined: 29 Sep 2013, 18:35
Contact:

Re: C++: DllCall: get parameter types/sizes

04 Nov 2017, 20:05

Many thanks for checking the parameters, much appreciated ;)
I have fixed 66 definitions and 710 functions in WinApi.
User avatar
jeeswg
Posts: 2930
Joined: 19 Dec 2016, 01:58
Location: UK

Re: C++: DllCall: get parameter types/sizes

04 Nov 2017, 20:31

Cheers, no problem. The Winapi.htm list has been useful to me many times and has been key in me checking and fixing my own small (700 or so) list of dll functions for correcting DllCall lines. ;)

Return to “Other Programming Languages”

Who is online

Users browsing this forum: No registered users and 1 guest