4 * Copyright 1996, 1997 Alexandre Julliard
16 #include "stackframe.h"
17 #include "selectors.h"
24 /* List of the 16-bit callback functions. This list is used */
25 /* by the build program to generate the file if1632/callto16.S */
27 /* ### start build ### */
28 extern LONG CALLBACK
CallTo16_sreg_(const CONTEXT
*context
, INT32 offset
);
29 extern LONG CALLBACK
CallTo16_lreg_(const CONTEXT
*context
, INT32 offset
);
30 extern WORD CALLBACK
CallTo16_word_ (FARPROC16
);
31 extern LONG CALLBACK
CallTo16_long_ (FARPROC16
);
32 extern WORD CALLBACK
CallTo16_word_w (FARPROC16
,WORD
);
33 extern LONG CALLBACK
CallTo16_long_l (FARPROC16
,LONG
);
34 extern WORD CALLBACK
CallTo16_word_ww (FARPROC16
,WORD
,WORD
);
35 extern WORD CALLBACK
CallTo16_word_wl (FARPROC16
,WORD
,LONG
);
36 extern WORD CALLBACK
CallTo16_word_ll (FARPROC16
,LONG
,LONG
);
37 extern LONG CALLBACK
CallTo16_long_ll (FARPROC16
,LONG
,LONG
);
38 extern WORD CALLBACK
CallTo16_word_www (FARPROC16
,WORD
,WORD
,WORD
);
39 extern WORD CALLBACK
CallTo16_word_wwl (FARPROC16
,WORD
,WORD
,LONG
);
40 extern WORD CALLBACK
CallTo16_word_wlw (FARPROC16
,WORD
,LONG
,WORD
);
41 extern LONG CALLBACK
CallTo16_long_wwl (FARPROC16
,WORD
,WORD
,LONG
);
42 extern LONG CALLBACK
CallTo16_long_lll (FARPROC16
,LONG
,LONG
,LONG
);
43 extern WORD CALLBACK
CallTo16_word_llwl (FARPROC16
,LONG
,LONG
,WORD
,LONG
);
44 extern WORD CALLBACK
CallTo16_word_lwll (FARPROC16
,LONG
,WORD
,LONG
,LONG
);
45 extern WORD CALLBACK
CallTo16_word_lwww (FARPROC16
,LONG
,WORD
,WORD
,WORD
);
46 extern WORD CALLBACK
CallTo16_word_wwll (FARPROC16
,WORD
,WORD
,LONG
,LONG
);
47 extern WORD CALLBACK
CallTo16_word_llll (FARPROC16
,LONG
,LONG
,LONG
,LONG
);
48 extern LONG CALLBACK
CallTo16_long_llll (FARPROC16
,LONG
,LONG
,LONG
,LONG
);
49 extern WORD CALLBACK
CallTo16_word_wllwl(FARPROC16
,WORD
,LONG
,LONG
,WORD
,LONG
);
50 extern LONG CALLBACK
CallTo16_long_lwwll(FARPROC16
,LONG
,WORD
,WORD
,LONG
,LONG
);
51 extern WORD CALLBACK
CallTo16_word_wwlll(FARPROC16
,WORD
,WORD
,LONG
,LONG
,LONG
);
52 extern WORD CALLBACK
CallTo16_word_wwwww(FARPROC16
,WORD
,WORD
,WORD
,WORD
,WORD
);
53 extern WORD CALLBACK
CallTo16_word_lwlll(FARPROC16
,LONG
,WORD
,LONG
,LONG
,LONG
);
54 extern LONG CALLBACK
CallTo16_long_lwlll(FARPROC16
,LONG
,WORD
,LONG
,LONG
,LONG
);
55 extern LONG CALLBACK
CallTo16_long_lllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,LONG
);
56 extern LONG CALLBACK
CallTo16_long_llllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,LONG
,
58 extern LONG CALLBACK
CallTo16_long_lllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,LONG
,
60 extern WORD CALLBACK
CallTo16_word_llwwlll(FARPROC16
,LONG
,LONG
,WORD
,WORD
,LONG
,
62 extern LONG CALLBACK
CallTo16_word_lwwlllll(FARPROC16
,LONG
,WORD
,WORD
,LONG
,LONG
,
64 extern LONG CALLBACK
CallTo16_long_llllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,LONG
,
66 extern LONG CALLBACK
CallTo16_long_lllllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,
67 LONG
,LONG
,LONG
,LONG
,LONG
);
68 extern LONG CALLBACK
CallTo16_long_llllllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,
69 LONG
,LONG
,LONG
,LONG
,LONG
,LONG
);
70 extern LONG CALLBACK
CallTo16_long_lllllllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,
71 LONG
,LONG
,LONG
,LONG
,LONG
,LONG
,
73 extern LONG CALLBACK
CallTo16_long_llllllllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,
74 LONG
,LONG
,LONG
,LONG
,LONG
,LONG
,
76 extern LONG CALLBACK
CallTo16_long_lwwllwlllllw(FARPROC16
,LONG
,WORD
,WORD
,LONG
,
77 LONG
,WORD
,LONG
,LONG
,LONG
,LONG
,
79 extern LONG CALLBACK
CallTo16_long_lllllllllllll(FARPROC16
,LONG
,LONG
,LONG
,LONG
,
80 LONG
,LONG
,LONG
,LONG
,LONG
,LONG
,
82 extern LONG CALLBACK
CallTo16_long_llllllllllllll(FARPROC16
,LONG
,LONG
,LONG
,
83 LONG
,LONG
,LONG
,LONG
,LONG
,
84 LONG
,LONG
,LONG
,LONG
,LONG
,
86 extern LONG CALLBACK
CallTo16_word_lwwwwlwwwwllll(FARPROC16
,LONG
,WORD
,WORD
,
87 WORD
,WORD
,LONG
,WORD
,WORD
,
88 WORD
,WORD
,LONG
,LONG
,LONG
,
90 extern LONG CALLBACK
CallTo16_long_lllllllllllllll(FARPROC16
,LONG
,LONG
,LONG
,
91 LONG
,LONG
,LONG
,LONG
,LONG
,
92 LONG
,LONG
,LONG
,LONG
,LONG
,
94 extern LONG CALLBACK
CallTo16_long_llllllllllllllll(FARPROC16
,LONG
,LONG
,LONG
,
95 LONG
,LONG
,LONG
,LONG
,LONG
,
96 LONG
,LONG
,LONG
,LONG
,LONG
,
98 /* ### stop build ### */
101 typedef void (*RELAY
)();
105 typedef struct tagTHUNK
107 BYTE popl_eax
; /* 0x58 popl %eax (return address)*/
108 BYTE pushl_func
; /* 0x68 pushl $proc */
109 FARPROC32 proc WINE_PACKED
;
110 BYTE pushl_eax
; /* 0x50 pushl %eax */
111 BYTE jmp
; /* 0xe9 jmp relay (relative jump)*/
112 RELAY relay WINE_PACKED
;
113 struct tagTHUNK
*next WINE_PACKED
;
118 #define DECL_THUNK(name,proc,relay) \
119 THUNK name = { 0x58, 0x68, (FARPROC32)(proc), 0x50, 0xe9, \
120 (RELAY)((char *)(relay) - (char *)(&(name).next)), NULL }
123 static THUNK
*firstThunk
= NULL
;
125 static LRESULT WINAPI
THUNK_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
126 UINT16 msg
, WPARAM16 wParam
,
128 static void WINAPI
THUNK_CallTaskReschedule(void);
129 static BOOL32 WINAPI
THUNK_WOWCallback16Ex( FARPROC16
,DWORD
,DWORD
,
132 /* TASK_Reschedule() 16-bit entry point */
133 static FARPROC16 TASK_RescheduleProc
;
135 extern void CallFrom16_p_long_wwwll(void);
137 /* Callbacks function table for the emulator */
138 static const CALLBACKS_TABLE CALLBACK_EmulatorTable
=
140 (void *)CallTo16_sreg_
, /* CallRegisterShortProc */
141 (void *)CallTo16_lreg_
, /* CallRegisterLongProc */
142 THUNK_CallTaskReschedule
, /* CallTaskRescheduleProc */
143 CallFrom16_p_long_wwwll
, /* CallFrom16WndProc */
144 THUNK_CallWndProc16
, /* CallWndProc */
145 (void *)CallTo16_long_lwwll
, /* CallDriverProc */
146 (void *)CallTo16_word_wwlll
, /* CallDriverCallback */
147 (void *)CallTo16_word_wwlll
, /* CallTimeFuncProc */
148 (void *)CallTo16_word_w
, /* CallWindowsExitProc */
149 (void *)CallTo16_word_lwww
, /* CallWordBreakProc */
150 (void *)CallTo16_word_ww
, /* CallBootAppProc */
151 (void *)CallTo16_word_www
, /* CallLoadAppSegProc */
152 (void *)CallTo16_word_
, /* CallSystemTimerProc */
153 (void *)CallTo16_long_l
, /* CallWOWCallbackProc */
154 THUNK_WOWCallback16Ex
, /* CallWOWCallback16Ex */
155 (void *)CallTo16_long_l
, /* CallASPIPostProc */
156 (void *)CallTo16_word_lwll
, /* CallDrvControlProc */
157 (void *)CallTo16_word_lwlll
, /* CallDrvEnableProc */
158 (void *)CallTo16_word_llll
, /* CallDrvEnumDFontsProc */
159 (void *)CallTo16_word_lwll
, /* CallDrvEnumObjProc */
160 (void *)CallTo16_word_lwwlllll
, /* CallDrvOutputProc */
161 (void *)CallTo16_long_lwlll
, /* CallDrvRealizeProc */
162 (void *)CallTo16_word_lwwwwlwwwwllll
, /* CallDrvStretchBltProc */
163 (void *)CallTo16_long_lwwllwlllllw
, /* CallDrvExtTextOutProc */
164 (void *)CallTo16_word_llwwlll
/* CallDrvGetCharWidth */
168 /***********************************************************************
171 BOOL32
THUNK_Init(void)
173 /* Set the window proc calling functions */
174 Callbacks
= &CALLBACK_EmulatorTable
;
175 /* Get the 16-bit reschedule function pointer */
176 TASK_RescheduleProc
= MODULE_GetWndProcEntry16( "TASK_Reschedule" );
181 /***********************************************************************
184 static THUNK
*THUNK_Alloc( FARPROC32 func
, RELAY relay
)
186 THUNK
*thunk
= HeapAlloc( GetProcessHeap(), 0, sizeof(*thunk
) );
189 thunk
->popl_eax
= 0x58;
190 thunk
->pushl_func
= 0x68;
192 thunk
->pushl_eax
= 0x50;
194 thunk
->relay
= (RELAY
)((char *)relay
- (char *)(&thunk
->next
));
195 thunk
->next
= firstThunk
;
202 /***********************************************************************
205 static THUNK
*THUNK_Find( FARPROC32 func
)
207 THUNK
*thunk
= firstThunk
;
208 while (thunk
&& (thunk
->proc
!= func
)) thunk
= thunk
->next
;
213 /***********************************************************************
216 static void THUNK_Free( THUNK
*thunk
)
218 if (HEAP_IsInsideHeap( GetProcessHeap(), 0, thunk
))
220 THUNK
**prev
= &firstThunk
;
221 while (*prev
&& (*prev
!= thunk
)) prev
= &(*prev
)->next
;
225 HeapFree( GetProcessHeap(), 0, thunk
);
229 ERR(thunk
, "invalid thunk addr %p\n", thunk
);
233 /***********************************************************************
234 * THUNK_CallWndProc16
236 * Call a 16-bit window procedure
238 static LRESULT WINAPI
THUNK_CallWndProc16( WNDPROC16 proc
, HWND16 hwnd
,
239 UINT16 msg
, WPARAM16 wParam
,
245 WND
*wndPtr
= WIN_FindWndPtr( hwnd
);
247 THDB
*thdb
= THREAD_Current();
249 /* Window procedures want ax = hInstance, ds = es = ss */
251 DS_reg(&context
) = SELECTOROF(thdb
->cur_stack
);
252 ES_reg(&context
) = DS_reg(&context
);
253 EAX_reg(&context
) = wndPtr
? wndPtr
->hInstance
: DS_reg(&context
);
254 CS_reg(&context
) = SELECTOROF(proc
);
255 EIP_reg(&context
) = OFFSETOF(proc
);
256 EBP_reg(&context
) = OFFSETOF(thdb
->cur_stack
)
257 + (WORD
)&((STACK16FRAME
*)0)->bp
;
261 /* Some programs (eg. the "Undocumented Windows" examples, JWP) only
262 work if structures passed in lParam are placed in the stack/data
263 segment. Programmers easily make the mistake of converting lParam
264 to a near rather than a far pointer, since Windows apparently
265 allows this. We copy the structures to the 16 bit stack; this is
266 ugly but makes these programs work. */
271 offset
= sizeof(CREATESTRUCT16
); break;
273 offset
= sizeof(DRAWITEMSTRUCT16
); break;
275 offset
= sizeof(COMPAREITEMSTRUCT16
); break;
279 void *s
= PTR_SEG_TO_LIN(lParam
);
280 lParam
= STACK16_PUSH( thdb
, offset
);
281 memcpy( PTR_SEG_TO_LIN(lParam
), s
, offset
);
285 args
= (WORD
*)THREAD_STACK16(thdb
) - 5;
286 args
[0] = LOWORD(lParam
);
287 args
[1] = HIWORD(lParam
);
292 ret
= CallTo16_sreg_( &context
, 5 * sizeof(WORD
) );
293 if (offset
) STACK16_POP( thdb
, offset
);
298 /***********************************************************************
299 * THUNK_CallTaskReschedule
301 static void WINAPI
THUNK_CallTaskReschedule(void)
303 CallTo16_word_(TASK_RescheduleProc
);
307 /***********************************************************************
308 * THUNK_EnumObjects16 (GDI.71)
310 INT16 WINAPI
THUNK_EnumObjects16( HDC16 hdc
, INT16 nObjType
,
311 GOBJENUMPROC16 func
, LPARAM lParam
)
313 DECL_THUNK( thunk
, func
, CallTo16_word_ll
);
314 return EnumObjects16( hdc
, nObjType
, (GOBJENUMPROC16
)&thunk
, lParam
);
318 /*************************************************************************
319 * THUNK_EnumFonts16 (GDI.70)
321 INT16 WINAPI
THUNK_EnumFonts16( HDC16 hdc
, LPCSTR lpFaceName
,
322 FONTENUMPROC16 func
, LPARAM lParam
)
324 DECL_THUNK( thunk
, func
, CallTo16_word_llwl
);
325 return EnumFonts16( hdc
, lpFaceName
, (FONTENUMPROC16
)&thunk
, lParam
);
328 /******************************************************************
329 * THUNK_EnumMetaFile16 (GDI.175)
331 BOOL16 WINAPI
THUNK_EnumMetaFile16( HDC16 hdc
, HMETAFILE16 hmf
,
332 MFENUMPROC16 func
, LPARAM lParam
)
334 DECL_THUNK( thunk
, func
, CallTo16_word_wllwl
);
335 return EnumMetaFile16( hdc
, hmf
, (MFENUMPROC16
)&thunk
, lParam
);
339 /*************************************************************************
340 * THUNK_EnumFontFamilies16 (GDI.330)
342 INT16 WINAPI
THUNK_EnumFontFamilies16( HDC16 hdc
, LPCSTR lpszFamily
,
343 FONTENUMPROC16 func
, LPARAM lParam
)
345 DECL_THUNK( thunk
, func
, CallTo16_word_llwl
);
346 return EnumFontFamilies16(hdc
, lpszFamily
, (FONTENUMPROC16
)&thunk
, lParam
);
350 /*************************************************************************
351 * THUNK_EnumFontFamiliesEx16 (GDI.613)
353 INT16 WINAPI
THUNK_EnumFontFamiliesEx16( HDC16 hdc
, LPLOGFONT16 lpLF
,
354 FONTENUMPROCEX16 func
, LPARAM lParam
,
357 DECL_THUNK( thunk
, func
, CallTo16_word_llwl
);
358 return EnumFontFamiliesEx16( hdc
, lpLF
, (FONTENUMPROCEX16
)&thunk
,
363 /**********************************************************************
364 * THUNK_LineDDA16 (GDI.100)
366 void WINAPI
THUNK_LineDDA16( INT16 nXStart
, INT16 nYStart
, INT16 nXEnd
,
367 INT16 nYEnd
, LINEDDAPROC16 func
, LPARAM lParam
)
369 DECL_THUNK( thunk
, func
, CallTo16_word_wwl
);
370 LineDDA16( nXStart
, nYStart
, nXEnd
, nYEnd
, (LINEDDAPROC16
)&thunk
, lParam
);
374 /*******************************************************************
375 * THUNK_EnumWindows16 (USER.54)
377 BOOL16 WINAPI
THUNK_EnumWindows16( WNDENUMPROC16 func
, LPARAM lParam
)
379 DECL_THUNK( thunk
, func
, CallTo16_word_wl
);
380 return EnumWindows16( (WNDENUMPROC16
)&thunk
, lParam
);
384 /**********************************************************************
385 * THUNK_EnumChildWindows16 (USER.55)
387 BOOL16 WINAPI
THUNK_EnumChildWindows16( HWND16 parent
, WNDENUMPROC16 func
,
390 DECL_THUNK( thunk
, func
, CallTo16_word_wl
);
391 return EnumChildWindows16( parent
, (WNDENUMPROC16
)&thunk
, lParam
);
395 /**********************************************************************
396 * THUNK_EnumTaskWindows16 (USER.225)
398 BOOL16 WINAPI
THUNK_EnumTaskWindows16( HTASK16 hTask
, WNDENUMPROC16 func
,
401 DECL_THUNK( thunk
, func
, CallTo16_word_wl
);
402 return EnumTaskWindows16( hTask
, (WNDENUMPROC16
)&thunk
, lParam
);
406 /***********************************************************************
407 * THUNK_EnumProps16 (USER.27)
409 INT16 WINAPI
THUNK_EnumProps16( HWND16 hwnd
, PROPENUMPROC16 func
)
411 DECL_THUNK( thunk
, func
, CallTo16_word_wlw
);
412 return EnumProps16( hwnd
, (PROPENUMPROC16
)&thunk
);
416 /***********************************************************************
417 * THUNK_GrayString16 (USER.185)
419 BOOL16 WINAPI
THUNK_GrayString16( HDC16 hdc
, HBRUSH16 hbr
,
420 GRAYSTRINGPROC16 func
, LPARAM lParam
,
421 INT16 cch
, INT16 x
, INT16 y
,
424 DECL_THUNK( thunk
, func
, CallTo16_word_wlw
);
426 return GrayString16( hdc
, hbr
, NULL
, lParam
, cch
, x
, y
, cx
, cy
);
428 return GrayString16( hdc
, hbr
, (GRAYSTRINGPROC16
)&thunk
, lParam
, cch
,
433 /***********************************************************************
434 * THUNK_SetWindowsHook16 (USER.121)
436 FARPROC16 WINAPI
THUNK_SetWindowsHook16( INT16 id
, HOOKPROC16 proc
)
438 HINSTANCE16 hInst
= FarGetOwner( HIWORD(proc
) );
439 HTASK16 hTask
= (id
== WH_MSGFILTER
) ? GetCurrentTask() : 0;
440 THUNK
*thunk
= THUNK_Alloc( (FARPROC16
)proc
, (RELAY
)CallTo16_long_wwl
);
441 if (!thunk
) return 0;
442 return (FARPROC16
)SetWindowsHookEx16( id
, (HOOKPROC16
)thunk
, hInst
, hTask
);
446 /***********************************************************************
447 * THUNK_UnhookWindowsHook16 (USER.234)
449 BOOL16 WINAPI
THUNK_UnhookWindowsHook16( INT16 id
, HOOKPROC16 proc
)
452 THUNK
*thunk
= THUNK_Find( (FARPROC16
)proc
);
453 if (!thunk
) return FALSE
;
454 ret
= UnhookWindowsHook16( id
, (HOOKPROC16
)thunk
);
460 /***********************************************************************
461 * THUNK_SetWindowsHookEx16 (USER.291)
463 HHOOK WINAPI
THUNK_SetWindowsHookEx16( INT16 id
, HOOKPROC16 proc
,
464 HINSTANCE16 hInst
, HTASK16 hTask
)
466 THUNK
*thunk
= THUNK_Alloc( (FARPROC16
)proc
, (RELAY
)CallTo16_long_wwl
);
467 if (!thunk
) return 0;
468 return SetWindowsHookEx16( id
, (HOOKPROC16
)thunk
, hInst
, hTask
);
472 /***********************************************************************
473 * THUNK_UnhookWindowHookEx16 (USER.292)
475 BOOL16 WINAPI
THUNK_UnhookWindowsHookEx16( HHOOK hhook
)
477 THUNK
*thunk
= (THUNK
*)HOOK_GetProc16( hhook
);
478 BOOL16 ret
= UnhookWindowsHookEx16( hhook
);
479 if (thunk
) THUNK_Free( thunk
);
485 static FARPROC16 defDCHookProc
= NULL
;
487 /***********************************************************************
488 * THUNK_SetDCHook (GDI.190)
490 BOOL16 WINAPI
THUNK_SetDCHook( HDC16 hdc
, FARPROC16 proc
, DWORD dwHookData
)
492 THUNK
*thunk
, *oldThunk
;
494 if (!defDCHookProc
) /* Get DCHook Win16 entry point */
495 defDCHookProc
= MODULE_GetEntryPoint( GetModuleHandle16("USER"), 362 );
497 if (proc
!= defDCHookProc
)
499 thunk
= THUNK_Alloc( proc
, (RELAY
)CallTo16_word_wwll
);
500 if (!thunk
) return FALSE
;
502 else thunk
= (THUNK
*)DCHook
;
504 /* Free the previous thunk */
505 GetDCHook( hdc
, (FARPROC16
*)&oldThunk
);
506 if (oldThunk
&& (oldThunk
!= (THUNK
*)DCHook
)) THUNK_Free( oldThunk
);
508 return SetDCHook( hdc
, (FARPROC16
)thunk
, dwHookData
);
512 /***********************************************************************
513 * THUNK_GetDCHook (GDI.191)
515 DWORD WINAPI
THUNK_GetDCHook( HDC16 hdc
, FARPROC16
*phookProc
)
518 DWORD ret
= GetDCHook( hdc
, (FARPROC16
*)&thunk
);
521 if (thunk
== (THUNK
*)DCHook
)
523 if (!defDCHookProc
) /* Get DCHook Win16 entry point */
524 defDCHookProc
= MODULE_GetEntryPoint(GetModuleHandle16("USER"),
526 *phookProc
= defDCHookProc
;
528 else *phookProc
= thunk
->proc
;
534 /***********************************************************************
535 * THUNK_SetTaskSignalProc (KERNEL.38)
537 FARPROC16 WINAPI
THUNK_SetTaskSignalProc( HTASK16 hTask
, FARPROC16 proc
)
539 static FARPROC16 defSignalProc16
= NULL
;
543 if( !defSignalProc16
)
544 defSignalProc16
= MODULE_GetEntryPoint(GetModuleHandle16("USER"), 314 );
546 if( proc
== defSignalProc16
)
547 thunk
= (THUNK
*)SetTaskSignalProc( hTask
, (FARPROC16
)&USER_SignalProc
);
550 thunk
= THUNK_Alloc( proc
, (RELAY
)CallTo16_word_wwwww
);
551 if( !thunk
) return FALSE
;
552 thunk
= (THUNK
*)SetTaskSignalProc( hTask
, (FARPROC16
)thunk
);
555 if( thunk
!= (THUNK
*)USER_SignalProc
)
557 if( !thunk
) return NULL
;
563 return defSignalProc16
;
567 /***********************************************************************
568 * THUNK_SetResourceHandler (KERNEL.67)
570 FARPROC16 WINAPI
THUNK_SetResourceHandler( HMODULE16 hModule
, SEGPTR typeId
, FARPROC16 proc
)
572 /* loader/ne_resource.c */
573 extern HGLOBAL16 WINAPI
NE_DefResourceHandler(HGLOBAL16
,HMODULE16
,HRSRC16
);
575 static FARPROC16 defDIBIconLoader16
= NULL
;
576 static FARPROC16 defDIBCursorLoader16
= NULL
;
577 static FARPROC16 defResourceLoader16
= NULL
;
581 if( !defResourceLoader16
)
583 HMODULE16 hUser
= GetModuleHandle16("USER");
584 defDIBIconLoader16
= MODULE_GetEntryPoint( hUser
, 357 );
585 defDIBCursorLoader16
= MODULE_GetEntryPoint( hUser
, 356 );
586 defResourceLoader16
= MODULE_GetWndProcEntry16( "DefResourceHandler" );
589 if( proc
== defResourceLoader16
)
590 thunk
= (THUNK
*)&NE_DefResourceHandler
;
591 else if( proc
== defDIBIconLoader16
)
592 thunk
= (THUNK
*)&LoadDIBIconHandler
;
593 else if( proc
== defDIBCursorLoader16
)
594 thunk
= (THUNK
*)&LoadDIBCursorHandler
;
597 thunk
= THUNK_Alloc( proc
, (RELAY
)CallTo16_word_www
);
598 if( !thunk
) return FALSE
;
601 thunk
= (THUNK
*)SetResourceHandler( hModule
, typeId
, (FARPROC16
)thunk
);
603 if( thunk
== (THUNK
*)&NE_DefResourceHandler
)
604 return defResourceLoader16
;
605 if( thunk
== (THUNK
*)&LoadDIBIconHandler
)
606 return defDIBIconLoader16
;
607 if( thunk
== (THUNK
*)&LoadDIBCursorHandler
)
608 return defDIBCursorLoader16
;
619 /***********************************************************************
620 * THUNK_WOWCallback16Ex (WOW32.3)(KERNEL32.55)
621 * Generic thunking routine to call 16 bit functions from 32bit code.
624 * TRUE if the call was done
626 static BOOL32 WINAPI
THUNK_WOWCallback16Ex(
627 FARPROC16 proc
, /* [in] 16bit function to call */
628 DWORD dwFlags
, /* [in] flags (WCB_*) */
629 DWORD cbArgs
, /* [in] number of arguments */
630 LPVOID xargs
, /* [in/out] arguments */
631 LPDWORD pdwret
/* [out] return value of the 16bit call */
633 LPDWORD args
= (LPDWORD
)xargs
;
636 TRACE(relay
,"(%p,0x%08lx,%ld,%p,%p)\n",
637 proc
,dwFlags
,cbArgs
,xargs
,pdwret
639 if (dwFlags
== WCB16_CDECL
) {
640 /* swap the arguments */
641 args
= HeapAlloc(GetProcessHeap(),0,cbArgs
*sizeof(DWORD
));
642 for (i
=0;i
<cbArgs
;i
++)
643 args
[i
] = ((DWORD
*)xargs
)[cbArgs
-i
-1];
646 case 0: ret
= CallTo16_long_(proc
);break;
647 case 1: ret
= CallTo16_long_l(proc
,args
[0]);break;
648 case 2: ret
= CallTo16_long_ll(proc
,args
[0],args
[1]);break;
649 case 3: ret
= CallTo16_long_lll(proc
,args
[0],args
[1],args
[2]);break;
650 case 4: ret
= CallTo16_long_llll(proc
,args
[0],args
[1],args
[2],args
[3]);
652 case 5: ret
= CallTo16_long_lllll(proc
,args
[0],args
[1],args
[2],args
[3],
656 case 6: ret
= CallTo16_long_llllll(proc
,args
[0],args
[1],args
[2],args
[3],
660 case 7: ret
= CallTo16_long_lllllll(proc
,args
[0],args
[1],args
[2],args
[3],
661 args
[4],args
[5],args
[6]
664 case 8: ret
= CallTo16_long_llllllll(proc
,args
[0],args
[1],args
[2],args
[3],
665 args
[4],args
[5],args
[6],args
[7]
668 case 9: ret
= CallTo16_long_lllllllll(proc
,args
[0],args
[1],args
[2],args
[3],
669 args
[4],args
[5],args
[6],args
[7],args
[8]
672 case 10:ret
= CallTo16_long_llllllllll(proc
,args
[0],args
[1],args
[2],args
[3],
673 args
[4],args
[5],args
[6],args
[7],args
[8],args
[9]
676 case 11:ret
= CallTo16_long_lllllllllll(proc
,args
[0],args
[1],args
[2],
677 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],args
[10]
680 case 12:ret
= CallTo16_long_llllllllllll(proc
,args
[0],args
[1],args
[2],
681 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],
685 case 13:ret
= CallTo16_long_lllllllllllll(proc
,args
[0],args
[1],args
[2],
686 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],
687 args
[10],args
[11],args
[12]
690 case 14:ret
= CallTo16_long_llllllllllllll(proc
,args
[0],args
[1],args
[2],
691 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],
692 args
[10],args
[11],args
[12],args
[13]
695 case 15:ret
= CallTo16_long_lllllllllllllll(proc
,args
[0],args
[1],args
[2],
696 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],
697 args
[10],args
[11],args
[12],args
[13],args
[14]
700 case 16:ret
= CallTo16_long_llllllllllllllll(proc
,args
[0],args
[1],args
[2],
701 args
[3],args
[4],args
[5],args
[6],args
[7],args
[8],args
[9],
702 args
[10],args
[11],args
[12],args
[13],args
[14],args
[15]
706 fprintf(stderr
,"CALLBACK_CallWOWCallback16Ex(), %ld arguments not supported.!n",cbArgs
);
707 if (dwFlags
== WCB16_CDECL
)
708 HeapFree(GetProcessHeap(),0,args
);
711 if (dwFlags
== WCB16_CDECL
)
712 HeapFree(GetProcessHeap(),0,args
);