https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/div?view=msvc-160
irrelevant post below, see viewtopic.php?p=417951#p417951
DllCall supports at most 64bits, so trying to call this function will fail. to call this function:
- retrieve its function pointer
- create a wrapper that calls it
- chunk the returned struct and return a small enough chunk normally and the rest via outparams
- or Buffer()-alloc enough memory and copy the struct there
Code: Select all
#Requires AutoHotkey v2.0-beta.1
if !ucrtbase := DllCall('GetModuleHandle', 'Str', 'ucrtbase', 'Ptr')
throw Error('ucrtbase.dll not loaded or missing, use windows 10')
if !lldiv := DllCall('GetProcAddress', 'Ptr', ucrtbase, 'AStr', 'lldiv', 'Ptr')
throw Error('lldiv not found')
if (A_PtrSize = 4)
NumPut('Int64', 0xEC83F8E483EC8B55, 'Int64', 0xFF1475FF24048D10, 'Int64', 0x0875FF0C75FF1075,
'Int64', 0x0F14C4831855FF50, 'Int64', 0xC1280F1C458B0810, 'Int64', 0x7E0F6608D8730F66,
'Int64', 0xD8730F66C1280FC2, 'Int64', 0x108904407E0F660C, 'Int64', 0xD9730F66C87E0F66,
'Int64', 0x5DE58BCA7E0F6604, 'Int64', 0x00000000000018C2, wrapper := Buffer(88))
else
NumPut('Int64', 0x8B4930EC83485340, 'Int64', 0x48C28B4CD98B49C0, 'Int64', 0xFF20244C8D48D18B,
'Int64', 0xC16F0F6608100FD0, 'Int64', 0x730F66C87E0F4866, 'Int64', 0x834803D60F6608D8,
'Int64', 0x00000000C35B30C4, wrapper := Buffer(56))
DllCall('VirtualProtect', 'Ptr', wrapper, 'Ptr', wrapper.Size, 'UInt', 0x40, 'UInt*', 0) ; PAGE_EXECUTE_READWRITE
quot := DllCall(wrapper, 'Int64', 0x7FFFFFFFFFFFFFFF, 'Int64', 2, 'Ptr', lldiv, 'Int64*', &rem := 0, 'Int64')
MsgBox quot '`n' rem
Code: Select all
// #include <stdlib.h>
typedef struct _lldiv_t
{
long long quot;
long long rem;
} lldiv_t;
using plldiv = lldiv_t(*)(__int64, __int64);
extern "C" __declspec(dllexport) __int64 wrapper(__int64 numer, __int64 denom, plldiv lldiv, __int64* rem)
{
const auto results = lldiv(numer, denom);
*rem = results.rem;
return results.quot;
}
https://autohotkey.com/board/topic/21038-unsolved-not-supported-numget-128-bits/