mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-19 05:15:40 +02:00
Fix Win32API on Windows (screw Windows)
This commit is contained in:
parent
6a1672f050
commit
39f47caef7
1 changed files with 32 additions and 3 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "binding-util.h"
|
#include "binding-util.h"
|
||||||
|
#include "debugwriter.h"
|
||||||
|
|
||||||
#define _T_VOID 0
|
#define _T_VOID 0
|
||||||
#define _T_NUMBER 1
|
#define _T_NUMBER 1
|
||||||
|
@ -21,6 +22,10 @@
|
||||||
// think there are many functions one would need to use that require
|
// think there are many functions one would need to use that require
|
||||||
// that many arguments anyway
|
// that many arguments anyway
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned long params[8];
|
||||||
|
} MiniFFIFuncArgs;
|
||||||
|
|
||||||
// L O N G, but variables won't get set up correctly otherwise
|
// L O N G, but variables won't get set up correctly otherwise
|
||||||
// should allow for __fastcalls (macOS likes these) and whatever else
|
// should allow for __fastcalls (macOS likes these) and whatever else
|
||||||
typedef PREFABI void *(*MINIFFI_FUNC)(unsigned long, unsigned long,
|
typedef PREFABI void *(*MINIFFI_FUNC)(unsigned long, unsigned long,
|
||||||
|
@ -213,9 +218,7 @@ RB_METHOD(MiniFFI_initialize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_METHOD(MiniFFI_call) {
|
RB_METHOD(MiniFFI_call) {
|
||||||
struct {
|
MiniFFIFuncArgs param;
|
||||||
unsigned long params[8];
|
|
||||||
} param;
|
|
||||||
#define params param.params
|
#define params param.params
|
||||||
VALUE func = rb_iv_get(self, "_func");
|
VALUE func = rb_iv_get(self, "_func");
|
||||||
VALUE own_imports = rb_iv_get(self, "_imports");
|
VALUE own_imports = rb_iv_get(self, "_imports");
|
||||||
|
@ -256,10 +259,36 @@ RB_METHOD(MiniFFI_call) {
|
||||||
}
|
}
|
||||||
params[i] = lParam;
|
params[i] = lParam;
|
||||||
}
|
}
|
||||||
|
#ifndef __WINDOWS__
|
||||||
unsigned long ret =
|
unsigned long ret =
|
||||||
(unsigned long)ApiFunction(params[0], params[1], params[2], params[3],
|
(unsigned long)ApiFunction(params[0], params[1], params[2], params[3],
|
||||||
params[4], params[5], params[6], params[7]);
|
params[4], params[5], params[6], params[7]);
|
||||||
|
|
||||||
|
// Setting stdcall doesn't work anymore, I HATE WINDOWS
|
||||||
|
#else
|
||||||
|
unsigned long ret = 0;
|
||||||
|
asm volatile(".intel_syntax noprefix\n"
|
||||||
|
"test ecx, ecx\n"
|
||||||
|
"jz call_void\n"
|
||||||
|
"sub ecx, 4\n"
|
||||||
|
"test ecx, ecx\n"
|
||||||
|
"jz loop_end\n"
|
||||||
|
"loop_start:\n"
|
||||||
|
"mov eax, [esi+ecx]\n"
|
||||||
|
"push eax\n"
|
||||||
|
"sub ecx, 4\n"
|
||||||
|
"test ecx, ecx\n"
|
||||||
|
"jnz loop_start\n"
|
||||||
|
"loop_end:\n"
|
||||||
|
"mov eax, [esi]\n"
|
||||||
|
"push eax\n"
|
||||||
|
"call_void:\n"
|
||||||
|
"call edi"
|
||||||
|
: "+a"(ret)
|
||||||
|
: "c"(nimport * 4), "S"(¶m), "D"(ApiFunction)
|
||||||
|
: "memory");
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (FIX2INT(own_exports)) {
|
switch (FIX2INT(own_exports)) {
|
||||||
case _T_NUMBER:
|
case _T_NUMBER:
|
||||||
case _T_INTEGER:
|
case _T_INTEGER:
|
||||||
|
|
Loading…
Add table
Reference in a new issue