annotate loader/module.c @ 25924:257833210f96

sync w/r25955
author gpoirier
date Tue, 05 Feb 2008 12:28:41 +0000
parents b70f5ac9c001
children c99d53b76ee5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * Modules
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright 1995 Alexandre Julliard
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13745
diff changeset
5 *
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18628
diff changeset
6 * Modified for use with MPlayer, detailed changelog at
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18628
diff changeset
7 * http://svn.mplayerhq.hu/mplayer/trunk/
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 13745
diff changeset
8 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 */
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
10
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
11 // define for quicktime calls debugging and/or MacOS-level emulation:
21290
efc774a1e5a4 fix compilation for win32 dll codec support for intel osx
nplourde
parents: 21261
diff changeset
12 #ifndef __APPLE__
8286
1a9ea966d840 patching out threads ;) raw measure: 18% cpu instead 30%
alex
parents: 8277
diff changeset
13 #define EMU_QTX_API
21290
efc774a1e5a4 fix compilation for win32 dll codec support for intel osx
nplourde
parents: 21261
diff changeset
14 #endif /* __APPLE__ */
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
15
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
16 // define for quicktime debugging (verbose logging):
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
17 //#define DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
18
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
19 #include "config.h"
21261
a2e02e6b6379 Rename config.h --> debug.h and include config.h explicitly.
diego
parents: 18878
diff changeset
20 #include "debug.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include <assert.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <sys/mman.h>
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
30 #include <inttypes.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
32 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
33 #include "wine/winerror.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
34 #include "wine/heap.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
35 #include "wine/module.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
36 #include "wine/pe_image.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
37 #include "wine/debugtools.h"
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
38
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
39 #undef HAVE_LIBDL
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
40
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
41 #ifdef HAVE_LIBDL
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
42 #include <dlfcn.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
43 #include "wine/elfdll.h"
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
44 #endif
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
45 #include "win32.h"
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
46 #include "driver.h"
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
47
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
48 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
49 #include "wrapper.h"
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
50 static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags);
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
51 static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
52 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
53
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
54 //#undef TRACE
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
55 //#define TRACE printf
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 //WINE_MODREF *local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 modref_list* local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
60 HANDLE SegptrHeap;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
61
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
62 WINE_MODREF* MODULE_FindModule(LPCSTR m)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 modref_list* list=local_wm;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
65 TRACE("FindModule: Module %s request\n", m);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 return NULL;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
68 // while(strcmp(m, list->wm->filename))
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
69 while(!strstr(list->wm->filename, m))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 {
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
71 TRACE("%s: %x\n", list->wm->filename, list->wm->module);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 return NULL;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
75 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 TRACE("Resolved to %s\n", list->wm->filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
78 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
80 static void MODULE_RemoveFromList(WINE_MODREF *mod)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 modref_list* list=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 if(list==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 if(mod==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 if((list->prev==NULL)&&(list->next==NULL))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 // uninstall_fs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 for(;list;list=list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 if(list->wm==mod)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 if(list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 list->prev->next=list->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 if(list->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 list->next->prev=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 if(list==local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 local_wm=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
108
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
109 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
110
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 modref_list* list=local_wm;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
114 TRACE("LookupHMODULE: Module %X request\n", m);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 if(list==NULL)
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
116 {
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
117 TRACE("LookupHMODULE failed\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 return NULL;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
119 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 while(m!=list->wm->module)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 // printf("Checking list %X wm %X module %X\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 // list, list->wm, list->wm->module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 if(list==NULL)
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
126 {
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
127 TRACE("LookupHMODULE failed\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 return NULL;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
129 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
130 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
131 TRACE("LookupHMODULE hit %p\n", list->wm);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
133 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 * MODULE_InitDll
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 WIN_BOOL retv = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141
25798
c8c9b4e89fb7 Surround variable declarations by preprocessor conditionals to avoid warnings:
diego
parents: 25794
diff changeset
142 #ifdef DEBUG
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
143 static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 "THREAD_ATTACH", "THREAD_DETACH" };
25798
c8c9b4e89fb7 Surround variable declarations by preprocessor conditionals to avoid warnings:
diego
parents: 25794
diff changeset
145 #endif
c8c9b4e89fb7 Surround variable declarations by preprocessor conditionals to avoid warnings:
diego
parents: 25794
diff changeset
146
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 /* Skip calls for modules loaded with special load flags */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 if ( ( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 || ( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 return TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 /* Call the initialization routine */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 switch ( wm->type )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 retv = PE_InitDLL( wm, type, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 case MODULE32_ELF:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 /* no need to do that, dlopen() already does */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 ERR("wine_modref type %d not handled.\n", wm->type );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 /* The state of the module list may have changed due to the call
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 to PE_InitDLL. We cannot assume that this module has not been
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 deleted. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 TRACE("(%p,%s,%p) - RETURN %d\n", wm, typeName[type], lpReserved, retv );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 * MODULE_DllProcessAttach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
186 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 * Send the process attach notification to all DLLs the given module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 * depends on (recursively). This is somewhat complicated due to the fact that
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 * - we have to respect the module dependencies, i.e. modules implicitly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 * referenced by another module have to be initialized before the module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 * itself can be initialized
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
193 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 * - the initialization routine of a DLL can itself call LoadLibrary,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 * thereby introducing a whole new set of dependencies (even involving
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 * the 'old' modules) at any time during the whole process
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 * (Note that this routine can be recursively entered not only directly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 * from itself, but also via LoadLibrary from one of the called initialization
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 * routines.)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 * Furthermore, we need to rearrange the main WINE_MODREF list to allow
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 * the process *detach* notifications to be sent in the correct order.
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
204 * This must not only take into account module dependencies, but also
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 * 'hidden' dependencies created by modules calling LoadLibrary in their
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 * attach notification routine.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 * The strategy is rather simple: we move a WINE_MODREF to the head of the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 * list after the attach notification has returned. This implies that the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 * detach notifications are called in the reverse of the sequence the attach
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 * notifications *returned*.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
216 static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 WIN_BOOL retv = TRUE;
24382
ea192b86100e warning fixes:
diego
parents: 21290
diff changeset
219 //int i;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 /* prevent infinite recursion in case of cyclical dependencies */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 if ( ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 || ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 TRACE("(%s,%p) - START\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 /* Tag current MODREF to prevent recursive loop */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 /* Recursively attach all DLLs this one depends on */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 /* for ( i = 0; retv && i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 retv = MODULE_DllProcessAttach( wm->deps[i], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 /* Call DLL entry point */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 //local_wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 if(local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
242 local_wm->next = (modref_list*) malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 local_wm->next->prev=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 local_wm->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 local_wm->next->wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 local_wm=local_wm->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 {
18878
3bf0d70b4c7f rm unnecesary casts from void* - part 2
reynaldo
parents: 18783
diff changeset
250 local_wm = malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 local_wm->next=local_wm->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 local_wm->wm=wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
253 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 /* Remove recursion flag */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 wm->flags &= ~WINE_MODREF_MARKER;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
256
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 wm->flags |= WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 * MODULE_DllProcessDetach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
272 *
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
273 * Send DLL process detach notifications. See the comment about calling
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 * sequence at MODULE_DllProcessAttach. Unless the bForceDetach flag
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 * is set, only DLLs with zero refcount are notified.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
277 static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
279 // WINE_MODREF *wm=local_wm;
24382
ea192b86100e warning fixes:
diego
parents: 21290
diff changeset
280 //modref_list* l = local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 MODULE_InitDll( wm, DLL_PROCESS_DETACH, lpReserved );
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
283 /* while (l)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
284 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
285 modref_list* f = l;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
286 l = l->next;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
287 free(f);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
288 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
289 local_wm = 0;*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
292 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
293 * MODULE_LoadLibraryExA (internal)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
294 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
295 * Load a PE style module according to the load order.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
296 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
297 * The HFILE parameter is not used and marked reserved in the SDK. I can
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
298 * only guess that it should force a file to be mapped, but I rather
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
299 * ignore the parameter because it would be extremely difficult to
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
300 * integrate this with different types of module represenations.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
301 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
302 */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
303 static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
304 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
305 DWORD err = GetLastError();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
306 WINE_MODREF *pwm;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
307 // module_loadorder_t *plo;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
308
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
309 SetLastError( ERROR_FILE_NOT_FOUND );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
310 TRACE("Trying native dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
311 pwm = PE_LoadLibraryExA(libname, flags);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
312 #ifdef HAVE_LIBDL
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
313 if(!pwm)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
314 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
315 TRACE("Trying ELF dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
316 pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
317 }
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
318 #endif
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
319 // printf("0x%08x\n", pwm);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
320 // break;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
321 if(pwm)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
322 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
323 /* Initialize DLL just loaded */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
324 TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
325 /* Set the refCount here so that an attach failure will */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
326 /* decrement the dependencies through the MODULE_FreeLibrary call. */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
327 pwm->refCount++;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
328
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
329 SetLastError( err ); /* restore last error */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
330 return pwm;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
331 }
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
332
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
333
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
334 WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError());
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
335 return NULL;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
336 }
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
337
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
338 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
339 * MODULE_FreeLibrary
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
340 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
341 * NOTE: Assumes that the process critical section is held!
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
342 */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
343 static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
344 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
345 TRACE("(%s) - START\n", wm->modname );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
346
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
347 /* Recursively decrement reference counts */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
348 //MODULE_DecRefCount( wm );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
349
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
350 /* Call process detach notifications */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
351 MODULE_DllProcessDetach( wm, FALSE, NULL );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
352
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
353 PE_UnloadLibrary(wm);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
354
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
355 TRACE("END\n");
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
356
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
357 return TRUE;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
358 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 * LoadLibraryExA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
365 WINE_MODREF *wm = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
366 char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
367 extern char* def_path;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
368 char path[512];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
369 char checked[2000];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
370 int i = -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
372 checked[0] = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 if(!libname)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 SetLastError(ERROR_INVALID_PARAMETER);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 }
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
378
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
379 wm=MODULE_FindModule(libname);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
380 if(wm) return wm->module;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
381
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
382 // if(fs_installed==0)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
383 // install_fs();
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
384
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
385 while (wm == 0 && listpath[++i])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
386 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
387 if (i < 2)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
388 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
389 if (i == 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
390 /* check just original file name */
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
391 strncpy(path, libname, 511);
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
392 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
393 /* check default user path */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
394 strncpy(path, def_path, 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
395 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
396 else if (strcmp(def_path, listpath[i]))
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
397 /* path from the list */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
398 strncpy(path, listpath[i], 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
399 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
400 continue;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
402 if (i > 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
403 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
404 strcat(path, "/");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
405 strncat(path, libname, 100);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
406 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
407 path[511] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
408 wm = MODULE_LoadLibraryExA( path, hfile, flags );
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
409
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
410 if (!wm)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
411 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
412 if (checked[0])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
413 strcat(checked, ", ");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
414 strcat(checked, path);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
415 checked[1500] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
416
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
417 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
418 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 if ( wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 if ( !MODULE_DllProcessAttach( wm, NULL ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 WARN_(module)("Attach failed for module '%s', \n", libname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 MODULE_FreeLibrary(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 SetLastError(ERROR_DLL_INIT_FAILED);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 wm = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430
25418
0cc73d213160 Stop MPlayer from complaining about bogus AviSynth DLL load failures.
diego
parents: 24382
diff changeset
431 if (!wm && !strstr(checked, "avisynth.dll"))
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
432 printf("Win32 LoadLibrary failed to load: %s\n", checked);
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
433
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
434 #define RVA(x) ((char *)wm->module+(unsigned int)(x))
13621
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
435 if (strstr(libname,"vp31vfw.dll") && wm)
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
436 {
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
437 int i;
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
438
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
439 // sse hack moved from patch dll into runtime patching
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
440 if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x1000)) {
13621
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
441 fprintf(stderr, "VP3 DLL found\n");
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
442 for (i=0;i<18;i++) RVA(0x4bd6)[i]=0x90;
13621
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
443 }
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
444 }
8c6b747eeacf runtime patching vp31vfw.dll, so non-patched dlls can be used aswell. note: this does not breaks if the dll is already patched
alex
parents: 13182
diff changeset
445
12042
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
446 // remove a few divs in the VP codecs that make trouble
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
447 if (strstr(libname,"vp5vfw.dll") && wm)
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
448 {
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
449 int i;
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
450 if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3930)) {
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
451 for (i=0;i<3;i++) RVA(0x4e86)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
452 for (i=0;i<3;i++) RVA(0x5a23)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
453 for (i=0;i<3;i++) RVA(0x5bff)[i]=0x90;
12042
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
454 } else {
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
455 fprintf(stderr, "Unsupported VP5 version\n");
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
456 return 0;
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
457 }
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
458 }
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
459
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
460 if (strstr(libname,"vp6vfw.dll") && wm)
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
461 {
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
462 int i;
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
463 if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3ef0)) {
12042
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
464 // looks like VP 6.1.0.2
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
465 for (i=0;i<6;i++) RVA(0x7268)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
466 for (i=0;i<6;i++) RVA(0x7e83)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
467 for (i=0;i<6;i++) RVA(0x806a)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
468 } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x4120)) {
12042
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
469 // looks like VP 6.2.0.10
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
470 for (i=0;i<6;i++) RVA(0x7688)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
471 for (i=0;i<6;i++) RVA(0x82c3)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
472 for (i=0;i<6;i++) RVA(0x84aa)[i]=0x90;
18628
ff4455b0bd7c Nop some instructions causing the vfwvp6 dll encoder to crash.
banan
parents: 18617
diff changeset
473 for (i=0;i<6;i++) RVA(0x1d2cc)[i]=0x90;
ff4455b0bd7c Nop some instructions causing the vfwvp6 dll encoder to crash.
banan
parents: 18617
diff changeset
474 for (i=0;i<6;i++) RVA(0x2179d)[i]=0x90;
ff4455b0bd7c Nop some instructions causing the vfwvp6 dll encoder to crash.
banan
parents: 18617
diff changeset
475 for (i=0;i<6;i++) RVA(0x1977f)[i]=0x90;
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
476 } else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==RVA(0x3e70)) {
12422
ef68b86beaf4 Support vp6vfw.dll version 6.0.7.3
rtognimp
parents: 12042
diff changeset
477 // looks like VP 6.0.7.3
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
478 for (i=0;i<6;i++) RVA(0x7559)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
479 for (i=0;i<6;i++) RVA(0x81c3)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
480 for (i=0;i<6;i++) RVA(0x839e)[i]=0x90;
12042
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
481 } else {
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
482 fprintf(stderr, "Unsupported VP6 version\n");
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
483 return 0;
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
484 }
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
485 }
ebea9d9163b0 Support for vp5 and vp6 dll decoders
rtognimp
parents: 11868
diff changeset
486
13745
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
487 // Windows Media Video 9 Advanced
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
488 if (strstr(libname,"wmvadvd.dll") && wm)
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
489 {
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
490 // The codec calls IsRectEmpty with coords 0,0,0,0 => result is 0
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
491 // but it really wants the rectangle to be not empty
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
492 if (PE_FindExportedFunction(wm, "CreateInstance", TRUE)==RVA(0xb812)) {
13745
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
493 // Dll version is 10.0.0.3645
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
494 *RVA(0x8b0f)=0xeb; // Jump always, ignoring IsRectEmpty result
13745
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
495 } else {
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
496 fprintf(stderr, "Unsupported WMVA version\n");
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
497 return 0;
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
498 }
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
499 }
3db10035d297 Windows media video advanced profile (wmva) support via binary codec
rtognimp
parents: 13622
diff changeset
500
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
501 if (strstr(libname,"QuickTime.qts") && wm)
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
502 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
503 void** ptr;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
504 void *dispatch_addr;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
505 int i;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
506
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
507 // dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE);
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
508 dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE);
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
509 if (dispatch_addr == RVA(0x124c30))
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
510 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
511 fprintf(stderr, "QuickTime5 DLLs found\n");
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
512 ptr = (void **)RVA(0x375ca4); // dispatch_ptr
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
513 for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ?
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
514 for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
515 for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ?
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
516 for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ?
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
517 for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
518 #if 0
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
519 /* CreateThread callers */
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
520 for (i=0;i<5;i++) RVA(0x1487c5)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
521 for (i=0;i<5;i++) RVA(0x14b275)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
522 for (i=0;i<5;i++) RVA(0x1a24b1)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
523 for (i=0;i<5;i++) RVA(0x1afc5a)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
524 for (i=0;i<5;i++) RVA(0x2f799c)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
525 for (i=0;i<5;i++) RVA(0x2f7efe)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
526 for (i=0;i<5;i++) RVA(0x2fa33e)[i]=0x90;
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
527 #endif
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
528
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
529 #if 0
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
530 /* TerminateQTML fix */
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
531 for (i=0;i<47;i++) RVA(0x2fa3b8)[i]=0x90; // terminate thread
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
532 for (i=0;i<47;i++) RVA(0x2f7f78)[i]=0x90; // terminate thread
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
533 for (i=0;i<77;i++) RVA(0x1a13d5)[i]=0x90;
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
534 RVA(0x08e0ae)[0] = 0xc3; // font/dc remover
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
535 for (i=0;i<24;i++) RVA(0x07a1ad)[i]=0x90; // destroy window
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
536 #endif
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
537 } else if (dispatch_addr == RVA(0x13b330))
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
538 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
539 fprintf(stderr, "QuickTime6 DLLs found\n");
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
540 ptr = (void **)RVA(0x3b9524); // dispatcher_ptr
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
541 for (i=0;i<5;i++) RVA(0x2730cc)[i]=0x90; // make_new_region
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
542 for (i=0;i<28;i++) RVA(0x2730f7)[i]=0x90; // call__call_CreateCompatibleDC
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
543 for (i=0;i<5;i++) RVA(0x273122)[i]=0x90; // jmp_to_call_loadbitmap
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
544 for (i=0;i<9;i++) RVA(0x273131)[i]=0x90; // call__calls_OLE_shit
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
545 for (i=0;i<96;i++) RVA(0x2ac852)[i]=0x90; // disable threads
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
546 } else if (dispatch_addr == RVA(0x13c3e0))
10795
2ab9ab4f07b4 Support for QuickTime6.3 DLLs. Patch by Dima K. <dimakar@yahoo.com>
mosu
parents: 8451
diff changeset
547 {
2ab9ab4f07b4 Support for QuickTime6.3 DLLs. Patch by Dima K. <dimakar@yahoo.com>
mosu
parents: 8451
diff changeset
548 fprintf(stderr, "QuickTime6.3 DLLs found\n");
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
549 ptr = (void **)RVA(0x3ca01c); // dispatcher_ptr
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
550 for (i=0;i<5;i++) RVA(0x268f6c)[i]=0x90; // make_new_region
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
551 for (i=0;i<28;i++) RVA(0x268f97)[i]=0x90; // call__call_CreateCompatibleDC
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
552 for (i=0;i<5;i++) RVA(0x268fc2)[i]=0x90; // jmp_to_call_loadbitmap
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
553 for (i=0;i<9;i++) RVA(0x268fd1)[i]=0x90; // call__calls_OLE_shit
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
554 for (i=0;i<96;i++) RVA(0x2b4722)[i]=0x90; // disable threads
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
555 } else
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
556 {
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
557 fprintf(stderr, "Unsupported QuickTime version (%p)\n",
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
558 dispatch_addr);
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
559 return 0;
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
560 }
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
561
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
562 fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]);
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
563
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
564 #ifdef EMU_QTX_API
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
565 report_entry = report_func;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
566 report_ret = report_func_ret;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
567 wrapper_target=ptr[0];
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
568 ptr[0]=wrapper;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
569 #endif
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
570 }
18617
8a1439ab0d51 Fix runtime-patching code to take into account the address when the codec is loaded.
reimar
parents: 15166
diff changeset
571 #undef RVA
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
572
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
573 return wm ? wm->module : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
574 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
575
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
576
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
577 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
578 * LoadLibraryA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
579 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
580 HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
581 return LoadLibraryExA(libname,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
582 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
583
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
584 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
585 * FreeLibrary
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
586 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
587 WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
588 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
589 WIN_BOOL retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
590 WINE_MODREF *wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
591
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
592 wm=MODULE32_LookupHMODULE(hLibModule);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
593
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
594 if ( !wm || !hLibModule )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
595 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
596 SetLastError( ERROR_INVALID_HANDLE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
597 return 0;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
598 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
599 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
600 retv = MODULE_FreeLibrary( wm );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
601
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
602 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
603
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
604 /* garbage... */
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
605 if (local_wm == NULL) my_garbagecollection();
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
606
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
607 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
608 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
609
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
610 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
611 * MODULE_DecRefCount
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
612 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
613 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
614 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
615 static void MODULE_DecRefCount( WINE_MODREF *wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
616 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
617 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
618
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
619 if ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
620 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
621
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
622 if ( wm->refCount <= 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
623 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
624
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
625 --wm->refCount;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
626 TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
627
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
628 if ( wm->refCount == 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
629 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
630 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
631
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
632 for ( i = 0; i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
633 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
634 MODULE_DecRefCount( wm->deps[i] );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
635
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
636 wm->flags &= ~WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
637 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
638 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
639
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
640 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
641 * GetProcAddress (KERNEL32.257)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
642 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
643 FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
644 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
645 return MODULE_GetProcAddress( hModule, function, TRUE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
646 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
647
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
648 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
649
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
650 /*
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
651 http://lists.apple.com/archives/quicktime-api/2003/Jan/msg00278.html
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
652 */
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
653
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
654 struct ComponentParameters {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
655 unsigned char flags; /* call modifiers: sync/async, deferred, immed, etc */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
656 unsigned char paramSize; /* size in bytes of actual parameters passed to this call */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
657 short what; /* routine selector, negative for Component management calls */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
658 long params[1]; /* actual parameters for the indicated routine */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
659 };
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
660 typedef struct ComponentParameters ComponentParameters;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
661
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
662 static char* component_func(int what){
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
663 if (what < 0) // Range 0: Standard Component Calls
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
664 switch(what){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
665 case -1: return "kComponentOpenSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
666 case -2: return "kComponentCloseSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
667 case -3: return "kComponentCanDoSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
668 case -4: return "kComponentVersionSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
669 case -5: return "kComponentRegisterSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
670 case -6: return "kComponentTargetSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
671 case -7: return "kComponentUnregisterSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
672 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
673
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
674 if (what >= 0 && what <= 0xff) // Range 1: Generic codecs
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
675 switch(what & 0xff){
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
676 case 0: return "kImageCodecGetCodecInfoSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
677 case 1: return "kImageCodecGetCompressionTimeSelect";
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
678 case 2: return "kImageCodecGetMaxCompressionSizeSelect";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
679 case 3: return "kImageCodecPreCompressSelect";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
680 case 4: return "kImageCodecBandCompressSelect";
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
681 case 5: return "kImageCodecPreDecompressSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
682 case 6: return "kImageCodecBandDecompressSelect";
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
683 case 7: return "kImageCodecBusySelect";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
684 // finish this list from the above URL
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
685 case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect";
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
686 case 0x12: return "kImageCodecDisposeMemorySelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
687 case 0x14: return "kImageCodecNewImageBufferMemorySelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
688 case 0x28: return "kImageCodecRequestGammaLevelSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
689 }
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
690
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
691 //if (what >= 0x100 && what <= 0x1ff) // Range 2: Specific to QT Photo JPEG codecs
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
692
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
693 if (what >= 0x200 && what <= 0x2ff) // Range 3: Base Decompressor
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
694 switch(what & 0xff){
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
695 case 0: return "Preflight";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
696 case 1: return "Initialize";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
697 case 2: return "BeginBand";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
698 case 3: return "DrawBand";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
699 case 4: return "EndBand";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
700 case 5: return "QueueStarting";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
701 case 6: return "QueueStopping";
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
702 }
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
703
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
704 return "???";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
705 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
706
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
707 static int c_level=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
708
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 25418
diff changeset
709 static int dump_component(char* name, int type, void* orig, ComponentParameters *params,void** glob){
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 25418
diff changeset
710 int ( *orig)(ComponentParameters *params, void** glob) = orig;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
711 int ret,i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
712
13622
3c7d56b95a5a better component_func
alex
parents: 13621
diff changeset
713 fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what));
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
714
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
715 for(i=0;i<params->paramSize/4;i++)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
716 fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
717
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
718 ++c_level;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
719 ret=orig(params,glob);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
720 --c_level;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
721
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
722 if(ret>=0x1000)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
723 fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
724 else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
725 fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
726 return ret;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
727 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
728
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
729 #define DECL_COMPONENT(sname,name,type) \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
730 static void* real_ ## sname = NULL; \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
731 static int fake_ ## sname(ComponentParameters *params,void** glob){ \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
732 return dump_component(name,type,real_ ## sname, params, glob); \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
733 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
734
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
735 #include "qt_comp.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
736
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
737 #undef DECL_COMPONENT
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
738
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
739 #include "qt_fv.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
740
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
741 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
742
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
743 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
744
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
745 static uint32_t ret_array[4096];
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
746 static int ret_i=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
747
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
748 static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags)
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
749 {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
750 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
751 int i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
752 int* dptr;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
753 void* pwrapper=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
754 void* pptr=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
755 char* pname=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
756 int plen=-1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
757 // find the code:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
758
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
759 dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
760 // printf("FUNC: flag=%d ptr=%p\n",dptr[0],dptr[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
761 if(dptr[0]&255){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
762 dptr=dptr[1];dptr+=4*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
763 // printf("FUNC: ptr2=%p eax=%p edx=%p\n",dptr[1],dptr[0],dptr[2]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
764 pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
765 } else {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
766 pwrapper=0x62924910;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
767 switch(dptr[1]){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
768 case 0x629248d0:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
769 dptr=0x62b672c0;dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
770 // printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
771 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
772 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
773 case 0x62924e40:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
774 dptr=0x62b67c70;dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
775 // printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
776 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
777 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
778 case 0x62924e60:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
779 dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
780 // printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
781 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
782 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
783 case 0x62924e80:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
784 dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
785 // printf("FUNC: ptr2=%p eax=%p edx=%p\n",0x62924910,dptr[0],dptr[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
786 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
787 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
788 default:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
789 printf("FUNC: unknown ptr & psize!\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
790 pwrapper=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
791 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
792 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
793
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
794 for(i=0;qt_fv_list[i].name;i++){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
795 if(qt_fv_list[i].id==reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
796 pname=qt_fv_list[i].name;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
797 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
798 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
799 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
800
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
801 printf("FUNC[%X/%s]: wrapper=%p func=%p len=%d\n",reg->eax,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
802 pname?pname:"???",pwrapper,pptr,plen);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
803
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
804 printf("FUNC: caller=%p ebx=%p\n",((uint32_t *)stack_base)[0],reg->ebx);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
805
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
806 if(pname)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
807 printf("%*sENTER(%d): %s(",ret_i*2,"",ret_i,pname);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
808 else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
809 printf("%*sENTER(%d): %X(",ret_i*2,"",ret_i,reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
810 for (i=0;i<plen/4;i++){
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
811 unsigned int val=((uint32_t *)stack_base)[1+i];
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
812 unsigned char* fcc=&val;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
813 printf("%s0x%X", i?", ":"",val);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
814 if(fcc[0]>=0x20 && fcc[0]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
815 fcc[1]>=0x20 && fcc[1]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
816 fcc[2]>=0x20 && fcc[2]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
817 fcc[3]>=0x20 && fcc[3]<128) printf("='%c%c%c%c'",fcc[3],fcc[2],fcc[1],fcc[0]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
818 else if(val>=8 && val<65536) printf("=%d",val);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
819 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
820 printf(")\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
821 fflush(stdout);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
822
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
823 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
824
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
825 #if 1
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
826 // emulate some functions:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
827 switch(reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
828 // memory management:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
829 case 0x150011: //NewPtrClear
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
830 case 0x150012: //NewPtrSysClear
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
831 reg->eax=(uint32_t)malloc(((uint32_t *)stack_base)[1]);
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
832 memset((void *)reg->eax,0,((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
833 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
834 printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
835 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
836 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
837 case 0x15000F: //NewPtr
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
838 case 0x150010: //NewPtrSys
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
839 reg->eax=(uint32_t)malloc(((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
840 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
841 printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
842 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
843 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
844 case 0x15002f: //DisposePtr
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
845 if(((uint32_t *)stack_base)[1]>=0x60000000)
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
846 printf("WARNING! Invalid Ptr handle!\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
847 else
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
848 free((void *)((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
849 reg->eax=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
850 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
851 printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
852 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
853 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
854 // mutexes:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
855 case 0x1d0033: //QTMLCreateMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
856 reg->eax=0xdeadbabe;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
857 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
858 printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
859 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
860 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
861 case 0x1d0034: //QTMLDestroyMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
862 case 0x1d0035: //QTMLGrabMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
863 case 0x1d0036: //QTMLReturnMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
864 case 0x1d003d: //QTMLTryGrabMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
865 reg->eax=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
866 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
867 printf("%*sLEAVE(%d): EMULATED! 0x%X\n",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
868 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
869 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
870 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
871 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
872
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
873 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
874 switch(reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
875 // case 0x00010000:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
876 // printf("FUNC: ImageCodecInitialize/ImageCodecGetCodecInfo(ci=%p,&icap=%p)\n",((uint32_t *)stack_base)[1],((uint32_t *)stack_base)[4]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
877 // break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
878 case 0x00010003:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
879 printf("FUNC: CountComponents(&desc=%p)\n",((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
880 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
881 case 0x00010004:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
882 printf("FUNC: FindNextComponent(prev=%p,&desc=%p)\n",((uint32_t *)stack_base)[1],((uint32_t *)stack_base)[2]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
883 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
884 case 0x00010007:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
885 printf("FUNC: OpenComponent(prev=%p)\n",((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
886 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
887 case 0x0003008b:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
888 printf("FUNC: QTNewGWorldFromPtr(&pts=%p,fourcc=%.4s,&rect=%p,x1=%p,x2=%p,x3=%p,plane=%p,stride=%d)\n",
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
889 ((uint32_t *)stack_base)[1],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
890 &(((uint32_t *)stack_base)[2]),
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
891 ((uint32_t *)stack_base)[3],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
892 ((uint32_t *)stack_base)[4],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
893 ((uint32_t *)stack_base)[5],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
894 ((uint32_t *)stack_base)[6],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
895 ((uint32_t *)stack_base)[7],
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
896 ((uint32_t *)stack_base)[8]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
897 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
898 case 0x001c0018:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
899 printf("FUNC: GetGWorldPixMap(gworld=%p)\n",((uint32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
900 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
901 case 0x00110001:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
902 printf("FUNC: Gestalt(fourcc=%.4s, &ret=%p)\n",&(((uint32_t *)stack_base)[1]),((uint32_t *)stack_base)[2]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
903 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
904 default: {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
905 int i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
906 for(i=0;qt_fv_list[i].name;i++){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
907 if(qt_fv_list[i].id==reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
908 printf("FUNC: %s\n",qt_fv_list[i].name);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
909 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
910 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
911 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
912 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
913 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
914
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
915 // print stack/reg information
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
916 printf("ENTER(%d) stack = %d bytes @ %p\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
917 "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
918 "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
919 "flags = 0x%08x\n", ret_i,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
920 stack_size, stack_base,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
921 reg->eax, reg->edx, reg->ebx, reg->ecx,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
922 reg->esp, reg->ebp, reg->esi, reg->edi,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
923 *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
924 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
925
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
926 // save ret addr:
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
927 ret_array[ret_i]=((uint32_t *)stack_base)[0];
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
928 ++ret_i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
929
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
930 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
931 // print first 7 longs in the stack (return address, arg[1], arg[2] ... )
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
932 printf("stack[] = { ");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
933 for (i=0;i<7;i++) {
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
934 printf("%08x ", ((uint32_t *)stack_base)[i]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
935 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
936 printf("}\n\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
937 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
938
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
939 // // mess with function parameters
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
940 // ((uint32_t *)stack_base)[1] = 0x66554433;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
941
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
942 // // mess with return address...
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
943 // reg->eax = 0x11223344;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
944 return 0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
945 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
946
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
947 static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags)
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
948 {
24382
ea192b86100e warning fixes:
diego
parents: 21290
diff changeset
949 //int i;
25798
c8c9b4e89fb7 Surround variable declarations by preprocessor conditionals to avoid warnings:
diego
parents: 25794
diff changeset
950 #ifdef DEBUG_QTX_API
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
951 short err;
25798
c8c9b4e89fb7 Surround variable declarations by preprocessor conditionals to avoid warnings:
diego
parents: 25794
diff changeset
952 #endif
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
953
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
954 // restore ret addr:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
955 --ret_i;
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
956 ((uint32_t *)stack_base)[0]=ret_array[ret_i];
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
957
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
958 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
959
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
960 #if 1
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
961 printf("%*sLEAVE(%d): 0x%X",ret_i*2,"",ret_i, reg->eax);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
962 err=reg->eax;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
963 if(err && (reg->eax>>16)==0) printf(" = %d",err);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
964 printf("\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
965 fflush(stdout);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
966 #else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
967 // print stack/reg information
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
968 printf("LEAVE(%d) stack = %d bytes @ %p\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
969 "eax = 0x%08x edx = 0x%08x ebx = 0x%08x ecx = 0x%08x\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
970 "esp = 0x%08x ebp = 0x%08x esi = 0x%08x edi = 0x%08x\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
971 "flags = 0x%08x\n", ret_i,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
972 stack_size, stack_base,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
973 reg->eax, reg->edx, reg->ebx, reg->ecx,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
974 reg->esp, reg->ebp, reg->esi, reg->edi,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
975 *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
976 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
977
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
978 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
979 // print first 7 longs in the stack (return address, arg[1], arg[2] ... )
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
980 printf("stack[] = { ");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
981 for (i=0;i<7;i++) {
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
982 printf("%08x ", ((uint32_t *)stack_base)[i]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
983 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
984 printf("}\n\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
985 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
986
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
987 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
988
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
989 // // mess with function parameters
11868
711e584107af switch to inttypes.h (u_int32_t vs uint32_t) in favour of Solaris9/x86 support
alex
parents: 10795
diff changeset
990 // ((uint32_t *)stack_base)[1] = 0x66554433;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
991
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
992 // // mess with return address...
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
993 // reg->eax = 0x11223344;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
994 return 0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
995 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
996
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
997 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
998
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
999 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1000 * MODULE_GetProcAddress (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1001 */
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
1002 FARPROC MODULE_GetProcAddress(
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1003 HMODULE hModule, /* [in] current module handle */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1004 LPCSTR function, /* [in] function to be looked up */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1005 WIN_BOOL snoop )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1006 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1007 WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
1008 // WINE_MODREF *wm=local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1009 FARPROC retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1010
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1011 #ifdef DEBUG_QTX_API
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1012 if (HIWORD(function))
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1013 fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1014 else
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1015 fprintf(stderr,"XXX GetProcAddress(%08lx,%p)\n",(DWORD)hModule,function);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1016 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1017
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1018 // TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1019 // else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1020 // TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1021
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1022 if (!wm) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1023 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1024 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1025 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1026 switch (wm->type)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1027 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1028 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1029 retproc = PE_FindExportedFunction( wm, function, snoop );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1030 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1031 break;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
1032 #ifdef HAVE_LIBDL
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1033 case MODULE32_ELF:
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
1034 retproc = (FARPROC) dlsym( (void*) wm->module, function);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1035 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1036 return retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1037 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1038 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1039 ERR("wine_modref type %d not handled.\n",wm->type);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1040 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1041 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1042 }
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1043
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1044 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1045 if (HIWORD(function) && retproc){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1046
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1047 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1048 #define DECL_COMPONENT(sname,name,type) \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1049 if(!strcmp(function,name)){ \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1050 fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1051 real_ ## sname = retproc; retproc = fake_ ## sname; \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1052 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1053 #include "qt_comp.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1054 #undef DECL_COMPONENT
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1055 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1056
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1057 if(!strcmp(function,"theQuickTimeDispatcher")
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 25418
diff changeset
1058 // || !strcmp(function,"CallComponentFunctionWithStorage")
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 25418
diff changeset
1059 // || !strcmp(function,"CallComponent")
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1060 ){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1061 fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1062 report_entry = report_func;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1063 report_ret = report_func_ret;
13182
25cb0d6432d4 loader gcc warning fixes and avifile sync
rathann
parents: 12422
diff changeset
1064 wrapper_target=(void(*)(void))retproc;
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
1065 retproc=(FARPROC)wrapper;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1066 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1067
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1068 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1069 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1070
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
1071 return retproc;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1072 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1073
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1074 static int acounter = 0;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1075 void CodecAlloc(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1076 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1077 acounter++;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
1078 //printf("**************CODEC ALLOC %d\n", acounter);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1079 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1080
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1081 void CodecRelease(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1082 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1083 acounter--;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
1084 //printf("**************CODEC RELEASE %d\n", acounter);
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1085 if (acounter == 0)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1086 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1087 for (;;)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1088 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1089 modref_list* list = local_wm;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1090 if (!local_wm)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1091 break;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1092 //printf("CODECRELEASE %p\n", list);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1093 MODULE_FreeLibrary(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1094 MODULE_RemoveFromList(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1095 if (local_wm == NULL)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1096 my_garbagecollection();
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1097 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1098 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
1099 }