4 * Copyright 1995 Martin von Loewis
19 #include "interfaces.h"
26 DWORD currentMalloc=0;
28 /***********************************************************************
29 * CoBuildVersion [COMPOBJ.1]
31 DWORD WINAPI CoBuildVersion()
33 dprintf_ole(stddeb,"CoBuildVersion()\n");
37 /***********************************************************************
38 * CoInitialize [COMPOBJ.2]
39 * lpReserved is an IMalloc pointer in 16bit OLE. We just stored it as-is.
41 HRESULT WINAPI CoInitialize(DWORD lpReserved)
43 dprintf_ole(stdnimp,"CoInitialize\n");
44 /* remember the LPMALLOC, maybe somebody wants to read it later on */
45 currentMalloc = lpReserved;
49 /***********************************************************************
50 * CoUnitialize [COMPOBJ.3]
52 void WINAPI CoUnitialize()
54 dprintf_ole(stdnimp,"CoUnitialize()\n");
57 /***********************************************************************
58 * CoGetMalloc [COMPOBJ.4]
60 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, DWORD * lpMalloc)
64 *lpMalloc = currentMalloc;
68 /* 16-bit E_NOTIMPL */
72 /***********************************************************************
75 OLESTATUS WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
77 dprintf_ole(stdnimp,"CoDisconnectObject:%p %lx\n",lpUnk,reserved);
81 /***********************************************************************
82 * IsEqualGUID [COMPOBJ.18]
84 BOOL16 WINAPI IsEqualGUID(GUID* g1, GUID* g2)
86 return !memcmp( g1, g2, sizeof(GUID) );
89 /***********************************************************************
90 * CLSIDFromString [COMPOBJ.20]
93 /* Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] */
95 OLESTATUS WINAPI CLSIDFromString(const LPCSTR idstr, CLSID *id)
97 BYTE *s = (BYTE *) idstr;
102 dprintf_ole(stddeb,"ClsIDFromString() %s -> %p\n", idstr, id);
104 /* quick lookup table */
105 memset(table, 0, 256);
107 for (i = 0; i < 10; i++) {
110 for (i = 0; i < 6; i++) {
111 table['A' + i] = i+10;
112 table['a' + i] = i+10;
115 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
117 if (strlen(idstr) != 38)
118 return OLE_ERROR_OBJECT;
122 s++; /* skip leading brace */
123 for (i = 0; i < 4; i++) {
124 p[3 - i] = table[*s]<<4 | table[*(s+1)];
130 for (i = 0; i < 2; i++) {
131 p[1-i] = table[*s]<<4 | table[*(s+1)];
137 for (i = 0; i < 2; i++) {
138 p[1-i] = table[*s]<<4 | table[*(s+1)];
144 /* these are just sequential bytes */
145 for (i = 0; i < 2; i++) {
146 *p++ = table[*s]<<4 | table[*(s+1)];
151 for (i = 0; i < 6; i++) {
152 *p++ = table[*s]<<4 | table[*(s+1)];
159 /***********************************************************************
160 * StringFromCLSID [COMPOBJ.19]
162 OLESTATUS WINAPI StringFromCLSID(const CLSID *id, LPSTR idstr)
164 static const char *hex = "0123456789ABCDEF";
168 sprintf(idstr, "{%08lx-%04x-%04x-%02x%02x-",
169 id->Data1, id->Data2, id->Data3,
170 id->Data4[0], id->Data4[1]);
174 for (i = 2; i < 8; i++) {
175 *s++ = hex[id->Data4[i]>>4];
176 *s++ = hex[id->Data4[i] & 0xf];
182 for (i = strlen(idstr)-1; i >= 0; i--) {
183 idstr[i] = toupper(idstr[i]);
186 dprintf_ole(stddeb,"StringFromClsID: %p->%s\n", id, idstr);
191 /***********************************************************************
192 * CLSIDFromProgID [COMPOBJ.61]
195 OLESTATUS WINAPI CLSIDFromProgID(LPCSTR progid,LPCLSID riid)
202 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);
203 sprintf(buf,"%s\\CLSID",progid);
204 if ((err=RegOpenKey32A(HKEY_CLASSES_ROOT,buf,&xhkey))) {
205 HeapFree(GetProcessHeap(),0,buf);
206 return OLE_ERROR_GENERIC;
208 HeapFree(GetProcessHeap(),0,buf);
209 buf2len = sizeof(buf2);
210 if ((err=RegQueryValue32A(xhkey,NULL,buf2,&buf2len))) {
212 return OLE_ERROR_GENERIC;
215 return CLSIDFromString(buf2,riid);
218 OLESTATUS WINAPI LookupETask(LPVOID p1,LPVOID p2) {
219 fprintf(stderr,"LookupETask(%p,%p),stub!\n",p1,p2);
223 OLESTATUS WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
224 fprintf(stderr,"CallObjectInWOW(%p,%p),stub!\n",p1,p2);
228 /***********************************************************************
229 * CoRegisterClassObject [COMPOBJ.5]
231 OLESTATUS WINAPI CoRegisterClassObject(
232 REFCLSID rclsid, LPUNKNOWN pUnk,DWORD dwClsContext,DWORD flags,
237 StringFromCLSID(rclsid,buf);
239 fprintf(stderr,"CoRegisterClassObject(%s,%p,0x%08lx,0x%08lx,%p),stub\n",
240 buf,pUnk,dwClsContext,flags,lpdwRegister
245 /***********************************************************************
246 * CoRegisterClassObject [COMPOBJ.27]
248 OLESTATUS WINAPI CoRegisterMessageFilter16(
249 LPMESSAGEFILTER lpMessageFilter,LPMESSAGEFILTER *lplpMessageFilter
251 fprintf(stderr,"CoRegisterMessageFilter(%p,%p),stub!\n",
252 lpMessageFilter,lplpMessageFilter
257 /***********************************************************************
258 * CoCreateInstance [COMPOBJ.13, OLE32.7]
260 HRESULT WINAPI CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter,
261 DWORD dwClsContext, REFIID riid, LPVOID *ppv)
263 fprintf(stderr, "CoCreateInstance(): stub !\n");
268 /***********************************************************************
269 * CoFreeUnusedLibraries [COMPOBJ.17]
271 void WINAPI CoFreeUnusedLibraries()
273 fprintf(stderr, "CoFreeUnusedLibraries(): stub !\n");
276 /***********************************************************************
277 * CoFileTimeNow [COMPOBJ.82, OLE32.10]
279 * stores the current system time in lpFileTime
281 HRESULT WINAPI CoFileTimeNow(FILETIME *lpFileTime)
283 DOSFS_UnixTimeToFileTime(time(NULL), lpFileTime, 0);