Files
Neutron/tools/binary/jimmy_carl_entry_probe.c

65 lines
3.7 KiB
C

/* Bounded original Carl contact dispatch, not physical pair admission or talk.
Synthetic actors; actual 40A3C0,470A90,470A60,4089B0,475D40 execute.
Native allocation and NPC animation/type callbacks are explicit adapters. */
#define main unused_grappler_main
#include "grappler_scalar_probe.c"
#undef main
static unsigned char jimmy[0x1f00], other[0x1f00], game[0x600];
static uintptr_t npc_complete[0x190/4], npc_game[0x440/4];
static uintptr_t jimmy_game[0x440/4], game_table[0x150/4];
static uintptr_t contacts[3];
static int support, support_calls, animation_calls, prepare_calls;
static int TC is_a(void *self, const char *type){(void)self;(void)type;return 0;}
static int TC supported(void *self){require(self==jimmy+0xc0,"support owner");support_calls++;return support;}
static void TC prepare(void *self){require(self==object,"NPC prepare owner");prepare_calls++;}
static void TC animate(void *self,const char *name,int repeat){
require(self==object&&name==(char*)object+0x898&&repeat==1,"NPC idle animation owner");animation_calls++;
}
static void *allocate(size_t size){require(size==12,"contact node allocation");return malloc(size);}
static void fix(uint32_t start,uint32_t end){
const uint32_t refs[]={0x509948,0x5099e4,0x408b94};
for(uint32_t a=start;a+4<=end;a++){
uint32_t value;memcpy(&value,AT(a),4);
for(unsigned i=0;i<sizeof(refs)/sizeof(refs[0]);i++)if(value==refs[i]){
value=(uintptr_t)AT(value);memcpy(AT(a),&value,4);a+=3;break;
}
}
}
int main(void){
setbuf(stdout,NULL);map_source();
fix(0x40a3c0,0x40a69a);fix(0x470a90,0x470b19);fix(0x4089b0,0x408b94);
for(unsigned i=0;i<11;i++){uint32_t *v=(void*)AT(0x408b94+4*i);*v=(uintptr_t)AT(*v);}
jump(AT(0x478990),allocate);
npc_complete[0x124/4]=(uintptr_t)AT(0x4089b0);
npc_complete[0x16c/4]=(uintptr_t)prepare;npc_complete[0xe0/4]=(uintptr_t)animate;
npc_game[0x3c/4]=(uintptr_t)AT(0x470a60);
jimmy_game[0x18/4]=(uintptr_t)is_a;jimmy_game[0x218/4]=(uintptr_t)supported;
game_table[0x144/4]=(uintptr_t)AT(0x475d40);*(void**)game=game_table;
*(void**)AT(0x509948)=game;
int cases=0;
for(int sup=0;sup<2;sup++)for(int mode=0;mode<2;mode++)for(int turn=-12;turn<=12;turn+=12)
for(int match=0;match<2;match++)for(int active=0;active<2;active++)for(int raw=0;raw<2;raw++){
memset(object,0,sizeof(object));memset(jimmy,0xa5,sizeof(jimmy));memset(other,0xa5,sizeof(other));
*(void**)object=npc_complete;*(void**)(object+0xc0)=npc_game;
*(void**)(jimmy+0xc0)=jimmy_game;*(void**)(other+0xc0)=jimmy_game;
*(short*)(jimmy+0xc0+0x704)=(short)mode;*(float*)(jimmy+0xc0+0x614)=(float)turn;
*(float*)(jimmy+0xc0+0x224)=15;*(float*)(jimmy+0xc0+0x22c)=28;
*(float*)(jimmy+0xc0+0x274)=7;*(float*)(jimmy+0xc0+0x27c)=-24;
contacts[0]=contacts[1]=(uintptr_t)contacts;contacts[2]=0;
*(void**)(object+0xc0+0x260)=contacts;*(int*)(object+0xc0+0x408)=-1;
*(void**)(object+0xc0+0x600)=jimmy+0xc0;*(int*)(object+0x6c8)=active?6:3;
*(void**)AT(0x5099e4)=(raw?jimmy:other)+0xc0;
unsigned char before[sizeof(jimmy)];memcpy(before,jimmy,sizeof(jimmy));
support=sup;support_calls=animation_calls=prepare_calls=0;
((void(TC*)(void*,void*))AT(0x40a3c0))(object+0xc0,(match?jimmy:other)+0xc0);
require(memcmp(before,jimmy,sizeof(jimmy))==0,"entire target Jimmy memory unchanged");
require(support_calls==0,"no support query");
require(*(int*)(object+0x6c8)==(match&&active?0:active?6:3),"NPC state admission");
require(animation_calls==(match&&active)&&prepare_calls==(match&&active),"NPC idle callback count");
require(*(int*)(object+0xc0+0x264)==1,"actual base contact appended node");
free((void*)contacts[0]);cases++;
}
printf("CARL_CONTACT {\"cases\":%d,\"jimmy_unchanged\":true,\"support_queries\":0}\n",cases);
puts("JIMMY_CARL_ENTRY_COMPLETE");return 0;
}