2 * Win32 builtin functions
4 * Copyright 1997 Alexandre Julliard
11 #include "builtin32.h"
18 #include "debugtools.h"
20 DECLARE_DEBUG_CHANNEL(relay)
21 DECLARE_DEBUG_CHANNEL(win32)
22 DECLARE_DEBUG_CHANNEL(module)
26 BYTE call; /* 0xe8 call callfrom32 (relative) */
27 DWORD callfrom32 WINE_PACKED; /* RELAY_CallFrom32 relative addr */
28 BYTE ret; /* 0xc2 ret $n or 0xc3 ret */
29 WORD args; /* nb of args to remove from the stack */
35 const DWORD nresources;
36 const DWORD restabsize;
37 const IMAGE_RESOURCE_DATA_ENTRY *entries;
42 const BUILTIN32_DESCRIPTOR *descr; /* DLL descriptor */
45 const BUILTIN32_RESOURCE *rsc;
48 #define BI32_INSTANTIATED 0x01
49 #define BI32_DANGER 0x02
51 extern const BUILTIN32_DESCRIPTOR ADVAPI32_Descriptor;
52 extern const BUILTIN32_DESCRIPTOR AVIFIL32_Descriptor;
53 extern const BUILTIN32_DESCRIPTOR COMCTL32_Descriptor;
54 extern const BUILTIN32_DESCRIPTOR COMDLG32_Descriptor;
55 extern const BUILTIN32_DESCRIPTOR CRTDLL_Descriptor;
56 extern const BUILTIN32_DESCRIPTOR DCIMAN32_Descriptor;
57 extern const BUILTIN32_DESCRIPTOR DDRAW_Descriptor;
58 extern const BUILTIN32_DESCRIPTOR DINPUT_Descriptor;
59 extern const BUILTIN32_DESCRIPTOR DPLAY_Descriptor;
60 extern const BUILTIN32_DESCRIPTOR DPLAYX_Descriptor;
61 extern const BUILTIN32_DESCRIPTOR DSOUND_Descriptor;
62 extern const BUILTIN32_DESCRIPTOR GDI32_Descriptor;
63 extern const BUILTIN32_DESCRIPTOR IMAGEHLP_Descriptor;
64 extern const BUILTIN32_DESCRIPTOR IMM32_Descriptor;
65 extern const BUILTIN32_DESCRIPTOR KERNEL32_Descriptor;
66 extern const BUILTIN32_DESCRIPTOR LZ32_Descriptor;
67 extern const BUILTIN32_DESCRIPTOR MPR_Descriptor;
68 extern const BUILTIN32_DESCRIPTOR MCIANIM_Descriptor;
69 extern const BUILTIN32_DESCRIPTOR MCIAVI_Descriptor;
70 extern const BUILTIN32_DESCRIPTOR MCICDA_Descriptor;
71 extern const BUILTIN32_DESCRIPTOR MCISEQ_Descriptor;
72 extern const BUILTIN32_DESCRIPTOR MCIWAVE_Descriptor;
73 extern const BUILTIN32_DESCRIPTOR MSACM32_Descriptor;
74 extern const BUILTIN32_DESCRIPTOR MSNET32_Descriptor;
75 extern const BUILTIN32_DESCRIPTOR MSVFW32_Descriptor;
76 extern const BUILTIN32_DESCRIPTOR NTDLL_Descriptor;
77 extern const BUILTIN32_DESCRIPTOR OLE32_Descriptor;
78 extern const BUILTIN32_DESCRIPTOR OLEAUT32_Descriptor;
79 extern const BUILTIN32_DESCRIPTOR OLECLI32_Descriptor;
80 extern const BUILTIN32_DESCRIPTOR OLEDLG_Descriptor;
81 extern const BUILTIN32_DESCRIPTOR OLESVR32_Descriptor;
82 extern const BUILTIN32_DESCRIPTOR PSAPI_Descriptor;
83 extern const BUILTIN32_DESCRIPTOR RASAPI32_Descriptor;
84 extern const BUILTIN32_DESCRIPTOR SHELL32_Descriptor;
85 extern const BUILTIN32_DESCRIPTOR SHLWAPI_Descriptor;
86 extern const BUILTIN32_DESCRIPTOR TAPI32_Descriptor;
87 extern const BUILTIN32_DESCRIPTOR USER32_Descriptor;
88 extern const BUILTIN32_DESCRIPTOR VERSION_Descriptor;
89 extern const BUILTIN32_DESCRIPTOR W32SKRNL_Descriptor;
90 extern const BUILTIN32_DESCRIPTOR WINEOSS_Descriptor;
91 extern const BUILTIN32_DESCRIPTOR WINMM_Descriptor;
92 extern const BUILTIN32_DESCRIPTOR WINSPOOL_Descriptor;
93 extern const BUILTIN32_DESCRIPTOR WNASPI32_Descriptor;
94 extern const BUILTIN32_DESCRIPTOR WOW32_Descriptor;
95 extern const BUILTIN32_DESCRIPTOR WSOCK32_Descriptor;
97 extern const BUILTIN32_RESOURCE comctl32_ResourceDescriptor;
98 extern const BUILTIN32_RESOURCE comdlg32_ResourceDescriptor;
99 extern const BUILTIN32_RESOURCE shell32_ResourceDescriptor;
100 extern const BUILTIN32_RESOURCE user32_ResourceDescriptor;
101 extern const BUILTIN32_RESOURCE winmm_ResourceDescriptor;
103 static BUILTIN32_DLL BuiltinDLLs[] =
105 { &ADVAPI32_Descriptor, 0, 0, NULL },
106 { &AVIFIL32_Descriptor, 0, 0, NULL },
107 { &COMCTL32_Descriptor, BI32_DANGER, 0, &comctl32_ResourceDescriptor },
108 { &COMDLG32_Descriptor, BI32_DANGER, 0, &comdlg32_ResourceDescriptor },
109 { &CRTDLL_Descriptor, BI32_DANGER, 0, NULL },
110 { &DCIMAN32_Descriptor, 0, 0, NULL },
111 { &DDRAW_Descriptor, 0, 0, NULL },
112 { &DINPUT_Descriptor, 0, 0, NULL },
113 { &DPLAY_Descriptor, 0, 0, NULL },
114 { &DPLAYX_Descriptor, 0, 0, NULL },
115 { &DSOUND_Descriptor, 0, 0, NULL },
116 { &GDI32_Descriptor, 0, 0, NULL },
117 { &IMAGEHLP_Descriptor, BI32_DANGER, 0, NULL },
118 { &IMM32_Descriptor, 0, 0, NULL },
119 { &KERNEL32_Descriptor, 0, 0, NULL },
120 { &LZ32_Descriptor, 0, 0, NULL },
121 { &MCIANIM_Descriptor, 0, 0, NULL },
122 { &MCIAVI_Descriptor, 0, 0, NULL },
123 { &MCICDA_Descriptor, 0, 0, NULL },
124 { &MCISEQ_Descriptor, 0, 0, NULL },
125 { &MCIWAVE_Descriptor, 0, 0, NULL },
126 { &MPR_Descriptor, 0, 0, NULL },
127 { &MSACM32_Descriptor, BI32_DANGER, 0, NULL },
128 { &MSNET32_Descriptor, 0, 0, NULL },
129 { &MSVFW32_Descriptor, 0, 0, NULL },
130 { &NTDLL_Descriptor, 0, 0, NULL },
131 { &OLE32_Descriptor, 0, 0, NULL },
132 { &OLEAUT32_Descriptor, 0, 0, NULL },
133 { &OLECLI32_Descriptor, 0, 0, NULL },
134 { &OLEDLG_Descriptor, 0, 0, NULL },
135 { &OLESVR32_Descriptor, 0, 0, NULL },
136 { &PSAPI_Descriptor, 0, 0, NULL },
137 { &RASAPI32_Descriptor, 0, 0, NULL },
138 { &SHELL32_Descriptor, BI32_DANGER, 0, &shell32_ResourceDescriptor },
139 { &SHLWAPI_Descriptor, 0, 0, NULL },
140 { &TAPI32_Descriptor, 0, 0, NULL },
141 { &USER32_Descriptor, 0, 0, &user32_ResourceDescriptor },
142 { &VERSION_Descriptor, 0, 0, NULL },
143 { &W32SKRNL_Descriptor, 0, 0, NULL },
144 { &WINMM_Descriptor, 0, 0, &winmm_ResourceDescriptor },
145 { &WINSPOOL_Descriptor, 0, 0, NULL },
146 { &WINEOSS_Descriptor, 0, 0, NULL },
147 { &WNASPI32_Descriptor, 0, 0, NULL },
148 { &WOW32_Descriptor, 0, 0, NULL },
149 { &WSOCK32_Descriptor, 0, 0, NULL },
154 extern void RELAY_CallFrom32();
155 extern void RELAY_CallFrom32Regs();
157 /***********************************************************************
158 * BUILTIN32_DoLoadImage
160 * Load a built-in Win32 module. Helper function for BUILTIN32_LoadImage.
162 static HMODULE BUILTIN32_DoLoadImage( BUILTIN32_DLL *dll )
165 IMAGE_DATA_DIRECTORY *dir;
166 IMAGE_DOS_HEADER *dos;
167 IMAGE_NT_HEADERS *nt;
168 IMAGE_SECTION_HEADER *sec;
169 IMAGE_EXPORT_DIRECTORY *exp;
170 IMAGE_IMPORT_DESCRIPTOR *imp;
174 DEBUG_ENTRY_POINT *debug;
175 INT i, size, nb_sections;
178 /* Allocate the module */
180 nb_sections = 2; /* exports + code */
181 if (dll->descr->nb_imports) nb_sections++;
182 size = (sizeof(IMAGE_DOS_HEADER)
183 + sizeof(IMAGE_NT_HEADERS)
184 + nb_sections * sizeof(IMAGE_SECTION_HEADER)
185 + (dll->descr->nb_imports+1) * sizeof(IMAGE_IMPORT_DESCRIPTOR)
186 + sizeof(IMAGE_EXPORT_DIRECTORY)
187 + dll->descr->nb_funcs * sizeof(LPVOID)
188 + dll->descr->nb_names * sizeof(LPSTR)
189 + dll->descr->fwd_size);
191 if (WARN_ON(relay) || TRACE_ON(relay))
192 size += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
194 addr = VirtualAlloc( NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
196 dos = (IMAGE_DOS_HEADER *)addr;
197 nt = (IMAGE_NT_HEADERS *)(dos + 1);
198 sec = (IMAGE_SECTION_HEADER *)(nt + 1);
199 imp = (IMAGE_IMPORT_DESCRIPTOR *)(sec + nb_sections);
200 exp = (IMAGE_EXPORT_DIRECTORY *)(imp + dll->descr->nb_imports + 1);
201 funcs = (LPVOID *)(exp + 1);
202 names = (LPSTR *)(funcs + dll->descr->nb_funcs);
203 pfwd = (LPSTR)(names + dll->descr->nb_names);
204 debug = (DEBUG_ENTRY_POINT *)(pfwd + dll->descr->fwd_size);
206 /* Build the DOS and NT headers */
208 dos->e_magic = IMAGE_DOS_SIGNATURE;
209 dos->e_lfanew = sizeof(*dos);
211 nt->Signature = IMAGE_NT_SIGNATURE;
212 nt->FileHeader.Machine = IMAGE_FILE_MACHINE_I386;
213 nt->FileHeader.NumberOfSections = nb_sections;
214 nt->FileHeader.SizeOfOptionalHeader = sizeof(nt->OptionalHeader);
215 nt->FileHeader.Characteristics = IMAGE_FILE_DLL;
217 nt->OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC;
218 nt->OptionalHeader.SizeOfCode = 0x1000;
219 nt->OptionalHeader.SizeOfInitializedData = 0;
220 nt->OptionalHeader.SizeOfUninitializedData = 0;
221 nt->OptionalHeader.ImageBase = (DWORD)addr;
222 nt->OptionalHeader.SectionAlignment = 0x1000;
223 nt->OptionalHeader.FileAlignment = 0x1000;
224 nt->OptionalHeader.MajorOperatingSystemVersion = 1;
225 nt->OptionalHeader.MinorOperatingSystemVersion = 0;
226 nt->OptionalHeader.MajorSubsystemVersion = 4;
227 nt->OptionalHeader.MinorSubsystemVersion = 0;
228 nt->OptionalHeader.SizeOfImage = size;
229 nt->OptionalHeader.SizeOfHeaders = (BYTE *)exp - addr;
230 nt->OptionalHeader.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES;
231 if (dll->descr->dllentrypoint)
232 nt->OptionalHeader.AddressOfEntryPoint = (DWORD)dll->descr->dllentrypoint - (DWORD)addr;
234 /* Build the code section */
236 strcpy( sec->Name, ".code" );
237 sec->SizeOfRawData = 0;
239 if (WARN_ON(relay) || TRACE_ON(relay))
240 sec->SizeOfRawData += dll->descr->nb_funcs * sizeof(DEBUG_ENTRY_POINT);
242 sec->Misc.VirtualSize = sec->SizeOfRawData;
243 sec->VirtualAddress = (BYTE *)debug - addr;
244 sec->PointerToRawData = (BYTE *)debug - addr;
245 sec->Characteristics = (IMAGE_SCN_CNT_INITIALIZED_DATA |
246 IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ);
249 /* Build the import directory */
251 if (dll->descr->nb_imports)
253 dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_IMPORT_DIRECTORY];
254 dir->VirtualAddress = (BYTE *)imp - addr;
255 dir->Size = sizeof(*imp) * (dll->descr->nb_imports + 1);
257 /* Build the imports section */
258 strcpy( sec->Name, ".idata" );
259 sec->Misc.VirtualSize = dir->Size;
260 sec->VirtualAddress = (BYTE *)imp - addr;
261 sec->SizeOfRawData = dir->Size;
262 sec->PointerToRawData = (BYTE *)imp - addr;
263 sec->Characteristics = (IMAGE_SCN_CNT_INITIALIZED_DATA |
264 IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ |
265 IMAGE_SCN_MEM_WRITE);
268 /* Build the imports */
269 for (i = 0; i < dll->descr->nb_imports; i++)
271 imp[i].u.Characteristics = 0;
272 imp[i].ForwarderChain = -1;
273 imp[i].Name = (BYTE *)dll->descr->imports[i] - addr;
274 /* hack: make first thunk point to some zero value */
275 imp[i].FirstThunk = (PIMAGE_THUNK_DATA)((BYTE *)&imp[i].u.Characteristics - addr);
279 /* Build the export directory */
281 dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_EXPORT_DIRECTORY];
282 dir->VirtualAddress = (BYTE *)exp - addr;
283 dir->Size = sizeof(*exp)
284 + dll->descr->nb_funcs * sizeof(LPVOID)
285 + dll->descr->nb_names * sizeof(LPSTR)
286 + dll->descr->fwd_size;
288 /* Build the exports section */
290 strcpy( sec->Name, ".edata" );
291 sec->Misc.VirtualSize = dir->Size;
292 sec->VirtualAddress = (BYTE *)exp - addr;
293 sec->SizeOfRawData = dir->Size;
294 sec->PointerToRawData = (BYTE *)exp - addr;
295 sec->Characteristics = (IMAGE_SCN_CNT_INITIALIZED_DATA |
296 IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ |
297 IMAGE_SCN_MEM_WRITE);
300 /* Build the resource directory */
305 IMAGE_RESOURCE_DATA_ENTRY *rdep;
307 rtab = HeapAlloc(GetProcessHeap(), 0, dll->rsc->restabsize);
310 ERR_(module)("Failed to get memory for resource directory\n");
311 VirtualFree(addr, size, MEM_RELEASE);
316 * The resource directory has to be copied because it contains
317 * RVAs. These would be invalid if the dll is instantiated twice.
319 memcpy(rtab, dll->rsc->restab, dll->rsc->restabsize);
321 dir = &nt->OptionalHeader.DataDirectory[IMAGE_FILE_RESOURCE_DIRECTORY];
322 dir->VirtualAddress = (DWORD)rtab - (DWORD)addr;
323 dir->Size = dll->rsc->restabsize;
324 rdep = (IMAGE_RESOURCE_DATA_ENTRY *)((DWORD)rtab + (DWORD)dll->rsc->entries - (DWORD)dll->rsc->restab);
325 for(i = 0; i < dll->rsc->nresources; i++)
327 rdep[i].OffsetToData += (DWORD)dll->rsc->restab - (DWORD)addr;
331 /* Build the exports section data */
333 exp->Name = ((BYTE *)dll->descr->name) - addr; /*??*/
334 exp->Base = dll->descr->base;
335 exp->NumberOfFunctions = dll->descr->nb_funcs;
336 exp->NumberOfNames = dll->descr->nb_names;
337 exp->AddressOfFunctions = (LPDWORD *)((BYTE *)funcs - addr);
338 exp->AddressOfNames = (LPDWORD *)((BYTE *)names - addr);
339 exp->AddressOfNameOrdinals = (LPWORD *)((BYTE *)dll->descr->ordinals - addr);
341 /* Build the funcs table */
343 for (i = 0; i < dll->descr->nb_funcs; i++, funcs++, debug++)
345 BYTE args = dll->descr->args[i];
348 if (!dll->descr->functions[i]) continue;
350 if (args == 0xfd) /* forward func */
352 strcpy( pfwd, (LPSTR)dll->descr->functions[i] );
353 *funcs = (LPVOID)((BYTE *)pfwd - addr);
354 pfwd += strlen(pfwd) + 1;
356 else *funcs = (LPVOID)((BYTE *)dll->descr->functions[i] - addr);
359 if (!(WARN_ON(relay) || TRACE_ON(relay))) continue;
360 for (j=0;j<dll->descr->nb_names;j++)
361 if (dll->descr->ordinals[j] == i)
363 if (j<dll->descr->nb_names) {
364 if (dll->descr->names[j]) {
366 sprintf(buffer,"%s.%d: %s",dll->descr->name,i,dll->descr->names[j]);
367 if (!RELAY_ShowDebugmsgRelay(buffer))
373 case 0xfd: /* forward */
374 case 0xff: /* stub or extern */
376 default: /* normal function (stdcall or cdecl or register) */
377 if (TRACE_ON(relay)) {
378 debug->call = 0xe8; /* lcall relative */
379 if (args & 0x40) /* register func */
380 debug->callfrom32 = (DWORD)RELAY_CallFrom32Regs -
383 debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
386 debug->call = 0xe9; /* ljmp relative */
387 debug->callfrom32 = (DWORD)dll->descr->functions[i] -
390 debug->ret = (args & 0x80) ? 0xc3 : 0xc2; /*ret/ret $n*/
391 debug->args = (args & 0x3f) * sizeof(int);
392 *funcs = (LPVOID)((BYTE *)debug - addr);
395 #endif /* __i386__ */
398 /* Build the names table */
400 for (i = 0; i < exp->NumberOfNames; i++, names++)
401 if (dll->descr->names[i])
402 *names = (LPSTR)((BYTE *)dll->descr->names[i] - addr);
404 return (HMODULE)addr;
407 /***********************************************************************
408 * BUILTIN32_LoadImage
410 * Load a built-in module.
412 HMODULE BUILTIN32_LoadImage( LPCSTR name, OFSTRUCT *ofs)
414 BUILTIN32_DLL *table;
415 char dllname[16], *p;
417 /* Fix the name in case we have a full path and extension */
419 if ((p = strrchr( name, '\\' ))) name = p + 1;
420 lstrcpynA( dllname, name, sizeof(dllname) );
421 if ((p = strrchr( dllname, '.' ))) *p = '\0';
423 for (table = BuiltinDLLs; table->descr; table++)
424 if (!lstrcmpiA( table->descr->name, dllname )) break;
425 if (!table->descr) return 0;
427 if ( (table->flags & BI32_INSTANTIATED) && (table->flags & BI32_DANGER) )
429 ERR_(module)("Attemp to instantiate built-in dll '%s' twice in the same address-space. Expect trouble!\n",
433 sprintf( ofs->szPathName, "%s.DLL", table->descr->name );
435 if ( !table->hModule )
436 table->hModule = BUILTIN32_DoLoadImage( table );
438 if ( table->hModule )
439 table->flags |= BI32_INSTANTIATED;
441 return table->hModule;
445 /***********************************************************************
446 * BUILTIN32_LoadLibraryExA
448 * Partly copied from the original PE_ version.
450 * Note: This implementation is not very nice and should be one with
451 * the BUILTIN32_LoadImage function. But, we don't care too much
452 * because this code will obsolete itself shortly when we get the
453 * modularization of wine implemented (BS 05-Mar-1999).
455 WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR path, DWORD flags, DWORD *err)
457 LPCSTR modName = NULL;
463 char dllname[256], *p;
465 /* Append .DLL to name if no extension present */
466 strcpy( dllname, path );
467 if (!(p = strrchr( dllname, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
468 strcat( dllname, ".DLL" );
470 hModule32 = BUILTIN32_LoadImage(path, &ofs);
473 *err = ERROR_FILE_NOT_FOUND;
477 /* Create 16-bit dummy module */
478 if ((hModule16 = MODULE_CreateDummyModule( &ofs, modName )) < 32)
480 *err = (DWORD)hModule16;
481 return NULL; /* FIXME: Should unload the builtin module */
484 pModule = (NE_MODULE *)GlobalLock16( hModule16 );
485 pModule->flags = NE_FFLAGS_LIBMODULE | NE_FFLAGS_SINGLEDATA | NE_FFLAGS_WIN32 | NE_FFLAGS_BUILTIN;
486 pModule->module32 = hModule32;
488 /* Create 32-bit MODREF */
489 if ( !(wm = PE_CreateModule( hModule32, &ofs, flags, TRUE )) )
491 ERR_(win32)("can't load %s\n",ofs.szPathName);
492 FreeLibrary16( hModule16 ); /* FIXME: Should unload the builtin module */
493 *err = ERROR_OUTOFMEMORY;
497 if (wm->binfmt.pe.pe_export)
498 SNOOP_RegisterDLL(wm->module,wm->modname,wm->binfmt.pe.pe_export->NumberOfFunctions);
505 /***********************************************************************
506 * BUILTIN32_UnloadLibrary
508 * Unload the built-in library and free the modref.
510 void BUILTIN32_UnloadLibrary(WINE_MODREF *wm)
512 /* FIXME: do something here */
516 /***********************************************************************
517 * BUILTIN32_GetEntryPoint
519 * Return the name of the DLL entry point corresponding
520 * to a relay entry point address. This is used only by relay debugging.
522 * This function _must_ return the real entry point to call
523 * after the debug info is printed.
525 ENTRYPOINT32 BUILTIN32_GetEntryPoint( char *buffer, void *relay,
526 unsigned int *typemask )
531 /* First find the module */
533 for (dll = BuiltinDLLs; dll->descr; dll++)
534 if ( dll->flags & BI32_INSTANTIATED )
536 IMAGE_SECTION_HEADER *sec = PE_SECTIONS(dll->hModule);
537 DEBUG_ENTRY_POINT *debug =
538 (DEBUG_ENTRY_POINT *)((DWORD)dll->hModule + sec[0].VirtualAddress);
539 DEBUG_ENTRY_POINT *func = (DEBUG_ENTRY_POINT *)relay;
541 if (debug <= func && func < debug + dll->descr->nb_funcs)
543 ordinal = func - debug;
549 return (ENTRYPOINT32)NULL;
551 /* Now find the function */
553 for (i = 0; i < dll->descr->nb_names; i++)
554 if (dll->descr->ordinals[i] == ordinal) break;
555 assert( i < dll->descr->nb_names );
557 sprintf( buffer, "%s.%d: %s", dll->descr->name, ordinal + dll->descr->base,
558 dll->descr->names[i] );
559 *typemask = dll->descr->argtypes[ordinal];
560 return dll->descr->functions[ordinal];
563 /***********************************************************************
564 * BUILTIN32_SwitchRelayDebug
566 * FIXME: enhance to do it module relative.
568 void BUILTIN32_SwitchRelayDebug(BOOL onoff) {
573 if (!(TRACE_ON(relay) || WARN_ON(relay)))
575 for (dll = BuiltinDLLs; dll->descr; dll++) {
576 IMAGE_SECTION_HEADER *sec;
577 DEBUG_ENTRY_POINT *debug;
578 if (!(dll->flags & BI32_INSTANTIATED))
581 sec = PE_SECTIONS(dll->hModule);
582 debug = (DEBUG_ENTRY_POINT *)((DWORD)dll->hModule + sec[1].VirtualAddress);
583 for (i = 0; i < dll->descr->nb_funcs; i++,debug++) {
584 if (!dll->descr->functions[i]) continue;
585 if ((dll->descr->args[i]==0xff) || (dll->descr->args[i]==0xfe))
588 debug->call = 0xe8; /* lcall relative */
589 debug->callfrom32 = (DWORD)RELAY_CallFrom32 -
592 debug->call = 0xe9; /* ljmp relative */
593 debug->callfrom32 = (DWORD)dll->descr->functions[i] -
598 #endif /* __i386__ */
602 /***********************************************************************
603 * BUILTIN32_Unimplemented
605 * This function is called for unimplemented 32-bit entry points (declared
606 * as 'stub' in the spec file).
608 void BUILTIN32_Unimplemented( const BUILTIN32_DESCRIPTOR *descr, int ordinal )
610 const char *func_name = "???";
613 __RESTORE_ES; /* Just in case */
615 for (i = 0; i < descr->nb_names; i++)
616 if (descr->ordinals[i] + descr->base == ordinal) break;
617 if (i < descr->nb_names) func_name = descr->names[i];
619 MESSAGE( "No handler for Win32 routine %s.%d: %s",
620 descr->name, ordinal, func_name );
622 MESSAGE( " (called from %p)", __builtin_return_address(1) );