Added DECL_GLOBAL_CONSTRUCTOR macro.
[wine.git] / misc / w32scomb.c
blob5ceb14595f9e1c82982e41cbb2502a8f1420844f
1 /*
2 * W32SCOMB
3 * DLL for Win32s
5 * Copyright (c) 1997 Andreas Mohr
6 */
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include "windef.h"
12 #include "wine/winbase16.h"
13 #include "module.h"
14 #include "ldt.h"
15 #include "selectors.h"
16 #include "heap.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(HMODULE handle, LPSTR func_name) {
26 HANDLE ThunkHeap = HeapCreate(HEAP_WINE_SEGPTR | HEAP_WINE_CODESEG, 0, 64);
27 LPBYTE x;
28 LPVOID tmpheap = HeapAlloc(ThunkHeap, 0, 32);
29 SEGPTR thunk = HEAP_GetSegptr(ThunkHeap, 0, tmpheap);
30 DWORD proc_16;
32 if (!handle) handle=GetModuleHandle16("WIN32S16");
33 proc_16 = (DWORD)WIN32_GetProcAddress16(handle, func_name);
35 x=PTR_SEG_TO_LIN(thunk);
36 *x++=0xba; *(DWORD*)x=proc_16;x+=4; /* movl proc_16, $edx */
37 *x++=0xea; *(DWORD*)x=(DWORD)GetProcAddress(GetModuleHandleA("KERNEL32"),"QT_Thunk");x+=4; /* jmpl QT_Thunk */
38 *(WORD*)x=__get_cs();
39 return thunk;