Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Built-in modules |
| 3 | * |
| 4 | * Copyright 1996 Alexandre Julliard |
| 5 | */ |
| 6 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 7 | #include <assert.h> |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 8 | #include <ctype.h> |
| 9 | #include <string.h> |
Alexandre Julliard | 383da68 | 2000-02-10 22:15:21 +0000 | [diff] [blame^] | 10 | #include <stdio.h> |
Marcus Meissner | 04c3e1d | 1999-02-19 10:37:02 +0000 | [diff] [blame] | 11 | #include "winbase.h" |
| 12 | #include "wine/winbase16.h" |
Huw D M Davies | 34acebc | 1999-02-19 16:03:19 +0000 | [diff] [blame] | 13 | #include "wine/winestring.h" |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 14 | #include "builtin16.h" |
Alexandre Julliard | 44ed71f | 1997-12-21 19:17:50 +0000 | [diff] [blame] | 15 | #include "builtin32.h" |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 16 | #include "global.h" |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 17 | #include "heap.h" |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 18 | #include "module.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 19 | #include "miscemu.h" |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 20 | #include "neexe.h" |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 21 | #include "stackframe.h" |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 22 | #include "user.h" |
Alexandre Julliard | e658d82 | 1997-11-30 17:45:40 +0000 | [diff] [blame] | 23 | #include "process.h" |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 24 | #include "task.h" |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 25 | #include "debugtools.h" |
Patrik Stridvall | fdcfdb9 | 1999-06-12 14:55:11 +0000 | [diff] [blame] | 26 | #include "toolhelp.h" |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 27 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 28 | DEFAULT_DEBUG_CHANNEL(module); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 29 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 30 | typedef struct |
| 31 | { |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 32 | LPVOID res_start; /* address of resource data */ |
| 33 | DWORD nr_res; |
| 34 | DWORD res_size; /* size of resource data */ |
| 35 | } BUILTIN16_RESOURCE; |
| 36 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 37 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 38 | /* Table of all built-in DLLs */ |
| 39 | |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 40 | #define MAX_DLLS 50 |
| 41 | |
| 42 | static const BUILTIN16_DESCRIPTOR *builtin_dlls[MAX_DLLS]; |
| 43 | static int nb_dlls; |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 44 | |
| 45 | /* list of DLLs that should always be loaded at startup */ |
| 46 | static const char * const always_load[] = |
| 47 | { |
| 48 | "system", "display", "wprocs", "wineps", NULL |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 51 | /* Ordinal number for interrupt 0 handler in WPROCS.DLL */ |
| 52 | #define FIRST_INTERRUPT_ORDINAL 100 |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 53 | |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 54 | |
| 55 | /*********************************************************************** |
| 56 | * BUILTIN_DoLoadModule16 |
| 57 | * |
| 58 | * Load a built-in Win16 module. Helper function for BUILTIN_LoadModule |
| 59 | * and BUILTIN_Init. |
| 60 | */ |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 61 | static HMODULE16 BUILTIN_DoLoadModule16( const BUILTIN16_DESCRIPTOR *descr ) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 62 | { |
| 63 | NE_MODULE *pModule; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 64 | int minsize, res_off; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 65 | SEGTABLEENTRY *pSegTable; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 66 | HMODULE16 hModule; |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 67 | const BUILTIN16_RESOURCE *rsrc = descr->rsrc; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 68 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 69 | if (!rsrc) |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 70 | { |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 71 | hModule = GLOBAL_CreateBlock( GMEM_MOVEABLE, descr->module_start, |
| 72 | descr->module_size, 0, |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 73 | FALSE, FALSE, FALSE, NULL ); |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 74 | if (!hModule) return 0; |
| 75 | FarSetOwner16( hModule, hModule ); |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 76 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 77 | pModule = (NE_MODULE *)GlobalLock16( hModule ); |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 78 | } |
| 79 | else |
| 80 | { |
| 81 | ET_BUNDLE *bundle; |
| 82 | |
| 83 | hModule = GLOBAL_Alloc( GMEM_MOVEABLE, |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 84 | descr->module_size + rsrc->res_size, |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 85 | 0, FALSE, FALSE, FALSE ); |
| 86 | if (!hModule) return 0; |
| 87 | FarSetOwner16( hModule, hModule ); |
| 88 | |
| 89 | pModule = (NE_MODULE *)GlobalLock16( hModule ); |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 90 | res_off = ((NE_MODULE *)descr->module_start)->res_table; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 91 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 92 | memcpy( (LPBYTE)pModule, descr->module_start, res_off ); |
| 93 | memcpy( (LPBYTE)pModule + res_off, rsrc->res_start, rsrc->res_size ); |
| 94 | memcpy( (LPBYTE)pModule + res_off + rsrc->res_size, |
| 95 | descr->module_start + res_off, descr->module_size - res_off ); |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 96 | |
| 97 | /* Have to fix up various pModule-based near pointers. Ugh! */ |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 98 | pModule->name_table += rsrc->res_size; |
| 99 | pModule->modref_table += rsrc->res_size; |
| 100 | pModule->import_table += rsrc->res_size; |
| 101 | pModule->entry_table += rsrc->res_size; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 102 | |
| 103 | for ( bundle = (ET_BUNDLE *)((LPBYTE)pModule + pModule->entry_table); |
| 104 | bundle->next; |
| 105 | bundle = (ET_BUNDLE *)((LPBYTE)pModule + bundle->next) ) |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 106 | bundle->next += rsrc->res_size; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 107 | |
| 108 | /* NOTE: (Ab)use the hRsrcMap parameter for resource data pointer */ |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 109 | pModule->hRsrcMap = rsrc->res_start; |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 110 | } |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 111 | pModule->self = hModule; |
| 112 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 113 | TRACE( "Built-in %s: hmodule=%04x\n", descr->name, hModule ); |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 114 | |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 115 | /* Allocate the code segment */ |
| 116 | |
| 117 | pSegTable = NE_SEG_TABLE( pModule ); |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 118 | pSegTable->hSeg = GLOBAL_CreateBlock( GMEM_FIXED, descr->code_start, |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 119 | pSegTable->minsize, hModule, |
| 120 | TRUE, TRUE, FALSE, NULL ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 121 | if (!pSegTable->hSeg) return 0; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 122 | pSegTable++; |
| 123 | |
| 124 | /* Allocate the data segment */ |
| 125 | |
| 126 | minsize = pSegTable->minsize ? pSegTable->minsize : 0x10000; |
| 127 | minsize += pModule->heap_size; |
| 128 | if (minsize > 0x10000) minsize = 0x10000; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 129 | pSegTable->hSeg = GLOBAL_Alloc( GMEM_FIXED, minsize, |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 130 | hModule, FALSE, FALSE, FALSE ); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 131 | if (!pSegTable->hSeg) return 0; |
| 132 | if (pSegTable->minsize) memcpy( GlobalLock16( pSegTable->hSeg ), |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 133 | descr->data_start, pSegTable->minsize); |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 134 | if (pModule->heap_size) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 135 | LocalInit16( GlobalHandleToSel16(pSegTable->hSeg), |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 136 | pSegTable->minsize, minsize ); |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 137 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 138 | if (rsrc) |
Andreas Mohr | a2da868 | 1999-12-06 01:20:00 +0000 | [diff] [blame] | 139 | NE_InitResourceHandler(hModule); |
| 140 | |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 141 | NE_RegisterModule( pModule ); |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 142 | return hModule; |
| 143 | } |
| 144 | |
| 145 | |
| 146 | /*********************************************************************** |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 147 | * BUILTIN_Init |
| 148 | * |
| 149 | * Load all built-in modules marked as 'always used'. |
| 150 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 151 | BOOL BUILTIN_Init(void) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 152 | { |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 153 | WORD vector; |
| 154 | HMODULE16 hModule; |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 155 | const char * const *ptr = always_load; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 156 | |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 157 | while (*ptr) |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 158 | { |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 159 | if (!BUILTIN_LoadModule( *ptr )) return FALSE; |
| 160 | ptr++; |
Alexandre Julliard | 17216f5 | 1997-10-12 16:30:17 +0000 | [diff] [blame] | 161 | } |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 162 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 163 | /* Set interrupt vectors from entry points in WPROCS.DLL */ |
| 164 | |
Alexandre Julliard | 2197901 | 1997-03-05 08:22:35 +0000 | [diff] [blame] | 165 | hModule = GetModuleHandle16( "WPROCS" ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 166 | for (vector = 0; vector < 256; vector++) |
| 167 | { |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 168 | FARPROC16 proc = NE_GetEntryPoint( hModule, |
| 169 | FIRST_INTERRUPT_ORDINAL + vector ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 170 | assert(proc); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 171 | INT_SetPMHandler( vector, proc ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 174 | return TRUE; |
| 175 | } |
| 176 | |
| 177 | |
| 178 | /*********************************************************************** |
| 179 | * BUILTIN_LoadModule |
| 180 | * |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 181 | * Load a built-in module. |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 182 | */ |
Alexandre Julliard | 74e4a28 | 2000-01-09 04:20:31 +0000 | [diff] [blame] | 183 | HMODULE16 BUILTIN_LoadModule( LPCSTR name ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 184 | { |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 185 | char dllname[16], *p; |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 186 | int i; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 187 | |
| 188 | /* Fix the name in case we have a full path and extension */ |
| 189 | |
| 190 | if ((p = strrchr( name, '\\' ))) name = p + 1; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 191 | lstrcpynA( dllname, name, sizeof(dllname) ); |
Eric Pouech | d2344fb | 1999-10-13 15:59:26 +0000 | [diff] [blame] | 192 | p = strrchr( dllname, '.' ); |
| 193 | |
| 194 | if (!p) strcat( dllname, ".dll" ); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 195 | |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 196 | for (i = 0; i < nb_dlls; i++) |
Eric Pouech | d2344fb | 1999-10-13 15:59:26 +0000 | [diff] [blame] | 197 | { |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 198 | const BUILTIN16_DESCRIPTOR *descr = builtin_dlls[i]; |
| 199 | NE_MODULE *pModule = (NE_MODULE *)descr->module_start; |
| 200 | OFSTRUCT *pOfs = (OFSTRUCT *)((LPBYTE)pModule + pModule->fileinfo); |
| 201 | if (!lstrcmpiA( pOfs->szPathName, dllname )) |
| 202 | return BUILTIN_DoLoadModule16( descr ); |
Eric Pouech | d2344fb | 1999-10-13 15:59:26 +0000 | [diff] [blame] | 203 | } |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 204 | return (HMODULE16)2; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | |
| 208 | /*********************************************************************** |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 209 | * BUILTIN_GetEntryPoint16 |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 210 | * |
Ulrich Weigand | 3dff7bb | 1999-07-11 13:58:31 +0000 | [diff] [blame] | 211 | * Return the ordinal, name, and type info corresponding to a CS:IP address. |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 212 | * This is used only by relay debugging. |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 213 | */ |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 214 | LPCSTR BUILTIN_GetEntryPoint16( STACK16FRAME *frame, LPSTR name, WORD *pOrd ) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 215 | { |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 216 | WORD i, max_offset; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 217 | register BYTE *p; |
| 218 | NE_MODULE *pModule; |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 219 | ET_BUNDLE *bundle; |
| 220 | ET_ENTRY *entry; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 221 | |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 222 | if (!(pModule = NE_GetPtr( FarGetOwner16( GlobalHandle16( frame->module_cs ) )))) |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 223 | return NULL; |
| 224 | |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 225 | max_offset = 0; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 226 | *pOrd = 0; |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 227 | bundle = (ET_BUNDLE *)((BYTE *)pModule + pModule->entry_table); |
Ulrich Weigand | a7e6e81 | 1999-04-22 09:54:15 +0000 | [diff] [blame] | 228 | do |
| 229 | { |
| 230 | entry = (ET_ENTRY *)((BYTE *)bundle+6); |
| 231 | for (i = bundle->first + 1; i <= bundle->last; i++) |
| 232 | { |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 233 | if ((entry->offs < frame->entry_ip) |
Ulrich Weigand | a7e6e81 | 1999-04-22 09:54:15 +0000 | [diff] [blame] | 234 | && (entry->segnum == 1) /* code segment ? */ |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 235 | && (entry->offs >= max_offset)) |
Ulrich Weigand | a7e6e81 | 1999-04-22 09:54:15 +0000 | [diff] [blame] | 236 | { |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 237 | max_offset = entry->offs; |
| 238 | *pOrd = i; |
Ulrich Weigand | a7e6e81 | 1999-04-22 09:54:15 +0000 | [diff] [blame] | 239 | } |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 240 | entry++; |
Ulrich Weigand | a7e6e81 | 1999-04-22 09:54:15 +0000 | [diff] [blame] | 241 | } |
Andreas Mohr | dca5e56 | 1999-04-16 08:17:17 +0000 | [diff] [blame] | 242 | } while ( (bundle->next) |
| 243 | && (bundle = (ET_BUNDLE *)((BYTE *)pModule+bundle->next))); |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 244 | |
| 245 | /* Search for the name in the resident names table */ |
| 246 | /* (built-in modules have no non-resident table) */ |
| 247 | |
| 248 | p = (BYTE *)pModule + pModule->name_table; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 249 | while (*p) |
| 250 | { |
| 251 | p += *p + 1 + sizeof(WORD); |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 252 | if (*(WORD *)(p + *p + 1) == *pOrd) break; |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Ulrich Weigand | 3dff7bb | 1999-07-11 13:58:31 +0000 | [diff] [blame] | 255 | sprintf( name, "%.*s.%d: %.*s", |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 256 | *((BYTE *)pModule + pModule->name_table), |
| 257 | (char *)pModule + pModule->name_table + 1, |
| 258 | *pOrd, *p, (char *)(p + 1) ); |
Ulrich Weigand | 3dff7bb | 1999-07-11 13:58:31 +0000 | [diff] [blame] | 259 | |
| 260 | /* Retrieve type info string */ |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 261 | return *(LPCSTR *)((LPBYTE)PTR_SEG_OFF_TO_LIN( frame->module_cs, frame->callfrom_ip ) + 4); |
Alexandre Julliard | ca22b33 | 1996-07-12 19:02:39 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | |
Alexandre Julliard | 112d307 | 2000-01-16 03:37:05 +0000 | [diff] [blame] | 265 | /*********************************************************************** |
| 266 | * BUILTIN_RegisterDLL |
| 267 | * |
| 268 | * Register a built-in DLL descriptor. |
| 269 | */ |
| 270 | void BUILTIN_RegisterDLL( const BUILTIN16_DESCRIPTOR *descr ) |
| 271 | { |
| 272 | assert( nb_dlls < MAX_DLLS ); |
| 273 | builtin_dlls[nb_dlls++] = descr; |
| 274 | } |
| 275 | |
| 276 | |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 277 | /********************************************************************** |
| 278 | * BUILTIN_DefaultIntHandler |
| 279 | * |
| 280 | * Default interrupt handler. |
| 281 | */ |
Patrik Stridvall | b8684a2 | 1999-07-31 17:32:05 +0000 | [diff] [blame] | 282 | void WINAPI BUILTIN_DefaultIntHandler( CONTEXT86 *context ) |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 283 | { |
| 284 | WORD ordinal; |
Ulrich Weigand | 3dff7bb | 1999-07-11 13:58:31 +0000 | [diff] [blame] | 285 | char name[80]; |
Ulrich Weigand | c50a1d0 | 1999-08-15 12:45:01 +0000 | [diff] [blame] | 286 | BUILTIN_GetEntryPoint16( CURRENT_STACK16, name, &ordinal ); |
Alexandre Julliard | 9ea19e5 | 1997-01-01 17:29:55 +0000 | [diff] [blame] | 287 | INT_BARF( context, ordinal - FIRST_INTERRUPT_ORDINAL ); |
| 288 | } |