wined3d: Add zero/near zero vertex rhw special case.
[wine] / dlls / msimtf / main.c
1 /*
2  * Copyright 2007 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winuser.h"
30 #include "winreg.h"
31 #include "advpub.h"
32 #include "ole2.h"
33 #include "dimm.h"
34
35 #include "wine/debug.h"
36
37 WINE_DEFAULT_DEBUG_CHANNEL(msimtf);
38
39 static HINSTANCE msimtf_instance;
40
41 static HRESULT CActiveIMM_Create(IUnknown *outer, REFIID riid, void **ppv)
42 {
43     FIXME("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
44     return E_NOINTERFACE;
45 }
46
47 /******************************************************************
48  *              DllMain (msimtf.@)
49  */
50 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
51 {
52     switch(fdwReason)
53     {
54     case DLL_WINE_PREATTACH:
55         return FALSE;  /* prefer native version */
56     case DLL_PROCESS_ATTACH:
57         msimtf_instance = hInstDLL;
58         DisableThreadLibraryCalls(hInstDLL);
59         break;
60     case DLL_PROCESS_DETACH:
61         break;
62     }
63     return TRUE;
64 }
65
66 typedef struct {
67     const IClassFactoryVtbl *lpClassFactoryVtbl;
68
69     HRESULT (*cf)(IUnknown*,REFIID,void**);
70 } ClassFactory;
71
72 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface,
73         REFIID riid, void **ppv)
74 {
75     *ppv = NULL;
76
77     if(IsEqualGUID(&IID_IUnknown, riid)) {
78         TRACE("(IID_IUnknown %p)\n", ppv);
79         *ppv = iface;
80     }else if(IsEqualGUID(&IID_IClassFactory, riid)) {
81         TRACE("IID_IClassFactory %p)\n", ppv);
82         *ppv = iface;
83     }
84
85     if(*ppv) {
86         IUnknown_AddRef((IUnknown*)*ppv);
87         return S_OK;
88     }
89
90     FIXME("(%s %p)\n", debugstr_guid(riid), ppv);
91     return E_NOINTERFACE;
92 }
93
94 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
95 {
96     return 2;
97 }
98
99 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
100 {
101     return 1;
102 }
103
104 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface,
105         IUnknown *pOuter, REFIID riid, void **ppv)
106 {
107     ClassFactory *This = (ClassFactory*)iface;
108     return This->cf(pOuter, riid, ppv);
109 }
110
111 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
112 {
113     FIXME("(%d)\n", dolock);
114     return S_OK;
115 }
116
117 static const IClassFactoryVtbl ClassFactoryVtbl = {
118     ClassFactory_QueryInterface,
119     ClassFactory_AddRef,
120     ClassFactory_Release,
121     ClassFactory_CreateInstance,
122     ClassFactory_LockServer
123 };
124
125 /******************************************************************
126  *              DllGetClassObject (msimtf.@)
127  */
128 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
129 {
130     if(IsEqualGUID(&CLSID_CActiveIMM, rclsid)) {
131         static ClassFactory cf = {
132             &ClassFactoryVtbl,
133             CActiveIMM_Create
134         };
135
136         TRACE("CLSID_CActiveIMM\n");
137
138         return IClassFactory_QueryInterface((IClassFactory*)&cf, riid, ppv);
139     }
140
141     FIXME("(%s %s %p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
142     return CLASS_E_CLASSNOTAVAILABLE;
143 }
144
145 /******************************************************************
146  *              DllCanUnloadNow (msimtf.@)
147  */
148 HRESULT WINAPI DllCanUnloadNow(void)
149 {
150     FIXME("()\n");
151     return S_FALSE;
152 }
153
154 #define INF_SET_CLSID(clsid)                  \
155     do                                        \
156     {                                         \
157         static CHAR name[] = "CLSID_" #clsid; \
158                                               \
159         pse[i].pszName = name;                \
160         clsids[i++] = &CLSID_ ## clsid;       \
161     } while (0)
162
163 static HRESULT register_server(BOOL doregister)
164 {
165     HRESULT hres;
166     HMODULE hAdvpack;
167     typeof(RegInstallA) *pRegInstall;
168     STRTABLEA strtable;
169     STRENTRYA pse[1];
170     static CLSID const *clsids[34];
171     int i = 0;
172
173     static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
174
175     INF_SET_CLSID(CActiveIMM);
176
177     for(i = 0; i < sizeof(pse)/sizeof(pse[0]); i++) {
178         pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, 39);
179         sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
180                 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
181                 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
182                 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
183     }
184
185     strtable.cEntries = sizeof(pse)/sizeof(pse[0]);
186     strtable.pse = pse;
187
188     hAdvpack = LoadLibraryW(wszAdvpack);
189     pRegInstall = (typeof(RegInstallA)*)GetProcAddress(hAdvpack, "RegInstall");
190
191     hres = pRegInstall(msimtf_instance, doregister ? "RegisterDll" : "UnregisterDll", &strtable);
192
193     for(i=0; i < sizeof(pse)/sizeof(pse[0]); i++)
194         HeapFree(GetProcessHeap(), 0, pse[i].pszValue);
195
196     return hres;
197 }
198
199 #undef INF_SET_CLSID
200
201 /***********************************************************************
202  *          DllRegisterServer (msimtf.@)
203  */
204 HRESULT WINAPI DllRegisterServer(void)
205 {
206     return register_server(TRUE);
207 }
208
209 /***********************************************************************
210  *          DllUnregisterServer (msimtf.@)
211  */
212 HRESULT WINAPI DllUnregisterServer(void)
213 {
214     return register_server(FALSE);
215 }