Removed a lot of occurences of windows.h (and added necessary other
[wine] / misc / w32scomb.c
1 /*
2  * W32SCOMB
3  * DLL for Win32s
4  *
5  * Copyright (c) 1997 Andreas Mohr
6  */
7
8 #include <stdio.h>
9 #include <string.h>
10 #include <stdlib.h>
11 #include "wintypes.h"
12 #include "wine/winbase16.h"
13 #include "module.h"
14 #include "ldt.h"
15 #include "selectors.h"
16 #include "heap.h"
17
18 /***********************************************************************
19  *           Get16DLLAddress       (KERNEL32)
20  *
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.
24  */
25 SEGPTR WINAPI Get16DLLAddress(HMODULE32 handle, LPSTR func_name) {
26         HANDLE32 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;
31         WORD cs;
32
33         if (!handle) handle=GetModuleHandle16("WIN32S16");
34         proc_16 = (DWORD)WIN32_GetProcAddress16(handle, func_name);
35
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;
40         return thunk;
41 }