Ignore ConfigueNotify size changes while the window is iconic.
[wine/multimedia.git] / if1632 / relay.c
blobf73c2560d013d737dbae3c376c59b4b7be444801
1 /*
2 * Copyright 1993 Robert J. Amstadt
3 * Copyright 1995 Alexandre Julliard
4 */
6 #include <assert.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include "wine/winbase16.h"
10 #include "winnt.h"
11 #include "module.h"
12 #include "stackframe.h"
13 #include "selectors.h"
14 #include "builtin16.h"
15 #include "syslevel.h"
16 #include "debugtools.h"
17 #include "callback.h"
19 DEFAULT_DEBUG_CHANNEL(relay);
21 /***********************************************************************
22 * RELAY_Init
24 BOOL RELAY_Init(void)
26 #ifdef __i386__
27 WORD codesel;
29 /* Allocate the code selector for CallTo16 routines */
31 extern void Call16_Ret_Start(), Call16_Ret_End();
32 extern void CallTo16_Ret();
33 extern void CALL32_CBClient_Ret();
34 extern void CALL32_CBClientEx_Ret();
35 extern SEGPTR CallTo16_RetAddr;
36 extern DWORD CallTo16_DataSelector;
37 extern SEGPTR CALL32_CBClient_RetAddr;
38 extern SEGPTR CALL32_CBClientEx_RetAddr;
40 codesel = SELECTOR_AllocBlock( (void *)Call16_Ret_Start,
41 (char *)Call16_Ret_End - (char *)Call16_Ret_Start,
42 WINE_LDT_FLAGS_CODE | WINE_LDT_FLAGS_32BIT );
43 if (!codesel) return FALSE;
45 /* Patch the return addresses for CallTo16 routines */
47 CallTo16_DataSelector = __get_ds();
48 CallTo16_RetAddr =
49 MAKESEGPTR( codesel, (char*)CallTo16_Ret - (char*)Call16_Ret_Start );
50 CALL32_CBClient_RetAddr =
51 MAKESEGPTR( codesel, (char*)CALL32_CBClient_Ret - (char*)Call16_Ret_Start );
52 CALL32_CBClientEx_RetAddr =
53 MAKESEGPTR( codesel, (char*)CALL32_CBClientEx_Ret - (char*)Call16_Ret_Start );
54 #endif
55 return TRUE;
59 * Stubs for the CallTo16/CallFrom16 routines on non-Intel architectures
60 * (these will never be called but need to be present to satisfy the linker ...)
62 #ifndef __i386__
63 /***********************************************************************
64 * wine_call_to_16_word (KERNEL32.@)
66 WORD WINAPI wine_call_to_16_word( FARPROC16 target, INT nArgs )
68 assert( FALSE );
71 /***********************************************************************
72 * wine_call_to_16_long (KERNEL32.@)
74 LONG WINAPI wine_call_to_16_long( FARPROC16 target, INT nArgs )
76 assert( FALSE );
79 /***********************************************************************
80 * wine_call_to_16_regs_short (KERNEL32.@)
82 void WINAPI wine_call_to_16_regs_short( CONTEXT86 *context, INT nArgs )
84 assert( FALSE );
87 /***********************************************************************
88 * wine_call_to_16_regs_long (KERNEL32.@)
90 void WINAPI wine_call_to_16_regs_long ( CONTEXT86 *context, INT nArgs )
92 assert( FALSE );
95 /***********************************************************************
96 * __wine_call_from_16_word (KERNEL32.@)
98 WORD __wine_call_from_16_word()
100 assert( FALSE );
103 /***********************************************************************
104 * __wine_call_from_16_long (KERNEL32.@)
106 LONG __wine_call_from_16_long()
108 assert( FALSE );
111 /***********************************************************************
112 * __wine_call_from_16_regs (KERNEL32.@)
114 void __wine_call_from_16_regs()
116 assert( FALSE );
119 /***********************************************************************
120 * __wine_call_from_16_thunk (KERNEL32.@)
122 void __wine_call_from_16_thunk()
124 assert( FALSE );
127 DWORD WINAPI CALL32_CBClient( FARPROC proc, LPWORD args, DWORD *esi )
128 { assert( FALSE ); }
130 DWORD WINAPI CALL32_CBClientEx( FARPROC proc, LPWORD args, DWORD *esi, INT *nArgs )
131 { assert( FALSE ); }
132 #endif
135 /* from relay32/relay386.c */
136 extern char **debug_relay_excludelist,**debug_relay_includelist;
137 extern int RELAY_ShowDebugmsgRelay(const char *func);
139 /***********************************************************************
140 * RELAY_DebugCallFrom16
142 void RELAY_DebugCallFrom16( CONTEXT86 *context )
144 STACK16FRAME *frame;
145 WORD ordinal;
146 char *args16, funstr[80];
147 const char *args;
148 int i, usecdecl, reg_func;
150 if (!TRACE_ON(relay)) return;
152 frame = CURRENT_STACK16;
153 args = BUILTIN_GetEntryPoint16( frame, funstr, &ordinal );
154 if (!args) return; /* happens for the two snoop register relays */
155 if (!RELAY_ShowDebugmsgRelay(funstr)) return;
156 DPRINTF( "%08lx:Call %s(",GetCurrentThreadId(),funstr);
157 VA_START16( args16 );
159 usecdecl = ( *args == 'c' );
160 args += 2;
161 reg_func = ( memcmp( args, "regs_", 5 ) == 0
162 || memcmp( args, "intr_", 5 ) == 0 );
163 args += 5;
165 if (usecdecl)
167 while (*args)
169 switch(*args)
171 case 'w':
172 case 's':
173 DPRINTF( "0x%04x", *(WORD *)args16 );
174 args16 += 2;
175 break;
176 case 'l':
177 DPRINTF( "0x%08x", *(int *)args16 );
178 args16 += 4;
179 break;
180 case 'p':
181 DPRINTF( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
182 args16 += 4;
183 break;
184 case 't':
185 case 'T':
186 DPRINTF( "%04x:%04x %s", *(WORD *)(args16+2), *(WORD *)args16,
187 debugres_a( MapSL(*(SEGPTR *)args16 )) );
188 args16 += 4;
189 break;
191 args++;
192 if (*args) DPRINTF( "," );
195 else /* not cdecl */
197 /* Start with the last arg */
198 for (i = 0; args[i]; i++)
200 switch(args[i])
202 case 'w':
203 case 's':
204 args16 += 2;
205 break;
206 case 'l':
207 case 'p':
208 case 't':
209 case 'T':
210 args16 += 4;
211 break;
215 while (*args)
217 switch(*args)
219 case 'w':
220 case 's':
221 args16 -= 2;
222 DPRINTF( "0x%04x", *(WORD *)args16 );
223 break;
224 case 'l':
225 args16 -= 4;
226 DPRINTF( "0x%08x", *(int *)args16 );
227 break;
228 case 't':
229 args16 -= 4;
230 DPRINTF( "0x%08x %s", *(int *)args16,
231 debugres_a( MapSL(*(SEGPTR *)args16 )));
232 break;
233 case 'p':
234 args16 -= 4;
235 DPRINTF( "%04x:%04x", *(WORD *)(args16+2), *(WORD *)args16 );
236 break;
237 case 'T':
238 args16 -= 4;
239 DPRINTF( "%04x:%04x %s", *(WORD *)(args16+2), *(WORD *)args16,
240 debugres_a( MapSL(*(SEGPTR *)args16 )));
241 break;
243 args++;
244 if (*args) DPRINTF( "," );
248 DPRINTF( ") ret=%04x:%04x ds=%04x\n", frame->cs, frame->ip, frame->ds );
249 VA_END16( args16 );
251 if (reg_func)
252 DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
253 AX_reg(context), BX_reg(context), CX_reg(context),
254 DX_reg(context), SI_reg(context), DI_reg(context),
255 (WORD)context->SegEs, context->EFlags );
257 SYSLEVEL_CheckNotLevel( 2 );
261 /***********************************************************************
262 * RELAY_DebugCallFrom16Ret
264 void RELAY_DebugCallFrom16Ret( CONTEXT86 *context, int ret_val )
266 STACK16FRAME *frame;
267 WORD ordinal;
268 char funstr[80];
269 const char *args;
271 if (!TRACE_ON(relay)) return;
272 frame = CURRENT_STACK16;
273 args = BUILTIN_GetEntryPoint16( frame, funstr, &ordinal );
274 if (!args) return;
275 if (!RELAY_ShowDebugmsgRelay(funstr)) return;
276 DPRINTF( "%08lx:Ret %s() ",GetCurrentThreadId(),funstr);
278 if ( memcmp( args+2, "long_", 5 ) == 0 )
280 DPRINTF( "retval=0x%08x ret=%04x:%04x ds=%04x\n",
281 ret_val, frame->cs, frame->ip, frame->ds );
283 else if ( memcmp( args+2, "word_", 5 ) == 0 )
285 DPRINTF( "retval=0x%04x ret=%04x:%04x ds=%04x\n",
286 ret_val & 0xffff, frame->cs, frame->ip, frame->ds );
288 else if ( memcmp( args+2, "regs_", 5 ) == 0
289 || memcmp( args+2, "intr_", 5 ) == 0 )
291 DPRINTF("retval=none ret=%04x:%04x ds=%04x\n",
292 (WORD)context->SegCs, LOWORD(context->Eip), (WORD)context->SegDs);
293 DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
294 AX_reg(context), BX_reg(context), CX_reg(context),
295 DX_reg(context), SI_reg(context), DI_reg(context),
296 (WORD)context->SegEs, context->EFlags );
299 SYSLEVEL_CheckNotLevel( 2 );
303 /***********************************************************************
304 * RELAY_DebugCallTo16
306 * 'target' contains either the function to call (normal CallTo16)
307 * or a pointer to the CONTEXT86 struct (register CallTo16).
308 * 'nb_args' is the number of argument bytes on the 16-bit stack;
309 * 'reg_func' specifies whether we have a register CallTo16 or not.
311 void RELAY_DebugCallTo16( LPVOID target, int nb_args, BOOL reg_func )
313 WORD *stack16;
314 TEB *teb;
316 if (!TRACE_ON(relay)) return;
317 teb = NtCurrentTeb();
318 stack16 = (WORD *)THREAD_STACK16(teb);
320 nb_args /= sizeof(WORD);
322 if ( reg_func )
324 CONTEXT86 *context = (CONTEXT86 *)target;
326 DPRINTF("%08lx:CallTo16(func=%04lx:%04x,ds=%04lx",
327 GetCurrentThreadId(),
328 context->SegCs, LOWORD(context->Eip), context->SegDs );
329 while (nb_args--) DPRINTF( ",0x%04x", *--stack16 );
330 DPRINTF(") ss:sp=%04x:%04x\n", SELECTOROF(teb->cur_stack),
331 OFFSETOF(teb->cur_stack) );
332 DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x BP=%04x ES=%04x FS=%04x\n",
333 AX_reg(context), BX_reg(context), CX_reg(context),
334 DX_reg(context), SI_reg(context), DI_reg(context),
335 BP_reg(context), (WORD)context->SegEs, (WORD)context->SegFs );
337 else
339 DPRINTF("%08lx:CallTo16(func=%04x:%04x,ds=%04x",
340 GetCurrentThreadId(),
341 HIWORD(target), LOWORD(target), SELECTOROF(teb->cur_stack) );
342 while (nb_args--) DPRINTF( ",0x%04x", *--stack16 );
343 DPRINTF(") ss:sp=%04x:%04x\n", SELECTOROF(teb->cur_stack),
344 OFFSETOF(teb->cur_stack) );
347 SYSLEVEL_CheckNotLevel( 2 );
351 /***********************************************************************
352 * RELAY_DebugCallTo16Ret
354 void RELAY_DebugCallTo16Ret( BOOL reg_func, int ret_val )
356 if (!TRACE_ON(relay)) return;
358 if (!reg_func)
360 DPRINTF("%08lx:RetFrom16() ss:sp=%04x:%04x retval=0x%08x\n",
361 GetCurrentThreadId(),
362 SELECTOROF(NtCurrentTeb()->cur_stack),
363 OFFSETOF(NtCurrentTeb()->cur_stack), ret_val);
365 else
367 CONTEXT86 *context = (CONTEXT86 *)ret_val;
369 DPRINTF("%08lx:RetFrom16() ss:sp=%04x:%04x\n",
370 GetCurrentThreadId(),
371 SELECTOROF(NtCurrentTeb()->cur_stack),
372 OFFSETOF(NtCurrentTeb()->cur_stack));
373 DPRINTF(" AX=%04x BX=%04x CX=%04x DX=%04x BP=%04x SP=%04x\n",
374 AX_reg(context), BX_reg(context), CX_reg(context),
375 DX_reg(context), BP_reg(context), LOWORD(context->Esp));
378 SYSLEVEL_CheckNotLevel( 2 );