/* Run only inside the isolated reference namespace. No original file is written. */ #include #include #include #include #include #define OMT_THISCALL __attribute__((thiscall)) typedef void *(OMT_THISCALL *ctor0)(void *); typedef void (OMT_THISCALL *writefn)(void *, void *, unsigned); typedef void (OMT_THISCALL *seekfn)(void *, unsigned, short); typedef void *(OMT_THISCALL *converterctor)(void *, void *, void *); typedef void (OMT_THISCALL *convertfn)(void *); static FARPROC required(HMODULE h, const char *name) { FARPROC p=GetProcAddress(h,name); if(!p){fprintf(stderr,"Missing export: %s\n",name);exit(2);} return p; } int main(int argc,char **argv) { setbuf(stdout,NULL); const char *input=argc>1?argv[1]:"ASE\\jimstop.ase"; FILE *f=fopen(input,"rb");if(!f){perror(input);return 2;} fseek(f,0,SEEK_END);long length=ftell(f);rewind(f); char *data=malloc(length);if(fread(data,1,length,f)!=(size_t)length)return 2;fclose(f); HMODULE h=LoadLibraryA("Z:\\work\\game\\OMT2.dll"); if(!h){fprintf(stderr,"LoadLibrary OMT error %lu\n",GetLastError());return 2;} unsigned char *stream=calloc(1,8192),*shape=calloc(1,8192),*converter=calloc(1,8192); ((ctor0)required(h,"??0OMediaMemStream@@QAE@XZ"))(stream); ((writefn)required(h,"?write@OMediaStream@@UAEXPAXK@Z"))(stream,data,length); ((seekfn)required(h,"?setposition@OMediaStream@@UAEXKF@Z"))(stream,0,0); ((ctor0)required(h,"??0OMedia3DShape@@QAE@XZ"))(shape); *(int*)required(h,"?obj_conv_mode@OMedia3DShapeConverter@@1W4omt_3DObjectConvertMode@@A")=0; *(int*)required(h,"?anim_conv_mode@OMedia3DShapeConverter@@1W4omt_3DAnimConvertMode@@A")=0; ((converterctor)required(h,"??0OMediaASEConverter@@QAE@PAVOMediaStreamOperators@@PAVOMedia3DShape@@@Z"))(converter,stream,shape); puts("CONVERT_BEGIN"); ((convertfn)required(h,"?convert@OMediaASEConverter@@UAEXXZ"))(converter); float *begin=*(float**)(shape+0x68),*end=*(float**)(shape+0x6c); intptr_t bytes=(intptr_t)end-(intptr_t)begin; if(!begin || bytes<=0 || bytes%16 || bytes>16000000){fputs("Unexpected shape layout\n",stderr);return 3;} printf("VERTICES %ld\n",(long)bytes/16); float lo[3]={FLT_MAX,FLT_MAX,FLT_MAX},hi[3]={-FLT_MAX,-FLT_MAX,-FLT_MAX}; for(float *p=begin;phi[i])hi[i]=p[i];}} printf("MIN %.9g %.9g %.9g\nMAX %.9g %.9g %.9g\n",lo[0],lo[1],lo[2],hi[0],hi[1],hi[2]); for(int i=0;i<3 && begin+i*4