2 * Copyright 1993 Robert J. Amstadt
3 * Copyright 1995 Alexandre Julliard
11 #include "registers.h"
12 #include "stackframe.h"
14 /* #define DEBUG_RELAY */
18 /* Make make_debug think these were really used */
22 #define DLL_ENTRY(name) \
23 { #name, name##_Code_Start, name##_Data_Start, \
24 name##_Module_Start, name##_Module_End, TRUE, 0 }
25 #define DLL_ENTRY_NOTUSED(name) \
26 { #name, name##_Code_Start, name##_Data_Start, \
27 name##_Module_Start, name##_Module_End, FALSE, 0 }
29 struct dll_table_s dll_builtin_table
[N_BUILTINS
] =
34 DLL_ENTRY_NOTUSED(WIN87EM
),
35 DLL_ENTRY_NOTUSED(SHELL
),
44 DLL_ENTRY_NOTUSED(COMMDLG
),
45 DLL_ENTRY_NOTUSED(OLE2
),
46 DLL_ENTRY_NOTUSED(OLE2CONV
),
47 DLL_ENTRY_NOTUSED(OLE2DISP
),
48 DLL_ENTRY_NOTUSED(OLE2NLS
),
49 DLL_ENTRY_NOTUSED(OLE2PROX
),
50 DLL_ENTRY_NOTUSED(OLECLI
),
51 DLL_ENTRY_NOTUSED(OLESVR
),
52 DLL_ENTRY_NOTUSED(COMPOBJ
),
53 DLL_ENTRY_NOTUSED(STORAGE
),
55 DLL_ENTRY_NOTUSED(DDEML
)
58 /* don't forget to increase N_BUILTINS in dlls.h if you add a dll */
60 /* Saved 16-bit stack */
61 WORD IF1632_Saved16_ss
= 0;
62 WORD IF1632_Saved16_sp
= 0;
64 /* Saved 32-bit stack */
65 DWORD IF1632_Saved32_esp
= 0;
66 SEGPTR IF1632_Stack32_base
= 0;
67 DWORD IF1632_Original32_esp
= 0;
69 /***********************************************************************
76 /* Allocate the code selector for CallTo16 routines */
78 extern void CALL16_Start(), CALL16_End();
79 extern void CALL16_Ret_word(), CALL16_Ret_long();
80 extern DWORD CALL16_RetAddr_word
, CALL16_RetAddr_long
;
82 codesel
= GLOBAL_CreateBlock( GMEM_FIXED
, (void *)CALL16_Start
,
83 (int)CALL16_End
- (int)CALL16_Start
,
84 0, TRUE
, TRUE
, FALSE
, NULL
);
85 if (!codesel
) return FALSE
;
87 /* Patch the return addresses for CallTo16 routines */
89 CALL16_RetAddr_word
= MAKELONG( (int)CALL16_Ret_word
- (int)CALL16_Start
,
91 CALL16_RetAddr_long
= MAKELONG( (int)CALL16_Ret_long
- (int)CALL16_Start
,
98 /***********************************************************************
101 void RELAY_DebugCall32( int func_type
, char *args
,
102 void *entry_point
, int args32
)
105 struct dll_table_s
*table
;
109 if (!debugging_relay
) return;
111 frame
= CURRENT_STACK16
;
112 table
= &dll_builtin_table
[frame
->dll_id
-1];
113 name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
114 printf( "Call %s.%d: %*.*s(",
115 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
117 args16
= (char *)frame
->args
;
118 for (i
= 0; i
< strlen(args
); i
++)
140 printf( "0x%04x", *(WORD
*)args16
);
144 printf( "0x%08x", *(int *)args16
);
148 printf( "%04x:%04x", *(WORD
*)(args16
+2), *(WORD
*)args16
);
152 if (*args
) printf( "," );
154 printf( ") ret=%04x:%04x ds=%04x\n", frame
->cs
, frame
->ip
, frame
->ds
);
156 if (func_type
== 2) /* register function */
158 struct sigcontext_struct
*context
= (struct sigcontext_struct
*)&args32
;
159 printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
160 AX_reg(context
), BX_reg(context
), CX_reg(context
),
161 DX_reg(context
), SI_reg(context
), DI_reg(context
),
162 ES_reg(context
), EFL_reg(context
) );
167 /***********************************************************************
170 void RELAY_DebugReturn( int func_type
, int ret_val
, int args32
)
173 struct dll_table_s
*table
;
176 if (*(DWORD
*)PTR_SEG_TO_LIN(IF1632_Stack32_base
) != 0xDEADBEEF)
178 fprintf(stderr
, "Wine wrote past the end of the 32 bit stack. Please report this.\n");
179 exit(1); /* There's probably no point in going on */
181 if (!debugging_relay
) return;
183 frame
= CURRENT_STACK16
;
184 table
= &dll_builtin_table
[frame
->dll_id
-1];
185 name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
186 printf( "Ret %s.%d: %*.*s() ",
187 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
191 printf( "retval=0x%08x ret=%04x:%04x ds=%04x\n",
192 ret_val
, frame
->cs
, frame
->ip
, frame
->ds
);
195 printf( "retval=0x%04x ret=%04x:%04x ds=%04x\n",
196 ret_val
& 0xffff, frame
->cs
, frame
->ip
, frame
->ds
);
199 printf( "retval=none ret=%04x:%04x ds=%04x\n",
200 frame
->cs
, frame
->ip
, frame
->ds
);
202 struct sigcontext_struct
*context
= (struct sigcontext_struct
*)&args32
;
203 printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
204 AX_reg(context
), BX_reg(context
), CX_reg(context
),
205 DX_reg(context
), SI_reg(context
), DI_reg(context
),
206 ES_reg(context
), EFL_reg(context
) );
213 /***********************************************************************
214 * RELAY_Unimplemented
216 * This function is called for unimplemented entry points (declared
217 * as 'stub' in the spec file).
219 void RELAY_Unimplemented(void)
221 STACK16FRAME
*frame
= CURRENT_STACK16
;
222 struct dll_table_s
*table
= &dll_builtin_table
[frame
->dll_id
-1];
223 char *name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
225 fprintf( stderr
, "No handler for routine %s.%d (%*.*s)\n",
226 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
231 /***********************************************************************
234 * 'stack' points to the called function address on the 32-bit stack.
239 * (stack+4) 16-bit ds
240 * (stack) func to call
242 void RELAY_DebugCall16( int* stack
, int nbargs
)
244 if (!debugging_relay
) return;
246 printf( "CallTo16(func=%04x:%04x,ds=%04x",
247 HIWORD(stack
[0]), LOWORD(stack
[0]), LOWORD(stack
[1]) );
249 while (nbargs
--) printf( ",0x%x", *stack
++ );