key dll issues: calls and structs

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

key dll issues: calls and structs

03 Jan 2017, 02:04

I have been trying to resolve all my key dll issues,
before going on to finish my GUI functions project.
These are classic problems, and I've tried to collect and outline them in a useful way,
so that this page can benefit users generally.
Any feedback/answers to these questions would be most welcome.

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

(1) PTR

;which is correct?
Ptr := A_PtrSize ? "Ptr" : "UInt" ;this is copied from AutoHotkey Help
Ptr := A_PtrSize ? "Ptr" : "Int" ;but help also says Ptr is 'equivalent to Int or Int64 depending on whether the exe running the script is 32-bit or 64-bit'

;is this correct?
UPtr := A_PtrSize ? "UPtr" : "UInt"

on 64-bit
is Ptr equal to Int64?
is UPtr also equal to Int64? (because UPtr 'is only unsigned in 32-bit builds as AutoHotkey does not support unsigned 64-bit integers')

[EDIT 2]
The help says:
Ptr := A_PtrSize ? "Ptr" : "UInt" ; If A_PtrSize is not defined, use UInt instead.
surely it should be:
Ptr := A_PtrSize ? "Ptr" : "Int"
or am I missing something?

32-bit, Ptr := ???
32-bit, UPtr := "UInt" ;is this correct?
64-bit, Ptr := "Int64"
64-bit, UPtr := "Int64"

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

(2) TYPES

are these conversions correct?
[EDIT: they have been modified to reflect Windows_Data_Types.txt]

OpenProcess: DWORD BOOL DWORD (HANDLE)
VirtualAllocEx: HANDLE LPVOID SIZE_T DWORD DWORD (LPVOID)
WriteProcessMemory: HANDLE LPVOID LPCVOID SIZE_T SIZE_T (BOOL)
ReadProcessMemory: HANDLE LPCVOID LPVOID SIZE_T SIZE_T (BOOL)
VirtualFreeEx: HANDLE LPVOID SIZE_T DWORD (BOOL)
CloseHandle: HANDLE (BOOL)

OpenProcess: uint int uint (ptr)
VirtualAllocEx: ptr ptr uptr uint uint (ptr)
WriteProcessMemory: ptr ptr ptr uptr uptr (int)
ReadProcessMemory: ptr ptr ptr uptr uptr (int)
VirtualFreeEx: ptr ptr uptr uint (int)
CloseHandle: ptr (int)

GetMenuBarInfo: HWND LONG LONG PMENUBARINFO (BOOL)

GetMenuBarInfo: ptr int int PMENUBARINFO(ptr?) (int)

[EDIT: is PMENUBARINFO just a pointer to a MENUBARINFO struct, and therefore Ptr][unusual types not in the lists pose a problem, when you want certainly]

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

(3) STRUCTS

are these conversions correct?

MENUBARINFO: DWORD RECT HMENU HWND BOOL BOOL

MENUBARINFO: uint 16 ptr ptr int int
MENUBARINFO (x32): 4 16 4 4 4 4 ;but this is incorrect I believe?
MENUBARINFO (x32): 4 16 4 4 2 2 ;this is correct I've heard, but BOOL is int, so should it end '4 4'?
MENUBARINFO (x64): 4 16 8 8 4 4 ;is this correct (probably isn't), what about alignment?

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

(4) REFERENCE

not in sizeof.ahk:
struct=bits (x32)/bits (x64)
RECT=16/16
PMENUBARINFO=ptr/ptr ;correct?

;are these correct, UPtr of Ptr?
from sizeof.ahk:
_DWORD:="UInt"
_HMENU:="UPTR" ;Windows_Data_Types.txt says Ptr
_HWND:="UPTR" ;Windows_Data_Types.txt says Ptr
_BOOL:="Int"
_LONG:="Int"
_HANDLE:="UPTR" ;Windows_Data_Types.txt says Ptr
_LPVOID:="UPTR" ;Windows_Data_Types.txt says Ptr
_SIZE_T:="UPTR"
_LPCVOID:="UPTR" ;Windows_Data_Types.txt says Ptr

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

(5) _Struct.ahk and sizeof.ahk

[Class _Struct]+[Func sizeof] ! updated 01.04.12 ! ++AHKv2 - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/5515 ... 412-ahkv2/

_Struct.ahk and sizeof.ahk crashed when I tried
to input variations on the 'PROCESSENTRY32' example from the link above.
Although some variations and the original example did work.
(I tried both 32-bit/64-bit latest versions of AutoHotkey, v1.1.24.04, on Windows 7.)

(Any established methods to assist with calls and structs would be helpful.)

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

(6) DLL RETHINK
If we had lines such as those in sections (2) and (3), types and structs,
that would eliminate the biggest waste of time I have faced in AutoHotkey.
I searched through key scripts/libraries, and the AutoHotkey Help file,
and identified 479 dll functions and by using MSDN, 83 structs connected to them,
that if we produced one-liners for them as below, would solve the core of dll problems.

Lines like this which I do not guarantee to be correct (and could edit later on if wrong, and add in the x64 one):
for DllCall:
OpenProcess: uint int uint (ptr)
for structs (NumGet/NumPut):
MENUBARINFO (x32): 4 16 4 4 2 2

[EDIT: If there are any good scripts/libraries that happen to have a lot of dll calls/structs in them, that are assured to be accurate, that would be very useful.]
Last edited by jeeswg on 03 Jan 2017, 04:13, edited 6 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

03 Jan 2017, 02:06

[EDIT: STRUCTURES UPDATED TO INCLUDE SIZES]

Lists of dll functions and structs.
I searched through key scripts/libraries, and the AutoHotkey Help file
for dll functions in lines containing DllCall.
I collected an initial 479 dll functions and (by checking MSDN for references)
an initial 83 structs.

[EDIT: it seemed the CODE tags didn't hide any of the lines if they were comma-separated, they are now CRLF-separated.]

Code: Select all

FUNCTIONS

e.g. 479 dll functions
advapi32\AdjustTokenPrivileges
advapi32\CryptAcquireContextW
advapi32\CryptCreateHash
advapi32\CryptDestroyHash
advapi32\CryptGetHashParam
advapi32\CryptHashData
advapi32\CryptReleaseContext
advapi32\IsTextUnicode
advapi32\LookupPrivilegeValueW
advapi32\MD5Final
advapi32\MD5Init
advapi32\MD5Update
advapi32\OpenProcessToken
advapi32\RegOpenKeyExW
advapi32\RegQueryInfoKeyW
advapi32\RegQueryValueExW
comctl32\DllGetVersion
comctl32\ImageList_Add
comctl32\ImageList_Create
comctl32\ImageList_Replace
comctl32\ImageList_ReplaceIcon
comctl32\InitCommonControlsEx
crypt32\CryptStringToBinaryW
dwmapi\DwmGetWindowAttribute
dwmapi\DwmIsCompositionEnabled
gdi32\BitBlt
gdi32\CreateCompatibleBitmap
gdi32\CreateCompatibleDC
gdi32\CreateDIBSection
gdi32\CreateFontIndirectW
gdi32\CreateFontW
gdi32\CreatePen
gdi32\CreateSolidBrush
gdi32\DeleteDC
gdi32\DeleteEnhMetaFile
gdi32\DeleteObject
gdi32\GetDeviceCaps
gdi32\GetDIBits
gdi32\GetEnhMetaFileBits
gdi32\GetFontUnicodeRanges
gdi32\GetObjectW
gdi32\GetStockObject
gdi32\GetTextExtentPoint32W
gdi32\GetTextFaceW
gdi32\RealizePalette
gdi32\Rectangle
gdi32\SelectObject
gdi32\SelectPalette
gdi32\SetBkColor
gdi32\SetEnhMetaFileBits
gdi32\SetStretchBltMode
gdi32\SetTextColor
gdi32\StretchBlt
gdiplus\GdipAddPathEllipse
gdiplus\GdipAddPathPolygon
gdiplus\GdipBitmapGetPixel
gdiplus\GdipBitmapLockBits
gdiplus\GdipBitmapSetPixel
gdiplus\GdipBitmapSetResolution
gdiplus\GdipBitmapUnlockBits
gdiplus\GdipCloneBitmapArea
gdiplus\GdipCloneBrush
gdiplus\GdipCreateBitmapFromFile
gdiplus\GdipCreateBitmapFromFileICM
gdiplus\GdipCreateBitmapFromGdiDib
gdiplus\GdipCreateBitmapFromHBITMAP
gdiplus\GdipCreateBitmapFromHICON
gdiplus\GdipCreateBitmapFromScan0
gdiplus\GdipCreateBitmapFromStream
gdiplus\GdipCreateFont
gdiplus\GdipCreateFontFamilyFromName
gdiplus\GdipCreateFromHDC
gdiplus\GdipCreateHatchBrush
gdiplus\GdipCreateHBITMAPFromBitmap
gdiplus\GdipCreateHICONFromBitmap
gdiplus\GdipCreateImageAttributes
gdiplus\GdipCreateLineBrush
gdiplus\GdipCreateLineBrushFromRect
gdiplus\GdipCreateMatrix
gdiplus\GdipCreateMatrix2
gdiplus\GdipCreatePath
gdiplus\GdipCreatePen1
gdiplus\GdipCreatePen2
gdiplus\GdipCreateRegion
gdiplus\GdipCreateSolidFill
gdiplus\GdipCreateStringFormat
gdiplus\GdipCreateTexture
gdiplus\GdipCreateTexture2
gdiplus\GdipDeleteBrush
gdiplus\GdipDeleteFont
gdiplus\GdipDeleteFontFamily
gdiplus\GdipDeleteGraphics
gdiplus\GdipDeleteMatrix
gdiplus\GdipDeletePath
gdiplus\GdipDeletePen
gdiplus\GdipDeleteRegion
gdiplus\GdipDeleteStringFormat
gdiplus\GdipDisposeImage
gdiplus\GdipDisposeImageAttributes
gdiplus\GdipDrawArc
gdiplus\GdipDrawBezier
gdiplus\GdipDrawEllipse
gdiplus\GdipDrawImagePointsRect
gdiplus\GdipDrawImageRectRect
gdiplus\GdipDrawLine
gdiplus\GdipDrawLines
gdiplus\GdipDrawPie
gdiplus\GdipDrawRectangle
gdiplus\GdipDrawString
gdiplus\GdipFillEllipse
gdiplus\GdipFillPath
gdiplus\GdipFillPie
gdiplus\GdipFillPolygon
gdiplus\GdipFillRectangle
gdiplus\GdipFillRegion
gdiplus\GdipGetClip
gdiplus\GdipGetDC
gdiplus\GdipGetDpiX
gdiplus\GdipGetDpiY
gdiplus\GdipGetEncoderParameterList
gdiplus\GdipGetEncoderParameterListSize
gdiplus\GdipGetImageEncoders
gdiplus\GdipGetImageEncodersSize
gdiplus\GdipGetImageGraphicsContext
gdiplus\GdipGetImageHeight
gdiplus\GdipGetImageHorizontalResolution
gdiplus\GdipGetImagePixelFormat
gdiplus\GdipGetImageVerticalResolution
gdiplus\GdipGetImageWidth
gdiplus\GdipGraphicsClear
gdiplus\GdipImageRotateFlip
gdiplus\GdiplusShutdown
gdiplus\GdiplusStartup
gdiplus\GdipMeasureString
gdiplus\GdipReleaseDC
gdiplus\GdipResetClip
gdiplus\GdipResetWorldTransform
gdiplus\GdipRotateWorldTransform
gdiplus\GdipSaveImageToFile
gdiplus\GdipScaleWorldTransform
gdiplus\GdipSetClipPath
gdiplus\GdipSetClipRect
gdiplus\GdipSetClipRegion
gdiplus\GdipSetCompositingMode
gdiplus\GdipSetImageAttributesColorMatrix
gdiplus\GdipSetInterpolationMode
gdiplus\GdipSetSmoothingMode
gdiplus\GdipSetStringFormatAlign
gdiplus\GdipSetTextRenderingHint
gdiplus\GdipTranslateWorldTransform
imagehlp\ImageDirectoryEntryToData
imagehlp\ImageRvaToVa
imagehlp\MapAndLoad
imagehlp\UnMapAndLoad
kernel32\AllocConsole
kernel32\AttachConsole
kernel32\CloseHandle
kernel32\CreateFileW
kernel32\CreateProcessW
kernel32\CreateRemoteThread
kernel32\CreateToolhelp32Snapshot
kernel32\DeleteFileA
kernel32\DeleteFileW
kernel32\DeviceIoControl
kernel32\ExpandEnvironmentStringsW
kernel32\FileTimeToLocalFileTime
kernel32\FileTimeToSystemTime
kernel32\FindClose
kernel32\FindFirstFileW
kernel32\FindNextFileW
kernel32\FindResourceW
kernel32\FormatMessageA
kernel32\FormatMessageW
kernel32\FreeConsole
kernel32\FreeLibrary
kernel32\GetACP
kernel32\GetCommandLineW
kernel32\GetCurrentProcessId
kernel32\GetCurrentThreadId
kernel32\GetDiskFreeSpaceExW
kernel32\GetEnvironmentVariableW
kernel32\GetExitCodeThread
kernel32\GetFileAttributesW
kernel32\GetFileSizeEx
kernel32\GetLastError
kernel32\GetLocalTime
kernel32\GetLogicalDrives
kernel32\GetLogicalDriveStringsW
kernel32\GetModuleFileNameW
kernel32\GetModuleHandleW
kernel32\GetPriorityClass
kernel32\GetProcAddress
kernel32\GetProcessTimes
kernel32\GetStdHandle
kernel32\GetTempFileNameW
kernel32\GetVersion
kernel32\GetVersionExW
kernel32\GlobalAlloc
kernel32\GlobalFree
kernel32\GlobalLock
kernel32\GlobalSize
kernel32\GlobalUnlock
kernel32\IsWow64Process
kernel32\LCMapStringW
kernel32\LoadLibraryW
kernel32\LoadResource
kernel32\LocalFileTimeToFileTime
kernel32\LockResource
kernel32\lstrcpy
kernel32\lstrcpyn
kernel32\lstrlen
kernel32\Module32First
kernel32\Module32Next
kernel32\MulDiv
kernel32\MultiByteToWideChar
kernel32\OpenProcess
kernel32\QueryPerformanceCounter
kernel32\ReadFile
kernel32\ReadProcessMemory
kernel32\RtlFillMemory
kernel32\RtlMoveMemory
kernel32\RtlZeroMemory
kernel32\SetFilePointerEx
kernel32\SetFileTime
kernel32\SetLastError
kernel32\SetProcessShutdownParameters
kernel32\SetSystemTime
kernel32\SizeofResource
kernel32\Sleep
kernel32\SystemTimeToFileTime
kernel32\SystemTimeToTzSpecificLocalTime
kernel32\TzSpecificLocalTimeToSystemTime
kernel32\VirtualAllocEx
kernel32\VirtualFreeEx
kernel32\VirtualProtect
kernel32\VirtualProtectEx
kernel32\VirtualQueryEx
kernel32\WaitForSingleObject
kernel32\WideCharToMultiByte
kernel32\Wow64DisableWow64FsRedirection
kernel32\WriteFile
kernel32\WriteProcessMemory
Magnification\MagInitialize
Magnification\MagSetImageScalingCallback
Magnification\MagSetWindowSource
Magnification\MagSetWindowTransform
Magnification\MagUninitialize
msvcrt\_wcsrev
msvcrt\atan2
msvcrt\atof
msvcrt\memcmp
msvcrt\memcpy
msvcrt\sprintf
msvcrt\swprintf
msvcrt\wcsstr
ntdll\RtlComputeCrc32
ole32\CLSIDFromProgID
ole32\CLSIDFromString
ole32\CoCreateGuid
ole32\CoCreateInstance
ole32\CoGetObject
ole32\CoInitialize
ole32\CoTaskMemAlloc
ole32\CoTaskMemFree
ole32\CoUninitialize
ole32\CreateStreamOnHGlobal
ole32\IsEqualGUID
ole32\OleInitialize
ole32\OleUninitialize
ole32\ProgIDFromCLSID
ole32\StringFromGUID2
oleacc\AccessibleChildren
oleacc\AccessibleObjectFromEvent
oleacc\AccessibleObjectFromPoint
oleacc\AccessibleObjectFromWindow
oleacc\GetRoleTextA
oleacc\GetRoleTextW
oleacc\GetStateTextA
oleacc\GetStateTextW
oleacc\ObjectFromLresult
oleacc\WindowFromAccessibleObject
oleaut32\DispGetParam
oleaut32\GetActiveObject
oleaut32\SafeArrayAccessData
oleaut32\SafeArrayDestroy
oleaut32\SafeArrayGetDim
oleaut32\SafeArrayUnaccessData
oleaut32\SysAllocString
oleaut32\SysFreeString
oleaut32\SysStringLen
oleaut32\VariantChangeTypeEx
oleaut32\VariantClear
powrprof\SetSuspendState
psapi\EnumProcesses
psapi\GetMappedFileNameW
psapi\GetModuleBaseNameW
psapi\GetModuleFileNameExA
psapi\GetModuleFileNameExW
psapi\GetProcessImageFileNameW
shell32\ExtractIconEx
shell32\SHAddToRecentDocs
shell32\SHBindToParent
shell32\SHChangeNotify
shell32\Shell_NotifyIcon
shell32\SHGetFileInfo
shell32\SHGetFileInfoW
shell32\SHGetFolderLocation
shell32\SHGetFolderPathW
shell32\SHParseDisplayName
shell32\SHQueryRecycleBinA
shlwapi\AssocQueryStringW
shlwapi\PathCreateFromUrlW
shlwapi\SHGetViewStatePropertyBag
shlwapi\StrCmpLogicalW
shlwapi\StrCmpNW
shlwapi\StrStrIW
shlwapi\UrlCreateFromPathW
user32\AttachThreadInput
user32\CallNextHookEx
user32\CallWindowProcA
user32\CallWindowProcW
user32\CharLowerW
user32\CharUpperW
user32\ClientToScreen
user32\CloseClipboard
user32\CopyIcon
user32\CopyImage
user32\CountClipboardFormats
user32\CreateCaret
user32\CreateCursor
user32\CreateDialogParamW
user32\CreateIconFromResourceEx
user32\CreatePopupMenu
user32\CreateWindowExW
user32\DefWindowProcW
user32\DestroyIcon
user32\DestroyMenu
user32\DrawIconEx
user32\DrawTextExW
user32\DrawTextW
user32\EmptyClipboard
user32\EnableMenuItem
user32\EnumClipboardFormats
user32\EnumDisplayDevicesW
user32\EnumWindows
user32\FillRect
user32\FindWindowExW
user32\FindWindowW
user32\GetActiveWindow
user32\GetAncestor
user32\GetCaretBlinkTime
user32\GetCaretPos
user32\GetClassLongW
user32\GetClientRect
user32\GetClipboardData
user32\GetClipboardFormatNameW
user32\GetCursorInfo
user32\GetCursorPos
user32\GetDC
user32\GetDCEx
user32\GetFocus
user32\GetForegroundWindow
user32\GetGUIThreadInfo
user32\GetIconInfo
user32\GetKeyNameTextW
user32\GetMenu
user32\GetMenuBarInfo
user32\GetMenuItemCount
user32\GetMenuItemID
user32\GetMenuItemInfoW
user32\GetMenuItemRect
user32\GetMenuStringW
user32\GetOpenClipboardWindow
user32\GetParent
user32\GetScrollPos
user32\GetSubMenu
user32\GetSysColor
user32\GetSystemMenu
user32\GetWindow
user32\GetWindowInfo
user32\GetWindowLongW
user32\GetWindowRect
user32\GetWindowRgnBox
user32\GetWindowTextA
user32\GetWindowThreadProcessId
user32\HideCaret
user32\InsertMenuW
user32\InvalidateRect
user32\IsCharAlphaW
user32\IsChild
user32\IsClipboardFormatAvailable
user32\IsWindow
user32\IsWindowUnicode
user32\IsWindowVisible
user32\LoadCursorFromFileW
user32\LoadCursorW
user32\LoadIconW
user32\LoadImageA
user32\LoadImageW
user32\LoadStringW
user32\LockWorkStation
user32\MessageBoxW
user32\ModifyMenuW
user32\OpenClipboard
user32\PaintDesktop
user32\PostMessageW
user32\PrintWindow
user32\PrivateExtractIconsW
user32\RedrawWindow
user32\RegisterClassW
user32\RegisterClipboardFormatW
user32\RegisterWindowMessageW
user32\ReleaseDC
user32\RemoveMenu
user32\ScreenToClient
user32\SendMessageA
user32\SendMessageW
user32\SetCaretBlinkTime
user32\SetClassLongW
user32\SetClipboardData
user32\SetCursorPos
user32\SetForegroundWindow
user32\SetMenu
user32\SetMenuInfo
user32\SetMenuItemBitmaps
user32\SetMenuItemInfoW
user32\SetParent
user32\SetRect
user32\SetSysColors
user32\SetSystemCursor
user32\SetWindowLongW
user32\SetWindowPos
user32\SetWindowsHookExW
user32\SetWinEventHook
user32\ShowCaret
user32\ShowWindow
user32\SystemParametersInfoW
user32\TrackPopupMenu
user32\TrackPopupMenuEx
user32\UnhookWinEvent
user32\UpdateLayeredWindow
user32\wsprintfA
user32\wsprintfW
uxtheme\SetWindowThemeAttribute
version\GetFileVersionInfoSizeW
version\GetFileVersionInfoW
version\VerQueryValueW
wininet\FtpCreateDirectoryW
wininet\FtpDeleteFileW
wininet\FtpFindFirstFileW
wininet\FtpGetCurrentDirectoryW
wininet\FtpGetFileSize
wininet\FtpGetFileW
wininet\FtpOpenFileW
wininet\FtpPutFileW
wininet\FtpRemoveDirectoryW
wininet\FtpRenameFileW
wininet\FtpSetCurrentDirectoryW
wininet\InternetCloseHandle
wininet\InternetConnectW
wininet\InternetFindNextFileW
wininet\InternetGetLastResponseInfoW
wininet\InternetOpenUrlW
wininet\InternetOpenW
wininet\InternetQueryDataAvailable
wininet\InternetReadFile
wininet\InternetSetStatusCallback
wininet\InternetWriteFile
winmm\timeBeginPeriod
winmm\timeEndPeriod
ws2_32\connect
ws2_32\htons
ws2_32\inet_addr
ws2_32\recv
ws2_32\socket
ws2_32\WSAAsyncSelect
ws2_32\WSACleanup
ws2_32\WSAGetLastError
ws2_32\WSAStartup

Code: Select all

STRUCTURES (struct name, size in bits x64, size in bits x32)

e.g. 90 structures (MSDN article title of the form '__ structure')
ACCESSTIMEOUT=12:12
ANIMATIONINFO=8:8
API_VERSION=8:8
AUDIODESCRIPTION=12:12
BIND_OPTS=16:16
BITMAP=32:24
BITMAPINFO=44:44
BITMAPINFOHEADER=40:40
BLENDFUNCTION=4:4
CHARFORMAT2=116:116
CLIENTCREATESTRUCT=16:8
COMBOBOXINFO=64:52
COPYDATASTRUCT=24:12
COSERVERINFO=32:16
CREATESTRUCT=80:48
CURSORINFO=24:20
DIBSECTION=104:84
DISPLAY_DEVICE=840:840
DISPPARAMS=24:16
DLLVERSIONINFO=20:20
DLLVERSIONINFO2=32:32
DRAWTEXTPARAMS=20:20
FILETIME=8:8
FILTERKEYS=24:24
GLYPHSET=20:20
GOPHER_FIND_DATA=1588:1588
GUID=16:16
GUITHREADINFO=72:48
HDITEM=72:48
HIGHCONTRAST=16:12
ICONINFO=32:20
ICONMETRICS=108:108
IMAGELISTDRAWPARAMS=88:68
IN6_ADDR=16:16
IN_ADDR=4:4
INITCOMMONCONTROLSEX=8:8
ITEMIDLIST=3:3
LOADED_IMAGE=88:48
LOGFONT=92:92
LOGFONTA=60:60
LOGFONTW=92:92
LOGPALETTE=8:8
LOGPEN=16:16
LVITEM=88:60
MDICREATESTRUCT=56:36
MEMORY_BASIC_INFORMATION=48:28
MENUBARINFO=48:32
MENUINFO=40:28
MENUITEMINFO=80:48
MENUITEMINFOW=80:48
MINIMIZEDMETRICS=20:20
MODULEENTRY32=1080:1064
MONITORINFOEX=104:104
MOUSEKEYS=28:28
MULTI_QI=24:12
NONCLIENTMETRICS=504:504
NOTIFYICONDATA=976:956
OPENFILENAMEW=152:88
OSVERSIONINFOEX=284:284
OVERLAPPED=32:20
POINT=8:8
PROCESS_INFORMATION=24:16
RECT=16:16
SECURITY_ATTRIBUTES=24:12
SHARDAPPIDINFOLINK=16:8
SHELLEXECUTEINFO=112:60
SHFILEINFO=696:692
SHQUERYRBINFO=24:20
SIZE=8:8
SOUNDSENTRY=56:48
STARTUPINFO=104:68
STARTUPINFOEX=112:72
STICKYKEYS=8:8
STRRET=272:264
SYSTEMTIME=16:16
TBBUTTON=32:20
THREADENTRY32=28:28
TIME_ZONE_INFORMATION=172:172
TOGGLEKEYS=8:8
TOKEN_PRIVILEGES=16:16
TPMPARAMS=20:20
TVITEM=56:40
VARIANT=24:16
VS_FIXEDFILEINFO=52:52
WIN32_FIND_DATA=592:592
WINDOWINFO=60:60
WNDCLASS=72:40
WNDCLASSEX=80:48
WNDCLASSW=72:40
WSADATA=408:400
Last edited by jeeswg on 11 Jan 2017, 03:25, edited 6 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 2453
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: key dll issues: calls and structs

03 Jan 2017, 02:36

May this helps you a bit: Windows Data Types for AHK

eg

Code: Select all

hProcess := DllCall("OpenProcess", "uint", dwDesiredAccess, "int", bInheritHandle, "uint", dwProcessId, "ptr")
; some code
DllCall("CloseHandle", "ptr", hProcess)
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
just me
Posts: 6464
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: key dll issues: calls and structs

03 Jan 2017, 02:59

(1) PTR
;which is correct?

Code: Select all

Ptr := A_PtrSize ? "Ptr" : "UInt" ;this is copied from AutoHotkey Help
This is the common method to make scripts AHK 1.0 (Basic) compatible. You shouldn't use it anymore.
on 64-bit
is Ptr equal to Int64?
is UPtr also equal to Int64? (because UPtr 'is only unsigned in 32-bit builds as AutoHotkey does not support unsigned 64-bit integers')
Yes.
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: key dll issues: calls and structs

03 Jan 2017, 03:32

MENUBARINFO: int 16 ptr ptr int int
DWORD is not equivalent to int. DWORD is unsigned.
MENUBARINFO (x32): 4 16 4 4 4 4 ;but this is incorrect I believe?
No, it is correct.
MENUBARINFO (x64): 4 16 8 8 4 4 ;is this correct (probably isn't), what about alignment?
As you guessed, it is incorrect due to alignment requirements.

The alignment requirement of a struct is the biggest alignment requirement of any of its members, so RECT must be aligned at a 32-bit boundary, which isn't a problem in this case.

By default, 64-bit integral fields must be aligned on a 64-bit boundary (an offset which is a multiple of 64 bits). A byte is 8 bits, so 64 bits = 8 bytes. If the first two fields are together 20 bytes, that would mean the next field would start at offset 20; but because of its alignment requirement, hMenu starts at the next multiple of 8, offset 24.

Alignment requirements can be overridden, but they are not for most of the structs defined in the Windows SDK.
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

03 Jan 2017, 04:21

Thank you all three of you, jNizM, just me and lexikos for some very useful information.
Apologies that some of the information I posted was wrong, I based it on sizeof.ahk, and don't really
have too much of a way of verifying what information is or isn't correct.
I could then assume that Windows_Data_Types.txt is correct, but what if there
is one typo there somewhere, or one A/U/32/64 difference not referred to!

MENUBARINFO (x32): 4 16 4 4 4 4 [size 36]

Regarding MENUBARINFO, so in 32-bit, its size is 36,
and the information in the two links below is incorrect:

WWW Tech Support/WinBatch/How To\Determine If Menu Bar Has Been Clicked.txt
http://techsupt.winbatch.com/webcgi/web ... licked.txt

The last two members of the MENUBARINFO structure are declared as bit fields. Change the structure size from 36 to 32 bytes and it should work.

Make this control Transparent? - Ask for Help - AutoHotkey Community
https://autohotkey.com/board/topic/5234 ... ansparent/

VarSetCapacity(pbmi,32,0) ;menubarinfo

(No wonder I'm having problems when there's conflicting information.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 2453
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: key dll issues: calls and structs

03 Jan 2017, 07:19

Code: Select all

typedef struct tagMENUBARINFO
{
    DWORD cbSize;
    RECT rcBar;          // rect of bar, popup, item
    HMENU hMenu;         // real menu handle of bar, popup
    HWND hwndMenu;       // hwnd of item submenu if one
    BOOL fBarFocused:1;  // bar, popup has the focus
    BOOL fFocused:1;     // item has the focus
} MENUBARINFO, *PMENUBARINFO, *LPMENUBARINFO;
sizeof(MENUBARINFO) with visual studio
x86 -> 32
x64 -> 48
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

03 Jan 2017, 11:39

Wow, jNizM! Do you have C++ code for that?
It would be good to make a command line exe that
accepts a parameter of a path (to a txt file containing the struct info copied from MSDN),
and then outputs the x32 and x64 sizeof values to stdout e.g. '32,48'.
('Hello World' and compiling JXRDecApp.exe from 'solution' files is my current level,
although I have read and understood a lot of the AHK source.)

Btw can the size of each parameter be retrieved, which is presumably:
'4 16 4 4 2 2' in this case, and similarly the offsets.
The example posted for MENUBARINFO, suggests that structs can be *smaller*
than the sum of their members, which is very confusing.

Btw I've found quite a few sources on alignments, but am finding
it hard to find a source that is both complete and straightforward to read.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 6488
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: key dll issues: calls and structs

05 Jan 2017, 01:23

I see. The struct definition on MSDN is incorrect, as one user has commented. Some information in my post was based on this incorrect definition.

I'm not very familiar with bit fields, but I'm fairly certain that fBarFocused and fFocused are not 2 bytes each. I suppose they are 1 bit each, followed by 30 unused bits. That is, they are 2 bits within a single "BOOL".
User avatar
jNizM
Posts: 2453
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: key dll issues: calls and structs

05 Jan 2017, 02:19

Here is an example I used (based on the info 'just me' told me how to work with them) in my nvapi-class
_NV_HDMI_SUPPORT_INFO_V2 Struct Reference (nvapi)
src/Class_NvAPI.ahk#L388 (github)
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 02:45

@lexikos, Eureka! Bit of a weird 'BOOL' that can be 0/1/2/3.
Are there any other weird anecdotes about dlls and structs
or known errors that anyone would like to share?

@jNizM, thank you for the link.
From where does sizeinfo get its information,
do you feed it the struct information from MSDN as a string?
Do you have a good link with C++ code for sizeof?
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 2453
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: key dll issues: calls and structs

05 Jan 2017, 02:58

I use AutoHotkey for this. Add the header and the struct name.
It generates a sizeof.cpp -> compile -> output = size

Pure sizeof.cpp looks like this:

Code: Select all

#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>

int main()
{
    std::cout << sizeof(MONITORINFOEX) << std::endl;
    return 0;
}
I use Visual Studio Community 2015 with Update 3 (with C++ settings & latest Windows Kits)
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 03:10

Great! I used your code, with the word MENUBARINFO, it returned 32, that is very very easy. How to do 64-bit? I'll share the results for the structs listed above when completed. Thanks so much.

Btw does it work on dll functions too? Since they are effectively structs? (I.e. specify a dll name/path and a function name.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jNizM
Posts: 2453
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: key dll issues: calls and structs

05 Jan 2017, 03:20

I compile it and catch the output.

For 64-Bit:

Code: Select all

@ECHO OFF
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\cl.exe" sizeof.cpp
For 32-Bit:

Code: Select all

@ECHO OFF
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\cl.exe" sizeof.cpp
[AHK] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1903) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 03:44

YESSS! I'm on fire like Mariah today!
I had a lot of trouble getting it all set up, but I've got it working now!
I'll explain in a moment. Your example seems to be 104 on both x32 and x64,
so that didn't confirm a difference,
however I also got 32 and 48 for MENUBARINFO as you did.
Last edited by jeeswg on 05 Jan 2017, 05:43, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 03:52

Well I'm sure glad you were around to answer the question. Cheers!
Btw my 64-bit Visual Studio paths were slightly different from yours.

Get sizeof values for structs (32-bit and 64-bit) via Visual Studio:

Code: Select all

==================================================
create sizeof32.cpp and sizeof64.cpp with identical contents as below,
with the name of your chosen struct e.g. MENUBARINFO
==================================================
#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>

int main()
{
    std::cout << sizeof(MENUBARINFO) << std::endl;
    return 0;
}
==================================================
create sizeof32.bat with contents as below
(paths depend on your version of Visual Studio)
==================================================
@ECHO OFF
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe" sizeof32.cpp
==================================================
create sizeof64.bat with contents as below
(paths depend on your version of Visual Studio)
==================================================
@ECHO OFF
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe" sizeof64.cpp
==================================================
now run sizeof32.bat and sizeof64.bat
to generate sizeof32.exe and sizeof64.exe
==================================================
now run sizeof32.exe and sizeof64.exe
they will return the sizeof values for your struct
==================================================
Last edited by jeeswg on 05 Jan 2017, 04:57, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 04:57

It appears that for invalid structure names like 'BISCUITBISC',
the exe never compiles.
I have obtained values for the roughly 90 structs above, but will
do some double-checking before posting them later today.

[EDIT: they are now posted above, see post 2, 18 of the 92 had errors compiling.]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

05 Jan 2017, 14:06

I provide below the code I used to retrieve 32-bit/64-bit sizeof information about structs
such as MENUBARINFO, via Visual Studio.
Taking the dll function GetMenuBarInfo as an example:
it also works on parameters like BOOL, HWND, LONG
and even the obscure PMENUBARINFO.

I will be producing further lists:
one for the sizes of common parameters,
one for additional structs listed within the file WinUser.h.

The WinUser.h file appears to have the same definition
as that on the MSDN page, suggesting perhaps
that sizeof has some special conditions for handling
consecutive BOOLs, merging them as one parameter.

The other key piece of useful information would be
to know the offsets for each parameter in a struct.
A further piece of useful information would be to know
for each parameter is it Ptr/UPtr etc.

One query is: if more files are included in the cpp file,
in addition to Winuser.h,
will there be additional structures for which the
sizeof values can be retrieved.

Code: Select all

;==================================================

vPath = %A_Desktop%\z list structs.txt
FileRead, vList, %vPath%
vList := JEE_StrReplace(vList, "`r`n", ",", "All")

vDir = %A_Desktop%\cpp sizeof
IfNotExist, %vDir%
FileCreateDir, %vDir%
vPathVS1 = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\vcvars32.bat
vPathVS2 = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\cl.exe
vPathVS3 = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat
vPathVS4 = C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe

Loop, 4
{
if FileExist(vPathVS%A_Index%)
continue
MsgBox % "error: Visual Studio file not found:`r`n" vPathVS%A_Index%
Return
}

;==================================================

vOutput := ""
VarSetCapacity(vOutput, 1000000*2)
Loop, Parse, vList, `,
{
vStruct := A_LoopField
if (vStruct = "")
continue

;===============
vOutput1 = ;continuation section
(Join`r`n
#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>

int main()
{
    std::cout << sizeof(%vStruct%) << std::endl;
    return 0;
}
)
;===============
vOutput2 = ;continuation section
(Join`r`n
@ECHO OFF
CALL "%vPathVS1%"
"%vPathVS2%" sizeof32.cpp
)
;===============
vOutput3 = ;continuation section
(Join`r`n
@ECHO OFF
CALL "%vPathVS3%"
"%vPathVS4%" sizeof64.cpp
)
;===============

vPath1A = %vDir%\sizeof32.cpp
vPath1B = %vDir%\sizeof64.cpp
vPath2 = %vDir%\sizeof32.bat
vPath3 = %vDir%\sizeof64.bat
vPath4 = %vDir%\sizeof32.exe
vPath5 = %vDir%\sizeof64.exe

IfExist, %vPath1A%
FileRecycle, %vPath1A%
IfExist, %vPath1B%
FileRecycle, %vPath1B%
FileAppend, %vOutput1%, *%vPath1A%
FileAppend, %vOutput1%, *%vPath1B%

IfNotExist, %vPath2%
FileAppend, %vOutput2%, *%vPath2%
IfNotExist, %vPath3%
FileAppend, %vOutput3%, *%vPath3%

RunWait, "%vPath2%", %vDir%, Hide
RunWait, "%vPath3%", %vDir%, Hide

vSize32 := vSize64 := "ERROR"
IfExist, %vPath4%
vSize32 := JEE_RunGetStdOut(vPath4)
else
vSize32 := "ERROR"
IfExist, %vPath5%
vSize64 := JEE_RunGetStdOut(vPath5)
else
vSize64 := "ERROR"

if (SubStr(vSize32, 1-2) = "`r`n")
vSize32 := SubStr(vSize32, 1, -2) ;trim right
if (SubStr(vSize64, 1-2) = "`r`n")
vSize64 := SubStr(vSize64, 1, -2) ;trim right

vOutput .= vStruct "=" vSize32 "," vSize64 "`r`n"

FileRecycle, %vPath4%
FileRecycle, %vPath5%
;JEE_Progress(vStruct " " vSize32 " " vSize64, 800)
;if (A_Index = 5)
;break
}

vPath = %A_Desktop%\z list structs sizeof %A_Now%.txt
FileAppend, %vOutput%, *%vPath%, UTF-8
Run, "%vPath%"
;JEE_MsgBox("done")
MsgBox done
Return

;==================================================

JEE_RunGetStdOut(vTarget)
{
DetectHiddenWindows, On
Run, %ComSpec%, , Hide, vPID
WinWait, ahk_pid %vPID%
DllCall("AttachConsole", "UInt", vPID)
objShell := ComObjCreate("WScript.Shell")
objExec := objShell.Exec(vTarget)
vStdOut := ""
While, !objExec.StdOut.AtEndOfStream
vStdOut := objExec.StdOut.ReadAll()
DllCall("FreeConsole")
Process Close, %vPID%
Return vStdOut
}

;==================================================

JEE_StrReplace(ByRef vInputVar, vSearchText, vReplaceText="", vAll="", vCaseSen="")
{
vCaseSenOrig := A_StringCaseSense
StringCaseSense, % vCaseSen ? "On" : "Off"
StringReplace, vOutput, vInputVar, %vSearchText%, %vReplaceText%, %vAll%
StringCaseSense, %vCaseSenOrig%
Return vOutput
}

;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

11 Jan 2017, 04:00

By including more references to .h files,
in the cpp files, sizeof works on more structs.
I now have values for all of the 90 structs in post 2 above.

Code: Select all

;==================================================
;before
#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>

int main()
{
    std::cout << sizeof(MONITORINFOEX) << std::endl;
    return 0;
}
;==================================================
;after
#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>
#include <CommCtrl.h>
#include <Richedit.h>
#include <Shlwapi.h>
#include <WinInet.h>
#include <TlHelp32.h>
#include <ShlObj.h>
#include <DbgHelp.h>
#include <In6addr.h>

int main()
{
    std::cout << sizeof(MONITORINFOEX) << std::endl;
    return 0;
}
;==================================================
By copying and pasting a struct definition from MSDN,
or a .h file, sizeof can be used to calculate
the size of a struct directly, rather than look up
the value from pre-calculated results.

Below is an example where the MENUBARINFO struct
is calculated as well as looked up.

Code: Select all

;==================================================
#define UNICODE 1
#include <iostream>
#include <windows.h>
#include <Winuser.h>
#include <CommCtrl.h>
#include <Richedit.h>
#include <Shlwapi.h>
#include <WinInet.h>
#include <TlHelp32.h>
#include <ShlObj.h>
#include <DbgHelp.h>
#include <In6addr.h>

struct TESTMENUBARINFO {
	DWORD cbSize;
	RECT  rcBar;
	HMENU hMenu;
	HWND  hwndMenu;
	BOOL  fBarFocused;
	BOOL  fFocused;
};

int main()
{
	std::cout << sizeof(TESTMENUBARINFO) << std::endl;
	std::cout << sizeof(MENUBARINFO) << std::endl;
	return 0;
}
;==================================================
Checking the 90 structs above I got the following discrepancies:
looked up directly v. calculated from struct:
LOGFONTA=60:60 [calculated: 92:92]
MENUBARINFO=48:32 [calculated: 48:36]
NOTIFYICONDATA=976:956 [calculated: 848:828]
SHQUERYRBINFO=24:20 [calculated: 24:24]

CHARFORMAT2=116:116 [calculated: ERROR:ERROR]
HDITEM=72:48 [calculated: ERROR:ERROR]
LVITEM=88:60 [calculated: ERROR:ERROR]
NONCLIENTMETRICS=504:504 [calculated: ERROR:ERROR]
OPENFILENAMEW=152:88 [calculated: ERROR:ERROR]

(I don't know why the compiling failed for the bottom 5.)

I have changed how I present the information in post 2,
putting the x64 value on the left
e.g. MENUBARINFO=48:32
to make it handy for code lines such as:
vSize := (A_PtrSize=8 ? 48:32).

I'll be increasing the size of the structs/parameters
list in post 2 from 90 to 824 after some checks.

Sources of information include .h files in
C:\Program Files (x86)\Windows Kits\8.1
and struct/dll definitions on MSDN.

Also:
Windows Data Types (Windows)
https://msdn.microsoft.com/en-us/librar ... s.85).aspx
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6648
Joined: 19 Dec 2016, 01:58
Location: UK

Re: key dll issues: calls and structs

11 Jan 2017, 20:08

HELP: I believe that when I compile a cpp file
and run sizeof, in x32 and x64 exe versions,
the parameter sizes are adjusted appropriately e.g. for HICON 8/4 (x64/x32),
however, I believe the padding/alignment,
is calculated as though it was x32 in both cases.

[EDIT: or maybe x32 and x64 actually have the same alignment rules,
so the only difference between x32/x64 structs,
is that now sometimes some of the parameters are bigger in x64 than in x32,
and just need to be shuffled about.]

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

I have been trying to understand alignment,
and believe the following is correct:
[EDIT: since amended see bottom of post]

(Not all the rules, but some of them:)
The rules of alignment (padding:)

32-bit:
1-byte/8-bit Char starts on a multiple of 1
2-byte/16-bit Short starts on a multiple of 2
4-byte/32-bit Int starts on a multiple of 4 [<<< the difference]
8-byte/64-bit Int64 starts on a multiple of 4 [<<< the difference] [EDIT: I now believe this is wrong]

64-bit:
1-byte/8-bit Char starts on a multiple of 1
2-byte/16-bit Short starts on a multiple of 2
4-byte/32-bit Int starts on a multiple of 8 [<<< the difference]
8-byte/64-bit Int64 starts on a multiple of 8 [<<< the difference]

bits:bytes (note: signed/unsigned parameters of the same size listed together)
8:1 CHAR [BOOLEAN,BYTE,INT8]
16:2 SHORT [INT16,WCHAR,WORD]
32:4 INT [BOOL,DWORD,DWORD32,FLOAT,INT32,LONG,LONG32,POINTER_32]
64:8 INT64 [DOUBLE,DWORDLONG,DWORD64,LONGLONG,LONG64,POINTER_64,QWORD]

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

[EDIT]
c++ - Why does the structure size differ in 32-bit and 64-bit program? - Stack Overflow
http://stackoverflow.com/questions/2783 ... it-program

Windows aligns doubles on 8 byte boundaries, even on 32 bit machines.

c++ - Double alignment - Stack Overflow
http://stackoverflow.com/questions/1110 ... -alignment

Windows uses 64-bit alignment of double values even in 32-bit mode

So the rules of alignment I believe are:

32-bit:
1-byte/8-bit Char starts on a multiple of 1
2-byte/16-bit Short starts on a multiple of 2
4-byte/32-bit Int starts on a multiple of 4 [<<< the difference]
8-byte/64-bit Int64 starts on a multiple of 8 [yes, even on 32-bit]

64-bit:
1-byte/8-bit Char starts on a multiple of 1
2-byte/16-bit Short starts on a multiple of 2
4-byte/32-bit Int starts on a multiple of 8 [<<< the difference]
8-byte/64-bit Int64 starts on a multiple of 8

OR ... both actually have the SAME RULES, so the only difference between x32/x64 structs,
is that now sometimes some of the parameters are bigger in x64 than in x32,
and just need to be shuffled about.]
Last edited by jeeswg on 12 Jan 2017, 03:13, edited 3 times in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask For Help”

Who is online

Users browsing this forum: divanebaba, Google [Bot], scriptors and 163 guests