2582
|
1 /* to compile: gcc -o qtxload qtxload.c ../libloader.a -lpthread -ldl -ggdb ../../cpudetect.o */
|
|
2
|
2501
|
3 #include <stdio.h>
|
2796
|
4 #include <stdlib.h>
|
|
5 #include <string.h>
|
|
6
|
2501
|
7 #include "qtxsdk/components.h"
|
2778
|
8 #include "qtxsdk/select.h"
|
2501
|
9
|
2778
|
10 #define DEF_DISPATCHER(name) ComponentResult (*##name)(ComponentParameters *, void **)
|
2501
|
11
|
|
12 /* ilyen egy sima komponens */
|
|
13 ComponentResult ComponentDummy(
|
2778
|
14 ComponentParameters *params,
|
2501
|
15 void **globals,
|
|
16 DEF_DISPATCHER(ComponentDispatch))
|
|
17 {
|
|
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);
|
|
23 }
|
|
24
|
2796
|
25 char *get_path(char* x){ return strdup(x);}
|
|
26
|
|
27 void* expLoadLibraryA(char* name);
|
|
28 void* GetProcAddress(void* handle,char* func);
|
|
29
|
|
30 #define __stdcall __attribute__((__stdcall__))
|
|
31 #define __cdecl __attribute__((__cdecl__))
|
|
32 #define APIENTRY
|
2501
|
33
|
2796
|
34 int main(int argc, char *argv[]){
|
2501
|
35 void *handler;
|
2796
|
36 ComponentResult (APIENTRY *
|
|
37 dispatcher)(ComponentParameters *params, Globals glob);
|
|
38 ComponentResult ret;
|
|
39 ComponentParameters *params;
|
|
40 ComponentDescription desc;
|
|
41 void *globals=NULL;
|
|
42 unsigned int esp=0;
|
2501
|
43
|
|
44 Setup_LDT_Keeper();
|
2768
|
45 handler = expLoadLibraryA("/usr/lib/win32/QuickTime.qts");
|
|
46 dispatcher = GetProcAddress(handler, "SorensonYUV9Dispatcher");
|
2796
|
47 // handler = expLoadLibraryA("/usr/lib/win32/On2_VP3.qtx");
|
|
48 // dispatcher = GetProcAddress(handler, "CDComponentDispatcher");
|
2501
|
49 printf("handler: %p, dispatcher: %p\n", handler, dispatcher);
|
2796
|
50
|
|
51 desc.componentType=0;
|
|
52 desc.componentSubType=0;
|
|
53 desc.componentManufacturer=0;
|
|
54 desc.componentFlags=0;
|
|
55 desc.componentFlagsMask=0;
|
2501
|
56
|
2796
|
57 params = malloc(sizeof(ComponentParameters)+2048);
|
2501
|
58
|
2796
|
59 params->flags = 0;
|
|
60 params->paramSize = sizeof(params->params[0]);
|
|
61 params->params[0] = 0x12345678;
|
2778
|
62
|
2796
|
63 // params->what = kComponentVersionSelect;
|
|
64 // params->what = kComponentRegisterSelect;
|
|
65 params->what = kComponentOpenSelect;
|
|
66 // params->what = kComponentCanDoSelect;
|
2778
|
67
|
2796
|
68 printf("params: flags: %d, paramSize: %d, what: %d, params[0] = %x\n",
|
|
69 params->flags, params->paramSize, params->what, params->params[0]);
|
2778
|
70
|
2796
|
71 __asm__ __volatile__ ("movl %%esp, %0\n\t" : "=a" (esp) :: "memory" );
|
|
72 printf("ESP=%p\n",esp);
|
2778
|
73
|
2796
|
74 ret = dispatcher(params, &globals);
|
|
75
|
|
76 __asm__ __volatile__ ("movl %%esp, %0\n\t" : "=a" (esp) :: "memory" );
|
|
77 printf("ESP=%p\n",esp);
|
2778
|
78
|
2796
|
79 printf("!!! CDComponentDispatch() => 0x%X glob=%p\n",ret,globals);
|
2501
|
80
|
2796
|
81 Restore_LDT_Keeper();
|
|
82 exit(0);
|
|
83 //return 0;
|
2501
|
84 }
|