"inline" is used elsewhere and more portable than "__inline"
[mplayer/glamo.git] / loader / qtx / qtxload.c
blob6dd088d643cb769b7e1c318c3fb3345057d5e196
1 /* to compile: gcc -o qtxload qtxload.c ../libloader.a -lpthread -ldl -ggdb ../../cpudetect.o */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
7 #include "qtxsdk/components.h"
8 #include "qtxsdk/select.h"
10 #define DEF_DISPATCHER(name) ComponentResult (*##name)(ComponentParameters *, void **)
12 /* ilyen egy sima komponens */
13 ComponentResult ComponentDummy(
14 ComponentParameters *params,
15 void **globals,
16 DEF_DISPATCHER(ComponentDispatch))
18 printf("ComponentDummy(params: %p, globals: %p, dispatcher: %p) called!\n",
19 params, globals, ComponentDispatch);
20 printf(" Dummy: global datas: %p\n", *globals);
21 printf(" Dummy: returning 0\n");
22 return(0);
25 char *get_path(const char* x){ return strdup(x);}
27 void* LoadLibraryA(char* name);
28 void* GetProcAddress(void* handle,char* func);
30 #define __stdcall __attribute__((__stdcall__))
31 #define __cdecl __attribute__((__cdecl__))
32 #define APIENTRY
34 unsigned int* x_table[0x00001837];
36 static OSErr (*InitializeQTML)(long flags);
38 int main(int argc, char *argv[]){
39 void *handler;
40 void *handler2;
41 void* theqtdp=NULL;
42 void* compcall=NULL;
43 void* compcallws=NULL;
44 ComponentResult (*dispatcher)(ComponentParameters *params, Globals glob);
45 ComponentResult ret;
46 ComponentParameters *params;
47 ComponentDescription desc;
48 void *globals=NULL;
49 unsigned int esp=0;
50 int i;
52 mp_msg_init();
53 mp_msg_set_level(10);
55 Setup_LDT_Keeper();
56 printf("loading qts\n");
57 // handler = LoadLibraryA("/root/.wine/fake_windows/Windows/System/QuickTime.qts");
58 handler = LoadLibraryA("QuickTime.qts");
59 theqtdp = GetProcAddress(handler, "theQuickTimeDispatcher");
60 compcall = GetProcAddress(handler, "_CallComponent");
61 compcallws = GetProcAddress(handler, "_CallComponentFunctionWithStorage");
63 InitializeQTML = 0x6299e590;//GetProcAddress(handler, "InitializeQTML");
64 InitializeQTML(6+16);
66 printf("loading svq3\n");
67 handler2= LoadLibraryA("/root/.wine/fake_windows/Windows/System/QuickTime/QuickTimeEssentials.qtx");
68 printf("done\n");
69 dispatcher = GetProcAddress(handler2, "SMD_ComponentDispatch");
70 // handler = expLoadLibraryA("/usr/lib/win32/On2_VP3.qtx");
71 // dispatcher = GetProcAddress(handler, "CDComponentDispatcher");
72 printf("handler: %p, dispatcher: %p theqtdp: %p\n", handler, dispatcher, theqtdp);
74 // printf("theQuickTimeDispatcher = %p\n",GetProcAddress(handler, "theQuickTimeDispatcher"));
76 // patch svq3 dll:
77 *((void**)0x63214c98) = NULL;
78 *((void**)0x63214c9c) = theqtdp; // theQt...
79 *((void**)0x63214ca0) = compcall; //0xdeadbeef; //dispatcher; // CallCOmponent_ptr
80 *((void**)0x63214ca4) = compcallws; //0xdeadbef2; //dispatcher; // CallComponentWithStorage_ptr
82 desc.componentType=0;
83 desc.componentSubType=0;
84 desc.componentManufacturer=0;
85 desc.componentFlags=0;
86 desc.componentFlagsMask=0;
88 params = malloc(sizeof(ComponentParameters)+2048);
90 params->flags = 0;
91 params->paramSize = 4;
92 params->what = kComponentOpenSelect;
93 params->params[0] = 0x830000; //0x820000|i; //(i<<16)|0x24; //0x820024;
94 ret = dispatcher(params, &globals);
95 printf("!!! CDComponentDispatch() => 0x%X glob=%p\n",ret,globals);
97 // memset(x_table,12,4*0x00001837);
99 //for(i=0;i<=255;i++){
101 // params->what = kComponentVersionSelect;
102 // params->what = kComponentRegisterSelect;
103 // params->what = kComponentOpenSelect;
104 // params->what = kComponentCanDoSelect;
106 printf("params: flags: %d, paramSize: %d, what: %d, params[0] = %x\n",
107 params->flags, params->paramSize, params->what, params->params[0]);
109 // __asm__ __volatile__ ("movl %%esp, %0\n\t" : "=a" (esp) :: "memory" );
110 // printf("ESP=%p\n",esp);
112 *((void**)0x62b7d640) = &x_table[0]; //malloc(0x00001837 * 4); // ugly hack?
114 printf("params=%p &glob=%p x_table=%p\n",params,&globals, &x_table[0]);
116 ret = dispatcher(params, &globals);
118 // __asm__ __volatile__ ("movl %%esp, %0\n\t" : "=a" (esp) :: "memory" );
119 // printf("ESP=%p\n",esp);
121 printf("!!! CDComponentDispatch() => %d glob=%p\n",ret,globals);
122 // if(ret!=-3000) break;
125 // for(i=0;i<0x00001837;i++)
126 // if(x_table[i]) printf("x_table[0x%X] = %p\n",i,x_table[i]);
128 Restore_LDT_Keeper();
129 exit(0);
130 //return 0;