annotate loader/module.c @ 10612:8e678e833591

docs updates
author diego
date Fri, 15 Aug 2003 12:05:18 +0000
parents fb88ccbc5ccc
children 2ab9ab4f07b4
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 */
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
6
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
7 // define for quicktime calls debugging and/or MacOS-level emulation:
8286
1a9ea966d840 patching out threads ;) raw measure: 18% cpu instead 30%
alex
parents: 8277
diff changeset
8 #define EMU_QTX_API
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
9
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
10 // define for quicktime debugging (verbose logging):
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
11 //#define DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
12
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
13 #include "config.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <assert.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
25 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
26 #include "wine/winerror.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
27 #include "wine/heap.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
28 #include "wine/module.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
29 #include "wine/pe_image.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
30 #include "wine/debugtools.h"
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
31
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
32 #undef HAVE_LIBDL
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
33
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
34 #ifdef HAVE_LIBDL
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
35 #include <dlfcn.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
36 #include "wine/elfdll.h"
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
37 #endif
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
38 #include "win32.h"
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
39 #include "driver.h"
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
40
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
41 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
42 #include "wrapper.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
43 static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
44 static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
45 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
46
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
47 //#undef TRACE
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
48 //#define TRACE printf
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 //WINE_MODREF *local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 modref_list* local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
53 HANDLE SegptrHeap;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
54
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
55 WINE_MODREF* MODULE_FindModule(LPCSTR m)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 modref_list* list=local_wm;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
58 TRACE("FindModule: Module %s request\n", m);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 return NULL;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
61 // while(strcmp(m, list->wm->filename))
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
62 while(!strstr(list->wm->filename, m))
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 {
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
64 TRACE("%s: %x\n", list->wm->filename, list->wm->module);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 return NULL;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
68 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 TRACE("Resolved to %s\n", list->wm->filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
71 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
73 static void MODULE_RemoveFromList(WINE_MODREF *mod)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 modref_list* list=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 if(list==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 if(mod==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 if((list->prev==NULL)&&(list->next==NULL))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 // uninstall_fs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 for(;list;list=list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 if(list->wm==mod)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 if(list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 list->prev->next=list->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 if(list->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 list->next->prev=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 if(list==local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 local_wm=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
101
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
102 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
103
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 modref_list* list=local_wm;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
107 TRACE("LookupHMODULE: Module %X request\n", m);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 if(list==NULL)
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
109 {
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
110 TRACE("LookupHMODULE failed\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 return NULL;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
112 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 while(m!=list->wm->module)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 // printf("Checking list %X wm %X module %X\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 // list, list->wm, list->wm->module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if(list==NULL)
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
119 {
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
120 TRACE("LookupHMODULE failed\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 return NULL;
8277
db673d118d3f some extra debugging
alex
parents: 8271
diff changeset
122 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
123 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
124 TRACE("LookupHMODULE hit %p\n", list->wm);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
126 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 * MODULE_InitDll
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 WIN_BOOL retv = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
135 static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 "THREAD_ATTACH", "THREAD_DETACH" };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 /* Skip calls for modules loaded with special load flags */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 if ( ( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 || ( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 return TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 /* Call the initialization routine */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 switch ( wm->type )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 retv = PE_InitDLL( wm, type, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 case MODULE32_ELF:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 /* no need to do that, dlopen() already does */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 ERR("wine_modref type %d not handled.\n", wm->type );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 /* The state of the module list may have changed due to the call
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 to PE_InitDLL. We cannot assume that this module has not been
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 deleted. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 TRACE("(%p,%s,%p) - RETURN %d\n", wm, typeName[type], lpReserved, retv );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 * MODULE_DllProcessAttach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
176 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 * Send the process attach notification to all DLLs the given module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 * depends on (recursively). This is somewhat complicated due to the fact that
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 * - we have to respect the module dependencies, i.e. modules implicitly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 * referenced by another module have to be initialized before the module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 * itself can be initialized
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
183 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 * - the initialization routine of a DLL can itself call LoadLibrary,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 * thereby introducing a whole new set of dependencies (even involving
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 * the 'old' modules) at any time during the whole process
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 * (Note that this routine can be recursively entered not only directly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 * from itself, but also via LoadLibrary from one of the called initialization
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 * routines.)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 * Furthermore, we need to rearrange the main WINE_MODREF list to allow
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 * the process *detach* notifications to be sent in the correct order.
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
194 * This must not only take into account module dependencies, but also
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 * 'hidden' dependencies created by modules calling LoadLibrary in their
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 * attach notification routine.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 * The strategy is rather simple: we move a WINE_MODREF to the head of the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 * list after the attach notification has returned. This implies that the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 * detach notifications are called in the reverse of the sequence the attach
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 * notifications *returned*.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
206 static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 WIN_BOOL retv = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 /* prevent infinite recursion in case of cyclical dependencies */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 if ( ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 || ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 TRACE("(%s,%p) - START\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 /* Tag current MODREF to prevent recursive loop */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 /* Recursively attach all DLLs this one depends on */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 /* for ( i = 0; retv && i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 retv = MODULE_DllProcessAttach( wm->deps[i], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 /* Call DLL entry point */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 //local_wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 if(local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
232 local_wm->next = (modref_list*) malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 local_wm->next->prev=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 local_wm->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 local_wm->next->wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 local_wm=local_wm->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
240 local_wm = (modref_list*)malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 local_wm->next=local_wm->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 local_wm->wm=wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
243 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 /* Remove recursion flag */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 wm->flags &= ~WINE_MODREF_MARKER;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
246
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 wm->flags |= WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 * MODULE_DllProcessDetach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
262 *
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
263 * Send DLL process detach notifications. See the comment about calling
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 * sequence at MODULE_DllProcessAttach. Unless the bForceDetach flag
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 * is set, only DLLs with zero refcount are notified.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
267 static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
269 // WINE_MODREF *wm=local_wm;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
270 modref_list* l = local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 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
273 /* while (l)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
274 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
275 modref_list* f = l;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
276 l = l->next;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
277 free(f);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
278 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
279 local_wm = 0;*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
282 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
283 * MODULE_LoadLibraryExA (internal)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
284 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
285 * Load a PE style module according to the load order.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
286 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
287 * 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
288 * 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
289 * ignore the parameter because it would be extremely difficult to
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
290 * integrate this with different types of module represenations.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
291 *
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 static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
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 DWORD err = GetLastError();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
296 WINE_MODREF *pwm;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
297 int i;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
298 // module_loadorder_t *plo;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
299
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
300 SetLastError( ERROR_FILE_NOT_FOUND );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
301 TRACE("Trying native dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
302 pwm = PE_LoadLibraryExA(libname, flags);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
303 #ifdef HAVE_LIBDL
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
304 if(!pwm)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
305 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
306 TRACE("Trying ELF dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
307 pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
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 #endif
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
310 // printf("0x%08x\n", pwm);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
311 // break;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
312 if(pwm)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
313 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
314 /* Initialize DLL just loaded */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
315 TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
316 /* Set the refCount here so that an attach failure will */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
317 /* decrement the dependencies through the MODULE_FreeLibrary call. */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
318 pwm->refCount++;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
319
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
320 SetLastError( err ); /* restore last error */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
321 return 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
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
324
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
325 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
326 return NULL;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
327 }
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 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
330 * MODULE_FreeLibrary
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 * NOTE: Assumes that the process critical section is held!
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 static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
335 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
336 TRACE("(%s) - START\n", wm->modname );
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 /* Recursively decrement reference counts */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
339 //MODULE_DecRefCount( wm );
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 /* Call process detach notifications */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
342 MODULE_DllProcessDetach( wm, FALSE, NULL );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
343
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
344 PE_UnloadLibrary(wm);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
345
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
346 TRACE("END\n");
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
347
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
348 return TRUE;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
349 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 * LoadLibraryExA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
356 WINE_MODREF *wm = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
357 char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
358 extern char* def_path;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
359 char path[512];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
360 char checked[2000];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
361 int i = -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
363 checked[0] = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 if(!libname)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 SetLastError(ERROR_INVALID_PARAMETER);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 }
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
369
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
370 wm=MODULE_FindModule(libname);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
371 if(wm) return wm->module;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
372
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
373 // if(fs_installed==0)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
374 // install_fs();
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
375
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
376 while (wm == 0 && listpath[++i])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
377 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
378 if (i < 2)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
379 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
380 if (i == 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
381 /* 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
382 strncpy(path, libname, 511);
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
383 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
384 /* check default user path */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
385 strncpy(path, def_path, 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
386 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
387 else if (strcmp(def_path, listpath[i]))
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
388 /* path from the list */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
389 strncpy(path, listpath[i], 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
390 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
391 continue;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
393 if (i > 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
394 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
395 strcat(path, "/");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
396 strncat(path, libname, 100);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
397 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
398 path[511] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
399 wm = MODULE_LoadLibraryExA( path, hfile, flags );
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
400
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
401 if (!wm)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
402 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
403 if (checked[0])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
404 strcat(checked, ", ");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
405 strcat(checked, path);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
406 checked[1500] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
407
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
408 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
409 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 if ( wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 if ( !MODULE_DllProcessAttach( wm, NULL ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 WARN_(module)("Attach failed for module '%s', \n", libname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 MODULE_FreeLibrary(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 SetLastError(ERROR_DLL_INIT_FAILED);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 wm = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
422 if (!wm)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
423 printf("Win32 LoadLibrary failed to load: %s\n", checked);
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
424
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
425 if (strstr(libname,"QuickTime.qts") && wm)
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
426 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
427 void** ptr;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
428 void *dispatch_addr;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
429 int i;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
430
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
431 // dispatch_addr = GetProcAddress(wm->module, "theQuickTimeDispatcher", TRUE);
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
432 dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE);
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
433 if (dispatch_addr == (void *)0x62924c30)
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
434 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
435 fprintf(stderr, "QuickTime5 DLLs found\n");
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
436 ptr = (void **)0x62b75ca4; // dispatch_ptr
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
437 for (i=0;i<5;i++) ((char*)0x6299e842)[i]=0x90; // make_new_region ?
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
438 for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; // call__call_CreateCompatibleDC ?
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
439 for (i=0;i<5;i++) ((char*)0x6299e898)[i]=0x90; // jmp_to_call_loadbitmap ?
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
440 for (i=0;i<9;i++) ((char*)0x6299e8ac)[i]=0x90; // call__calls_OLE_shit ?
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
441 for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; // disable threads
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
442 #if 0
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
443 /* CreateThread callers */
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
444 for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
445 for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
446 for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
447 for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
448 for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
449 for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
450 for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
451 #endif
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
452
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
453 #if 0
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
454 /* TerminateQTML fix */
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
455 for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; // terminate thread
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
456 for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; // terminate thread
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
457 for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
458 ((char *)0x6288e0ae)[0] = 0xc3; // font/dc remover
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
459 for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; // destroy window
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
460 #endif
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
461 } else if (dispatch_addr == (void *)0x6693b330)
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
462 {
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
463 fprintf(stderr, "QuickTime6 DLLs found\n");
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
464 ptr = (void **)0x66bb9524; // dispatcher_ptr
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
465 for (i=0;i<5;i++) ((char *)0x66a730cc)[i]=0x90; // make_new_region
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
466 for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; // call__call_CreateCompatibleDC
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
467 for (i=0;i<5;i++) ((char *)0x66a73122)[i]=0x90; // jmp_to_call_loadbitmap
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
468 for (i=0;i<9;i++) ((char *)0x66a73131)[i]=0x90; // call__calls_OLE_shit
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
469 for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; // disable threads
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
470 } else
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
471 {
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
472 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
473 dispatch_addr);
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
474 return 0;
8318
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
475 }
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
476
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
477 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
478
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
479 #ifdef EMU_QTX_API
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
480 report_entry = report_func;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
481 report_ret = report_func_ret;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
482 wrapper_target=ptr[0];
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
483 ptr[0]=wrapper;
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
484 #endif
1ed329d61051 both qt5 and qt6 patching support (qt6 addresses found by arpi)
alex
parents: 8286
diff changeset
485 }
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
486
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 return wm ? wm->module : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
489
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
490
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
491 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
492 * LoadLibraryA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494 HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
495 return LoadLibraryExA(libname,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
496 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
497
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
498 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
499 * FreeLibrary
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
500 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
501 WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
502 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
503 WIN_BOOL retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
504 WINE_MODREF *wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 wm=MODULE32_LookupHMODULE(hLibModule);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
507
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 if ( !wm || !hLibModule )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
509 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
510 SetLastError( ERROR_INVALID_HANDLE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 return 0;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
512 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
513 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
514 retv = MODULE_FreeLibrary( wm );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
515
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
516 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
517
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
518 /* garbage... */
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
519 if (local_wm == NULL) my_garbagecollection();
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
520
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
521 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
522 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
523
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
524 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
525 * MODULE_DecRefCount
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
526 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
527 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
528 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
529 static void MODULE_DecRefCount( WINE_MODREF *wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
530 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
531 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
532
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
533 if ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
534 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
535
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
536 if ( wm->refCount <= 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
537 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
538
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
539 --wm->refCount;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
540 TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
541
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
542 if ( wm->refCount == 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
543 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
544 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
545
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
546 for ( i = 0; i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
547 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
548 MODULE_DecRefCount( wm->deps[i] );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
549
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
550 wm->flags &= ~WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
551 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
552 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
553
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
554 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
555 * GetProcAddress (KERNEL32.257)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
556 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
557 FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
558 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
559 return MODULE_GetProcAddress( hModule, function, TRUE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
560 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
561
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
562 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
563
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
564 struct ComponentParameters {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
565 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
566 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
567 short what; /* routine selector, negative for Component management calls */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
568 long params[1]; /* actual parameters for the indicated routine */
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
569 };
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
570 typedef struct ComponentParameters ComponentParameters;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
571
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
572 static char* component_func(int what){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
573 switch(what){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
574 case -1: return "kComponentOpenSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
575 case -2: return "kComponentCloseSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
576 case -3: return "kComponentCanDoSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
577 case -4: return "kComponentVersionSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
578 case -5: return "kComponentRegisterSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
579 case -6: return "kComponentTargetSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
580 case -7: return "kComponentUnregisterSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
581 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
582 return "???";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
583 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
584
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
585 static char* component_func_type(int type,int what){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
586 if(type==1) switch(what){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
587 case 0: return "kImageCodecGetCodecInfoSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
588 case 1: return "kImageCodecGetCompressionTimeSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
589 case 5: return "kImageCodecPreDecompressSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
590 case 6: return "kImageCodecBandDecompressSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
591 case 0x12: return "kImageCodecDisposeMemorySelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
592 case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
593 case 0x14: return "kImageCodecNewImageBufferMemorySelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
594 case 0x28: return "kImageCodecRequestGammaLevelSelect";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
595 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
596 return "???";
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
597 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
598
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
599
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
600 static int c_level=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
601
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
602 static int dump_component(char* name,int type,void* _orig, ComponentParameters *params,void** glob){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
603 int ( *orig)(ComponentParameters *params, void** glob) = _orig;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
604 int ret,i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
605
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
606 if(params->what<0)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
607 fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=%d %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what));
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
608 else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
609 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_type(type,params->what));
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
610
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
611 for(i=0;i<params->paramSize/4;i++)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
612 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
613
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
614 ++c_level;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
615 ret=orig(params,glob);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
616 --c_level;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
617
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
618 if(ret>=0x1000)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
619 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
620 else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
621 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
622 return ret;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
623 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
624
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
625 #define DECL_COMPONENT(sname,name,type) \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
626 static void* real_ ## sname = NULL; \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
627 static int fake_ ## sname(ComponentParameters *params,void** glob){ \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
628 return dump_component(name,type,real_ ## sname, params, glob); \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
629 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
630
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
631 #include "qt_comp.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
632
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
633 #undef DECL_COMPONENT
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
634
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
635 #include "qt_fv.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
636
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
637 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
638
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
639 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
640
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
641 static u_int32_t ret_array[4096];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
642 static int ret_i=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
643
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
644 static int report_func(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
645 {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
646 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
647 int i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
648 int* dptr;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
649 void* pwrapper=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
650 void* pptr=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
651 char* pname=NULL;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
652 int plen=-1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
653 // find the code:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
654
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
655 dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
656 // 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
657 if(dptr[0]&255){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
658 dptr=dptr[1];dptr+=4*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
659 // 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
660 pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
661 } else {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
662 pwrapper=0x62924910;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
663 switch(dptr[1]){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
664 case 0x629248d0:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
665 dptr=0x62b672c0;dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
666 // 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
667 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
668 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
669 case 0x62924e40:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
670 dptr=0x62b67c70;dptr+=2*(reg->eax&65535);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
671 // 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
672 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
673 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
674 case 0x62924e60:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
675 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
676 // 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
677 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
678 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
679 case 0x62924e80:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
680 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
681 // 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
682 pptr=dptr[0]; plen=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
683 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
684 default:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
685 printf("FUNC: unknown ptr & psize!\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
686 pwrapper=dptr[1];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
687 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
688 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
689
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
690 for(i=0;qt_fv_list[i].name;i++){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
691 if(qt_fv_list[i].id==reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
692 pname=qt_fv_list[i].name;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
693 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
694 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
695 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
696
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
697 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
698 pname?pname:"???",pwrapper,pptr,plen);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
699
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
700 printf("FUNC: caller=%p ebx=%p\n",((u_int32_t *)stack_base)[0],reg->ebx);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
701
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
702 if(pname)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
703 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
704 else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
705 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
706 for (i=0;i<plen/4;i++){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
707 unsigned int val=((u_int32_t *)stack_base)[1+i];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
708 unsigned char* fcc=&val;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
709 printf("%s0x%X", i?", ":"",val);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
710 if(fcc[0]>=0x20 && fcc[0]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
711 fcc[1]>=0x20 && fcc[1]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
712 fcc[2]>=0x20 && fcc[2]<128 &&
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
713 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
714 else if(val>=8 && val<65536) printf("=%d",val);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
715 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
716 printf(")\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
717 fflush(stdout);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
718
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
719 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
720
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
721 #if 1
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
722 // emulate some functions:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
723 switch(reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
724 // memory management:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
725 case 0x150011: //NewPtrClear
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
726 case 0x150012: //NewPtrSysClear
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
727 reg->eax=(u_int32_t)malloc(((u_int32_t *)stack_base)[1]);
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
728 memset((void *)reg->eax,0,((u_int32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
729 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
730 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
731 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
732 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
733 case 0x15000F: //NewPtr
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
734 case 0x150010: //NewPtrSys
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
735 reg->eax=(u_int32_t)malloc(((u_int32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
736 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
737 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
738 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
739 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
740 case 0x15002f: //DisposePtr
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
741 if(((u_int32_t *)stack_base)[1]>=0x60000000)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
742 printf("WARNING! Invalid Ptr handle!\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
743 else
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
744 free((void *)((u_int32_t *)stack_base)[1]);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
745 reg->eax=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
746 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
747 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
748 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
749 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
750 // mutexes:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
751 case 0x1d0033: //QTMLCreateMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
752 reg->eax=0xdeadbabe;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
753 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
754 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
755 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
756 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
757 case 0x1d0034: //QTMLDestroyMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
758 case 0x1d0035: //QTMLGrabMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
759 case 0x1d0036: //QTMLReturnMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
760 case 0x1d003d: //QTMLTryGrabMutex
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
761 reg->eax=0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
762 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
763 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
764 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
765 return 1;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
766 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
767 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
768
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
769 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
770 switch(reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
771 // case 0x00010000:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
772 // printf("FUNC: ImageCodecInitialize/ImageCodecGetCodecInfo(ci=%p,&icap=%p)\n",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[4]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
773 // break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
774 case 0x00010003:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
775 printf("FUNC: CountComponents(&desc=%p)\n",((u_int32_t *)stack_base)[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
776 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
777 case 0x00010004:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
778 printf("FUNC: FindNextComponent(prev=%p,&desc=%p)\n",((u_int32_t *)stack_base)[1],((u_int32_t *)stack_base)[2]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
779 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
780 case 0x00010007:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
781 printf("FUNC: OpenComponent(prev=%p)\n",((u_int32_t *)stack_base)[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 0x0003008b:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
784 printf("FUNC: QTNewGWorldFromPtr(&pts=%p,fourcc=%.4s,&rect=%p,x1=%p,x2=%p,x3=%p,plane=%p,stride=%d)\n",
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
785 ((u_int32_t *)stack_base)[1],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
786 &(((u_int32_t *)stack_base)[2]),
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
787 ((u_int32_t *)stack_base)[3],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
788 ((u_int32_t *)stack_base)[4],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
789 ((u_int32_t *)stack_base)[5],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
790 ((u_int32_t *)stack_base)[6],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
791 ((u_int32_t *)stack_base)[7],
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
792 ((u_int32_t *)stack_base)[8]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
793 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
794 case 0x001c0018:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
795 printf("FUNC: GetGWorldPixMap(gworld=%p)\n",((u_int32_t *)stack_base)[1]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
796 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
797 case 0x00110001:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
798 printf("FUNC: Gestalt(fourcc=%.4s, &ret=%p)\n",&(((u_int32_t *)stack_base)[1]),((u_int32_t *)stack_base)[2]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
799 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
800 default: {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
801 int i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
802 for(i=0;qt_fv_list[i].name;i++){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
803 if(qt_fv_list[i].id==reg->eax){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
804 printf("FUNC: %s\n",qt_fv_list[i].name);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
805 break;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
806 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
807 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
808 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
809 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
810
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
811 // print stack/reg information
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
812 printf("ENTER(%d) stack = %d bytes @ %p\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
813 "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
814 "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
815 "flags = 0x%08x\n", ret_i,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
816 stack_size, stack_base,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
817 reg->eax, reg->edx, reg->ebx, reg->ecx,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
818 reg->esp, reg->ebp, reg->esi, reg->edi,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
819 *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
820 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
821
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
822 // save ret addr:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
823 ret_array[ret_i]=((u_int32_t *)stack_base)[0];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
824 ++ret_i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
825
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
826 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
827 // 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
828 printf("stack[] = { ");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
829 for (i=0;i<7;i++) {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
830 printf("%08x ", ((u_int32_t *)stack_base)[i]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
831 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
832 printf("}\n\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
833 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
834
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
835 // // mess with function parameters
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
836 // ((u_int32_t *)stack_base)[1] = 0x66554433;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
837
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
838 // // mess with return address...
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
839 // reg->eax = 0x11223344;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
840 return 0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
841 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
842
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
843 static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, u_int32_t *flags)
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
844 {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
845 int i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
846 short err;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
847
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
848 // restore ret addr:
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
849 --ret_i;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
850 ((u_int32_t *)stack_base)[0]=ret_array[ret_i];
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
851
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
852 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
853
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
854 #if 1
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
855 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
856 err=reg->eax;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
857 if(err && (reg->eax>>16)==0) printf(" = %d",err);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
858 printf("\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
859 fflush(stdout);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
860 #else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
861 // print stack/reg information
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
862 printf("LEAVE(%d) stack = %d bytes @ %p\n"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
863 "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
864 "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
865 "flags = 0x%08x\n", ret_i,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
866 stack_size, stack_base,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
867 reg->eax, reg->edx, reg->ebx, reg->ecx,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
868 reg->esp, reg->ebp, reg->esi, reg->edi,
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
869 *flags);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
870 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
871
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
872 #if 0
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
873 // 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
874 printf("stack[] = { ");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
875 for (i=0;i<7;i++) {
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
876 printf("%08x ", ((u_int32_t *)stack_base)[i]);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
877 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
878 printf("}\n\n");
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
879 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
880
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
881 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
882
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
883 // // mess with function parameters
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
884 // ((u_int32_t *)stack_base)[1] = 0x66554433;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
885
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
886 // // mess with return address...
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
887 // reg->eax = 0x11223344;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
888 return 0;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
889 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
890
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
891 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
892
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
893 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
894 * MODULE_GetProcAddress (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
895 */
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
896 FARPROC MODULE_GetProcAddress(
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
897 HMODULE hModule, /* [in] current module handle */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
898 LPCSTR function, /* [in] function to be looked up */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
899 WIN_BOOL snoop )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
900 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
901 WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
902 // WINE_MODREF *wm=local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
903 FARPROC retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
904
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
905 #ifdef DEBUG_QTX_API
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
906 if (HIWORD(function))
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
907 fprintf(stderr,"XXX GetProcAddress(%08lx,%s)\n",(DWORD)hModule,function);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
908 else
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
909 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
910 #endif
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 // TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
913 // else
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
914 // TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
915
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
916 if (!wm) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
917 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
918 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
919 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
920 switch (wm->type)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
921 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
922 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
923 retproc = PE_FindExportedFunction( wm, function, snoop );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
924 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
925 break;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
926 #ifdef HAVE_LIBDL
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
927 case MODULE32_ELF:
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
928 retproc = (FARPROC) dlsym( (void*) wm->module, function);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
929 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
930 return retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
931 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
932 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
933 ERR("wine_modref type %d not handled.\n",wm->type);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
934 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
935 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
936 }
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
937
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
938 #ifdef EMU_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
939 if (HIWORD(function) && retproc){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
940
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
941 #ifdef DEBUG_QTX_API
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
942 #define DECL_COMPONENT(sname,name,type) \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
943 if(!strcmp(function,name)){ \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
944 fprintf(stderr,name "dispatcher catched -> %p\n",retproc); \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
945 real_ ## sname = retproc; retproc = fake_ ## sname; \
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
946 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
947 #include "qt_comp.h"
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
948 #undef DECL_COMPONENT
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
949 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
950
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
951 if(!strcmp(function,"theQuickTimeDispatcher")
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
952 // || !strcmp(function,"_CallComponentFunctionWithStorage")
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
953 // || !strcmp(function,"_CallComponent")
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
954 ){
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
955 fprintf(stderr,"theQuickTimeDispatcher catched -> %p\n",retproc);
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
956 report_entry = report_func;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
957 report_ret = report_func_ret;
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
958 wrapper_target=retproc;
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8318
diff changeset
959 retproc=(FARPROC)wrapper;
8269
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
960 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
961
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
962 }
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
963 #endif
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
964
8b905703a450 - qtx (quicktime's macos emulation layer) debugging/emulation environment :)
arpi
parents: 7386
diff changeset
965 return retproc;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
966 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
967
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
968 static int acounter = 0;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
969 void CodecAlloc(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
970 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
971 acounter++;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
972 //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
973 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
974
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
975 void CodecRelease(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
976 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
977 acounter--;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
978 //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
979 if (acounter == 0)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
980 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
981 for (;;)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
982 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
983 modref_list* list = local_wm;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
984 if (!local_wm)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
985 break;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
986 //printf("CODECRELEASE %p\n", list);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
987 MODULE_FreeLibrary(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
988 MODULE_RemoveFromList(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
989 if (local_wm == NULL)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
990 my_garbagecollection();
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
991 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
992 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
993 }