Files
WoW-Hybrid-gateway/tests/engine_transfer_channel_win_fixture.c
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

96 lines
6.4 KiB
C

/* New loading-only policy boundary; no original game function runs here.
* Native readiness predicates are explicit owner/connection proof STUBS.
* Core source-backed phase semantics are validated in native_far_transfer_test.
*/
#define GW_TRANSFER_CHANNEL_FIXTURE 1
#define fixture_start unused_baseline_fixture_start
#include "engine_channel_win_fixture.c"
#undef fixture_start
static void* sealed_owner;
static void* sealed_connection;
static unsigned sealed_phase;
int WINAPI gw_wire_native_channel_transfer_ready(void* owner){
return sealed_phase && owner==gw_fixture_owner && owner==sealed_owner &&
sealed_connection==*(void**)((unsigned char*)owner+0x1a0);
}
#ifdef GW_OWNERSHIP_LOSS_DIAGNOSTIC_FIXTURE
#include "../native/wine_pipe_host.h"
#include "../native/wine_engine_realm.h"
#include "../native/engine_realm_context.h"
struct gw_pipe_control gw_wire_pipe_data;
struct gw_pipe_world_control gw_wire_world_data;
struct gw_pipe_world_failure gw_wire_world_failure;
struct gw_engine_realm_previous gw_wire_realm_previous;
static unsigned owner_heartbeats,owner_detaches;
static LONG heartbeat_result;
LONG WINAPI gw_wire_account_engine_heartbeat(void){++owner_heartbeats;return heartbeat_result;}
void WINAPI gw_wire_account_detach_engine_session(void){++owner_detaches;}
/* The driver extracts this function verbatim from wine_pipe_host.c. This
* fixture compiles the production poller, not a second loss classifier. */
#include GW_OWNER_LOSS_POLLER_INCLUDE
static void owner_case(unsigned char* p){
gw_wire_pipe_data=(struct gw_pipe_control){.abi=1,.size=sizeof(gw_wire_pipe_data),
.stage=1,.owner=(uint64_t)p,.connection=(uint64_t)(p+0x300),
.pipe=(uint64_t)(p+0x380),.world_auth=1};
gw_wire_world_data=(struct gw_pipe_world_control){.abi=1,.size=sizeof(gw_wire_world_data),.realm_context_bound=GW_WORLD_REALM_CONTEXT_BOUND};
gw_wire_world_failure=(struct gw_pipe_world_failure){.abi=1,.size=48};
*(LONG*)(p+0x98)=5;*(void**)(p+0x1a0)=p+0x300;
*(void**)(p+0x228)=p+0x370;*(void**)(p+0x370)=p+0x380;
owner_heartbeats=owner_detaches=0;heartbeat_result=0;
}
static void ownership_loss_cases(void){
unsigned char* p=VirtualAlloc(0,4096,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);
check(p!=0,60);
owner_case(p);gw_wire_engine_session_poll(p);
check(owner_heartbeats==1&&!owner_detaches&&!gw_wire_pipe_data.closed&&!gw_wire_world_failure.phase,61);
owner_case(p);*(LONG*)(p+0x98)=4;gw_wire_engine_session_poll(p);
check(owner_heartbeats==1&&!owner_detaches&&!gw_wire_pipe_data.closed&&!gw_wire_world_failure.phase,62);
owner_case(p);*(LONG*)(p+0x98)=9;gw_wire_engine_session_poll(p);
check(owner_detaches==1&&gw_wire_pipe_data.closed&&!gw_wire_pipe_data.error&&gw_wire_world_failure.phase==12&&gw_wire_world_failure.result==1&&gw_wire_world_failure.index==9,63);
gw_wire_engine_session_poll(p);check(owner_detaches==1&&gw_wire_world_failure.result==1,64);
owner_case(p);*(void**)(p+0x1a0)=p+0x301;gw_wire_engine_session_poll(p);
check(owner_detaches==1&&gw_wire_world_failure.phase==12&&gw_wire_world_failure.result==2&&gw_wire_world_failure.index==5,65);
owner_case(p);*(void**)(p+0x228)=0;gw_wire_engine_session_poll(p);
check(owner_detaches==1&&gw_wire_world_failure.phase==12&&gw_wire_world_failure.result==4,66);
owner_case(p);*(void**)(p+0x370)=p+0x381;gw_wire_engine_session_poll(p);
check(owner_detaches==1&&gw_wire_world_failure.phase==12&&gw_wire_world_failure.result==8,67);
owner_case(p);gw_wire_world_failure.phase=7;gw_wire_world_failure.result=-99;gw_wire_world_failure.index=123;
*(LONG*)(p+0x98)=9;gw_wire_engine_session_poll(p);
check(owner_detaches==1&&gw_wire_pipe_data.closed&&gw_wire_world_failure.phase==7&&gw_wire_world_failure.result==-99&&gw_wire_world_failure.index==123,68);
owner_case(p);gw_wire_engine_session_poll(p+8);
check(!owner_detaches&&!owner_heartbeats&&!gw_wire_pipe_data.closed&&!gw_wire_world_failure.phase,69);
owner_case(p);gw_wire_pipe_data.world_auth=0;gw_wire_engine_session_poll(p);
check(!owner_detaches&&!owner_heartbeats&&!gw_wire_pipe_data.closed&&!gw_wire_world_failure.phase,70);
owner_case(p);heartbeat_result=-1;gw_wire_engine_session_poll(p);
check(owner_heartbeats==1&&!owner_detaches&&!gw_wire_pipe_data.closed&&!gw_wire_world_failure.phase,71);
VirtualFree(p,0,MEM_RELEASE);
}
void fixture_start(void){ownership_loss_cases();ExitProcess(0);}
#else
void fixture_start(void){
unsigned char* p;void** head;struct node* n;
gw_fixture_owner=VirtualAlloc(0,4096,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);check(gw_fixture_owner!=0,1);
p=gw_fixture_owner;InitializeCriticalSection((CRITICAL_SECTION*)(p+0x70));*(LONG*)(p+0x98)=5;
*(void**)(p+0x1a0)=p;p[0x219]=1;head=(void**)(p+0x200);head[0]=head;head[1]=(void*)((uintptr_t)head|1);
ready=0; // No native self-create/world-ready proof during map loading.
reset();n=append(2,21);gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,50);
sealed_owner=p;sealed_connection=p;sealed_phase=2;
reset();gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.enabled && !gw_wire_channel_policy.error && sends==1 && destroys==1 && releases==1,51);
reset();n=append(2,21);sealed_phase=0;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,52);
reset();sealed_phase=2;sealed_owner=p+8;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,53);
reset();sealed_owner=p;sealed_connection=p+8;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,54);
reset();sealed_connection=p;*(void**)(p+0x1a8)=p;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,55);*(void**)(p+0x1a8)=0;
reset();*(LONG*)(p+0x98)=4;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==3 && !sends && head[1]==n,56);*(LONG*)(p+0x98)=5;
reset();n->buffer.cursor=0;gw_wire_channel_policy.command=1;gw_wire_channel_poll(p);
check(gw_wire_channel_policy.error==4 && !sends && head[1]==n,57);n->buffer.cursor=16;
check(finish_node(n,head),58);DeleteCriticalSection((CRITICAL_SECTION*)(p+0x70));VirtualFree(p,0,MEM_RELEASE);ExitProcess(0);
}
#endif