annotate loader/elfdll.c @ 31712:0f81290cb05d

Add some comments to the rgb2yuv_table, clarifying the standard where are defined.
author stefano
date Sat, 24 Jul 2010 11:19:35 +0000
parents 4790fe65b11a
children db0bb7511440
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 * Elf-dll loader functions
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright 1999 Bertho A. Stultiens
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 7386
diff changeset
5 *
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
6 * Modified for use with MPlayer, detailed changelog at
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 15166
diff changeset
7 * http://svn.mplayerhq.hu/mplayer/trunk/
15166
f5537cc95b02 Mark modified imported files as such to comply with GPL ¡ø2a.
diego
parents: 7386
diff changeset
8 *
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 */
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
10 #include "config.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 #ifdef HAVE_LIBDL
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
7386
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
14 #include "wine/windef.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
15 #include "wine/module.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
16 #include "wine/heap.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
17 #include "wine/elfdll.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
18 #include "wine/debugtools.h"
174e2a58b4cd avifile sync - 95% cosmetics 5% bug
arpi
parents: 2139
diff changeset
19 #include "wine/winerror.h"
25773
dfeedb0580f0 Add missing #include, fixes the warning:
diego
parents: 24388
diff changeset
20 #include "debug.h"
30901
76a13038105e Rename get_path.[ch] --> path.[ch].
diego
parents: 30900
diff changeset
21 #include "path.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 //DEFAULT_DEBUG_CHANNEL(elfdll)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
2139
e06cabbd1a9b changes merged back from avifile cvs
arpi
parents: 2069
diff changeset
25 #include <stdio.h>
e06cabbd1a9b changes merged back from avifile cvs
arpi
parents: 2069
diff changeset
26 #include <stdlib.h>
e06cabbd1a9b changes merged back from avifile cvs
arpi
parents: 2069
diff changeset
27 #include <string.h>
e06cabbd1a9b changes merged back from avifile cvs
arpi
parents: 2069
diff changeset
28 #include <ctype.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <dlfcn.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 //WINE_MODREF *local_wm=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 extern modref_list* local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 /*------------------ HACKS -----------------*/
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 25849
diff changeset
37 DWORD fixup_imports(WINE_MODREF *wm);
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 25849
diff changeset
38 void dump_exports(HMODULE hModule);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 /*---------------- END HACKS ---------------*/
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 struct elfdll_image
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 HMODULE pe_module_start;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 DWORD pe_module_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 /****************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 * ELFDLL_dlopen
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 * Wrapper for dlopen to search the EXTRA_LD_LIBRARY_PATH from wine.conf
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 * manually because libdl.so caches the environment and does not accept our
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 * changes.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 void *ELFDLL_dlopen(const char *libname, int flags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 char buffer[256];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 int namelen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 void *handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 char *ldpath;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 /* First try the default path search of dlopen() */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 handle = dlopen(libname, flags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 if(handle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 return handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 /* Now try to construct searches through our extra search-path */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 namelen = strlen(libname);
30907
b32527b30d17 Get rid of pointless def_path variable; use codec_path directly instead.
diego
parents: 30901
diff changeset
69 ldpath = codec_path;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 while(ldpath && *ldpath)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 char *cptr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 char *from;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 from = ldpath;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 cptr = strchr(ldpath, ':');
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 if(!cptr)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 len = strlen(ldpath);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 ldpath = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 len = cptr - ldpath;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 ldpath = cptr + 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 if(len + namelen + 1 >= sizeof(buffer))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 ERR("Buffer overflow! Check EXTRA_LD_LIBRARY_PATH or increase buffer size.\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 strncpy(buffer, from, len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 if(len)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 buffer[len] = '/';
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 strcpy(buffer + len + 1, libname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 strcpy(buffer + len, libname);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 TRACE("Trying dlopen('%s', %d)\n", buffer, flags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 handle = dlopen(buffer, flags);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 if(handle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 return handle;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 /****************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 * get_sobasename (internal)
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 static LPSTR get_sobasename(LPCSTR path, LPSTR name)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 char *cptr;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 /* Strip the path from the library name */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 if((cptr = strrchr(path, '/')))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 char *cp = strrchr(cptr+1, '\\');
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 if(cp && cp > cptr)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 cptr = cp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 cptr = strrchr(path, '\\');
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 if(!cptr)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 cptr = (char *)path; /* No '/' nor '\\' in path */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 cptr++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 strcpy(name, cptr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 cptr = strrchr(name, '.');
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 if(cptr)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 *cptr = '\0'; /* Strip extension */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 /* Convert to lower case.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 * This must be done manually because it is not sure that
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 * other modules are accessible.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 for(cptr = name; *cptr; cptr++)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 *cptr = tolower(*cptr);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 return name;
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 /****************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 * ELFDLL_CreateModref (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 * INPUT
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 * hModule - the header from the elf-dll's data-segment
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 * path - requested path from original call
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 * OUTPUT
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 * A WINE_MODREF pointer to the new object
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 * BUGS
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 * - Does not handle errors due to dependencies correctly
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 * - path can be wrong
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 #define RVA(base, va) (((DWORD)base) + ((DWORD)va))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 static WINE_MODREF *ELFDLL_CreateModref(HMODULE hModule, LPCSTR path)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 // IMAGE_NT_HEADERS *nt = PE_HEADER(hModule);
24388
7cfc461fa31f warning fixes:
diego
parents: 18783
diff changeset
172 // IMAGE_DATA_DIRECTORY *dir;
7cfc461fa31f warning fixes:
diego
parents: 18783
diff changeset
173 // IMAGE_IMPORT_DESCRIPTOR *pe_import = NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 WINE_MODREF *wm;
24388
7cfc461fa31f warning fixes:
diego
parents: 18783
diff changeset
175 // int len;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 HANDLE procheap = GetProcessHeap();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 wm = (WINE_MODREF *)HeapAlloc(procheap, HEAP_ZERO_MEMORY, sizeof(*wm));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 if(!wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 wm->module = hModule;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 wm->type = MODULE32_ELF; /* FIXME */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 // dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_EXPORT;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 // if(dir->Size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 // wm->binfmt.pe.pe_export = (PIMAGE_EXPORT_DIRECTORY)RVA(hModule, dir->VirtualAddress);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 // dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_IMPORT;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 // if(dir->Size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 // pe_import = wm->binfmt.pe.pe_import = (PIMAGE_IMPORT_DESCRIPTOR)RVA(hModule, dir->VirtualAddress);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 // dir = nt->OptionalHeader.DataDirectory+IMAGE_DIRECTORY_ENTRY_RESOURCE;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 // if(dir->Size)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 // wm->binfmt.pe.pe_resource = (PIMAGE_RESOURCE_DIRECTORY)RVA(hModule, dir->VirtualAddress);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
198 wm->filename = malloc(strlen(path)+1);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 strcpy(wm->filename, path);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 wm->modname = strrchr( wm->filename, '\\' );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 if (!wm->modname) wm->modname = wm->filename;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 else wm->modname++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 len = GetShortPathNameA( wm->filename, NULL, 0 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 wm->short_filename = (char *)HeapAlloc( procheap, 0, len+1 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 GetShortPathNameA( wm->filename, wm->short_filename, len+1 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 wm->short_modname = strrchr( wm->short_filename, '\\' );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 if (!wm->short_modname) wm->short_modname = wm->short_filename;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 else wm->short_modname++;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 /* Link MODREF into process list */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 // EnterCriticalSection( &PROCESS_Current()->crit_section );
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
214
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 if(local_wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
217 local_wm->next = malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 local_wm->next->prev=local_wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 local_wm->next->next=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 local_wm->next->wm=wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 local_wm=local_wm->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 29263
diff changeset
225 local_wm = malloc(sizeof(modref_list));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 local_wm->next=local_wm->prev=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 local_wm->wm=wm;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
228 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 // LeaveCriticalSection( &PROCESS_Current()->crit_section );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 return wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 /****************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 * ELFDLL_LoadLibraryExA (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 * Implementation of elf-dll loading for PE modules
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 WINE_MODREF *ELFDLL_LoadLibraryExA(LPCSTR path, DWORD flags)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 LPVOID dlhandle;
24388
7cfc461fa31f warning fixes:
diego
parents: 18783
diff changeset
242 // struct elfdll_image *image;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 char name[129];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 char soname[129];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 WINE_MODREF *wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 get_sobasename(path, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 strcpy(soname, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 strcat(soname, ".so");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 /* Try to open the elf-dll */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 dlhandle = ELFDLL_dlopen(soname, RTLD_LAZY);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 if(!dlhandle)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 WARN("Could not load %s (%s)\n", soname, dlerror());
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 SetLastError( ERROR_FILE_NOT_FOUND );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 return NULL;
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 /* Get the 'dllname_elfdll_image' variable */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 /* strcpy(soname, name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 strcat(soname, "_elfdll_image");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 image = (struct elfdll_image *)dlsym(dlhandle, soname);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
264 if(!image)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 ERR("Could not get elfdll image descriptor %s (%s)\n", soname, dlerror());
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 dlclose(dlhandle);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 SetLastError( ERROR_BAD_FORMAT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 wm = ELFDLL_CreateModref((int)dlhandle, path);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 if(!wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 ERR("Could not create WINE_MODREF for %s\n", path);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 dlclose(dlhandle);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 SetLastError( ERROR_OUTOFMEMORY );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 return NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 return wm;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 /****************************************************************************
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 * ELFDLL_UnloadLibrary (internal)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 * Unload an elf-dll completely from memory and deallocate the modref
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 void ELFDLL_UnloadLibrary(WINE_MODREF *wm)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 #endif /*HAVE_LIBDL*/