5 * Copyright (c) 1997 Andreas Mohr
14 #include "selectors.h"
18 /***********************************************************************
19 * Get16DLLAddress (KERNEL32)
21 * This function is used by a Win32s DLL if it wants to call a Win16 function.
22 * A 16:16 segmented pointer to the function is returned.
23 * Written without any docu.
25 SEGPTR WINAPI
Get16DLLAddress(HMODULE32 handle
, LPSTR func_name
) {
26 HANDLE32 ThunkHeap
= HeapCreate(HEAP_WINE_SEGPTR
| HEAP_WINE_CODESEG
, 0, 64);
28 LPVOID tmpheap
= HeapAlloc(ThunkHeap
, 0, 32);
29 SEGPTR thunk
= HEAP_GetSegptr(ThunkHeap
, 0, tmpheap
);
33 if (!handle
) handle
=GetModuleHandle16("WIN32S16");
34 proc_16
= (DWORD
)WIN32_GetProcAddress16(handle
, func_name
);
36 x
=PTR_SEG_TO_LIN(thunk
);
37 *x
++=0xba; *(DWORD
*)x
=proc_16
;x
+=4; /* movl proc_16, $edx */
38 *x
++=0xea; *(DWORD
*)x
=(DWORD
)GetProcAddress32(GetModuleHandle32A("KERNEL32"),"QT_Thunk");x
+=4; /* jmpl QT_Thunk */
39 GET_CS(cs
); *(WORD
*)x
=(WORD
)cs
;