diff -r 0fe2b7509707 Modules/_ctypes/libffi_msvc/ffi.c --- a/Modules/_ctypes/libffi_msvc/ffi.c Tue Jul 19 16:41:20 2016 -0500 +++ b/Modules/_ctypes/libffi_msvc/ffi.c Thu Jul 21 13:02:01 2016 +0100 @@ -378,7 +378,7 @@ if ( cif->rtype->type == FFI_TYPE_STRUCT ) { *rvalue = *(void **) argp; - argp += 4; + argp += sizeof(void *); } p_argv = avalue; @@ -396,6 +396,16 @@ /* because we're little endian, this is what it turns into. */ +#ifdef _WIN64 + if (z > 8) + { + /* On Win64, if a single argument takes more than 8 bytes, + then it is always passed by reference. */ + *p_argv = *((void**)argp); + z = 8; + } + else +#endif *p_argv = (void*) argp; p_argv++;