Files
praxisandClaude Fable 5.2 8e02dccb86 In-client stack: transport, session lifecycle and engine bridge
175 files, from working commit b1a079a.

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

150 lines
11 KiB
C

/* Exact accepted DX12 carrier403b1036: headers (except declarative ImageBase)/export directory and
* complete original CreateDevice .pdata extent. No body relocations. This is
* a compatibility guard, not a claim to authenticate arbitrary module code.
* The deployment receipt separately pins the complete file SHA256. */
#ifndef GW_DX12_CARRIER_FORWARDING_H
#define GW_DX12_CARRIER_FORWARDING_H
#include <stdint.h>
#include <stddef.h>
typedef int (*GwDx12CarrierRead)(void *,uint32_t,void *,size_t,int);
static int gw_dx12_carrier_region_valid(uintptr_t module,uintptr_t address,size_t count,
uintptr_t allocation,uintptr_t base,uintptr_t size,uint32_t state,
uint32_t protect,uint32_t type,int execute) {
uint32_t access=protect&0xffu;
if(!module || allocation!=module || type!=0x1000000u || state!=0x1000u ||
(protect&0x100u) || !count || address<base || address-base>=size ||
count>size-(address-base))return 0;
if(execute)return access==0x20u || access==0x80u;
return access==2u || access==4u || access==8u || access==0x20u || access==0x40u || access==0x80u;
}
static const unsigned char gw_dx12_carrier_headers[1024]={
0x4d,0x5a,0x90,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0xff,0xff,0x00,0x00,
0xb8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,
0x0e,0x1f,0xba,0x0e,0x00,0xb4,0x09,0xcd,0x21,0xb8,0x01,0x4c,0xcd,0x21,0x54,0x68,
0x69,0x73,0x20,0x70,0x72,0x6f,0x67,0x72,0x61,0x6d,0x20,0x63,0x61,0x6e,0x6e,0x6f,
0x74,0x20,0x62,0x65,0x20,0x72,0x75,0x6e,0x20,0x69,0x6e,0x20,0x44,0x4f,0x53,0x20,
0x6d,0x6f,0x64,0x65,0x2e,0x0d,0x0d,0x0a,0x24,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x50,0x45,0x00,0x00,0x64,0x86,0x0c,0x00,0x2d,0x7d,0xe9,0x6a,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf0,0x00,0x2e,0x22,0x0b,0x02,0x02,0x2c,0x00,0x30,0x01,0x00,
0x00,0xb0,0x00,0x00,0x00,0x10,0x00,0x00,0x30,0x13,0x00,0x00,0x00,0x10,0x00,0x00,
0x00,0x00,0x4e,0x5e,0x03,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,
0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
0x00,0x20,0x02,0x00,0x00,0x10,0x00,0x00,0x19,0x3c,0x02,0x00,0x03,0x00,0x60,0x01,
0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x10,0x02,0x00,0x9d,0x01,0x00,0x00,
0x00,0x00,0x02,0x00,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x90,0x01,0x00,0x88,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xf0,0x01,0x00,0x9c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xa0,0x55,0x01,0x00,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd3,0x01,0x00,0x98,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0x74,0x65,0x78,0x74,0x00,0x00,0x00,
0x30,0x29,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0x30,0x01,0x00,0x00,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x60,
0x2e,0x64,0x61,0x74,0x61,0x00,0x00,0x00,0x30,0x04,0x00,0x00,0x00,0x40,0x01,0x00,
0x00,0x10,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc0,0x2e,0x72,0x64,0x61,0x74,0x61,0x00,0x00,
0xb0,0x3e,0x00,0x00,0x00,0x50,0x01,0x00,0x00,0x40,0x00,0x00,0x00,0x50,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,
0x2e,0x70,0x64,0x61,0x74,0x61,0x00,0x00,0x88,0x08,0x00,0x00,0x00,0x90,0x01,0x00,
0x00,0x10,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x2e,0x78,0x64,0x61,0x74,0x61,0x00,0x00,
0x28,0x09,0x00,0x00,0x00,0xa0,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0xa0,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,
0x2e,0x62,0x73,0x73,0x00,0x00,0x00,0x00,0x70,0x0b,0x00,0x00,0x00,0xb0,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xc0,0x2e,0x65,0x64,0x61,0x74,0x61,0x00,0x00,
0x71,0x01,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0xb0,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,
0x2e,0x69,0x64,0x61,0x74,0x61,0x00,0x00,0xb4,0x0b,0x00,0x00,0x00,0xd0,0x01,0x00,
0x00,0x10,0x00,0x00,0x00,0xc0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x2e,0x74,0x6c,0x73,0x00,0x00,0x00,0x00,
0x10,0x00,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x10,0x00,0x00,0x00,0xd0,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc0,
0x2e,0x72,0x65,0x6c,0x6f,0x63,0x00,0x00,0x9c,0x00,0x00,0x00,0x00,0xf0,0x01,0x00,
0x00,0x10,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x42,0x2e,0x67,0x77,0x69,0x6d,0x70,0x00,0x00,
0x10,0x01,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x10,0x00,0x00,0x00,0xf0,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0xc0,
0x2e,0x67,0x77,0x65,0x78,0x70,0x00,0x00,0x9d,0x01,0x00,0x00,0x00,0x10,0x02,0x00,
0x00,0x10,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char gw_dx12_carrier_exports[413]={
0x00,0x00,0x00,0x00,0x2d,0x7d,0xe9,0x6a,0x00,0x00,0x00,0x00,0x78,0x10,0x02,0x00,
0x5f,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x28,0x10,0x02,0x00,
0x48,0x10,0x02,0x00,0x68,0x10,0x02,0x00,0xf0,0x1d,0x01,0x00,0x60,0x1e,0x01,0x00,
0xd0,0x1e,0x01,0x00,0xe0,0x1f,0x01,0x00,0xf0,0x20,0x01,0x00,0x60,0x21,0x01,0x00,
0x71,0x11,0x02,0x00,0x70,0x1f,0x01,0x00,0x82,0x10,0x02,0x00,0x94,0x10,0x02,0x00,
0xb9,0x10,0x02,0x00,0xe7,0x10,0x02,0x00,0x07,0x11,0x02,0x00,0x1e,0x11,0x02,0x00,
0x30,0x11,0x02,0x00,0x4c,0x11,0x02,0x00,0x06,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0x07,0x00,0x03,0x00,0x04,0x00,0x05,0x00,0x64,0x33,0x64,0x31,0x32,0x2e,0x64,0x6c,
0x6c,0x00,0x44,0x33,0x44,0x31,0x32,0x43,0x72,0x65,0x61,0x74,0x65,0x44,0x65,0x76,
0x69,0x63,0x65,0x00,0x44,0x33,0x44,0x31,0x32,0x43,0x72,0x65,0x61,0x74,0x65,0x52,
0x6f,0x6f,0x74,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,0x44,0x65,0x73,0x65,
0x72,0x69,0x61,0x6c,0x69,0x7a,0x65,0x72,0x00,0x44,0x33,0x44,0x31,0x32,0x43,0x72,
0x65,0x61,0x74,0x65,0x56,0x65,0x72,0x73,0x69,0x6f,0x6e,0x65,0x64,0x52,0x6f,0x6f,
0x74,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,0x44,0x65,0x73,0x65,0x72,0x69,
0x61,0x6c,0x69,0x7a,0x65,0x72,0x00,0x44,0x33,0x44,0x31,0x32,0x45,0x6e,0x61,0x62,
0x6c,0x65,0x45,0x78,0x70,0x65,0x72,0x69,0x6d,0x65,0x6e,0x74,0x61,0x6c,0x46,0x65,
0x61,0x74,0x75,0x72,0x65,0x73,0x00,0x44,0x33,0x44,0x31,0x32,0x47,0x65,0x74,0x44,
0x65,0x62,0x75,0x67,0x49,0x6e,0x74,0x65,0x72,0x66,0x61,0x63,0x65,0x00,0x44,0x33,
0x44,0x31,0x32,0x47,0x65,0x74,0x49,0x6e,0x74,0x65,0x72,0x66,0x61,0x63,0x65,0x00,
0x44,0x33,0x44,0x31,0x32,0x53,0x65,0x72,0x69,0x61,0x6c,0x69,0x7a,0x65,0x52,0x6f,
0x6f,0x74,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,0x00,0x44,0x33,0x44,0x31,
0x32,0x53,0x65,0x72,0x69,0x61,0x6c,0x69,0x7a,0x65,0x56,0x65,0x72,0x73,0x69,0x6f,
0x6e,0x65,0x64,0x52,0x6f,0x6f,0x74,0x53,0x69,0x67,0x6e,0x61,0x74,0x75,0x72,0x65,
0x00,0x47,0x57,0x4e,0x61,0x74,0x69,0x76,0x65,0x42,0x72,0x69,0x64,0x67,0x65,0x2e,
0x67,0x77,0x5f,0x73,0x74,0x61,0x72,0x74,0x75,0x70,0x5f,0x44,0x33,0x44,0x31,0x32,
0x43,0x72,0x65,0x61,0x74,0x65,0x44,0x65,0x76,0x69,0x63,0x65,0x00,
};
static const unsigned char gw_dx12_carrier_entry[111]={
0x55,0x41,0x54,0x57,0x56,0x53,0x48,0x83,0xec,0x30,0x48,0x8d,0x6c,0x24,0x30,0x48,
0x89,0xcb,0x89,0xd6,0x48,0x8d,0x0d,0xf5,0x25,0x00,0x00,0x4c,0x89,0xc7,0x4d,0x89,
0xcc,0x4c,0x8d,0x05,0xc8,0x0b,0x00,0x00,0x45,0x31,0xc9,0x48,0x8d,0x15,0xfe,0x0c,
0x00,0x00,0xff,0x15,0xb8,0xb5,0x00,0x00,0x48,0x8b,0x0d,0x61,0x25,0x00,0x00,0x48,
0x85,0xc9,0x74,0x24,0x48,0x8b,0x01,0x49,0x89,0xf9,0x4c,0x89,0x64,0x24,0x20,0x41,
0x89,0xf0,0x48,0x89,0xda,0xff,0x10,0x48,0x83,0xc4,0x30,0x5b,0x5e,0x5f,0x41,0x5c,
0x5d,0xc3,0x66,0x0f,0x1f,0x44,0x00,0x00,0xb8,0x02,0x40,0x00,0x80,0xeb,0xe8,
};
static void *gw_dx12_carrier_resolve(void *module,void *resolved,void *self,
GwDx12CarrierRead read,uint32_t *error) {
unsigned char bytes[1024];size_t i;int result;uint64_t preferred_base=0;
if(error)*error=0;
if(!resolved || resolved!=self)return resolved;
if(!module || !read || (uintptr_t)module>UINTPTR_MAX-0x22000u){if(error)*error=10;return 0;}
result=read(module,0x0u,bytes,1024u,0);
if(result!=1){if(error)*error=result==-1?20:21;return 0;}
/* PE32+ OptionalHeader.ImageBase is a preferred-address declaration,
* not an allocation identity. The observed owned carrier retains a third
* aligned address here. All reads stay bound to the actual HMODULE by
* VirtualQuery; never derive a pointer from this header field. */
for(i=0;i<8u;++i)preferred_base|=(uint64_t)bytes[176u+i]<<(8u*i);
if(!preferred_base || (preferred_base&0xffffu)){if(error)*error=11;return 0;}
for(i=0;i<1024u;++i){
if(i>=176u && i<184u)continue;
if(bytes[i]!=gw_dx12_carrier_headers[i]){if(error)*error=11;return 0;}
}
result=read(module,0x21000u,bytes,413u,0);
if(result!=1){if(error)*error=result==-1?20:21;return 0;}
for(i=0;i<413u;++i)if(bytes[i]!=gw_dx12_carrier_exports[i]){if(error)*error=12;return 0;}
result=read(module,0x11d80u,bytes,111u,1);
if(result!=1){if(error)*error=result==-1?20:21;return 0;}
for(i=0;i<111u;++i)if(bytes[i]!=gw_dx12_carrier_entry[i]){if(error)*error=13;return 0;}
return (void *)((uintptr_t)module+0x11d80u);
}
#endif