Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Helpful script writing tricks and HowTo's
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by jNizM » 04 Feb 2022, 04:31

4 | 4 when I use WinDef.h (but not sure why)

Code: Select all

CONST

A variable whose value is to remain constant during execution.
This type is declared in WinDef.h as follows:
#define CONST const
but all I found about const in WinDef.h is:

Code: Select all

typedef struct tagRECT
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;

typedef const RECT FAR* LPCRECT;

typedef struct _RECTL       /* rcl */
{
    LONG    left;
    LONG    top;
    LONG    right;
    LONG    bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL FAR* LPCRECTL;
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by TheArkive » 04 Feb 2022, 04:33

That makes sense. If you keep the compiler set to x86, then the size of that would certainly be 4, ptr size on x86.

I imagine the sizeof value would be 8 on x64 (pointer size).

EDIT: i mean x64 in 2nd sentence, so changed it.
Last edited by TheArkive on 04 Feb 2022, 04:41, edited 1 time in total.

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by TheArkive » 04 Feb 2022, 04:35

The size of any object that is referenced by pointer will always be pointer size, regardless of the size of the object that it points to. The actual size has to be determined by actually doing sizeof(real_object) such as sizeof(RECT) or sizeof(tagRECT).

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by TheArkive » 04 Feb 2022, 04:57

@jNizM

I was able to verify size = 4 | 8 where typedef const RECTL FAR* LPCRECTL.

Just wondering if you were able to do the same? I used MSVC BuildTools (just updated this morning).

But I don't think this is a case for CONST. I still think CONST should be removed from the list.

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by jNizM » 04 Feb 2022, 05:01

LPCRECT and LPCRECTL = 4 | 8
while the struct RECT and RECTL itself = 16 | 16
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by TheArkive » 04 Feb 2022, 05:07

Yes indeed, I got that as well. I plan to compute struct sizes in a later version of ConstScanner. But I'll do this is after I'm able to catalog as many entries as possible in a specific context (currently WIN64 AMD64 Unicode context).

The calcs will be done by just analyzing types and doing basic addition, and obeying union rules (largest element). And of course I will verify with compiler as often as possible.

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by jNizM » 04 Feb 2022, 05:27

[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile

User avatar
TheArkive
Posts: 1030
Joined: 05 Aug 2016, 08:06
Location: The Construct
Contact:

Re: Windows Data Type Sizes - DllCall() / NumGet() / NumPut()

Post by TheArkive » 04 Feb 2022, 08:24

Woah. That's a lot! Thanks for the links :D ... that will be helpful for me to either pick up where these projects left off, or to fill in extra data.

Thanks!

Post Reply

Return to “Tutorials (v1)”