Dest buffer was printed out as str.
[wine/multimedia.git] / misc / w32scomb.c
blob4d77ce86823d45c3e01e5355cbe422325c3f5b30
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 "windows.h"
12 #include "module.h"
13 #include "ldt.h"
14 #include "selectors.h"
15 #include "winbase.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(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;
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;
40 return thunk;