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
] =
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
)
104 struct dll_table_s
*table
;
108 if (!debugging_relay
) return;
110 frame
= CURRENT_STACK16
;
111 table
= &dll_builtin_table
[frame
->dll_id
-1];
112 name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
113 printf( "Call %s.%d: %*.*s(",
114 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
116 args16
= (char *)frame
->args
;
117 for (i
= 0; i
< strlen(args
); i
++)
139 printf( "0x%04x", *(WORD
*)args16
);
143 printf( "0x%08x", *(int *)args16
);
147 printf( "%04x:%04x", *(WORD
*)(args16
+2), *(WORD
*)args16
);
151 if (*args
) printf( "," );
153 printf( ") ret=%04x:%04x ds=%04x\n", frame
->cs
, frame
->ip
, frame
->ds
);
155 if (func_type
== 2) /* register function */
157 struct sigcontext_struct
*context
= (struct sigcontext_struct
*)args16
;
158 printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
159 AX
, BX
, CX
, DX
, SI
, DI
, ES
, EFL
);
164 /***********************************************************************
167 void RELAY_DebugReturn( int func_type
, int ret_val
)
170 struct dll_table_s
*table
;
173 if (*(DWORD
*)PTR_SEG_TO_LIN(IF1632_Stack32_base
) != 0xDEADBEEF) {
174 fprintf(stderr
, "Wine wrote past the end of the 32 bit stack. Please report this.\n");
176 if (!debugging_relay
) return;
178 frame
= CURRENT_STACK16
;
179 table
= &dll_builtin_table
[frame
->dll_id
-1];
180 name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
181 printf( "Ret %s.%d: %*.*s() ",
182 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
186 printf( "retval=0x%08x ds=%04x\n", ret_val
, frame
->ds
);
189 printf( "retval=0x%04x ds=%04x\n", ret_val
& 0xffff, frame
->ds
);
192 printf( "retval=none ds=%04x\n", frame
->ds
);
198 /***********************************************************************
199 * RELAY_Unimplemented
201 * This function is called for unimplemented entry points (declared
202 * as 'stub' in the spec file).
204 void RELAY_Unimplemented(void)
206 STACK16FRAME
*frame
= CURRENT_STACK16
;
207 struct dll_table_s
*table
= &dll_builtin_table
[frame
->dll_id
-1];
208 char *name
= MODULE_GetEntryPointName( table
->hModule
, frame
->ordinal_number
);
210 fprintf( stderr
, "No handler for routine %s.%d (%*.*s)\n",
211 table
->name
, frame
->ordinal_number
, *name
, *name
, name
+ 1 );
216 /***********************************************************************
219 * 'stack' points to the called function address on the 32-bit stack.
224 * (stack+4) 16-bit ds
225 * (stack) func to call
227 void RELAY_DebugCall16( int* stack
, int nbargs
)
229 if (!debugging_relay
) return;
231 printf( "CallTo16(func=%04x:%04x,ds=%04x",
232 HIWORD(stack
[0]), LOWORD(stack
[0]), LOWORD(stack
[1]) );
234 while (nbargs
--) printf( ",0x%x", *stack
++ );