annotate loader/module.c @ 7957:31fd09cc9ba2

passing picture_type (might be usefull for postprocessing)
author michael
date Tue, 29 Oct 2002 11:26:26 +0000
parents 174e2a58b4cd
children 8b905703a450
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 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
6 #include "config.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 #include <assert.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <sys/types.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
19 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
20 #include "wine/winerror.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
21 #include "wine/heap.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
22 #include "wine/module.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
23 #include "wine/pe_image.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
24 #include "wine/debugtools.h"
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
25 #ifdef HAVE_LIBDL
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
26 #include <dlfcn.h>
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
27 #include "wine/elfdll.h"
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
28 #endif
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
29 #include "win32.h"
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
30 #include "driver.h"
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
31
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
32 //#undef TRACE
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
33 //#define TRACE printf
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 //WINE_MODREF *local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 modref_list* local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
38 HANDLE SegptrHeap;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
39
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
40 WINE_MODREF* MODULE_FindModule(LPCSTR m)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 modref_list* list=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 TRACE("Module %s request\n", m);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 while(strcmp(m, list->wm->filename))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 {
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
48 TRACE("%s: %x\n", list->wm->filename, list->wm->module);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 return NULL;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
52 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 TRACE("Resolved to %s\n", list->wm->filename);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
55 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
1307
d8c1b0b38edc Add prototypes to wine/loader stuff, so that we can catch __stdcall function
jkeil
parents: 128
diff changeset
57 static void MODULE_RemoveFromList(WINE_MODREF *mod)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 modref_list* list=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 if(list==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 if(mod==0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 if((list->prev==NULL)&&(list->next==NULL))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 // uninstall_fs();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 for(;list;list=list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 if(list->wm==mod)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 if(list->prev)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 list->prev->next=list->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 if(list->next)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 list->next->prev=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 if(list==local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 local_wm=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 free(list);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 }
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
85
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
86 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
87
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 modref_list* list=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 TRACE("Module %X request\n", m);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 while(m!=list->wm->module)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 // printf("Checking list %X wm %X module %X\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 // list, list->wm, list->wm->module);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 list=list->prev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 if(list==NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 return NULL;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
101 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
102 TRACE("LookupHMODULE hit %p\n", list->wm);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 return list->wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
104 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 * MODULE_InitDll
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 WIN_BOOL retv = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
113 static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 "THREAD_ATTACH", "THREAD_DETACH" };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 /* Skip calls for modules loaded with special load flags */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 if ( ( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 || ( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 return TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 /* Call the initialization routine */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 switch ( wm->type )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 retv = PE_InitDLL( wm, type, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 case MODULE32_ELF:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 /* no need to do that, dlopen() already does */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 ERR("wine_modref type %d not handled.\n", wm->type );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 /* The state of the module list may have changed due to the call
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 to PE_InitDLL. We cannot assume that this module has not been
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 deleted. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 TRACE("(%p,%s,%p) - RETURN %d\n", wm, typeName[type], lpReserved, retv );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 * MODULE_DllProcessAttach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
154 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 * Send the process attach notification to all DLLs the given module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 * depends on (recursively). This is somewhat complicated due to the fact that
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 * - we have to respect the module dependencies, i.e. modules implicitly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 * referenced by another module have to be initialized before the module
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 * itself can be initialized
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
161 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 * - the initialization routine of a DLL can itself call LoadLibrary,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 * thereby introducing a whole new set of dependencies (even involving
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 * the 'old' modules) at any time during the whole process
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 * (Note that this routine can be recursively entered not only directly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 * from itself, but also via LoadLibrary from one of the called initialization
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 * routines.)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 * Furthermore, we need to rearrange the main WINE_MODREF list to allow
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 * the process *detach* notifications to be sent in the correct order.
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
172 * This must not only take into account module dependencies, but also
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 * 'hidden' dependencies created by modules calling LoadLibrary in their
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 * attach notification routine.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 * The strategy is rather simple: we move a WINE_MODREF to the head of the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 * list after the attach notification has returned. This implies that the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 * detach notifications are called in the reverse of the sequence the attach
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 * notifications *returned*.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
184 static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 WIN_BOOL retv = TRUE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 assert( wm );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 /* prevent infinite recursion in case of cyclical dependencies */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 if ( ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 || ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 TRACE("(%s,%p) - START\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 /* Tag current MODREF to prevent recursive loop */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 /* Recursively attach all DLLs this one depends on */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 /* for ( i = 0; retv && i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 retv = MODULE_DllProcessAttach( wm->deps[i], lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 /* Call DLL entry point */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 //local_wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 if(local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
210 local_wm->next = (modref_list*) malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 local_wm->next->prev=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 local_wm->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 local_wm->next->wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 local_wm=local_wm->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 {
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
218 local_wm = (modref_list*)malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 local_wm->next=local_wm->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 local_wm->wm=wm;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
221 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 /* Remove recursion flag */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 wm->flags &= ~WINE_MODREF_MARKER;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
224
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 if ( retv )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 wm->flags |= WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 /*************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 * MODULE_DllProcessDetach
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
240 *
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
241 * Send DLL process detach notifications. See the comment about calling
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 * sequence at MODULE_DllProcessAttach. Unless the bForceDetach flag
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 * is set, only DLLs with zero refcount are notified.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 */
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
245 static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 {
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
247 // WINE_MODREF *wm=local_wm;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
248 modref_list* l = local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 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
251 /* while (l)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
252 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
253 modref_list* f = l;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
254 l = l->next;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
255 free(f);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
256 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
257 local_wm = 0;*/
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
260 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
261 * MODULE_LoadLibraryExA (internal)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
262 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
263 * Load a PE style module according to the load order.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
264 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
265 * 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
266 * 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
267 * ignore the parameter because it would be extremely difficult to
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
268 * integrate this with different types of module represenations.
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
269 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
270 */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
271 static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
272 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
273 DWORD err = GetLastError();
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
274 WINE_MODREF *pwm;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
275 int i;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
276 // module_loadorder_t *plo;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
277
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
278 SetLastError( ERROR_FILE_NOT_FOUND );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
279 TRACE("Trying native dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
280 pwm = PE_LoadLibraryExA(libname, flags);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
281 #ifdef HAVE_LIBDL
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
282 if(!pwm)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
283 {
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
284 TRACE("Trying ELF dll '%s'\n", libname);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
285 pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags);
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 #endif
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
288 // printf("0x%08x\n", pwm);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
289 // break;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
290 if(pwm)
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 /* Initialize DLL just loaded */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
293 TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module);
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
294 /* Set the refCount here so that an attach failure will */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
295 /* decrement the dependencies through the MODULE_FreeLibrary call. */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
296 pwm->refCount++;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
297
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
298 SetLastError( err ); /* restore last error */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
299 return pwm;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
300 }
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
301
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
302
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
303 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
304 return NULL;
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
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
307 /***********************************************************************
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
308 * MODULE_FreeLibrary
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
309 *
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
310 * NOTE: Assumes that the process critical section is held!
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
311 */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
312 static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
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 TRACE("(%s) - START\n", wm->modname );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
315
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
316 /* Recursively decrement reference counts */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
317 //MODULE_DecRefCount( wm );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
318
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
319 /* Call process detach notifications */
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
320 MODULE_DllProcessDetach( wm, FALSE, NULL );
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
321
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
322 PE_UnloadLibrary(wm);
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 TRACE("END\n");
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
325
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
326 return TRUE;
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
327 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 * LoadLibraryExA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 {
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
334 WINE_MODREF *wm = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
335 char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", 0 };
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
336 extern char* def_path;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
337 char path[512];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
338 char checked[2000];
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
339 int i = -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
341 checked[0] = 0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 if(!libname)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 SetLastError(ERROR_INVALID_PARAMETER);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 }
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
347 // if(fs_installed==0)
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
348 // install_fs();
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
349
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
350 while (wm == 0 && listpath[++i])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
351 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
352 if (i < 2)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
353 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
354 if (i == 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
355 /* 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
356 strncpy(path, libname, 511);
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
357 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
358 /* check default user path */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
359 strncpy(path, def_path, 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
360 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
361 else if (strcmp(def_path, listpath[i]))
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
362 /* path from the list */
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
363 strncpy(path, listpath[i], 300);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
364 else
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
365 continue;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
367 if (i > 0)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
368 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
369 strcat(path, "/");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
370 strncat(path, libname, 100);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
371 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
372 path[511] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
373 wm = MODULE_LoadLibraryExA( path, hfile, flags );
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
374
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
375 if (!wm)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
376 {
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
377 if (checked[0])
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
378 strcat(checked, ", ");
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
379 strcat(checked, path);
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
380 checked[1500] = 0;
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
381
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
382 }
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
383 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 if ( wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 if ( !MODULE_DllProcessAttach( wm, NULL ) )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 WARN_(module)("Attach failed for module '%s', \n", libname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 MODULE_FreeLibrary(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 SetLastError(ERROR_DLL_INIT_FAILED);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 wm = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
396 if (!wm)
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
397 printf("Win32 LoadLibrary failed to load: %s\n", checked);
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 6768
diff changeset
398
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
399
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 return wm ? wm->module : 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 * LoadLibraryA (KERNEL32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 HMODULE WINAPI LoadLibraryA(LPCSTR libname) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 return LoadLibraryExA(libname,0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 * FreeLibrary
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 WIN_BOOL retv = FALSE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 WINE_MODREF *wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 wm=MODULE32_LookupHMODULE(hLibModule);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 if ( !wm || !hLibModule )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 SetLastError( ERROR_INVALID_HANDLE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 return 0;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
425 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 retv = MODULE_FreeLibrary( wm );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
428
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 MODULE_RemoveFromList(wm);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430
128
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
431 /* garbage... */
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
432 if (local_wm == NULL) my_garbagecollection();
28091b3caff9 DLL loader updated from avifile-0.60beta4
arpi_esp
parents: 1
diff changeset
433
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 return retv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 * MODULE_DecRefCount
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 * NOTE: Assumes that the process critical section is held!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 static void MODULE_DecRefCount( WINE_MODREF *wm )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 if ( wm->flags & WINE_MODREF_MARKER )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 if ( wm->refCount <= 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 --wm->refCount;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 if ( wm->refCount == 0 )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 wm->flags |= WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 for ( i = 0; i < wm->nDeps; i++ )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 if ( wm->deps[i] )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 MODULE_DecRefCount( wm->deps[i] );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 wm->flags &= ~WINE_MODREF_MARKER;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 * GetProcAddress (KERNEL32.257)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 return MODULE_GetProcAddress( hModule, function, TRUE );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 /***********************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476 * MODULE_GetProcAddress (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 */
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
478 FARPROC MODULE_GetProcAddress(
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479 HMODULE hModule, /* [in] current module handle */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 LPCSTR function, /* [in] function to be looked up */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 WIN_BOOL snoop )
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 WINE_MODREF *wm = MODULE32_LookupHMODULE( hModule );
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
484 // WINE_MODREF *wm=local_wm;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485 FARPROC retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 if (HIWORD(function))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488 TRACE_(win32)("(%08lx,%s)\n",(DWORD)hModule,function);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
489 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
490 TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
491 if (!wm) {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
492 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
495 switch (wm->type)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
496 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
497 case MODULE32_PE:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
498 retproc = PE_FindExportedFunction( wm, function, snoop );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
499 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
500 return retproc;
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
501 #ifdef HAVE_LIBDL
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
502 case MODULE32_ELF:
2069
ce45cce7f7a5 sync with avifile
arpi
parents: 1307
diff changeset
503 retproc = (FARPROC) dlsym( (void*) wm->module, function);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
504 if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
505 return retproc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
506 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
507 default:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
508 ERR("wine_modref type %d not handled.\n",wm->type);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
509 SetLastError(ERROR_INVALID_HANDLE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
510 return (FARPROC)0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
511 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
512 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
513
2651
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
514 static int acounter = 0;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
515 void CodecAlloc(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
516 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
517 acounter++;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
518 //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
519 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
520
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
521 void CodecRelease(void)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
522 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
523 acounter--;
3465
4dad31e655b6 avifile merge. kabi: indent changes really suxxxx
arpi
parents: 2651
diff changeset
524 //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
525 if (acounter == 0)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
526 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
527 for (;;)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
528 {
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
529 modref_list* list = local_wm;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
530 if (!local_wm)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
531 break;
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
532 //printf("CODECRELEASE %p\n", list);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
533 MODULE_FreeLibrary(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
534 MODULE_RemoveFromList(list->wm);
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
535 if (local_wm == NULL)
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
536 my_garbagecollection();
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
537 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
538 }
958d10763c34 partially synced with avifile... (TODO: migrate to new registry.c and driver.c)
arpi
parents: 2069
diff changeset
539 }