98 lines
3.9 KiB
C
98 lines
3.9 KiB
C
/* Offline Win64 ABI fixture for the selected 70334 virtual-helper dispatcher.
|
|
* The helper vtable pointers are inert numeric identities; this test never
|
|
* loads or runs a game client, graphics DLL or network provider. */
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
typedef uintptr_t word;
|
|
struct Helper { word vtable; };
|
|
typedef word (__stdcall *HelperCall)(struct Helper *, void *, void *, word,
|
|
word, word, word, word, word, word);
|
|
|
|
extern word __stdcall gw_startup_graphics_virtual_dispatch(
|
|
struct Helper *, void *, void *, word, word, word, word, word, word, word);
|
|
|
|
static unsigned wrapper11_calls, wrapper12_calls, original_calls;
|
|
static unsigned observed_kind;
|
|
static struct Helper *observed_helper;
|
|
static void *observed_output, *observed_wrapper;
|
|
static word observed_args[7];
|
|
|
|
void gw_test_bridge_d3d11(void) { ++wrapper11_calls; }
|
|
void gw_test_bridge_d3d12(void) { ++wrapper12_calls; }
|
|
|
|
static word record(unsigned kind, struct Helper *helper, void *output,
|
|
void *wrapper, word a4, word a5, word a6, word a7,
|
|
word a8, word a9, word a10) {
|
|
++original_calls;
|
|
observed_kind = kind;
|
|
observed_helper = helper;
|
|
observed_output = output;
|
|
observed_wrapper = wrapper;
|
|
observed_args[0] = a4;
|
|
observed_args[1] = a5;
|
|
observed_args[2] = a6;
|
|
observed_args[3] = a7;
|
|
observed_args[4] = a8;
|
|
observed_args[5] = a9;
|
|
observed_args[6] = a10;
|
|
((void (*)(void))wrapper)();
|
|
return (word)0xA0B00000u + kind;
|
|
}
|
|
|
|
#define ORIGINAL(name, id) \
|
|
word __stdcall name(struct Helper *h, void *o, void *w, word a4, word a5, \
|
|
word a6, word a7, word a8, word a9, word a10) { \
|
|
return record(id, h, o, w, a4, a5, a6, a7, a8, a9, a10); \
|
|
}
|
|
ORIGINAL(gw_test_dx11_original, 11)
|
|
ORIGINAL(gw_test_dx12_72280_original, 12)
|
|
ORIGINAL(gw_test_dx12_72470_original, 13)
|
|
ORIGINAL(gw_test_dx12_71930_original, 14)
|
|
|
|
static int one(word vtable, unsigned kind, int expect_dx11) {
|
|
static const word args[7] = {
|
|
0x1122334455667701ULL, 0x1122334455667702ULL,
|
|
0x1122334455667703ULL, 0x1122334455667704ULL,
|
|
0x1122334455667705ULL, 0x1122334455667706ULL,
|
|
0x1122334455667707ULL
|
|
};
|
|
struct Helper h = { vtable };
|
|
word output = 0x87654321u;
|
|
unsigned before11 = wrapper11_calls, before12 = wrapper12_calls;
|
|
unsigned before_original = original_calls;
|
|
word result = gw_startup_graphics_virtual_dispatch(
|
|
&h, &output, (void *)(uintptr_t)0x12345678u, args[0], args[1],
|
|
args[2], args[3], args[4], args[5], args[6]);
|
|
if (result != (word)0xA0B00000u + kind ||
|
|
original_calls != before_original + 1 || observed_kind != kind ||
|
|
observed_helper != &h || observed_output != &output ||
|
|
observed_wrapper != (expect_dx11 ? (void *)gw_test_bridge_d3d11
|
|
: (void *)gw_test_bridge_d3d12) ||
|
|
wrapper11_calls != before11 + (unsigned)expect_dx11 ||
|
|
wrapper12_calls != before12 + (unsigned)!expect_dx11) return 1;
|
|
for (unsigned i = 0; i < 7; ++i)
|
|
if (observed_args[i] != args[i]) return 2;
|
|
return 0;
|
|
}
|
|
|
|
int main(void) {
|
|
static const struct { word vtable; unsigned kind; int dx11; } cases[] = {
|
|
{0x1450e3c20ULL, 11, 1}, {0x1450e3ce0ULL, 11, 1},
|
|
{0x1450e8ba8ULL, 11, 1}, {0x1450e8c20ULL, 11, 1},
|
|
{0x1450e9020ULL, 12, 0}, {0x1450e9080ULL, 13, 0},
|
|
{0x1450eb480ULL, 12, 0}, {0x1450eb5a8ULL, 14, 0}
|
|
};
|
|
for (unsigned i = 0; i < sizeof(cases) / sizeof(cases[0]); ++i) {
|
|
int error = one(cases[i].vtable, cases[i].kind, cases[i].dx11);
|
|
if (error) {
|
|
fprintf(stderr, "dispatcher case %u failed: %d\n", i, error);
|
|
return 1;
|
|
}
|
|
}
|
|
if (wrapper11_calls != 4 || wrapper12_calls != 4 || original_calls != 8)
|
|
return 2;
|
|
puts("graphics virtual dispatcher: 8/8 ABI cases passed");
|
|
return 0;
|
|
}
|