- Timestamp:
- Nov 12, 2002, 6:07:48 PM (23 years ago)
- Location:
- trunk/src
- Files:
-
- 2 added
- 1 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/compobj.c
r8620 r9400 46 46 #include "wine/obj_storage.h" 47 47 #include "wine/obj_channel.h" 48 #include "wine/winbase16.h"49 48 #include "compobj_private.h" 50 #include "ifs.h"51 49 52 50 #include "wine/debug.h" 53 51 54 52 WINE_DEFAULT_DEBUG_CHANNEL(ole); 55 56 /****************************************************************************57 * COM External Lock structures and methods declaration58 *59 * This api provides a linked list to managed external references to60 * COM objects.61 *62 * The public interface consists of three calls:63 * COM_ExternalLockAddRef64 * COM_ExternalLockRelease65 * COM_ExternalLockFreeList66 */67 68 #define EL_END_OF_LIST 069 #define EL_NOT_FOUND 070 71 /*72 * Declaration of the static structure that manage the73 * external lock to COM objects.74 */75 typedef struct COM_ExternalLock COM_ExternalLock;76 typedef struct COM_ExternalLockList COM_ExternalLockList;77 78 struct COM_ExternalLock79 {80 IUnknown *pUnk; /* IUnknown referenced */81 ULONG uRefCount; /* external lock counter to IUnknown object*/82 COM_ExternalLock *next; /* Pointer to next element in list */83 };84 85 struct COM_ExternalLockList86 {87 COM_ExternalLock *head; /* head of list */88 };89 90 /*91 * Declaration and initialization of the static structure that manages92 * the external lock to COM objects.93 */94 static COM_ExternalLockList elList = { EL_END_OF_LIST };95 96 /*97 * Public Interface to the external lock list98 */99 static void COM_ExternalLockFreeList();100 static void COM_ExternalLockAddRef(IUnknown *pUnk);101 static void COM_ExternalLockRelease(IUnknown *pUnk, BOOL bRelAll);102 void COM_ExternalLockDump(); /* testing purposes, not static to avoid warning */103 104 /*105 * Private methods used to managed the linked list106 */107 static BOOL COM_ExternalLockInsert(108 IUnknown *pUnk);109 110 static void COM_ExternalLockDelete(111 COM_ExternalLock *element);112 113 static COM_ExternalLock* COM_ExternalLockFind(114 IUnknown *pUnk);115 116 static COM_ExternalLock* COM_ExternalLockLocate(117 COM_ExternalLock *element,118 IUnknown *pUnk);119 53 120 54 /**************************************************************************** … … 123 57 * TODO: Most of these things will have to be made thread-safe. 124 58 */ 125 HINSTANCE16 COMPOBJ_hInstance = 0;126 59 HINSTANCE COMPOBJ_hInstance32 = 0; 127 static int COMPOBJ_Attach = 0; 128 129 LPMALLOC16 currentMalloc16=NULL; 130 LPMALLOC currentMalloc32=NULL; 131 132 HTASK16 hETask = 0; 133 WORD Table_ETask[62]; 60 61 static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, DWORD dwClsContext, LPUNKNOWN* ppUnk); 62 static void COM_RevokeAllClasses(); 63 static void COM_ExternalLockFreeList(); 64 65 /***************************************************************************** 66 * Appartment management stuff 67 * 68 * NOTE: 69 * per Thread values are stored in the TEB on offset 0xF80 70 * 71 * see www.microsoft.com/msj/1099/bugslayer/bugslayer1099.htm 72 * 73 */ 74 75 typedef struct { 76 unsigned char threadingModell; /* we use the COINIT flags */ 77 unsigned long threadID; 78 long AppartmentLockCount; 79 } OleAppartmentData; 80 81 typedef struct { 82 OleAppartmentData *AppartmentData; 83 } OleThreadData; 84 85 /* not jet used 86 static CRITICAL_SECTION csAppartmentData = CRITICAL_SECTION_INIT("csAppartmentData"); 87 */ 88 /* 89 * the first STA created in a process is the main STA 90 */ 91 92 /* not jet used 93 static OleAppartmentData * mainSTA; 94 */ 95 96 /* 97 * a Process can only have one MTA 98 */ 99 100 /* not jet used 101 static OleAppartmentData * processMTA; 102 */ 103 134 104 135 105 /* … … 159 129 } RegisteredClass; 160 130 161 static CRITICAL_SECTION csRegisteredClassList ;131 static CRITICAL_SECTION csRegisteredClassList = CRITICAL_SECTION_INIT("csRegisteredClassList"); 162 132 static RegisteredClass* firstRegisteredClass = NULL; 163 133 164 /* this open DLL table belongs in a per process table, but my guess is that 165 * it shouldn't live in the kernel, so I'll put them out here in DLL 166 * space assuming that there is one OLE32 per process. 167 */ 134 /***************************************************************************** 135 * This section contains OpenDllList definitions 136 * 137 * The OpenDllList contains only handles of dll loaded by CoGetClassObject or 138 * other functions what do LoadLibrary _without_ giving back a HMODULE. 139 * Without this list these handles would be freed never. 140 * 141 * FIXME: a DLL what says OK whenn asked for unloading is unloaded in the 142 * next unload-call but not before 600 sec. 143 */ 144 168 145 typedef struct tagOpenDll { 169 146 HINSTANCE hLibrary; … … 171 148 } OpenDll; 172 149 173 static CRITICAL_SECTION csOpenDllList ;150 static CRITICAL_SECTION csOpenDllList = CRITICAL_SECTION_INIT("csOpenDllList"); 174 151 static OpenDll *openDllList = NULL; /* linked list of open dlls */ 175 152 176 /***************************************************************************** 177 * This section contains prototypes to internal methods for this 178 * module 179 */ 180 static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, 181 DWORD dwClsContext, 182 LPUNKNOWN* ppUnk); 183 184 static void COM_RevokeAllClasses(); 153 static void COMPOBJ_DLLList_Add(HANDLE hLibrary); 154 static void COMPOBJ_DllList_FreeUnused(int Timeout); 185 155 186 156 … … 190 160 void COMPOBJ_InitProcess( void ) 191 161 { 192 InitializeCriticalSection( &csRegisteredClassList );193 InitializeCriticalSection( &csOpenDllList );194 162 } 195 163 196 164 void COMPOBJ_UninitProcess( void ) 197 165 { 198 DeleteCriticalSection( &csRegisteredClassList ); 199 DeleteCriticalSection( &csOpenDllList ); 166 } 167 168 /***************************************************************************** 169 * This section contains OpenDllList implemantation 170 */ 171 172 static void COMPOBJ_DLLList_Add(HANDLE hLibrary) 173 { 174 OpenDll *ptr; 175 OpenDll *tmp; 176 177 TRACE("\n"); 178 179 EnterCriticalSection( &csOpenDllList ); 180 181 if (openDllList == NULL) { 182 /* empty list -- add first node */ 183 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 184 openDllList->hLibrary=hLibrary; 185 openDllList->next = NULL; 186 } else { 187 /* search for this dll */ 188 int found = FALSE; 189 for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) { 190 if (ptr->hLibrary == hLibrary) { 191 found = TRUE; 192 break; 193 } 194 } 195 if (!found) { 196 /* dll not found, add it */ 197 tmp = openDllList; 198 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 199 openDllList->hLibrary = hLibrary; 200 openDllList->next = tmp; 201 } 202 } 203 204 LeaveCriticalSection( &csOpenDllList ); 205 } 206 207 static void COMPOBJ_DllList_FreeUnused(int Timeout) 208 { 209 OpenDll *curr, *next, *prev = NULL; 210 typedef HRESULT(*DllCanUnloadNowFunc)(void); 211 DllCanUnloadNowFunc DllCanUnloadNow; 212 213 TRACE("\n"); 214 215 EnterCriticalSection( &csOpenDllList ); 216 217 for (curr = openDllList; curr != NULL; ) { 218 DllCanUnloadNow = (DllCanUnloadNowFunc) GetProcAddress(curr->hLibrary, "DllCanUnloadNow"); 219 220 if ( (DllCanUnloadNow != NULL) && (DllCanUnloadNow() == S_OK) ) { 221 next = curr->next; 222 223 TRACE("freeing 0x%08x\n", curr->hLibrary); 224 FreeLibrary(curr->hLibrary); 225 226 HeapFree(GetProcessHeap(), 0, curr); 227 if (curr == openDllList) { 228 openDllList = next; 229 } else { 230 prev->next = next; 231 } 232 233 curr = next; 234 } else { 235 prev = curr; 236 curr = curr->next; 237 } 238 } 239 240 LeaveCriticalSection( &csOpenDllList ); 200 241 } 201 242 … … 211 252 TRACE("Returning version %d, build %d.\n", rmm, rup); 212 253 return (rmm<<16)+rup; 213 }214 215 /******************************************************************************216 * CoInitialize [COMPOBJ.2]217 * Set the win16 IMalloc used for memory management218 */219 HRESULT WINAPI CoInitialize16(220 LPVOID lpReserved /* [in] pointer to win16 malloc interface */221 ) {222 currentMalloc16 = (LPMALLOC16)lpReserved;223 return S_OK;224 254 } 225 255 … … 306 336 307 337 return hr; 308 }309 310 /***********************************************************************311 * CoUninitialize [COMPOBJ.3]312 * Don't know what it does.313 * 3-Nov-98 -- this was originally misspelled, I changed it to what I314 * believe is the correct spelling315 */316 void WINAPI CoUninitialize16(void)317 {318 TRACE("()\n");319 CoFreeAllLibraries();320 338 } 321 339 … … 368 386 } 369 387 370 #ifndef __WIN32OS2__371 /***********************************************************************372 * CoGetMalloc [COMPOBJ.4]373 * RETURNS374 * The current win16 IMalloc375 */376 HRESULT WINAPI CoGetMalloc16(377 DWORD dwMemContext, /* [in] unknown */378 LPMALLOC16 * lpMalloc /* [out] current win16 malloc interface */379 ) {380 if(!currentMalloc16)381 currentMalloc16 = IMalloc16_Constructor();382 *lpMalloc = currentMalloc16;383 return S_OK;384 }385 #endif386 /******************************************************************************387 * CoGetMalloc [OLE32.20]388 *389 * RETURNS390 * The current win32 IMalloc391 */392 HRESULT WINAPI CoGetMalloc(393 DWORD dwMemContext, /* [in] unknown */394 LPMALLOC *lpMalloc /* [out] current win32 malloc interface */395 ) {396 if(!currentMalloc32)397 currentMalloc32 = IMalloc_Constructor();398 *lpMalloc = currentMalloc32;399 return S_OK;400 }401 #ifndef __WIN32OS2__402 /***********************************************************************403 * CoCreateStandardMalloc [COMPOBJ.71]404 */405 HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,406 LPMALLOC16 *lpMalloc)407 {408 /* FIXME: docu says we shouldn't return the same allocator as in409 * CoGetMalloc16 */410 *lpMalloc = IMalloc16_Constructor();411 return S_OK;412 }413 #endif414 388 /****************************************************************************** 415 389 * CoDisconnectObject [COMPOBJ.15] … … 420 394 TRACE("(%p, %lx)\n",lpUnk,reserved); 421 395 return S_OK; 422 }423 424 /***********************************************************************425 * IsEqualGUID [COMPOBJ.18]426 *427 * Compares two Unique Identifiers.428 *429 * RETURNS430 * TRUE if equal431 */432 BOOL16 WINAPI IsEqualGUID16(433 GUID* g1, /* [in] unique id 1 */434 GUID* g2 /* [in] unique id 2 */435 ) {436 return !memcmp( g1, g2, sizeof(GUID) );437 }438 439 /******************************************************************************440 * CLSIDFromString [COMPOBJ.20]441 * Converts a unique identifier from its string representation into442 * the GUID struct.443 *444 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]445 *446 * RETURNS447 * the converted GUID448 */449 HRESULT WINAPI CLSIDFromString16(450 LPCOLESTR16 idstr, /* [in] string representation of guid */451 CLSID *id /* [out] GUID converted from string */452 ) {453 BYTE *s = (BYTE *) idstr;454 BYTE *p;455 int i;456 BYTE table[256];457 458 if (!s)459 s = "{00000000-0000-0000-0000-000000000000}";460 else { /* validate the CLSID string */461 462 if (strlen(s) != 38)463 return CO_E_CLASSSTRING;464 465 if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))466 return CO_E_CLASSSTRING;467 468 for (i=1; i<37; i++)469 {470 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;471 if (!(((s[i] >= '0') && (s[i] <= '9')) ||472 ((s[i] >= 'a') && (s[i] <= 'f')) ||473 ((s[i] >= 'A') && (s[i] <= 'F')))474 )475 return CO_E_CLASSSTRING;476 }477 }478 479 TRACE("%s -> %p\n", s, id);480 481 /* quick lookup table */482 memset(table, 0, 256);483 484 for (i = 0; i < 10; i++) {485 table['0' + i] = i;486 }487 for (i = 0; i < 6; i++) {488 table['A' + i] = i+10;489 table['a' + i] = i+10;490 }491 492 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */493 494 p = (BYTE *) id;495 496 s++; /* skip leading brace */497 for (i = 0; i < 4; i++) {498 p[3 - i] = table[*s]<<4 | table[*(s+1)];499 s += 2;500 }501 p += 4;502 s++; /* skip - */503 504 for (i = 0; i < 2; i++) {505 p[1-i] = table[*s]<<4 | table[*(s+1)];506 s += 2;507 }508 p += 2;509 s++; /* skip - */510 511 for (i = 0; i < 2; i++) {512 p[1-i] = table[*s]<<4 | table[*(s+1)];513 s += 2;514 }515 p += 2;516 s++; /* skip - */517 518 /* these are just sequential bytes */519 for (i = 0; i < 2; i++) {520 *p++ = table[*s]<<4 | table[*(s+1)];521 s += 2;522 }523 s++; /* skip - */524 525 for (i = 0; i < 6; i++) {526 *p++ = table[*s]<<4 | table[*(s+1)];527 s += 2;528 }529 530 return S_OK;531 396 } 532 397 … … 553 418 * the converted GUID 554 419 */ 420 HRESULT WINAPI __CLSIDFromStringA( 421 LPCSTR idstr, /* [in] string representation of guid */ 422 CLSID *id) /* [out] GUID converted from string */ 423 { 424 BYTE *s = (BYTE *) idstr; 425 int i; 426 BYTE table[256]; 427 428 if (!s) 429 s = "{00000000-0000-0000-0000-000000000000}"; 430 else { /* validate the CLSID string */ 431 432 if (strlen(s) != 38) 433 return CO_E_CLASSSTRING; 434 435 if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}')) 436 return CO_E_CLASSSTRING; 437 438 for (i=1; i<37; i++) { 439 if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue; 440 if (!(((s[i] >= '0') && (s[i] <= '9')) || 441 ((s[i] >= 'a') && (s[i] <= 'f')) || 442 ((s[i] >= 'A') && (s[i] <= 'F')))) 443 return CO_E_CLASSSTRING; 444 } 445 } 446 447 TRACE("%s -> %p\n", s, id); 448 449 /* quick lookup table */ 450 memset(table, 0, 256); 451 452 for (i = 0; i < 10; i++) { 453 table['0' + i] = i; 454 } 455 for (i = 0; i < 6; i++) { 456 table['A' + i] = i+10; 457 table['a' + i] = i+10; 458 } 459 460 /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */ 461 462 id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 | 463 table[s[5]] << 12 | table[s[6]] << 8 | table[s[7]] << 4 | table[s[8]]); 464 id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]]; 465 id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]]; 466 467 /* these are just sequential bytes */ 468 id->Data4[0] = table[s[20]] << 4 | table[s[21]]; 469 id->Data4[1] = table[s[22]] << 4 | table[s[23]]; 470 id->Data4[2] = table[s[25]] << 4 | table[s[26]]; 471 id->Data4[3] = table[s[27]] << 4 | table[s[28]]; 472 id->Data4[4] = table[s[29]] << 4 | table[s[30]]; 473 id->Data4[5] = table[s[31]] << 4 | table[s[32]]; 474 id->Data4[6] = table[s[33]] << 4 | table[s[34]]; 475 id->Data4[7] = table[s[35]] << 4 | table[s[36]]; 476 477 return S_OK; 478 } 479 480 /*****************************************************************************/ 481 555 482 HRESULT WINAPI CLSIDFromString( 556 483 LPCOLESTR idstr, /* [in] string representation of GUID */ … … 562 489 if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL )) 563 490 return CO_E_CLASSSTRING; 564 ret = CLSIDFromString16(xid,id); 491 492 493 ret = __CLSIDFromStringA(xid,id); 565 494 if(ret != S_OK) { /* It appears a ProgID is also valid */ 566 495 ret = CLSIDFromProgID(idstr, id); … … 610 539 return S_OK; 611 540 } 612 #ifndef __WIN32OS2__ 613 /****************************************************************************** 614 * StringFromCLSID [COMPOBJ.19] 615 * Converts a GUID into the respective string representation. 616 * The target string is allocated using the OLE IMalloc. 617 * RETURNS 618 * the string representation and HRESULT 619 */ 620 HRESULT WINAPI StringFromCLSID16( 621 REFCLSID id, /* [in] the GUID to be converted */ 622 LPOLESTR16 *idstr /* [out] a pointer to a to-be-allocated segmented pointer pointing to the resulting string */ 623 624 ) { 625 extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags, 626 DWORD cbArgs, LPVOID pArgs, LPDWORD pdwRetCode ); 627 LPMALLOC16 mllc; 628 HRESULT ret; 629 DWORD args[2]; 630 631 ret = CoGetMalloc16(0,&mllc); 632 if (ret) return ret; 633 634 args[0] = (DWORD)mllc; 635 args[1] = 40; 636 637 /* No need for a Callback entry, we have WOWCallback16Ex which does 638 * everything we need. 639 */ 640 if (!K32WOWCallback16Ex( 641 (DWORD)((ICOM_VTABLE(IMalloc16)*)MapSL( 642 (SEGPTR)ICOM_VTBL(((LPMALLOC16)MapSL((SEGPTR)mllc)))) 643 )->Alloc, 644 WCB16_CDECL, 645 2*sizeof(DWORD), 646 (LPVOID)args, 647 (LPDWORD)idstr 648 )) { 649 WARN("CallTo16 IMalloc16 failed\n"); 650 return E_FAIL; 651 } 652 return WINE_StringFromCLSID(id,MapSL((SEGPTR)*idstr)); 653 } 654 #endif 541 542 655 543 /****************************************************************************** 656 544 * StringFromCLSID [OLE32.151] … … 755 643 756 644 /****************************************************************************** 757 * CLSIDFromProgID [COMPOBJ.61]758 * Converts a program id into the respective GUID. (By using a registry lookup)759 * RETURNS760 * riid associated with the progid761 */762 HRESULT WINAPI CLSIDFromProgID16(763 LPCOLESTR16 progid, /* [in] program id as found in registry */764 LPCLSID riid /* [out] associated CLSID */765 ) {766 char *buf,buf2[80];767 DWORD buf2len;768 HRESULT err;769 HKEY xhkey;770 771 buf = HeapAlloc(GetProcessHeap(),0,strlen(progid)+8);772 sprintf(buf,"%s\\CLSID",progid);773 if ((err=RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&xhkey))) {774 HeapFree(GetProcessHeap(),0,buf);775 return CO_E_CLASSSTRING;776 }777 HeapFree(GetProcessHeap(),0,buf);778 buf2len = sizeof(buf2);779 if ((err=RegQueryValueA(xhkey,NULL,buf2,&buf2len))) {780 RegCloseKey(xhkey);781 return CO_E_CLASSSTRING;782 }783 RegCloseKey(xhkey);784 return CLSIDFromString16(buf2,riid);785 }786 787 /******************************************************************************788 645 * CLSIDFromProgID [OLE32.2] 789 646 * Converts a program id into the respective GUID. (By using a registry lookup) … … 816 673 } 817 674 RegCloseKey(xhkey); 818 return CLSIDFromString16(buf2,riid);675 return __CLSIDFromStringA(buf2,riid); 819 676 } 820 677 … … 877 734 /* We have the CLSid we want back from the registry as a string, so 878 735 lets convert it into a CLSID structure */ 879 if ( (CLSIDFromString16(buf2,pclsid)) != NOERROR) 880 { 736 if ( (__CLSIDFromStringA(buf2,pclsid)) != NOERROR) { 881 737 return E_INVALIDARG; 882 738 } … … 928 784 return S_OK; 929 785 } 930 #ifndef __WIN32OS2__ 931 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */ 932 /*********************************************************************** 933 * LookupETask (COMPOBJ.94) 934 */ 935 HRESULT WINAPI LookupETask16(HTASK16 *hTask,LPVOID p) { 936 FIXME("(%p,%p),stub!\n",hTask,p); 937 if ((*hTask = GetCurrentTask()) == hETask) { 938 memcpy(p, Table_ETask, sizeof(Table_ETask)); 939 } 940 return 0; 941 } 942 943 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */ 944 /*********************************************************************** 945 * SetETask (COMPOBJ.95) 946 */ 947 HRESULT WINAPI SetETask16(HTASK16 hTask, LPVOID p) { 948 FIXME("(%04x,%p),stub!\n",hTask,p); 949 hETask = hTask; 950 return 0; 951 } 952 953 /* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */ 954 /*********************************************************************** 955 * CALLOBJECTINWOW (COMPOBJ.201) 956 */ 957 HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) { 958 FIXME("(%p,%p),stub!\n",p1,p2); 959 return 0; 960 } 961 962 /****************************************************************************** 963 * CoRegisterClassObject [COMPOBJ.5] 964 * 965 * Don't know where it registers it ... 966 */ 967 HRESULT WINAPI CoRegisterClassObject16( 968 REFCLSID rclsid, 969 LPUNKNOWN pUnk, 970 DWORD dwClsContext, /* [in] CLSCTX flags indicating the context in which to run the executable */ 971 DWORD flags, /* [in] REGCLS flags indicating how connections are made */ 972 LPDWORD lpdwRegister 973 ) { 974 char buf[80]; 975 976 WINE_StringFromCLSID(rclsid,buf); 977 978 FIXME("(%s,%p,0x%08lx,0x%08lx,%p),stub\n", 979 buf,pUnk,dwClsContext,flags,lpdwRegister 980 ); 981 return 0; 982 } 983 984 985 /****************************************************************************** 986 * CoRevokeClassObject [COMPOBJ.6] 987 * 988 */ 989 HRESULT WINAPI CoRevokeClassObject16(DWORD dwRegister) /* [in] token on class obj */ 990 { 991 FIXME("(0x%08lx),stub!\n", dwRegister); 992 return 0; 993 } 994 995 /****************************************************************************** 996 * CoFileTimeToDosDateTime [COMPOBJ.30] 997 */ 998 BOOL16 WINAPI CoFileTimeToDosDateTime16(const FILETIME *ft, LPWORD lpDosDate, LPWORD lpDosTime) 999 { 1000 return FileTimeToDosDateTime(ft, lpDosDate, lpDosTime); 1001 } 1002 1003 /****************************************************************************** 1004 * CoDosDateTimeToFileTime [COMPOBJ.31] 1005 */ 1006 BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft) 1007 { 1008 return DosDateTimeToFileTime(wDosDate, wDosTime, ft); 1009 } 1010 #endif 786 787 1011 788 /*** 1012 789 * COM_GetRegisteredClassObject … … 1296 1073 1297 1074 /*********************************************************************** 1075 * compobj_RegReadPath [internal] 1076 * 1077 * Reads a registry value and expands it when nessesary 1078 */ 1079 HRESULT compobj_RegReadPath(char * keyname, char * valuename, char * dst, int dstlen) 1080 { 1081 HRESULT hres; 1082 HKEY key; 1083 DWORD keytype; 1084 char src[MAX_PATH]; 1085 DWORD dwLength = dstlen; 1086 1087 if((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key)) == ERROR_SUCCESS) { 1088 if( (hres = RegQueryValueExA(key, NULL, NULL, &keytype, (LPBYTE)src, &dwLength)) == ERROR_SUCCESS ) { 1089 if (keytype == REG_EXPAND_SZ) { 1090 if (dstlen <= ExpandEnvironmentStringsA(src, dst, dstlen)) hres = ERROR_MORE_DATA; 1091 } else { 1092 strncpy(dst, src, dstlen); 1093 } 1094 } 1095 RegCloseKey (key); 1096 } 1097 return hres; 1098 } 1099 1100 /*********************************************************************** 1298 1101 * CoGetClassObject [COMPOBJ.7] 1299 1102 * CoGetClassObject [OLE32.16] … … 1311 1114 HRESULT hres = E_UNEXPECTED; 1312 1115 char xclsid[80]; 1313 WCHAR ProviderName[MAX_PATH+1];1314 DWORD ProviderNameLen = sizeof(ProviderName);1315 1116 HINSTANCE hLibrary; 1316 1117 #ifdef __WIN32OS2__ 1317 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 1318 REFIID iid, LPVOID *ppv); 1118 typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); 1319 1119 #else 1320 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, 1321 REFIID iid, LPVOID *ppv); 1120 typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv); 1322 1121 #endif 1323 1122 DllGetClassObjectFunc DllGetClassObject; … … 1325 1124 WINE_StringFromCLSID((LPCLSID)rclsid,xclsid); 1326 1125 1327 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", 1328 debugstr_guid(rclsid), 1329 debugstr_guid(iid) 1330 ); 1126 TRACE("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid)); 1331 1127 1332 1128 if (pServerInfo) { … … 1356 1152 } 1357 1153 1358 if ((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext) { 1359 HKEY key; 1360 char buf[200]; 1361 1362 memset(ProviderName,0,sizeof(ProviderName)); 1363 sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid); 1364 if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) || 1365 ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)), 1366 RegCloseKey (key), 1367 hres != ERROR_SUCCESS)) 1368 { 1154 /* first try: in-process */ 1155 if ((CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER) & dwClsContext) { 1156 char keyname[MAX_PATH]; 1157 char dllpath[MAX_PATH+1]; 1158 1159 sprintf(keyname,"CLSID\\%s\\InprocServer32",xclsid); 1160 1161 if ( compobj_RegReadPath(keyname, NULL, dllpath, sizeof(dllpath)) != ERROR_SUCCESS) { 1162 /* failure: CLSID is not found in registry */ 1163 WARN("class %s not registred\n", xclsid); 1369 1164 hres = REGDB_E_CLASSNOTREG; 1370 } 1371 /* Don't ask me. MSDN says that CoGetClassObject does NOT call CoLoadLibrary */ 1372 else if ((hLibrary = CoLoadLibrary(ProviderName, TRUE)) == 0) 1373 { 1374 FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(ProviderName)); 1375 hres = E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */ 1165 } else { 1166 if ((hLibrary = LoadLibraryExA(dllpath, 0, LOAD_WITH_ALTERED_SEARCH_PATH)) == 0) { 1167 /* failure: DLL could not be loaded */ 1168 ERR("couldn't load InprocServer32 dll %s\n", dllpath); 1169 hres = E_ACCESSDENIED; /* FIXME: or should this be CO_E_DLLNOTFOUND? */ 1170 } else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) { 1171 /* failure: the dll did not export DllGetClassObject */ 1172 ERR("couldn't find function DllGetClassObject in %s\n", dllpath); 1173 FreeLibrary( hLibrary ); 1174 hres = CO_E_DLLNOTFOUND; 1175 } else { 1176 /* OK: get the ClassObject */ 1177 COMPOBJ_DLLList_Add( hLibrary ); 1178 return DllGetClassObject(rclsid, iid, ppv); 1179 } 1376 1180 } 1377 else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject"))) 1378 { 1379 /* not sure if this should be called here CoFreeLibrary(hLibrary);*/ 1380 FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(ProviderName)); 1381 hres = E_ACCESSDENIED; 1382 } 1383 else 1384 { 1385 /* Ask the DLL for its class object. (there was a note here about 1386 * class factories but this is good. 1387 */ 1388 return DllGetClassObject(rclsid, iid, ppv); 1389 } 1390 } 1391 1181 } 1392 1182 1393 1183 /* Next try out of process */ … … 1426 1216 IStorage *pstg=0; 1427 1217 HRESULT res; 1428 int nbElm =0,length=0,i=0;1429 LONG sizeProgId =20;1218 int nbElm, length, i; 1219 LONG sizeProgId; 1430 1220 LPOLESTR *pathDec=0,absFile=0,progId=0; 1431 WCHAR extention[100]={0}; 1432 1433 TRACE("()\n"); 1221 LPWSTR extension; 1222 static const WCHAR bkslashW[] = {'\\',0}; 1223 static const WCHAR dotW[] = {'.',0}; 1224 1225 TRACE("%s, %p\n", debugstr_w(filePathName), pclsid); 1434 1226 1435 1227 /* if the file contain a storage object the return the CLSID writen by IStorage_SetClass method*/ … … 1475 1267 1476 1268 /* failed if the path represente a directory and not an absolute file name*/ 1477 if ( lstrcmpW(absFile,(LPOLESTR)"\\"))1269 if (!lstrcmpW(absFile, bkslashW)) 1478 1270 return MK_E_INVALIDEXTENSION; 1479 1271 1480 1272 /* get the extension of the file */ 1273 extension = NULL; 1481 1274 length=lstrlenW(absFile); 1482 for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--); 1275 for(i = length-1; (i >= 0) && *(extension = &absFile[i]) != '.'; i--) 1276 /* nothing */; 1277 1278 if (!extension || !lstrcmpW(extension, dotW)) 1279 return MK_E_INVALIDEXTENSION; 1280 1281 res=RegQueryValueW(HKEY_CLASSES_ROOT, extension, NULL, &sizeProgId); 1483 1282 1484 1283 /* get the progId associated to the extension */ 1485 progId=CoTaskMemAlloc(sizeProgId); 1486 1487 res=RegQueryValueW(HKEY_CLASSES_ROOT,extention,progId,&sizeProgId); 1488 1489 if (res==ERROR_MORE_DATA){ 1490 1491 progId = CoTaskMemRealloc(progId,sizeProgId); 1492 res=RegQueryValueW(HKEY_CLASSES_ROOT,extention,progId,&sizeProgId); 1493 } 1284 progId = CoTaskMemAlloc(sizeProgId); 1285 res = RegQueryValueW(HKEY_CLASSES_ROOT, extension, progId, &sizeProgId); 1286 1494 1287 if (res==ERROR_SUCCESS) 1495 1288 /* return the clsid associated to the progId */ … … 1507 1300 return MK_E_INVALIDEXTENSION; 1508 1301 } 1509 /******************************************************************************1510 * CoRegisterMessageFilter [COMPOBJ.27]1511 */1512 HRESULT WINAPI CoRegisterMessageFilter16(1513 LPMESSAGEFILTER lpMessageFilter,1514 LPMESSAGEFILTER *lplpMessageFilter1515 ) {1516 FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);1517 return 0;1518 }1519 1520 1302 /*********************************************************************** 1521 1303 * CoCreateInstance [COMPOBJ.13] … … 1644 1426 1645 1427 /*********************************************************************** 1428 * CoLoadLibrary (OLE32.30) 1429 */ 1430 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree) 1431 { 1432 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1433 1434 return LoadLibraryExW(lpszLibName, 0, LOAD_WITH_ALTERED_SEARCH_PATH); 1435 } 1436 1437 /*********************************************************************** 1646 1438 * CoFreeLibrary [OLE32.13] 1439 * 1440 * NOTES: don't belive the docu 1647 1441 */ 1648 1442 void WINAPI CoFreeLibrary(HINSTANCE hLibrary) 1649 1443 { 1650 OpenDll *ptr, *prev; 1651 OpenDll *tmp; 1652 1653 EnterCriticalSection( &csOpenDllList ); 1654 1655 /* lookup library in linked list */ 1656 prev = NULL; 1657 for (ptr = openDllList; ptr != NULL; ptr=ptr->next) { 1658 if (ptr->hLibrary == hLibrary) { 1659 break; 1660 } 1661 prev = ptr; 1662 } 1663 1664 if (ptr == NULL) { 1665 /* shouldn't happen if user passed in a valid hLibrary */ 1666 goto end; 1667 } 1668 /* assert: ptr points to the library entry to free */ 1669 1670 /* free library and remove node from list */ 1671 FreeLibrary(hLibrary); 1672 if (ptr == openDllList) { 1673 tmp = openDllList->next; 1674 HeapFree(GetProcessHeap(), 0, openDllList); 1675 openDllList = tmp; 1676 } else { 1677 tmp = ptr->next; 1678 HeapFree(GetProcessHeap(), 0, ptr); 1679 prev->next = tmp; 1680 } 1681 end: 1682 LeaveCriticalSection( &csOpenDllList ); 1444 FreeLibrary(hLibrary); 1683 1445 } 1684 1446 … … 1686 1448 /*********************************************************************** 1687 1449 * CoFreeAllLibraries [OLE32.12] 1450 * 1451 * NOTES: don't belive the docu 1688 1452 */ 1689 1453 void WINAPI CoFreeAllLibraries(void) 1690 1454 { 1691 OpenDll *ptr, *tmp; 1692 1693 EnterCriticalSection( &csOpenDllList ); 1694 1695 for (ptr = openDllList; ptr != NULL; ) { 1696 tmp=ptr->next; 1697 CoFreeLibrary(ptr->hLibrary); 1698 ptr = tmp; 1699 } 1700 1701 LeaveCriticalSection( &csOpenDllList ); 1702 } 1703 1455 /* NOP */ 1456 } 1704 1457 1705 1458 … … 1707 1460 * CoFreeUnusedLibraries [COMPOBJ.17] 1708 1461 * CoFreeUnusedLibraries [OLE32.14] 1462 * 1463 * FIXME: Calls to CoFreeUnusedLibraries from any thread always route 1464 * through the main apartment's thread to call DllCanUnloadNow 1709 1465 */ 1710 1466 void WINAPI CoFreeUnusedLibraries(void) 1711 1467 { 1712 OpenDll *ptr, *tmp; 1713 typedef HRESULT(*DllCanUnloadNowFunc)(void); 1714 DllCanUnloadNowFunc DllCanUnloadNow; 1715 1716 EnterCriticalSection( &csOpenDllList ); 1717 1718 for (ptr = openDllList; ptr != NULL; ) { 1719 DllCanUnloadNow = (DllCanUnloadNowFunc) 1720 GetProcAddress(ptr->hLibrary, "DllCanUnloadNow"); 1721 1722 if ( (DllCanUnloadNow != NULL) && 1723 (DllCanUnloadNow() == S_OK) ) { 1724 tmp=ptr->next; 1725 CoFreeLibrary(ptr->hLibrary); 1726 ptr = tmp; 1727 } else { 1728 ptr=ptr->next; 1729 } 1730 } 1731 1732 LeaveCriticalSection( &csOpenDllList ); 1468 COMPOBJ_DllList_FreeUnused(0); 1733 1469 } 1734 1470 … … 1747 1483 1748 1484 /*********************************************************************** 1749 * CoTaskMemAlloc (OLE32.43)1750 * RETURNS1751 * pointer to newly allocated block1752 */1753 LPVOID WINAPI CoTaskMemAlloc(1754 ULONG size /* [in] size of memoryblock to be allocated */1755 ) {1756 LPMALLOC lpmalloc;1757 HRESULT ret = CoGetMalloc(0,&lpmalloc);1758 1759 if (FAILED(ret))1760 return NULL;1761 1762 return IMalloc_Alloc(lpmalloc,size);1763 }1764 /***********************************************************************1765 * CoTaskMemFree (OLE32.44)1766 */1767 VOID WINAPI CoTaskMemFree(1768 LPVOID ptr /* [in] pointer to be freed */1769 ) {1770 LPMALLOC lpmalloc;1771 HRESULT ret = CoGetMalloc(0,&lpmalloc);1772 1773 if (FAILED(ret))1774 return;1775 1776 IMalloc_Free(lpmalloc, ptr);1777 }1778 1779 /***********************************************************************1780 * CoTaskMemRealloc (OLE32.45)1781 * RETURNS1782 * pointer to newly allocated block1783 */1784 LPVOID WINAPI CoTaskMemRealloc(1785 LPVOID pvOld,1786 ULONG size) /* [in] size of memoryblock to be allocated */1787 {1788 LPMALLOC lpmalloc;1789 HRESULT ret = CoGetMalloc(0,&lpmalloc);1790 1791 if (FAILED(ret))1792 return NULL;1793 1794 return IMalloc_Realloc(lpmalloc, pvOld, size);1795 }1796 1797 /***********************************************************************1798 1485 * CoLoadLibrary (OLE32.30) 1799 1486 */ 1800 HINSTANCE WINAPI CoLoadLibrary(LPOLESTR lpszLibName, BOOL bAutoFree) 1801 { 1802 HINSTANCE hLibrary; 1803 OpenDll *ptr; 1804 OpenDll *tmp; 1805 1806 TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree); 1807 1808 hLibrary = LoadLibraryExW(lpszLibName, 0, LOAD_WITH_ALTERED_SEARCH_PATH); 1809 1810 if (!bAutoFree) 1811 return hLibrary; 1812 1813 EnterCriticalSection( &csOpenDllList ); 1814 1815 if (openDllList == NULL) { 1816 /* empty list -- add first node */ 1817 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1818 openDllList->hLibrary=hLibrary; 1819 openDllList->next = NULL; 1487 static void COM_RevokeAllClasses() 1488 { 1489 EnterCriticalSection( &csRegisteredClassList ); 1490 1491 while (firstRegisteredClass!=0) 1492 { 1493 CoRevokeClassObject(firstRegisteredClass->dwCookie); 1494 } 1495 1496 LeaveCriticalSection( &csRegisteredClassList ); 1497 } 1498 1499 /**************************************************************************** 1500 * COM External Lock methods implementation 1501 * 1502 * This api provides a linked list to managed external references to 1503 * COM objects. 1504 * 1505 * The public interface consists of three calls: 1506 * COM_ExternalLockAddRef 1507 * COM_ExternalLockRelease 1508 * COM_ExternalLockFreeList 1509 */ 1510 1511 #define EL_END_OF_LIST 0 1512 #define EL_NOT_FOUND 0 1513 1514 /* 1515 * Declaration of the static structure that manage the 1516 * external lock to COM objects. 1517 */ 1518 typedef struct COM_ExternalLock COM_ExternalLock; 1519 typedef struct COM_ExternalLockList COM_ExternalLockList; 1520 1521 struct COM_ExternalLock 1522 { 1523 IUnknown *pUnk; /* IUnknown referenced */ 1524 ULONG uRefCount; /* external lock counter to IUnknown object*/ 1525 COM_ExternalLock *next; /* Pointer to next element in list */ 1526 }; 1527 1528 struct COM_ExternalLockList 1529 { 1530 COM_ExternalLock *head; /* head of list */ 1531 }; 1532 1533 /* 1534 * Declaration and initialization of the static structure that manages 1535 * the external lock to COM objects. 1536 */ 1537 static COM_ExternalLockList elList = { EL_END_OF_LIST }; 1538 1539 /* 1540 * Private methods used to managed the linked list 1541 */ 1542 1543 1544 static COM_ExternalLock* COM_ExternalLockLocate( 1545 COM_ExternalLock *element, 1546 IUnknown *pUnk); 1547 1548 /**************************************************************************** 1549 * Internal - Insert a new IUnknown* to the linked list 1550 */ 1551 static BOOL COM_ExternalLockInsert( 1552 IUnknown *pUnk) 1553 { 1554 COM_ExternalLock *newLock = NULL; 1555 COM_ExternalLock *previousHead = NULL; 1556 1557 /* 1558 * Allocate space for the new storage object 1559 */ 1560 newLock = HeapAlloc(GetProcessHeap(), 0, sizeof(COM_ExternalLock)); 1561 1562 if (newLock!=NULL) { 1563 if ( elList.head == EL_END_OF_LIST ) { 1564 elList.head = newLock; /* The list is empty */ 1820 1565 } else { 1821 /* search for this dll */ 1822 int found = FALSE; 1823 for (ptr = openDllList; ptr->next != NULL; ptr=ptr->next) { 1824 if (ptr->hLibrary == hLibrary) { 1825 found = TRUE; 1826 break; 1827 } 1828 } 1829 if (!found) { 1830 /* dll not found, add it */ 1831 tmp = openDllList; 1832 openDllList = (OpenDll*)HeapAlloc(GetProcessHeap(),0, sizeof(OpenDll)); 1833 openDllList->hLibrary = hLibrary; 1834 openDllList->next = tmp; 1835 } 1836 } 1837 1838 LeaveCriticalSection( &csOpenDllList ); 1839 1840 return hLibrary; 1841 } 1842 1843 /*********************************************************************** 1844 * CoInitializeWOW (OLE32.27) 1845 */ 1846 HRESULT WINAPI CoInitializeWOW(DWORD x,DWORD y) { 1847 FIXME("(0x%08lx,0x%08lx),stub!\n",x,y); 1848 return 0; 1849 } 1850 1851 /****************************************************************************** 1852 * CoLockObjectExternal [COMPOBJ.63] 1853 */ 1854 HRESULT WINAPI CoLockObjectExternal16( 1855 LPUNKNOWN pUnk, /* [in] object to be locked */ 1856 BOOL16 fLock, /* [in] do lock */ 1857 BOOL16 fLastUnlockReleases /* [in] ? */ 1858 ) { 1859 FIXME("(%p,%d,%d),stub!\n",pUnk,fLock,fLastUnlockReleases); 1860 return S_OK; 1566 /* insert does it at the head */ 1567 previousHead = elList.head; 1568 elList.head = newLock; 1569 } 1570 1571 /* Set new list item data member */ 1572 newLock->pUnk = pUnk; 1573 newLock->uRefCount = 1; 1574 newLock->next = previousHead; 1575 1576 return TRUE; 1577 } 1578 return FALSE; 1579 } 1580 1581 /**************************************************************************** 1582 * Internal - Method that removes an item from the linked list. 1583 */ 1584 static void COM_ExternalLockDelete( 1585 COM_ExternalLock *itemList) 1586 { 1587 COM_ExternalLock *current = elList.head; 1588 1589 if ( current == itemList ) { 1590 /* this section handles the deletion of the first node */ 1591 elList.head = itemList->next; 1592 HeapFree( GetProcessHeap(), 0, itemList); 1593 } else { 1594 do { 1595 if ( current->next == itemList ){ /* We found the item to free */ 1596 current->next = itemList->next; /* readjust the list pointers */ 1597 HeapFree( GetProcessHeap(), 0, itemList); 1598 break; 1599 } 1600 1601 /* Skip to the next item */ 1602 current = current->next; 1603 1604 } while ( current != EL_END_OF_LIST ); 1605 } 1606 } 1607 1608 /**************************************************************************** 1609 * Internal - Recursivity agent for IUnknownExternalLockList_Find 1610 * 1611 * NOTES: how long can the list be ?? (recursive!!!) 1612 */ 1613 static COM_ExternalLock* COM_ExternalLockLocate( COM_ExternalLock *element, IUnknown *pUnk) 1614 { 1615 if ( element == EL_END_OF_LIST ) 1616 return EL_NOT_FOUND; 1617 else if ( element->pUnk == pUnk ) /* We found it */ 1618 return element; 1619 else /* Not the right guy, keep on looking */ 1620 return COM_ExternalLockLocate( element->next, pUnk); 1621 } 1622 1623 /**************************************************************************** 1624 * Public - Method that increments the count for a IUnknown* in the linked 1625 * list. The item is inserted if not already in the list. 1626 */ 1627 static void COM_ExternalLockAddRef(IUnknown *pUnk) 1628 { 1629 COM_ExternalLock *externalLock = COM_ExternalLockLocate(elList.head, pUnk); 1630 1631 /* 1632 * Add an external lock to the object. If it was already externally 1633 * locked, just increase the reference count. If it was not. 1634 * add the item to the list. 1635 */ 1636 if ( externalLock == EL_NOT_FOUND ) 1637 COM_ExternalLockInsert(pUnk); 1638 else 1639 externalLock->uRefCount++; 1640 1641 /* 1642 * Add an internal lock to the object 1643 */ 1644 IUnknown_AddRef(pUnk); 1645 } 1646 1647 /**************************************************************************** 1648 * Public - Method that decrements the count for a IUnknown* in the linked 1649 * list. The item is removed from the list if its count end up at zero or if 1650 * bRelAll is TRUE. 1651 */ 1652 static void COM_ExternalLockRelease( 1653 IUnknown *pUnk, 1654 BOOL bRelAll) 1655 { 1656 COM_ExternalLock *externalLock = COM_ExternalLockLocate(elList.head, pUnk); 1657 1658 if ( externalLock != EL_NOT_FOUND ) { 1659 do { 1660 externalLock->uRefCount--; /* release external locks */ 1661 IUnknown_Release(pUnk); /* release local locks as well */ 1662 1663 if ( bRelAll == FALSE ) break; /* perform single release */ 1664 1665 } while ( externalLock->uRefCount > 0 ); 1666 1667 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ 1668 COM_ExternalLockDelete(externalLock); 1669 } 1670 } 1671 /**************************************************************************** 1672 * Public - Method that frees the content of the list. 1673 */ 1674 static void COM_ExternalLockFreeList() 1675 { 1676 COM_ExternalLock *head; 1677 1678 head = elList.head; /* grab it by the head */ 1679 while ( head != EL_END_OF_LIST ) { 1680 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 1681 head = elList.head; /* get the new head... */ 1682 } 1683 } 1684 1685 /**************************************************************************** 1686 * Public - Method that dump the content of the list. 1687 */ 1688 void COM_ExternalLockDump() 1689 { 1690 COM_ExternalLock *current = elList.head; 1691 1692 DPRINTF("\nExternal lock list contains:\n"); 1693 1694 while ( current != EL_END_OF_LIST ) { 1695 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 1696 1697 /* Skip to the next item */ 1698 current = current->next; 1699 } 1861 1700 } 1862 1701 … … 1870 1709 { 1871 1710 1872 if (fLock) 1873 { 1874 /* 1875 * Increment the external lock coutner, COM_ExternalLockAddRef also 1876 * increment the object's internal lock counter. 1877 */ 1878 COM_ExternalLockAddRef( pUnk); 1879 } 1880 else 1881 { 1882 /* 1883 * Decrement the external lock coutner, COM_ExternalLockRelease also 1884 * decrement the object's internal lock counter. 1885 */ 1886 COM_ExternalLockRelease( pUnk, fLastUnlockReleases); 1887 } 1888 1889 return S_OK; 1890 } 1891 1892 /*********************************************************************** 1893 * CoGetState [COMPOBJ.115] 1894 */ 1895 HRESULT WINAPI CoGetState16(LPDWORD state) 1896 { 1897 FIXME("(%p),stub!\n", state); 1898 *state = 0; 1899 return S_OK; 1900 } 1711 if (fLock) { 1712 /* 1713 * Increment the external lock coutner, COM_ExternalLockAddRef also 1714 * increment the object's internal lock counter. 1715 */ 1716 COM_ExternalLockAddRef( pUnk); 1717 } else { 1718 /* 1719 * Decrement the external lock coutner, COM_ExternalLockRelease also 1720 * decrement the object's internal lock counter. 1721 */ 1722 COM_ExternalLockRelease( pUnk, fLastUnlockReleases); 1723 } 1724 1725 return S_OK; 1726 } 1727 1728 /*********************************************************************** 1729 * CoInitializeWOW (OLE32.27) 1730 */ 1731 HRESULT WINAPI CoInitializeWOW(DWORD x,DWORD y) { 1732 FIXME("(0x%08lx,0x%08lx),stub!\n",x,y); 1733 return 0; 1734 } 1735 1736 static IUnknown * pUnkState = 0; /* FIXME: thread local */ 1737 static int nStatCounter = 0; /* global */ 1738 static HMODULE hOleAut32 = 0; /* global */ 1739 1740 /*********************************************************************** 1741 * CoGetState [OLE32.24] 1742 * 1743 * NOTES: might be incomplete 1744 */ 1745 HRESULT WINAPI CoGetState(IUnknown ** ppv) 1746 { 1747 FIXME("\n"); 1748 1749 if(pUnkState) { 1750 IUnknown_AddRef(pUnkState); 1751 *ppv = pUnkState; 1752 FIXME("-- %p\n", *ppv); 1753 return S_OK; 1754 } 1755 *ppv = NULL; 1756 return E_FAIL; 1757 1758 } 1759 1901 1760 /*********************************************************************** 1902 1761 * CoSetState [OLE32.42] 1903 */ 1904 HRESULT WINAPI CoSetState(LPDWORD state) 1905 { 1906 FIXME("(%p),stub!\n", state); 1907 if (state) *state = 0; 1908 return S_OK; 1909 } 1910 /*********************************************************************** 1911 * CoCreateFreeThreadedMarshaler [OLE32.5] 1912 */ 1913 HRESULT WINAPI CoCreateFreeThreadedMarshaler (LPUNKNOWN punkOuter, LPUNKNOWN* ppunkMarshal) 1914 { 1915 FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal); 1916 1917 return S_OK; 1918 } 1919 1920 /*** 1921 * COM_RevokeAllClasses 1922 * 1923 * This method is called when the COM libraries are uninitialized to 1924 * release all the references to the class objects registered with 1925 * the library 1926 */ 1927 static void COM_RevokeAllClasses() 1928 { 1929 EnterCriticalSection( &csRegisteredClassList ); 1930 1931 while (firstRegisteredClass!=0) 1932 { 1933 CoRevokeClassObject(firstRegisteredClass->dwCookie); 1934 } 1935 1936 LeaveCriticalSection( &csRegisteredClassList ); 1937 } 1938 1939 /**************************************************************************** 1940 * COM External Lock methods implementation 1941 */ 1942 1943 /**************************************************************************** 1944 * Public - Method that increments the count for a IUnknown* in the linked 1945 * list. The item is inserted if not already in the list. 1946 */ 1947 static void COM_ExternalLockAddRef( 1948 IUnknown *pUnk) 1949 { 1950 COM_ExternalLock *externalLock = COM_ExternalLockFind(pUnk); 1951 1952 /* 1953 * Add an external lock to the object. If it was already externally 1954 * locked, just increase the reference count. If it was not. 1955 * add the item to the list. 1956 */ 1957 if ( externalLock == EL_NOT_FOUND ) 1958 COM_ExternalLockInsert(pUnk); 1959 else 1960 externalLock->uRefCount++; 1961 1962 /* 1963 * Add an internal lock to the object 1964 */ 1965 IUnknown_AddRef(pUnk); 1966 } 1967 1968 /**************************************************************************** 1969 * Public - Method that decrements the count for a IUnknown* in the linked 1970 * list. The item is removed from the list if its count end up at zero or if 1971 * bRelAll is TRUE. 1972 */ 1973 static void COM_ExternalLockRelease( 1974 IUnknown *pUnk, 1975 BOOL bRelAll) 1976 { 1977 COM_ExternalLock *externalLock = COM_ExternalLockFind(pUnk); 1978 1979 if ( externalLock != EL_NOT_FOUND ) 1980 { 1981 do 1982 { 1983 externalLock->uRefCount--; /* release external locks */ 1984 IUnknown_Release(pUnk); /* release local locks as well */ 1985 1986 if ( bRelAll == FALSE ) 1987 break; /* perform single release */ 1988 1989 } while ( externalLock->uRefCount > 0 ); 1990 1991 if ( externalLock->uRefCount == 0 ) /* get rid of the list entry */ 1992 COM_ExternalLockDelete(externalLock); 1993 } 1994 } 1995 /**************************************************************************** 1996 * Public - Method that frees the content of the list. 1997 */ 1998 static void COM_ExternalLockFreeList() 1999 { 2000 COM_ExternalLock *head; 2001 2002 head = elList.head; /* grab it by the head */ 2003 while ( head != EL_END_OF_LIST ) 2004 { 2005 COM_ExternalLockDelete(head); /* get rid of the head stuff */ 2006 2007 head = elList.head; /* get the new head... */ 2008 } 2009 } 2010 2011 /**************************************************************************** 2012 * Public - Method that dump the content of the list. 2013 */ 2014 void COM_ExternalLockDump() 2015 { 2016 COM_ExternalLock *current = elList.head; 2017 2018 DPRINTF("\nExternal lock list contains:\n"); 2019 2020 while ( current != EL_END_OF_LIST ) 2021 { 2022 DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount); 2023 2024 /* Skip to the next item */ 2025 current = current->next; 2026 } 2027 2028 } 2029 2030 /**************************************************************************** 2031 * Internal - Find a IUnknown* in the linked list 2032 */ 2033 static COM_ExternalLock* COM_ExternalLockFind( 2034 IUnknown *pUnk) 2035 { 2036 return COM_ExternalLockLocate(elList.head, pUnk); 2037 } 2038 2039 /**************************************************************************** 2040 * Internal - Recursivity agent for IUnknownExternalLockList_Find 2041 */ 2042 static COM_ExternalLock* COM_ExternalLockLocate( 2043 COM_ExternalLock *element, 2044 IUnknown *pUnk) 2045 { 2046 if ( element == EL_END_OF_LIST ) 2047 return EL_NOT_FOUND; 2048 2049 else if ( element->pUnk == pUnk ) /* We found it */ 2050 return element; 2051 2052 else /* Not the right guy, keep on looking */ 2053 return COM_ExternalLockLocate( element->next, pUnk); 2054 } 2055 2056 /**************************************************************************** 2057 * Internal - Insert a new IUnknown* to the linked list 2058 */ 2059 static BOOL COM_ExternalLockInsert( 2060 IUnknown *pUnk) 2061 { 2062 COM_ExternalLock *newLock = NULL; 2063 COM_ExternalLock *previousHead = NULL; 2064 2065 /* 2066 * Allocate space for the new storage object 2067 */ 2068 newLock = HeapAlloc(GetProcessHeap(), 0, sizeof(COM_ExternalLock)); 2069 2070 if (newLock!=NULL) 2071 { 2072 if ( elList.head == EL_END_OF_LIST ) 2073 { 2074 elList.head = newLock; /* The list is empty */ 2075 } 2076 else 2077 { 2078 /* 2079 * insert does it at the head 2080 */ 2081 previousHead = elList.head; 2082 elList.head = newLock; 2083 } 2084 2085 /* 2086 * Set new list item data member 2087 */ 2088 newLock->pUnk = pUnk; 2089 newLock->uRefCount = 1; 2090 newLock->next = previousHead; 2091 2092 return TRUE; 2093 } 2094 else 2095 return FALSE; 2096 } 2097 2098 /**************************************************************************** 2099 * Internal - Method that removes an item from the linked list. 2100 */ 2101 static void COM_ExternalLockDelete( 2102 COM_ExternalLock *itemList) 2103 { 2104 COM_ExternalLock *current = elList.head; 2105 2106 if ( current == itemList ) 2107 { 2108 /* 2109 * this section handles the deletion of the first node 2110 */ 2111 elList.head = itemList->next; 2112 HeapFree( GetProcessHeap(), 0, itemList); 2113 } 2114 else 2115 { 2116 do 2117 { 2118 if ( current->next == itemList ) /* We found the item to free */ 2119 { 2120 current->next = itemList->next; /* readjust the list pointers */ 2121 2122 HeapFree( GetProcessHeap(), 0, itemList); 2123 break; 2124 } 2125 2126 /* Skip to the next item */ 2127 current = current->next; 2128 2129 } while ( current != EL_END_OF_LIST ); 2130 } 2131 } 2132 2133 /*********************************************************************** 2134 * DllEntryPoint [COMPOBJ.116] 2135 * 2136 * Initialization code for the COMPOBJ DLL 2137 * 2138 * RETURNS: 2139 */ 2140 BOOL WINAPI COMPOBJ_DllEntryPoint(DWORD Reason, HINSTANCE16 hInst, WORD ds, WORD HeapSize, DWORD res1, WORD res2) 2141 { 2142 TRACE("(%08lx, %04x, %04x, %04x, %08lx, %04x)\n", Reason, hInst, ds, HeapSize, 2143 res1, res2); 2144 switch(Reason) 2145 { 2146 case DLL_PROCESS_ATTACH: 2147 if (!COMPOBJ_Attach++) COMPOBJ_hInstance = hInst; 2148 break; 2149 2150 case DLL_PROCESS_DETACH: 2151 if(!--COMPOBJ_Attach) 2152 COMPOBJ_hInstance = 0; 2153 break; 2154 } 2155 return TRUE; 2156 } 1762 * 1763 * NOTES: FIXME: protect this with a crst 1764 */ 1765 HRESULT WINAPI CoSetState(IUnknown * pv) 1766 { 1767 FIXME("(%p),stub!\n", pv); 1768 1769 if (pv) { 1770 IUnknown_AddRef(pv); 1771 nStatCounter++; 1772 if (nStatCounter == 1) LoadLibraryA("OLEAUT32.DLL"); 1773 } 1774 1775 if (pUnkState) { 1776 TRACE("-- release %p now\n", pUnkState); 1777 IUnknown_Release(pUnkState); 1778 nStatCounter--; 1779 if (!nStatCounter) FreeLibrary(hOleAut32); 1780 } 1781 pUnkState = pv; 1782 return S_OK; 1783 } 1784 2157 1785 2158 1786 /****************************************************************************** … … 2184 1812 CLSIDFromString(wbuf,pClsidNew); 2185 1813 done: 2186 if (hkey) RegCloseKey(hkey); 2187 2188 return res; 1814 if (hkey) RegCloseKey(hkey); 1815 return res; 2189 1816 } 2190 1817 … … 2262 1889 return !memcmp(rguid1,rguid2,sizeof(GUID)); 2263 1890 } 1891 1892 /*********************************************************************** 1893 * CoInitializeSecurity [OLE32.164] 1894 */ 1895 HRESULT WINAPI CoInitializeSecurity(PSECURITY_DESCRIPTOR pSecDesc, LONG cAuthSvc, 1896 SOLE_AUTHENTICATION_SERVICE* asAuthSvc, 1897 void* pReserved1, DWORD dwAuthnLevel, 1898 DWORD dwImpLevel, void* pReserved2, 1899 DWORD dwCapabilities, void* pReserved3) 1900 { 1901 FIXME("(%p,%ld,%p,%p,%ld,%ld,%p,%ld,%p) - stub!\n", pSecDesc, cAuthSvc, 1902 asAuthSvc, pReserved1, dwAuthnLevel, dwImpLevel, pReserved2, 1903 dwCapabilities, pReserved3); 1904 return S_OK; 1905 } -
trunk/src/ole32/compobj_private.h
r8620 r9400 125 125 int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable); 126 126 127 HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id); 128 127 129 #endif /* __WINE_OLE_COMPOBJ_H */ -
trunk/src/ole32/datacache.c
r8620 r9400 827 827 828 828 if (FAILED(hres)) 829 return hres;829 return (HMETAFILE)hres; 830 830 831 831 /* -
trunk/src/ole32/filemoniker.c
r8620 r9400 871 871 872 872 if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker)) 873 874 873 return S_FALSE; 875 874 876 res=CreateBindCtx(0,&bind); 877 if (FAILED(res)) 878 return res; 879 880 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath); 881 882 if (lstrcmpiW(filePath, 883 This->filePathName)!=0) 884 885 return S_FALSE; 886 887 return S_OK; 875 res = CreateBindCtx(0,&bind); 876 if (FAILED(res)) return res; 877 878 if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) { 879 int result = lstrcmpiW(filePath, This->filePathName); 880 CoTaskMemFree(filePath); 881 if ( result == 0 ) return S_OK; 882 } 883 return S_FALSE; 884 888 885 } 889 886 … … 1100 1097 int len=lstrlenW(str); 1101 1098 1099 TRACE("%s, %p\n", debugstr_w(str), *stringTable); 1100 1102 1101 strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR)); 1103 1102 -
trunk/src/ole32/hglobalstream.c
r8620 r9400 34 34 #include "winbase.h" 35 35 #include "winerror.h" 36 #include "winternl.h" 36 37 37 38 #include "wine/debug.h" … … 574 575 575 576 /* 576 * The caller is allowed to pass in NULL as the new position return value.577 * If it happens, we assign it to a dynamic variable to avoid special cases578 * in the code below.579 */580 if (plibNewPosition == 0)581 {582 plibNewPosition = &newPosition;583 }584 585 /*586 577 * The file pointer is moved depending on the given "function" 587 578 * parameter. … … 590 581 { 591 582 case STREAM_SEEK_SET: 592 plibNewPosition->s.HighPart = 0;593 plibNewPosition->s.LowPart= 0;583 newPosition.s.HighPart = 0; 584 newPosition.s.LowPart = 0; 594 585 break; 595 586 case STREAM_SEEK_CUR: 596 *plibNewPosition = This->currentPosition;587 newPosition = This->currentPosition; 597 588 break; 598 589 case STREAM_SEEK_END: 599 *plibNewPosition = This->streamSize;590 newPosition = This->streamSize; 600 591 break; 601 592 default: … … 604 595 605 596 /* 606 * We don't support files with offsets of 64 bits.607 */608 assert(dlibMove.s.HighPart == 0);609 610 /*611 * Check if we end-up before the beginning of the file. That should trigger an612 * error.613 */614 if ( (dlibMove.s.LowPart<0) && (plibNewPosition->s.LowPart < (ULONG)(-dlibMove.s.LowPart)) )615 {616 /*617 * I don't know what error to send there.618 */619 return E_FAIL;620 }621 622 /*623 597 * Move the actual file pointer 624 598 * If the file pointer ends-up after the end of the stream, the next Write operation will 625 599 * make the file larger. This is how it is documented. 626 600 */ 627 plibNewPosition->s.LowPart += dlibMove.s.LowPart; 628 This->currentPosition = *plibNewPosition; 601 #ifdef __WIN32OS2__ 602 *(LARGE_INTEGER *)&newPosition = RtlpLargeIntegerAdd( (LARGE_INTEGER *)&newPosition, &dlibMove ); 603 #else 604 newPosition.QuadPart = RtlLargeIntegerAdd(newPosition.QuadPart, dlibMove.QuadPart); 605 #endif 606 if (newPosition.QuadPart < 0) return STG_E_INVALIDFUNCTION; 607 608 if (plibNewPosition) *plibNewPosition = newPosition; 609 This->currentPosition = newPosition; 629 610 630 611 return S_OK; … … 844 825 IStream** ppstm) /* [out] */ 845 826 { 846 FIXME("not implemented!\n"); 847 return E_NOTIMPL; 848 } 827 ULARGE_INTEGER dummy; 828 LARGE_INTEGER offset; 829 HRESULT hr; 830 HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface; 831 TRACE(" Cloning %p (deleteOnRelease=%d seek position=%ld)\n",iface,This->deleteOnRelease,(long)This->currentPosition.QuadPart); 832 hr=CreateStreamOnHGlobal(This->supportHandle, FALSE, ppstm); 833 if(FAILED(hr)) 834 return hr; 835 offset.QuadPart=(LONGLONG)This->currentPosition.QuadPart; 836 HGLOBALStreamImpl_Seek(*ppstm,offset,STREAM_SEEK_SET,&dummy); 837 return S_OK; 838 } -
trunk/src/ole32/ifs.c
r8441 r9400 28 28 #include "ole2.h" 29 29 #include "windef.h" 30 #include "winbase.h" 30 31 #include "winerror.h" 31 32 32 33 #include "wine/obj_base.h" 33 #include "wine/winbase16.h"34 #include "ifs.h"35 34 36 35 #include "wine/debug.h" 37 36 38 WINE_DEFAULT_DEBUG_CHANNEL(relay); 39 40 /* --- IUnknown implementation */ 41 42 typedef struct 43 { 44 /* IUnknown fields */ 45 ICOM_VFIELD(IUnknown); 46 DWORD ref; 47 } IUnknownImpl; 48 49 /****************************************************************************** 50 * IUnknown_AddRef [VTABLE:IUNKNOWN.1] 51 */ 52 static ULONG WINAPI IUnknown_fnAddRef(LPUNKNOWN iface) { 53 ICOM_THIS(IUnknownImpl,iface); 54 TRACE("(%p)->AddRef()\n",This); 55 return ++(This->ref); 56 } 57 58 /****************************************************************************** 59 * IUnknown_Release [VTABLE:IUNKNOWN.2] 60 */ 61 static ULONG WINAPI IUnknown_fnRelease(LPUNKNOWN iface) { 62 ICOM_THIS(IUnknownImpl,iface); 63 TRACE("(%p)->Release()\n",This); 64 if (!--(This->ref)) { 65 HeapFree(GetProcessHeap(),0,This); 66 return 0; 67 } 68 return This->ref; 69 } 70 71 /****************************************************************************** 72 * IUnknown_QueryInterface [VTABLE:IUNKNOWN.0] 73 */ 74 static HRESULT WINAPI IUnknown_fnQueryInterface(LPUNKNOWN iface,REFIID refiid,LPVOID *obj) { 75 ICOM_THIS(IUnknownImpl,iface); 76 77 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 78 79 if (!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown))) { 80 *obj = This; 81 return 0; 82 } 83 return OLE_E_ENUM_NOMORE; 84 } 85 86 static ICOM_VTABLE(IUnknown) uvt = 37 #ifdef __WIN32OS2__ 38 #define CRITICAL_SECTION_INIT(name) { (void *)(__FILE__ ": " name), -1, 0, 0, 0, 0 } 39 #endif 40 41 WINE_DEFAULT_DEBUG_CHANNEL(ole); 42 43 /****************************************************************************** 44 * IMalloc32 implementation 45 * 46 * NOTES 47 * For supporting CoRegisterMallocSpy the IMalloc implementation must know if 48 * a given memory block was allocated with a spy active. 49 * 50 *****************************************************************************/ 51 /* set the vtable later */ 52 extern ICOM_VTABLE(IMalloc) VT_IMalloc32; 53 54 typedef struct { 55 ICOM_VFIELD(IMalloc); 56 DWORD dummy; /* nothing, we are static */ 57 IMallocSpy * pSpy; /* the spy when active */ 58 DWORD SpyedAllocationsLeft; /* number of spyed allocations left */ 59 BOOL SpyReleasePending; /* CoRevokeMallocSpy called with spyed allocations left*/ 60 LPVOID * SpyedBlocks; /* root of the table */ 61 int SpyedBlockTableLength; /* size of the table*/ 62 } _Malloc32; 63 64 /* this is the static object instance */ 65 _Malloc32 Malloc32 = {&VT_IMalloc32, 0, NULL, 0, 0, NULL, 0}; 66 67 /* with a spy active all calls from pre to post methods are threadsave */ 68 static CRITICAL_SECTION IMalloc32_SpyCS = CRITICAL_SECTION_INIT("IMalloc32_SpyCS"); 69 70 /* resize the old table */ 71 static int SetSpyedBlockTableLength ( int NewLength ) 72 { 73 Malloc32.SpyedBlocks = (LPVOID*)LocalReAlloc((HLOCAL)Malloc32.SpyedBlocks, NewLength, GMEM_ZEROINIT); 74 Malloc32.SpyedBlockTableLength = NewLength; 75 return Malloc32.SpyedBlocks ? 1 : 0; 76 } 77 78 /* add a location to the table */ 79 static int AddMemoryLocation(LPVOID * pMem) 80 { 81 LPVOID * Current; 82 83 /* allocate the table if not already allocated */ 84 if (!Malloc32.SpyedBlockTableLength) { 85 if (!SetSpyedBlockTableLength(0x1000)) return 0; 86 } 87 88 /* find a free location */ 89 Current = Malloc32.SpyedBlocks; 90 while (*Current) { 91 Current++; 92 if (Current >= Malloc32.SpyedBlocks + Malloc32.SpyedBlockTableLength) { 93 /* no more space in table, grow it */ 94 if (!SetSpyedBlockTableLength( Malloc32.SpyedBlockTableLength + 0x1000 )) return 0; 95 } 96 }; 97 98 /* put the location in our table */ 99 *Current = pMem; 100 Malloc32.SpyedAllocationsLeft++; 101 /*TRACE("%lu\n",Malloc32.SpyedAllocationsLeft);*/ 102 return 1; 103 } 104 105 static int RemoveMemoryLocation(LPVOID * pMem) 106 { 107 LPVOID * Current = Malloc32.SpyedBlocks; 108 109 /* find the location */ 110 while (*Current != pMem) { 111 Current++; 112 if (Current >= Malloc32.SpyedBlocks + Malloc32.SpyedBlockTableLength) return 0; /* not found */ 113 } 114 115 /* location found */ 116 Malloc32.SpyedAllocationsLeft--; 117 /*TRACE("%lu\n",Malloc32.SpyedAllocationsLeft);*/ 118 *Current = NULL; 119 return 1; 120 } 121 122 /****************************************************************************** 123 * IMalloc32_QueryInterface [VTABLE] 124 */ 125 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) { 126 127 TRACE("(%s,%p)\n",debugstr_guid(refiid),obj); 128 129 if (IsEqualIID(&IID_IUnknown,refiid) || IsEqualIID(&IID_IMalloc,refiid)) { 130 *obj = (LPMALLOC)&Malloc32; 131 return S_OK; 132 } 133 return E_NOINTERFACE; 134 } 135 136 /****************************************************************************** 137 * IMalloc32_AddRefRelease [VTABLE] 138 */ 139 static ULONG WINAPI IMalloc_fnAddRefRelease (LPMALLOC iface) { 140 return 1; 141 } 142 143 /****************************************************************************** 144 * IMalloc32_Alloc [VTABLE] 145 */ 146 static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface, DWORD cb) { 147 148 LPVOID addr; 149 150 TRACE("(%ld)\n",cb); 151 152 if(Malloc32.pSpy) { 153 EnterCriticalSection(&IMalloc32_SpyCS); 154 cb = IMallocSpy_PreAlloc(Malloc32.pSpy, cb); 155 if (0==cb) { 156 /* PreAlloc can force Alloc to fail */ 157 LeaveCriticalSection(&IMalloc32_SpyCS); 158 return NULL; 159 } 160 } 161 162 163 addr = HeapAlloc(GetProcessHeap(),0,cb); 164 165 if(Malloc32.pSpy) { 166 addr = IMallocSpy_PostAlloc(Malloc32.pSpy, addr); 167 if (addr) AddMemoryLocation(addr); 168 LeaveCriticalSection(&IMalloc32_SpyCS); 169 } 170 171 TRACE("--(%p)\n",addr); 172 return addr; 173 } 174 175 /****************************************************************************** 176 * IMalloc32_Realloc [VTABLE] 177 */ 178 static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) { 179 180 LPVOID pNewMemory; 181 182 TRACE("(%p,%ld)\n",pv,cb); 183 184 if(Malloc32.pSpy) { 185 LPVOID pRealMemory; 186 BOOL fSpyed; 187 188 EnterCriticalSection(&IMalloc32_SpyCS); 189 fSpyed = RemoveMemoryLocation(pv); 190 cb = IMallocSpy_PreRealloc(Malloc32.pSpy, pv, cb, &pRealMemory, fSpyed); 191 192 /* check if can release the spy */ 193 if(Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft) { 194 IMallocSpy_Release(Malloc32.pSpy); 195 Malloc32.SpyReleasePending = FALSE; 196 Malloc32.pSpy = NULL; 197 } 198 199 if (0==cb) { 200 /* PreRealloc can force Realloc to fail */ 201 LeaveCriticalSection(&IMalloc32_SpyCS); 202 return NULL; 203 } 204 pv = pRealMemory; 205 } 206 207 pNewMemory = HeapReAlloc(GetProcessHeap(),0,pv,cb); 208 209 if(Malloc32.pSpy) { 210 pNewMemory = IMallocSpy_PostRealloc(Malloc32.pSpy, pNewMemory, TRUE); 211 if (pNewMemory) AddMemoryLocation(pNewMemory); 212 LeaveCriticalSection(&IMalloc32_SpyCS); 213 } 214 215 TRACE("--(%p)\n",pNewMemory); 216 return pNewMemory; 217 } 218 219 /****************************************************************************** 220 * IMalloc32_Free [VTABLE] 221 */ 222 static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) { 223 224 BOOL fSpyed = 0; 225 226 TRACE("(%p)\n",pv); 227 228 if(Malloc32.pSpy) { 229 EnterCriticalSection(&IMalloc32_SpyCS); 230 fSpyed = RemoveMemoryLocation(pv); 231 pv = IMallocSpy_PreFree(Malloc32.pSpy, pv, fSpyed); 232 } 233 234 HeapFree(GetProcessHeap(),0,pv); 235 236 if(Malloc32.pSpy) { 237 IMallocSpy_PostFree(Malloc32.pSpy, fSpyed); 238 239 /* check if can release the spy */ 240 if(Malloc32.SpyReleasePending && !Malloc32.SpyedAllocationsLeft) { 241 IMallocSpy_Release(Malloc32.pSpy); 242 Malloc32.SpyReleasePending = FALSE; 243 Malloc32.pSpy = NULL; 244 } 245 246 LeaveCriticalSection(&IMalloc32_SpyCS); 247 } 248 } 249 250 /****************************************************************************** 251 * IMalloc32_GetSize [VTABLE] 252 * 253 * NOTES 254 * FIXME returns: 255 * win95: size allocated (4 byte boundarys) 256 * win2k: size originally requested !!! (allocated on 8 byte boundarys) 257 */ 258 static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) { 259 260 DWORD cb; 261 BOOL fSpyed = 0; 262 263 TRACE("(%p)\n",pv); 264 265 if(Malloc32.pSpy) { 266 EnterCriticalSection(&IMalloc32_SpyCS); 267 pv = IMallocSpy_PreGetSize(Malloc32.pSpy, pv, fSpyed); 268 } 269 270 cb = HeapSize(GetProcessHeap(),0,pv); 271 272 if(Malloc32.pSpy) { 273 cb = IMallocSpy_PostGetSize(Malloc32.pSpy, cb, fSpyed); 274 LeaveCriticalSection(&IMalloc32_SpyCS); 275 } 276 277 return cb; 278 } 279 280 /****************************************************************************** 281 * IMalloc32_DidAlloc [VTABLE] 282 */ 283 static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) { 284 285 BOOL fSpyed = 0; 286 int didAlloc; 287 288 TRACE("(%p)\n",pv); 289 290 if(Malloc32.pSpy) { 291 EnterCriticalSection(&IMalloc32_SpyCS); 292 pv = IMallocSpy_PreDidAlloc(Malloc32.pSpy, pv, fSpyed); 293 } 294 295 didAlloc = -1; 296 297 if(Malloc32.pSpy) { 298 didAlloc = IMallocSpy_PostDidAlloc(Malloc32.pSpy, pv, fSpyed, didAlloc); 299 LeaveCriticalSection(&IMalloc32_SpyCS); 300 } 301 return didAlloc; 302 } 303 304 /****************************************************************************** 305 * IMalloc32_HeapMinimize [VTABLE] 306 */ 307 static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) { 308 TRACE("()\n"); 309 310 if(Malloc32.pSpy) { 311 EnterCriticalSection(&IMalloc32_SpyCS); 312 IMallocSpy_PreHeapMinimize(Malloc32.pSpy); 313 } 314 315 if(Malloc32.pSpy) { 316 IMallocSpy_PostHeapMinimize(Malloc32.pSpy); 317 LeaveCriticalSection(&IMalloc32_SpyCS); 318 } 319 } 320 321 #ifdef __WIN32OS2__ 322 ICOM_VTABLE(IMalloc) VT_IMalloc32 = 323 #else 324 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 325 #endif 87 326 { 88 327 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 89 IUnknown_fnQueryInterface, 90 IUnknown_fnAddRef, 91 IUnknown_fnRelease 328 IMalloc_fnQueryInterface, 329 IMalloc_fnAddRefRelease, 330 IMalloc_fnAddRefRelease, 331 IMalloc_fnAlloc, 332 IMalloc_fnRealloc, 333 IMalloc_fnFree, 334 IMalloc_fnGetSize, 335 IMalloc_fnDidAlloc, 336 IMalloc_fnHeapMinimize 92 337 }; 93 338 94 339 /****************************************************************************** 95 * IUnknown_Constructor [INTERNAL] 96 */ 97 LPUNKNOWN 98 IUnknown_Constructor() { 99 IUnknownImpl* unk; 100 101 unk = (IUnknownImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IUnknownImpl)); 102 ICOM_VTBL(unk) = &uvt; 103 unk->ref = 1; 104 return (LPUNKNOWN)unk; 105 } 106 107 #ifndef __WIN32OS2__ 108 /* --- IMalloc16 implementation */ 109 110 111 typedef struct 112 { 113 /* IUnknown fields */ 114 ICOM_VFIELD(IMalloc16); 115 DWORD ref; 116 /* IMalloc16 fields */ 117 } IMalloc16Impl; 118 119 /****************************************************************************** 120 * IMalloc16_QueryInterface [COMPOBJ.500] 121 */ 122 HRESULT WINAPI IMalloc16_fnQueryInterface(IMalloc16* iface,REFIID refiid,LPVOID *obj) { 123 ICOM_THIS(IMalloc16Impl,iface); 124 125 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 126 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 127 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 128 ) { 129 *obj = This; 130 return 0; 131 } 132 return OLE_E_ENUM_NOMORE; 133 } 134 135 /****************************************************************************** 136 * IMalloc16_AddRef [COMPOBJ.501] 137 */ 138 ULONG WINAPI IMalloc16_fnAddRef(IMalloc16* iface) { 139 ICOM_THIS(IMalloc16Impl,iface); 140 TRACE("(%p)->AddRef()\n",This); 141 return 1; /* cannot be freed */ 142 } 143 144 /****************************************************************************** 145 * IMalloc16_Release [COMPOBJ.502] 146 */ 147 ULONG WINAPI IMalloc16_fnRelease(IMalloc16* iface) { 148 ICOM_THIS(IMalloc16Impl,iface); 149 TRACE("(%p)->Release()\n",This); 150 return 1; /* cannot be freed */ 151 } 152 153 /****************************************************************************** 154 * IMalloc16_Alloc [COMPOBJ.503] 155 */ 156 SEGPTR WINAPI IMalloc16_fnAlloc(IMalloc16* iface,DWORD cb) { 157 ICOM_THIS(IMalloc16Impl,iface); 158 TRACE("(%p)->Alloc(%ld)\n",This,cb); 159 return MapLS( HeapAlloc( GetProcessHeap(), 0, cb ) ); 160 } 161 162 /****************************************************************************** 163 * IMalloc16_Realloc [COMPOBJ.504] 164 */ 165 SEGPTR WINAPI IMalloc16_fnRealloc(IMalloc16* iface,SEGPTR pv,DWORD cb) 166 { 167 SEGPTR ret; 168 ICOM_THIS(IMalloc16Impl,iface); 169 TRACE("(%p)->Realloc(%08lx,%ld)\n",This,pv,cb); 170 ret = MapLS( HeapReAlloc( GetProcessHeap(), 0, MapSL(pv), cb ) ); 171 UnMapLS(pv); 172 return ret; 173 } 174 175 /****************************************************************************** 176 * IMalloc16_Free [COMPOBJ.505] 177 */ 178 VOID WINAPI IMalloc16_fnFree(IMalloc16* iface,SEGPTR pv) 179 { 180 void *ptr = MapSL(pv); 181 ICOM_THIS(IMalloc16Impl,iface); 182 TRACE("(%p)->Free(%08lx)\n",This,pv); 183 UnMapLS(pv); 184 HeapFree( GetProcessHeap(), 0, ptr ); 185 } 186 187 /****************************************************************************** 188 * IMalloc16_GetSize [COMPOBJ.506] 189 */ 190 DWORD WINAPI IMalloc16_fnGetSize(const IMalloc16* iface,SEGPTR pv) 191 { 192 ICOM_CTHIS(IMalloc16Impl,iface); 193 TRACE("(%p)->GetSize(%08lx)\n",This,pv); 194 return HeapSize( GetProcessHeap(), 0, MapSL(pv) ); 195 } 196 197 /****************************************************************************** 198 * IMalloc16_DidAlloc [COMPOBJ.507] 199 */ 200 INT16 WINAPI IMalloc16_fnDidAlloc(const IMalloc16* iface,LPVOID pv) { 201 ICOM_CTHIS(IMalloc16,iface); 202 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 203 return (INT16)-1; 204 } 205 206 /****************************************************************************** 207 * IMalloc16_HeapMinimize [COMPOBJ.508] 208 */ 209 LPVOID WINAPI IMalloc16_fnHeapMinimize(IMalloc16* iface) { 210 ICOM_THIS(IMalloc16Impl,iface); 211 TRACE("(%p)->HeapMinimize()\n",This); 212 return NULL; 213 } 214 215 /****************************************************************************** 216 * IMalloc16_Constructor [VTABLE] 217 */ 218 LPMALLOC16 219 IMalloc16_Constructor() 220 { 221 static ICOM_VTABLE(IMalloc16) vt16; 222 static SEGPTR msegvt16; 223 IMalloc16Impl* This; 224 HMODULE16 hcomp = GetModuleHandle16("COMPOBJ"); 225 226 This = HeapAlloc( GetProcessHeap(), 0, sizeof(IMalloc16Impl) ); 227 if (!msegvt16) 228 { 229 #define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"IMalloc16_"#x);assert(vt16.x) 230 VTENT(QueryInterface); 231 VTENT(AddRef); 232 VTENT(Release); 233 VTENT(Alloc); 234 VTENT(Realloc); 235 VTENT(Free); 236 VTENT(GetSize); 237 VTENT(DidAlloc); 238 VTENT(HeapMinimize); 239 #undef VTENT 240 msegvt16 = MapLS( &vt16 ); 340 * IMallocSpy implementation 341 *****************************************************************************/ 342 343 /* set the vtable later */ 344 extern ICOM_VTABLE(IMallocSpy) VT_IMallocSpy; 345 346 typedef struct { 347 ICOM_VFIELD(IMallocSpy); 348 DWORD ref; 349 } _MallocSpy; 350 351 /* this is the static object instance */ 352 _MallocSpy MallocSpy = {&VT_IMallocSpy, 0}; 353 354 /****************************************************************************** 355 * IMalloc32_QueryInterface [VTABLE] 356 */ 357 static HRESULT WINAPI IMallocSpy_fnQueryInterface(LPMALLOCSPY iface,REFIID refiid,LPVOID *obj) 358 { 359 360 TRACE("(%s,%p)\n",debugstr_guid(refiid),obj); 361 362 if (IsEqualIID(&IID_IUnknown,refiid) || IsEqualIID(&IID_IMallocSpy,refiid)) { 363 *obj = (LPMALLOC)&MallocSpy; 364 return S_OK; 365 } 366 return E_NOINTERFACE; 367 } 368 369 /****************************************************************************** 370 * IMalloc32_AddRef [VTABLE] 371 */ 372 static ULONG WINAPI IMallocSpy_fnAddRef (LPMALLOCSPY iface) 373 { 374 375 ICOM_THIS (_MallocSpy, iface); 376 377 TRACE ("(%p)->(count=%lu)\n", This, This->ref); 378 379 return ++(This->ref); 380 } 381 382 /****************************************************************************** 383 * IMalloc32_AddRelease [VTABLE] 384 * 385 * NOTES 386 * Our MallocSpy is static. If the count reaches 0 we dump the leaks 387 */ 388 static ULONG WINAPI IMallocSpy_fnRelease (LPMALLOCSPY iface) 389 { 390 391 ICOM_THIS (_MallocSpy, iface); 392 393 TRACE ("(%p)->(count=%lu)\n", This, This->ref); 394 395 if (!--(This->ref)) { 396 /* our allocation list MUST be empty here */ 241 397 } 242 ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)msegvt16; 243 This->ref = 1; 244 return (LPMALLOC16)MapLS( This ); 245 } 398 return This->ref; 399 } 400 401 static ULONG WINAPI IMallocSpy_fnPreAlloc(LPMALLOCSPY iface, ULONG cbRequest) 402 { 403 ICOM_THIS (_MallocSpy, iface); 404 TRACE ("(%p)->(%lu)\n", This, cbRequest); 405 return cbRequest; 406 } 407 static PVOID WINAPI IMallocSpy_fnPostAlloc(LPMALLOCSPY iface, void* pActual) 408 { 409 ICOM_THIS (_MallocSpy, iface); 410 TRACE ("(%p)->(%p)\n", This, pActual); 411 return pActual; 412 } 413 414 static PVOID WINAPI IMallocSpy_fnPreFree(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed) 415 { 416 ICOM_THIS (_MallocSpy, iface); 417 TRACE ("(%p)->(%p %u)\n", This, pRequest, fSpyed); 418 return pRequest; 419 } 420 static void WINAPI IMallocSpy_fnPostFree(LPMALLOCSPY iface, BOOL fSpyed) 421 { 422 ICOM_THIS (_MallocSpy, iface); 423 TRACE ("(%p)->(%u)\n", This, fSpyed); 424 } 425 426 static ULONG WINAPI IMallocSpy_fnPreRealloc(LPMALLOCSPY iface, void* pRequest, ULONG cbRequest, void** ppNewRequest, BOOL fSpyed) 427 { 428 ICOM_THIS (_MallocSpy, iface); 429 TRACE ("(%p)->(%p %lu %u)\n", This, pRequest, cbRequest, fSpyed); 430 *ppNewRequest = pRequest; 431 return cbRequest; 432 } 433 434 static PVOID WINAPI IMallocSpy_fnPostRealloc(LPMALLOCSPY iface, void* pActual, BOOL fSpyed) 435 { 436 ICOM_THIS (_MallocSpy, iface); 437 TRACE ("(%p)->(%p %u)\n", This, pActual, fSpyed); 438 return pActual; 439 } 440 441 static PVOID WINAPI IMallocSpy_fnPreGetSize(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed) 442 { 443 ICOM_THIS (_MallocSpy, iface); 444 TRACE ("(%p)->(%p %u)\n", This, pRequest, fSpyed); 445 return pRequest; 446 } 447 448 static ULONG WINAPI IMallocSpy_fnPostGetSize(LPMALLOCSPY iface, ULONG cbActual, BOOL fSpyed) 449 { 450 ICOM_THIS (_MallocSpy, iface); 451 TRACE ("(%p)->(%lu %u)\n", This, cbActual, fSpyed); 452 return cbActual; 453 } 454 455 static PVOID WINAPI IMallocSpy_fnPreDidAlloc(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed) 456 { 457 ICOM_THIS (_MallocSpy, iface); 458 TRACE ("(%p)->(%p %u)\n", This, pRequest, fSpyed); 459 return pRequest; 460 } 461 462 static int WINAPI IMallocSpy_fnPostDidAlloc(LPMALLOCSPY iface, void* pRequest, BOOL fSpyed, int fActual) 463 { 464 ICOM_THIS (_MallocSpy, iface); 465 TRACE ("(%p)->(%p %u %u)\n", This, pRequest, fSpyed, fActual); 466 return fActual; 467 } 468 469 static int WINAPI IMallocSpy_fnPreHeapMinimize(LPMALLOCSPY iface) 470 { 471 ICOM_THIS (_MallocSpy, iface); 472 TRACE ("(%p)->()\n", This); 473 return 0; 474 } 475 476 static int WINAPI IMallocSpy_fnPostHeapMinimize(LPMALLOCSPY iface) 477 { 478 ICOM_THIS (_MallocSpy, iface); 479 TRACE ("(%p)->()\n", This); 480 return 0; 481 } 482 483 static void MallocSpyDumpLeaks() { 484 TRACE("leaks: %lu\n", Malloc32.SpyedAllocationsLeft); 485 } 486 487 #ifdef __WIN32OS2__ 488 ICOM_VTABLE(IMallocSpy) VT_IMallocSpy = 489 #else 490 static ICOM_VTABLE(IMallocSpy) VT_IMallocSpy = 246 491 #endif 247 248 /* --- IMalloc32 implementation */ 249 250 typedef struct 251 { 252 /* IUnknown fields */ 253 ICOM_VFIELD(IMalloc); 254 DWORD ref; 255 } IMalloc32Impl; 256 257 /****************************************************************************** 258 * IMalloc32_QueryInterface [VTABLE] 259 */ 260 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) { 261 ICOM_THIS(IMalloc32Impl,iface); 262 263 TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); 264 if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) || 265 !memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) 266 ) { 267 *obj = This; 268 return S_OK; 269 } 270 return OLE_E_ENUM_NOMORE; 271 } 272 273 /****************************************************************************** 274 * IMalloc32_AddRef [VTABLE] 275 */ 276 static ULONG WINAPI IMalloc_fnAddRef(LPMALLOC iface) { 277 ICOM_THIS(IMalloc32Impl,iface); 278 TRACE("(%p)->AddRef()\n",This); 279 return 1; /* cannot be freed */ 280 } 281 282 /****************************************************************************** 283 * IMalloc32_Release [VTABLE] 284 */ 285 static ULONG WINAPI IMalloc_fnRelease(LPMALLOC iface) { 286 ICOM_THIS(IMalloc32Impl,iface); 287 TRACE("(%p)->Release()\n",This); 288 return 1; /* cannot be freed */ 289 } 290 291 /****************************************************************************** 292 * IMalloc32_Alloc [VTABLE] 293 */ 294 static LPVOID WINAPI IMalloc_fnAlloc(LPMALLOC iface,DWORD cb) { 295 LPVOID addr; 296 ICOM_THIS(IMalloc32Impl,iface); 297 addr = HeapAlloc(GetProcessHeap(),0,cb); 298 TRACE("(%p)->Alloc(%ld) -> %p\n",This,cb,addr); 299 return addr; 300 } 301 302 /****************************************************************************** 303 * IMalloc32_Realloc [VTABLE] 304 */ 305 static LPVOID WINAPI IMalloc_fnRealloc(LPMALLOC iface,LPVOID pv,DWORD cb) { 306 ICOM_THIS(IMalloc32Impl,iface); 307 TRACE("(%p)->Realloc(%p,%ld)\n",This,pv,cb); 308 return HeapReAlloc(GetProcessHeap(),0,pv,cb); 309 } 310 311 /****************************************************************************** 312 * IMalloc32_Free [VTABLE] 313 */ 314 static VOID WINAPI IMalloc_fnFree(LPMALLOC iface,LPVOID pv) { 315 ICOM_THIS(IMalloc32Impl,iface); 316 TRACE("(%p)->Free(%p)\n",This,pv); 317 HeapFree(GetProcessHeap(),0,pv); 318 } 319 320 /****************************************************************************** 321 * IMalloc32_GetSize [VTABLE] 322 */ 323 static DWORD WINAPI IMalloc_fnGetSize(LPMALLOC iface,LPVOID pv) { 324 ICOM_CTHIS(IMalloc,iface); 325 TRACE("(%p)->GetSize(%p)\n",This,pv); 326 return HeapSize(GetProcessHeap(),0,pv); 327 } 328 329 /****************************************************************************** 330 * IMalloc32_DidAlloc [VTABLE] 331 */ 332 static INT WINAPI IMalloc_fnDidAlloc(LPMALLOC iface,LPVOID pv) { 333 ICOM_CTHIS(IMalloc32Impl,iface); 334 TRACE("(%p)->DidAlloc(%p)\n",This,pv); 335 return -1; 336 } 337 338 /****************************************************************************** 339 * IMalloc32_HeapMinimize [VTABLE] 340 */ 341 static VOID WINAPI IMalloc_fnHeapMinimize(LPMALLOC iface) { 342 ICOM_THIS(IMalloc32Impl,iface); 343 TRACE("(%p)->HeapMinimize()\n",This); 344 } 345 346 static ICOM_VTABLE(IMalloc) VT_IMalloc32 = 347 { 348 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 349 IMalloc_fnQueryInterface, 350 IMalloc_fnAddRef, 351 IMalloc_fnRelease, 352 IMalloc_fnAlloc, 353 IMalloc_fnRealloc, 354 IMalloc_fnFree, 355 IMalloc_fnGetSize, 356 IMalloc_fnDidAlloc, 357 IMalloc_fnHeapMinimize 492 { 493 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE 494 IMallocSpy_fnQueryInterface, 495 IMallocSpy_fnAddRef, 496 IMallocSpy_fnRelease, 497 IMallocSpy_fnPreAlloc, 498 IMallocSpy_fnPostAlloc, 499 IMallocSpy_fnPreFree, 500 IMallocSpy_fnPostFree, 501 IMallocSpy_fnPreRealloc, 502 IMallocSpy_fnPostRealloc, 503 IMallocSpy_fnPreGetSize, 504 IMallocSpy_fnPostGetSize, 505 IMallocSpy_fnPreDidAlloc, 506 IMallocSpy_fnPostDidAlloc, 507 IMallocSpy_fnPreHeapMinimize, 508 IMallocSpy_fnPostHeapMinimize 358 509 }; 359 510 360 511 /****************************************************************************** 361 * IMalloc32_Constructor [VTABLE] 362 */ 363 LPMALLOC 364 IMalloc_Constructor() { 365 IMalloc32Impl* This; 366 367 This = (IMalloc32Impl*)HeapAlloc(GetProcessHeap(),0,sizeof(IMalloc32Impl)); 368 ICOM_VTBL(This) = &VT_IMalloc32; 369 This->ref = 1; 370 return (LPMALLOC)This; 371 } 372 373 /**************************************************************************** 374 * API Functions 375 */ 512 * CoGetMalloc [OLE32.20] 513 * 514 * RETURNS 515 * The win32 IMalloc 516 */ 517 HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC *lpMalloc) 518 { 519 *lpMalloc = (LPMALLOC)&Malloc32; 520 return S_OK; 521 } 522 523 /*********************************************************************** 524 * CoTaskMemAlloc [OLE32.43] 525 * RETURNS 526 * pointer to newly allocated block 527 */ 528 LPVOID WINAPI CoTaskMemAlloc(ULONG size) 529 { 530 return IMalloc_Alloc((LPMALLOC)&Malloc32,size); 531 } 532 /*********************************************************************** 533 * CoTaskMemFree [OLE32.44] 534 */ 535 VOID WINAPI CoTaskMemFree(LPVOID ptr) 536 { 537 IMalloc_Free((LPMALLOC)&Malloc32, ptr); 538 } 539 540 /*********************************************************************** 541 * CoTaskMemRealloc [OLE32.45] 542 * RETURNS 543 * pointer to newly allocated block 544 */ 545 LPVOID WINAPI CoTaskMemRealloc(LPVOID pvOld, ULONG size) 546 { 547 return IMalloc_Realloc((LPMALLOC)&Malloc32, pvOld, size); 548 } 549 550 /*********************************************************************** 551 * CoRegisterMallocSpy [OLE32.37] 552 * 553 * NOTES 554 * if a mallocspy is already registered, we cant do it again since 555 * only the spy knows, how to free a memory block 556 */ 557 HRESULT WINAPI CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy) 558 { 559 IMallocSpy* pSpy; 560 HRESULT hres = E_INVALIDARG; 561 562 TRACE("\n"); 563 564 /* HACK TO ACTIVATE OUT SPY */ 565 if (pMallocSpy == (LPVOID)-1) pMallocSpy =(IMallocSpy*)&MallocSpy; 566 567 if(Malloc32.pSpy) return CO_E_OBJISREG; 568 569 EnterCriticalSection(&IMalloc32_SpyCS); 570 571 if (SUCCEEDED(IUnknown_QueryInterface(pMallocSpy, &IID_IMallocSpy, (LPVOID*)&pSpy))) { 572 Malloc32.pSpy = pSpy; 573 hres = S_OK; 574 } 575 576 LeaveCriticalSection(&IMalloc32_SpyCS); 577 578 return hres; 579 } 580 581 /*********************************************************************** 582 * CoRevokeMallocSpy [OLE32.41] 583 * 584 * NOTES 585 * we can't rewoke a malloc spy as long as memory blocks allocated with 586 * the spy are active since only the spy knows how to free them 587 */ 588 HRESULT WINAPI CoRevokeMallocSpy(void) 589 { 590 HRESULT hres = S_OK; 591 TRACE("\n"); 592 593 EnterCriticalSection(&IMalloc32_SpyCS); 594 595 /* if it's our spy it's time to dump the leaks */ 596 if (Malloc32.pSpy == (IMallocSpy*)&MallocSpy) { 597 MallocSpyDumpLeaks(); 598 } 599 600 if (Malloc32.SpyedAllocationsLeft) { 601 TRACE("SpyReleasePending with %lu allocations left\n", Malloc32.SpyedAllocationsLeft); 602 Malloc32.SpyReleasePending = TRUE; 603 hres = E_ACCESSDENIED; 604 } else { 605 IMallocSpy_Release(Malloc32.pSpy); 606 Malloc32.pSpy = NULL; 607 } 608 LeaveCriticalSection(&IMalloc32_SpyCS); 609 610 return S_OK; 611 } 376 612 377 613 /****************************************************************************** -
trunk/src/ole32/itemmoniker.c
r8620 r9400 388 388 if (!This->itemName) 389 389 return E_OUTOFMEMORY; 390 strcpyW(This->itemName,lpszItem);390 lstrcpyW(This->itemName,lpszItem); 391 391 392 392 if (!lpszDelim) … … 395 395 delim = lpszDelim ? lpszDelim : emptystr; 396 396 397 sizeStr2= strlenW(delim);397 sizeStr2=lstrlenW(delim); 398 398 This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1)); 399 399 if (!This->itemDelimiter) { … … 401 401 return E_OUTOFMEMORY; 402 402 } 403 strcpyW(This->itemDelimiter,delim);403 lstrcpyW(This->itemDelimiter,delim); 404 404 return S_OK; 405 405 } … … 612 612 LPOLESTR dispName1,dispName2; 613 613 IBindCtx* bind; 614 HRESULT res ;614 HRESULT res = S_FALSE; 615 615 616 616 TRACE("(%p,%p)\n",iface,pmkOtherMoniker); 617 617 618 if (pmkOtherMoniker==NULL) 619 return S_FALSE; 620 621 /* This method returns S_OK if both monikers are item monikers and their display names are */ 622 /* identical (using a case-insensitive comparison); otherwise, the method returns S_FALSE. */ 623 624 IMoniker_GetClassID(pmkOtherMoniker,&clsid); 625 626 if (!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) 627 return S_FALSE; 628 629 res=CreateBindCtx(0,&bind); 630 if (FAILED(res)) 631 return res; 632 633 IMoniker_GetDisplayName(iface,bind,NULL,&dispName1); 634 IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2); 635 636 if (lstrcmpW(dispName1,dispName2)!=0) 637 return S_FALSE; 638 639 return S_OK; 618 if (!pmkOtherMoniker) return S_FALSE; 619 620 621 /* check if both are ItemMoniker */ 622 if(FAILED (IMoniker_GetClassID(pmkOtherMoniker,&clsid))) return S_FALSE; 623 if(!IsEqualCLSID(&clsid,&CLSID_ItemMoniker)) return S_FALSE; 624 625 /* check if both displaynames are the same */ 626 if(SUCCEEDED ((res = CreateBindCtx(0,&bind)))) { 627 if(SUCCEEDED (IMoniker_GetDisplayName(iface,bind,NULL,&dispName1))) { 628 if(SUCCEEDED (IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&dispName2))) { 629 if(lstrcmpW(dispName1,dispName2)==0) res = S_OK; 630 CoTaskMemFree(dispName2); 631 } 632 CoTaskMemFree(dispName1); 633 } 634 } 635 return res; 640 636 } 641 637 … … 843 839 return E_OUTOFMEMORY; 844 840 845 strcpyW(*ppszDisplayName,This->itemDelimiter);846 strcatW(*ppszDisplayName,This->itemName);841 lstrcpyW(*ppszDisplayName,This->itemDelimiter); 842 lstrcatW(*ppszDisplayName,This->itemName); 847 843 848 844 return S_OK; -
trunk/src/ole32/marshal.c
r8620 r9400 317 317 } 318 318 hres = PIPE_GetNewPipeBuf(&mid,&chanbuf); 319 if (hres) 320 FIXME("Failed to get an rpc channel buffer for %s\n",debugstr_guid(riid)); 321 IRpcProxyBuffer_Connect(rpcproxy,chanbuf); 322 IRpcProxyBuffer_Release(rpcproxy); /* no need */ 319 if (hres) { 320 ERR("Failed to get an rpc channel buffer for %s\n",debugstr_guid(riid)); 321 } else { 322 IRpcProxyBuffer_Connect(rpcproxy,chanbuf); 323 IRpcProxyBuffer_Release(rpcproxy); /* no need */ 324 } 323 325 IPSFactoryBuffer_Release(psfacbuf); 324 return S_OK;326 return hres; 325 327 } 326 328 … … 483 485 MESSAGE(" Wine registry by running: `regedit winedefault.reg'\n\n"); 484 486 } else { 485 FIXME("Failed to Marshal the interface, %lx?\n",hres); 487 if (IsEqualGUID(riid,&IID_IOleObject)) { 488 ERR("WINE currently cannot marshal IOleObject interfaces. This means you cannot embed/link OLE objects between applications.\n"); 489 } else { 490 FIXME("Failed to marshal the interface %s, %lx?\n",debugstr_guid(riid),hres); 491 } 486 492 } 487 493 goto release_marshal; -
trunk/src/ole32/ole2stubs.c
r8620 r9400 98 98 FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid)); 99 99 100 if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER , riid, (LPVOID*)&pUnk))))100 if (SUCCEEDED((hres = CoCreateInstance(rclsid, 0, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER|CLSCTX_LOCAL_SERVER , riid, (LPVOID*)&pUnk)))) 101 101 { 102 102 if (pClientSite) -
trunk/src/ole32/ole32.def
r8553 r9400 168 168 WriteStringStream = _WriteStringStream@0 @162 169 169 CoInitializeEx = _CoInitializeEx@8 @163 170 ;164 stub CoInitializeSecurity # stdcall (ptr long ptr ptr long long ptr long ptr) return 0,ERR_NOTIMPLEMENTED 170 CoInitializeSecurity = _CoInitializeSecurity@36 @164 171 171 CoCreateInstanceEx = _CoCreateInstanceEx@24 @165 172 172 PropVariantClear = _PropVariantClear@4 @166 -
trunk/src/ole32/ole32.mak
r8445 r9400 1 # $Id: ole32.mak,v 1.2 0 2002-05-16 19:26:29sandervl Exp $1 # $Id: ole32.mak,v 1.21 2002-11-12 17:06:02 sandervl Exp $ 2 2 3 3 # … … 39 39 $(OBJDIR)\bindctx.obj \ 40 40 $(OBJDIR)\compositemoniker.obj \ 41 $(OBJDIR)\compobj.obj \ 41 42 $(OBJDIR)\datacache.obj \ 42 43 $(OBJDIR)\defaulthandler.obj \ 43 44 $(OBJDIR)\errorinfo.obj \ 44 45 $(OBJDIR)\filemoniker.obj \ 46 $(OBJDIR)\ftmarshal.obj \ 45 47 $(OBJDIR)\hglobalstream.obj \ 46 48 $(OBJDIR)\initialise.obj \ … … 52 54 $(OBJDIR)\ole2.obj \ 53 55 $(OBJDIR)\oleobj.obj \ 54 $(OBJDIR)\compobj.obj \55 56 $(OBJDIR)\clipboard.obj \ 56 57 $(OBJDIR)\ole2stubs.obj \ -
trunk/src/ole32/ole32dbg.def
r8553 r9400 169 169 170 170 CoInitializeEx = _DbgCoInitializeEx@8 @163 171 ;164 stub CoInitializeSecurity # stdcall (ptr long ptr ptr long long ptr long ptr) return 0,ERR_NOTIMPLEMENTED 171 CoInitializeSecurity = _DbgCoInitializeSecurity@36 @164 172 172 CoCreateInstanceEx = _DbgCoCreateInstanceEx@24 @165 173 173 PropVariantClear = _DbgPropVariantClear@4 @166 -
trunk/src/ole32/stg_stream.c
r8636 r9400 30 30 #include "winbase.h" 31 31 #include "winerror.h" 32 #include " ntddk.h"32 #include "winternl.h" 33 33 #include "wine/debug.h" 34 34 … … 565 565 plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart, dlibMove.QuadPart ); 566 566 #endif 567 568 567 /* 569 568 * tell the caller what we calculated -
trunk/src/ole32/storage32.c
r8620 r9400 2321 2321 * Create the block chain abstractions. 2322 2322 */ 2323 This->rootBlockChain = 2324 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL); 2325 2326 This->smallBlockDepotChain = BlockChainStream_Construct( 2327 This, 2328 &This->smallBlockDepotStart, 2329 PROPERTY_NULL); 2323 if(!(This->rootBlockChain = 2324 BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL))) 2325 return STG_E_READFAULT; 2326 2327 if(!(This->smallBlockDepotChain = 2328 BlockChainStream_Construct(This, &This->smallBlockDepotStart, 2329 PROPERTY_NULL))) 2330 return STG_E_READFAULT; 2330 2331 2331 2332 /* … … 2381 2382 { 2382 2383 /* TODO CLEANUP */ 2383 return E_FAIL;2384 return STG_E_READFAULT; 2384 2385 } 2385 2386 … … 2387 2388 * Create the block chain abstraction for the small block root chain. 2388 2389 */ 2389 This->smallBlockRootChain = BlockChainStream_Construct( 2390 This, 2391 NULL, 2392 This->rootPropertySetIndex); 2390 if(!(This->smallBlockRootChain = 2391 BlockChainStream_Construct(This, NULL, This->rootPropertySetIndex))) 2392 return STG_E_READFAULT; 2393 2393 2394 2394 return hr; … … 2731 2731 * blockIndex - Index of the block to retrieve the chain 2732 2732 * for. 2733 * nextBlockIndex - receives the return value. 2733 2734 * 2734 2735 * Returns: This method returns the index of the next block in the chain. … … 2745 2746 * See Windows documentation for more details on IStorage methods. 2746 2747 */ 2747 ULONGStorageImpl_GetNextBlockInChain(2748 HRESULT StorageImpl_GetNextBlockInChain( 2748 2749 StorageImpl* This, 2749 ULONG blockIndex) 2750 ULONG blockIndex, 2751 ULONG* nextBlockIndex) 2750 2752 { 2751 2753 ULONG offsetInDepot = blockIndex * sizeof (ULONG); 2752 2754 ULONG depotBlockCount = offsetInDepot / This->bigBlockSize; 2753 2755 ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize; 2754 ULONG nextBlockIndex = BLOCK_SPECIAL;2755 2756 void* depotBuffer; 2756 2757 ULONG depotBlockIndexPos; 2757 2758 assert(depotBlockCount < This->bigBlockDepotCount); 2758 int index; 2759 2760 *nextBlockIndex = BLOCK_SPECIAL; 2761 2762 if(depotBlockCount >= This->bigBlockDepotCount) 2763 { 2764 WARN("depotBlockCount %ld, bigBlockDepotCount %ld\n", depotBlockCount, 2765 This->bigBlockDepotCount); 2766 return STG_E_READFAULT; 2767 } 2759 2768 2760 2769 /* … … 2779 2788 depotBuffer = StorageImpl_GetROBigBlock(This, depotBlockIndexPos); 2780 2789 2781 if (depotBuffer!=0) 2782 { 2783 int index; 2784 2785 for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++) 2786 { 2787 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), &nextBlockIndex); 2788 This->blockDepotCached[index] = nextBlockIndex; 2789 } 2790 2791 StorageImpl_ReleaseBigBlock(This, depotBuffer); 2792 } 2793 } 2794 2795 nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)]; 2796 2797 return nextBlockIndex; 2790 if (!depotBuffer) 2791 return STG_E_READFAULT; 2792 2793 for (index = 0; index < NUM_BLOCKS_PER_DEPOT_BLOCK; index++) 2794 { 2795 StorageUtl_ReadDWord(depotBuffer, index*sizeof(ULONG), nextBlockIndex); 2796 This->blockDepotCached[index] = *nextBlockIndex; 2797 } 2798 StorageImpl_ReleaseBigBlock(This, depotBuffer); 2799 } 2800 2801 *nextBlockIndex = This->blockDepotCached[depotBlockOffset/sizeof(ULONG)]; 2802 2803 return S_OK; 2798 2804 } 2799 2805 … … 3044 3050 StorageUtl_WriteWord(headerBigBlock, 0x1c, (WORD)-2); 3045 3051 StorageUtl_WriteDWord(headerBigBlock, 0x38, (DWORD)0x1000); 3046 StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);3047 3052 } 3048 3053 … … 3050 3055 * Write the information to the header. 3051 3056 */ 3052 if (headerBigBlock!=0) 3053 { 3054 StorageUtl_WriteWord( 3055 headerBigBlock, 3056 OFFSET_BIGBLOCKSIZEBITS, 3057 This->bigBlockSizeBits); 3058 3059 StorageUtl_WriteWord( 3060 headerBigBlock, 3061 OFFSET_SMALLBLOCKSIZEBITS, 3062 This->smallBlockSizeBits); 3063 3057 StorageUtl_WriteWord( 3058 headerBigBlock, 3059 OFFSET_BIGBLOCKSIZEBITS, 3060 This->bigBlockSizeBits); 3061 3062 StorageUtl_WriteWord( 3063 headerBigBlock, 3064 OFFSET_SMALLBLOCKSIZEBITS, 3065 This->smallBlockSizeBits); 3066 3067 StorageUtl_WriteDWord( 3068 headerBigBlock, 3069 OFFSET_BBDEPOTCOUNT, 3070 This->bigBlockDepotCount); 3071 3072 StorageUtl_WriteDWord( 3073 headerBigBlock, 3074 OFFSET_ROOTSTARTBLOCK, 3075 This->rootStartBlock); 3076 3077 StorageUtl_WriteDWord( 3078 headerBigBlock, 3079 OFFSET_SBDEPOTSTART, 3080 This->smallBlockDepotStart); 3081 3082 StorageUtl_WriteDWord( 3083 headerBigBlock, 3084 OFFSET_SBDEPOTCOUNT, 3085 This->smallBlockDepotChain ? 3086 BlockChainStream_GetCount(This->smallBlockDepotChain) : 0); 3087 3088 StorageUtl_WriteDWord( 3089 headerBigBlock, 3090 OFFSET_EXTBBDEPOTSTART, 3091 This->extBigBlockDepotStart); 3092 3093 StorageUtl_WriteDWord( 3094 headerBigBlock, 3095 OFFSET_EXTBBDEPOTCOUNT, 3096 This->extBigBlockDepotCount); 3097 3098 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 3099 { 3064 3100 StorageUtl_WriteDWord( 3065 3101 headerBigBlock, 3066 OFFSET_BBDEPOTCOUNT, 3067 This->bigBlockDepotCount); 3068 3069 StorageUtl_WriteDWord( 3070 headerBigBlock, 3071 OFFSET_ROOTSTARTBLOCK, 3072 This->rootStartBlock); 3073 3074 StorageUtl_WriteDWord( 3075 headerBigBlock, 3076 OFFSET_SBDEPOTSTART, 3077 This->smallBlockDepotStart); 3078 3079 StorageUtl_WriteDWord( 3080 headerBigBlock, 3081 OFFSET_EXTBBDEPOTSTART, 3082 This->extBigBlockDepotStart); 3083 3084 StorageUtl_WriteDWord( 3085 headerBigBlock, 3086 OFFSET_EXTBBDEPOTCOUNT, 3087 This->extBigBlockDepotCount); 3088 3089 for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++) 3090 { 3091 StorageUtl_WriteDWord( 3092 headerBigBlock, 3093 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 3094 (This->bigBlockDepotStart[index])); 3095 } 3102 OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index), 3103 (This->bigBlockDepotStart[index])); 3096 3104 } 3097 3105 … … 3382 3390 &bbHeadOfChain, 3383 3391 PROPERTY_NULL); 3384 3392 if(!bbTempChain) return NULL; 3385 3393 /* 3386 3394 * Grow the big block chain. … … 4163 4171 newStream->tailIndex = blockIndex; 4164 4172 4165 blockIndex = StorageImpl_GetNextBlockInChain( 4166 parentStorage, 4167 blockIndex); 4173 if(FAILED(StorageImpl_GetNextBlockInChain( 4174 parentStorage, 4175 blockIndex, 4176 &blockIndex))) 4177 { 4178 HeapFree(GetProcessHeap(), 0, newStream); 4179 return NULL; 4180 } 4168 4181 } 4169 4182 … … 4226 4239 count++; 4227 4240 4228 blockIndex =StorageImpl_GetNextBlockInChain(4241 if(FAILED(StorageImpl_GetNextBlockInChain( 4229 4242 This->parentStorage, 4230 blockIndex); 4243 blockIndex, 4244 &blockIndex))) 4245 return 0; 4231 4246 } 4232 4247 … … 4275 4290 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4276 4291 { 4277 blockIndex = 4278 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4279 4292 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex))) 4293 return FALSE; 4280 4294 blockNoInSequence--; 4281 4295 } … … 4310 4324 * Step to the next big block. 4311 4325 */ 4312 blockIndex =4313 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);4326 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex))) 4327 return FALSE; 4314 4328 4315 4329 bufferWalker += bytesToReadInBuffer; … … 4364 4378 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 4365 4379 { 4366 blockIndex =4367 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4368 4380 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4381 &blockIndex))) 4382 return FALSE; 4369 4383 blockNoInSequence--; 4370 4384 } … … 4399 4413 * Step to the next big block. 4400 4414 */ 4401 blockIndex =4402 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4403 4415 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4416 &blockIndex))) 4417 return FALSE; 4404 4418 bufferWalker += bytesToWrite; 4405 4419 size -= bytesToWrite; … … 4444 4458 while (count < numBlocks) 4445 4459 { 4446 blockIndex =4447 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4448 4460 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4461 &blockIndex))) 4462 return FALSE; 4449 4463 count++; 4450 4464 } 4451 4465 4452 4466 /* Get the next block before marking the new end */ 4453 extraBlock = 4454 StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex); 4467 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, 4468 &extraBlock))) 4469 return FALSE; 4455 4470 4456 4471 /* Mark the new end of chain */ … … 4468 4483 while (extraBlock != BLOCK_END_OF_CHAIN) 4469 4484 { 4470 blockIndex =4471 StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock); 4472 4485 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock, 4486 &blockIndex))) 4487 return FALSE; 4473 4488 StorageImpl_FreeBigBlock(This->parentStorage, extraBlock); 4474 4489 extraBlock = blockIndex; … … 4548 4563 currentBlock = blockIndex; 4549 4564 4550 blockIndex = 4551 StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock); 4565 if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock, 4566 &blockIndex))) 4567 return FALSE; 4552 4568 } 4553 4569 … … 4736 4752 * - BLOCK_UNUSED: small block 'blockIndex' is free 4737 4753 */ 4738 ULONGSmallBlockChainStream_GetNextBlockInChain(4754 HRESULT SmallBlockChainStream_GetNextBlockInChain( 4739 4755 SmallBlockChainStream* This, 4740 ULONG blockIndex) 4756 ULONG blockIndex, 4757 ULONG* nextBlockInChain) 4741 4758 { 4742 4759 ULARGE_INTEGER offsetOfBlockInDepot; 4743 4760 DWORD buffer; 4744 ULONG nextBlockInChain = BLOCK_END_OF_CHAIN;4745 4761 ULONG bytesRead; 4746 4762 BOOL success; 4763 4764 *nextBlockInChain = BLOCK_END_OF_CHAIN; 4747 4765 4748 4766 offsetOfBlockInDepot.s.HighPart = 0; … … 4761 4779 if (success) 4762 4780 { 4763 StorageUtl_ReadDWord(&buffer, 0, &nextBlockInChain); 4764 } 4765 4766 return nextBlockInChain; 4781 StorageUtl_ReadDWord(&buffer, 0, nextBlockInChain); 4782 return S_OK; 4783 } 4784 4785 return STG_E_READFAULT; 4767 4786 } 4768 4787 … … 4869 4888 { 4870 4889 sbdIndex = nextBlock; 4871 nextBlock = 4872 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex); 4890 StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex, &nextBlock); 4873 4891 } 4874 4892 … … 5007 5025 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 5008 5026 { 5009 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5010 5027 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5028 &blockIndex))) 5029 return FALSE; 5011 5030 blockNoInSequence--; 5012 5031 } … … 5049 5068 * Step to the next big block. 5050 5069 */ 5051 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5070 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5071 return FALSE; 5052 5072 bufferWalker += bytesToReadInBuffer; 5053 5073 size -= bytesToReadInBuffer; … … 5095 5115 while ( (blockNoInSequence > 0) && (blockIndex != BLOCK_END_OF_CHAIN)) 5096 5116 { 5097 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);5098 5117 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5118 return FALSE; 5099 5119 blockNoInSequence--; 5100 5120 } … … 5139 5159 * Step to the next big block. 5140 5160 */ 5141 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5161 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5162 &blockIndex))) 5163 return FALSE; 5142 5164 bufferWalker += bytesToWriteInBuffer; 5143 5165 size -= bytesToWriteInBuffer; … … 5174 5196 while (count < numBlocks) 5175 5197 { 5176 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5198 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5199 &blockIndex))) 5200 return FALSE; 5177 5201 count++; 5178 5202 } … … 5204 5228 { 5205 5229 /* Get the next block before marking the new end */ 5206 extraBlock = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5230 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, 5231 &extraBlock))) 5232 return FALSE; 5207 5233 5208 5234 /* Mark the new end of chain */ … … 5218 5244 while (extraBlock != BLOCK_END_OF_CHAIN) 5219 5245 { 5220 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, extraBlock); 5246 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, extraBlock, 5247 &blockIndex))) 5248 return FALSE; 5221 5249 SmallBlockChainStream_FreeBlock(This, extraBlock); 5222 5250 extraBlock = blockIndex; … … 5281 5309 oldNumBlocks++; 5282 5310 currentBlock = blockIndex; 5283 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, currentBlock); 5311 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, currentBlock, &blockIndex))) 5312 return FALSE; 5284 5313 } 5285 5314 … … 5321 5350 count++; 5322 5351 5323 blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex); 5352 if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex))) 5353 return 0; 5324 5354 } 5325 5355 … … 5744 5774 newStorage, 5745 5775 0, 5746 0,5776 0, 5747 5777 plkbyt, 5748 5778 grfMode, -
trunk/src/ole32/storage32.h
r8441 r9400 7 7 * 8 8 * This include file contains definitions of types and function 9 * prototypes that are used in the many files implementing the 9 * prototypes that are used in the many files implementing the 10 10 * storage functionality 11 11 * … … 43 43 static const ULONG OFFSET_ROOTSTARTBLOCK = 0x00000030; 44 44 static const ULONG OFFSET_SBDEPOTSTART = 0x0000003C; 45 static const ULONG OFFSET_SBDEPOTCOUNT = 0x00000040; 45 46 static const ULONG OFFSET_EXTBBDEPOTSTART = 0x00000044; 46 47 static const ULONG OFFSET_EXTBBDEPOTCOUNT = 0x00000048; … … 50 51 static const ULONG OFFSET_PS_PROPERTYTYPE = 0x00000042; 51 52 static const ULONG OFFSET_PS_PREVIOUSPROP = 0x00000044; 52 static const ULONG OFFSET_PS_NEXTPROP = 0x00000048; 53 static const ULONG OFFSET_PS_NEXTPROP = 0x00000048; 53 54 static const ULONG OFFSET_PS_DIRPROP = 0x0000004C; 54 55 static const ULONG OFFSET_PS_GUID = 0x00000050; … … 57 58 static const ULONG OFFSET_PS_TSS2 = 0x0000006C; 58 59 static const ULONG OFFSET_PS_TSD2 = 0x00000070; 59 static const ULONG OFFSET_PS_STARTBLOCK = 0x00000074; 60 static const ULONG OFFSET_PS_SIZE = 0x00000078; 60 static const ULONG OFFSET_PS_STARTBLOCK = 0x00000074; 61 static const ULONG OFFSET_PS_SIZE = 0x00000078; 61 62 static const WORD DEF_BIG_BLOCK_SIZE_BITS = 0x0009; 62 63 static const WORD DEF_SMALL_BLOCK_SIZE_BITS = 0x0006; … … 70 71 71 72 #define PROPERTY_NAME_MAX_LEN 0x20 72 #define PROPERTY_NAME_BUFFER_LEN 0x40 73 #define PROPERTY_NAME_BUFFER_LEN 0x40 73 74 74 75 #define PROPSET_BLOCK_SIZE 0x00000080 … … 142 143 * 143 144 * The big block file is an abstraction of a flat file separated in 144 * same sized blocks. The implementation for the methods described in 145 * same sized blocks. The implementation for the methods described in 145 146 * this section appear in stg_bigblockfile.c 146 147 */ … … 209 210 */ 210 211 ULONG ref; 211 212 /* 213 * Ancestor storage (top level) 214 */ 215 StorageImpl* ancestorStorage; 216 212 213 /* 214 * Ancestor storage (top level) 215 */ 216 StorageImpl* ancestorStorage; 217 217 218 /* 218 219 * Index of the property for the root of … … 220 221 */ 221 222 ULONG rootPropertySetIndex; 222 223 /* 223 224 /* 224 225 * virtual Destructor method. 225 226 */ … … 235 236 REFIID riid, 236 237 void** ppvObject); 237 238 ULONG WINAPI StorageBaseImpl_AddRef( 238 239 ULONG WINAPI StorageBaseImpl_AddRef( 239 240 IStorage* iface); 240 241 ULONG WINAPI StorageBaseImpl_Release( 241 242 ULONG WINAPI StorageBaseImpl_Release( 242 243 IStorage* iface); 243 244 HRESULT WINAPI StorageBaseImpl_OpenStream( 244 245 HRESULT WINAPI StorageBaseImpl_OpenStream( 245 246 IStorage* iface, 246 247 const OLECHAR* pwcsName, /* [string][in] */ 247 248 void* reserved1, /* [unique][in] */ 248 DWORD grfMode, /* [in] */ 249 DWORD reserved2, /* [in] */ 250 IStream** ppstm); /* [out] */ 251 252 HRESULT WINAPI StorageBaseImpl_OpenStorage( 249 DWORD grfMode, /* [in] */ 250 DWORD reserved2, /* [in] */ 251 IStream** ppstm); /* [out] */ 252 253 HRESULT WINAPI StorageBaseImpl_OpenStorage( 253 254 IStorage* iface, 254 const OLECHAR* pwcsName, /* [string][unique][in] */ 255 IStorage* pstgPriority, /* [unique][in] */ 256 DWORD grfMode, /* [in] */ 257 SNB snbExclude, /* [unique][in] */ 258 DWORD reserved, /* [in] */ 259 IStorage** ppstg); /* [out] */ 260 261 HRESULT WINAPI StorageBaseImpl_EnumElements( 255 const OLECHAR* pwcsName, /* [string][unique][in] */ 256 IStorage* pstgPriority, /* [unique][in] */ 257 DWORD grfMode, /* [in] */ 258 SNB snbExclude, /* [unique][in] */ 259 DWORD reserved, /* [in] */ 260 IStorage** ppstg); /* [out] */ 261 262 HRESULT WINAPI StorageBaseImpl_EnumElements( 262 263 IStorage* iface, 263 DWORD reserved1, /* [in] */ 264 void* reserved2, /* [size_is][unique][in] */ 265 DWORD reserved3, /* [in] */ 266 IEnumSTATSTG** ppenum); /* [out] */ 267 268 HRESULT WINAPI StorageBaseImpl_Stat( 264 DWORD reserved1, /* [in] */ 265 void* reserved2, /* [size_is][unique][in] */ 266 DWORD reserved3, /* [in] */ 267 IEnumSTATSTG** ppenum); /* [out] */ 268 269 HRESULT WINAPI StorageBaseImpl_Stat( 269 270 IStorage* iface, 270 STATSTG* pstatstg, /* [out] */ 271 DWORD grfStatFlag); /* [in] */ 271 STATSTG* pstatstg, /* [out] */ 272 DWORD grfStatFlag); /* [in] */ 272 273 273 274 HRESULT WINAPI StorageBaseImpl_RenameElement( … … 304 305 */ 305 306 ULONG ref; 306 struct StorageImpl* ancestorStorage; 307 struct StorageImpl* ancestorStorage; 307 308 ULONG rootPropertySetIndex; 308 309 void (*v_destructor)(struct StorageImpl*); 309 310 310 311 /* 311 312 * The following data members are specific to the Storage32Impl … … 341 342 BlockChainStream* rootBlockChain; 342 343 BlockChainStream* smallBlockDepotChain; 343 BlockChainStream* smallBlockRootChain; 344 BlockChainStream* smallBlockRootChain; 344 345 345 346 /* 346 347 * Pointer to the big block file abstraction 347 348 */ 348 BigBlockFile* bigBlockFile; 349 BigBlockFile* bigBlockFile; 349 350 }; 350 351 351 352 /* 352 353 * Method declaration for the Storage32Impl class 353 */ 354 355 HRESULT WINAPI StorageImpl_CreateStorage( 354 */ 355 356 HRESULT WINAPI StorageImpl_CreateStorage( 356 357 IStorage* iface, 357 const OLECHAR* pwcsName, /* [string][in] */ 358 DWORD grfMode, /* [in] */ 359 DWORD dwStgFmt, /* [in] */ 360 DWORD reserved2, /* [in] */ 361 IStorage** ppstg); /* [out] */ 362 363 HRESULT WINAPI StorageImpl_CopyTo( 358 const OLECHAR* pwcsName, /* [string][in] */ 359 DWORD grfMode, /* [in] */ 360 DWORD dwStgFmt, /* [in] */ 361 DWORD reserved2, /* [in] */ 362 IStorage** ppstg); /* [out] */ 363 364 HRESULT WINAPI StorageImpl_CopyTo( 364 365 IStorage* iface, 365 DWORD ciidExclude, /* [in] */ 366 const IID* rgiidExclude, /* [size_is][unique][in] */ 367 SNB snbExclude, /* [unique][in] */ 368 IStorage* pstgDest); /* [unique][in] */ 369 370 HRESULT WINAPI StorageImpl_MoveElementTo( 366 DWORD ciidExclude, /* [in] */ 367 const IID* rgiidExclude, /* [size_is][unique][in] */ 368 SNB snbExclude, /* [unique][in] */ 369 IStorage* pstgDest); /* [unique][in] */ 370 371 HRESULT WINAPI StorageImpl_MoveElementTo( 371 372 IStorage* iface, 372 const OLECHAR* pwcsName, /* [string][in] */ 373 IStorage* pstgDest, /* [unique][in] */ 374 const OLECHAR* pwcsNewName, /* [string][in] */ 375 DWORD grfFlags); /* [in] */ 376 377 HRESULT WINAPI StorageImpl_Commit( 373 const OLECHAR* pwcsName, /* [string][in] */ 374 IStorage* pstgDest, /* [unique][in] */ 375 const OLECHAR* pwcsNewName, /* [string][in] */ 376 DWORD grfFlags); /* [in] */ 377 378 HRESULT WINAPI StorageImpl_Commit( 378 379 IStorage* iface, 379 DWORD grfCommitFlags); /* [in] */ 380 381 HRESULT WINAPI StorageImpl_Revert( 380 DWORD grfCommitFlags); /* [in] */ 381 382 HRESULT WINAPI StorageImpl_Revert( 382 383 IStorage* iface); 383 384 HRESULT WINAPI StorageImpl_DestroyElement( 384 385 HRESULT WINAPI StorageImpl_DestroyElement( 385 386 IStorage* iface, 386 const OLECHAR* pwcsName); /* [string][in] */ 387 388 HRESULT WINAPI StorageImpl_SetElementTimes( 387 const OLECHAR* pwcsName); /* [string][in] */ 388 389 HRESULT WINAPI StorageImpl_SetElementTimes( 389 390 IStorage* iface, 390 const OLECHAR* pwcsName, /* [string][in] */ 391 const FILETIME* pctime, /* [in] */ 392 const FILETIME* patime, /* [in] */ 393 const FILETIME* pmtime); /* [in] */ 394 395 HRESULT WINAPI StorageImpl_SetStateBits( 391 const OLECHAR* pwcsName, /* [string][in] */ 392 const FILETIME* pctime, /* [in] */ 393 const FILETIME* patime, /* [in] */ 394 const FILETIME* pmtime); /* [in] */ 395 396 HRESULT WINAPI StorageImpl_SetStateBits( 396 397 IStorage* iface, 397 DWORD grfStateBits, /* [in] */ 398 DWORD grfMask); /* [in] */ 398 DWORD grfStateBits, /* [in] */ 399 DWORD grfMask); /* [in] */ 399 400 400 401 HRESULT WINAPI StorageImpl_Stat(IStorage* iface, … … 443 444 ULONG blockIndex); 444 445 445 ULONG StorageImpl_GetNextBlockInChain( 446 StorageImpl* This, 447 ULONG blockIndex); 446 HRESULT StorageImpl_GetNextBlockInChain( 447 StorageImpl* This, 448 ULONG blockIndex, 449 ULONG* nextBlockIndex); 448 450 449 451 void StorageImpl_SetNextBlockInChain( 450 452 StorageImpl* This, 451 453 ULONG blockIndex, 452 454 ULONG nextBlock); 453 455 454 456 HRESULT StorageImpl_LoadFileHeader( … … 503 505 */ 504 506 ULONG ref; 505 struct StorageImpl* ancestorStorage; 507 struct StorageImpl* ancestorStorage; 506 508 ULONG rootPropertySetIndex; 507 509 void (*v_destructor)(struct StorageInternalImpl*); … … 516 518 */ 517 519 StorageInternalImpl* StorageInternalImpl_Construct( 518 StorageImpl* ancestorStorage, 520 StorageImpl* ancestorStorage, 519 521 ULONG rootTropertyIndex); 520 522 … … 522 524 StorageInternalImpl* This); 523 525 524 HRESULT WINAPI StorageInternalImpl_Commit( 526 HRESULT WINAPI StorageInternalImpl_Commit( 525 527 IStorage* iface, 526 DWORD grfCommitFlags); /* [in] */ 527 528 HRESULT WINAPI StorageInternalImpl_Revert( 528 DWORD grfCommitFlags); /* [in] */ 529 530 HRESULT WINAPI StorageInternalImpl_Revert( 529 531 IStorage* iface); 530 532 … … 541 543 ICOM_VFIELD(IEnumSTATSTG); /* Needs to be the first item in the struct 542 544 * since we want to cast this in a IEnumSTATSTG pointer */ 543 545 544 546 ULONG ref; /* Reference count */ 545 547 StorageImpl* parentStorage; /* Reference to the parent storage */ … … 565 567 REFIID riid, 566 568 void** ppvObject); 567 569 568 570 ULONG WINAPI IEnumSTATSTGImpl_AddRef( 569 IEnumSTATSTG* iface); 570 571 IEnumSTATSTG* iface); 572 571 573 ULONG WINAPI IEnumSTATSTGImpl_Release( 572 574 IEnumSTATSTG* iface); 573 575 574 576 HRESULT WINAPI IEnumSTATSTGImpl_Next( 575 577 IEnumSTATSTG* iface, … … 577 579 STATSTG* rgelt, 578 580 ULONG* pceltFetched); 579 581 580 582 HRESULT WINAPI IEnumSTATSTGImpl_Skip( 581 583 IEnumSTATSTG* iface, 582 584 ULONG celt); 583 585 584 586 HRESULT WINAPI IEnumSTATSTGImpl_Reset( 585 587 IEnumSTATSTG* iface); 586 588 587 589 HRESULT WINAPI IEnumSTATSTGImpl_Clone( 588 590 IEnumSTATSTG* iface, … … 626 628 ICOM_VFIELD(IStream); /* Needs to be the first item in the struct 627 629 * since we want to cast this in a IStream pointer */ 628 630 629 631 /* 630 632 * Reference count … … 656 658 */ 657 659 ULARGE_INTEGER currentPosition; 658 660 659 661 /* 660 662 * The information in the stream is represented by a chain of small blocks … … 682 684 HRESULT WINAPI StgStreamImpl_QueryInterface( 683 685 IStream* iface, 684 REFIID riid, /* [in] */ 685 void** ppvObject); /* [iid_is][out] */ 686 686 REFIID riid, /* [in] */ 687 void** ppvObject); /* [iid_is][out] */ 688 687 689 ULONG WINAPI StgStreamImpl_AddRef( 688 690 IStream* iface); 689 691 690 692 ULONG WINAPI StgStreamImpl_Release( 691 693 IStream* iface); 692 693 HRESULT WINAPI StgStreamImpl_Read( 694 695 HRESULT WINAPI StgStreamImpl_Read( 694 696 IStream* iface, 695 697 void* pv, /* [length_is][size_is][out] */ 696 ULONG cb, /* [in] */ 697 ULONG* pcbRead); /* [out] */ 698 698 ULONG cb, /* [in] */ 699 ULONG* pcbRead); /* [out] */ 700 699 701 HRESULT WINAPI StgStreamImpl_Write( 700 702 IStream* iface, 701 const void* pv, /* [size_is][in] */ 702 ULONG cb, /* [in] */ 703 ULONG* pcbWritten); /* [out] */ 704 705 HRESULT WINAPI StgStreamImpl_Seek( 703 const void* pv, /* [size_is][in] */ 704 ULONG cb, /* [in] */ 705 ULONG* pcbWritten); /* [out] */ 706 707 HRESULT WINAPI StgStreamImpl_Seek( 706 708 IStream* iface, 707 LARGE_INTEGER dlibMove, /* [in] */ 708 DWORD dwOrigin, /* [in] */ 709 LARGE_INTEGER dlibMove, /* [in] */ 710 DWORD dwOrigin, /* [in] */ 709 711 ULARGE_INTEGER* plibNewPosition); /* [out] */ 710 711 HRESULT WINAPI StgStreamImpl_SetSize( 712 713 HRESULT WINAPI StgStreamImpl_SetSize( 712 714 IStream* iface, 713 ULARGE_INTEGER libNewSize); /* [in] */ 714 715 HRESULT WINAPI StgStreamImpl_CopyTo( 715 ULARGE_INTEGER libNewSize); /* [in] */ 716 717 HRESULT WINAPI StgStreamImpl_CopyTo( 716 718 IStream* iface, 717 IStream* pstm, /* [unique][in] */ 718 ULARGE_INTEGER cb, /* [in] */ 719 ULARGE_INTEGER* pcbRead, /* [out] */ 720 ULARGE_INTEGER* pcbWritten); /* [out] */ 721 722 HRESULT WINAPI StgStreamImpl_Commit( 719 IStream* pstm, /* [unique][in] */ 720 ULARGE_INTEGER cb, /* [in] */ 721 ULARGE_INTEGER* pcbRead, /* [out] */ 722 ULARGE_INTEGER* pcbWritten); /* [out] */ 723 724 HRESULT WINAPI StgStreamImpl_Commit( 723 725 IStream* iface, 724 DWORD grfCommitFlags); /* [in] */ 725 726 HRESULT WINAPI StgStreamImpl_Revert( 726 DWORD grfCommitFlags); /* [in] */ 727 728 HRESULT WINAPI StgStreamImpl_Revert( 727 729 IStream* iface); 728 729 HRESULT WINAPI StgStreamImpl_LockRegion( 730 731 HRESULT WINAPI StgStreamImpl_LockRegion( 730 732 IStream* iface, 731 ULARGE_INTEGER libOffset, /* [in] */ 732 ULARGE_INTEGER cb, /* [in] */ 733 DWORD dwLockType); /* [in] */ 734 735 HRESULT WINAPI StgStreamImpl_UnlockRegion( 733 ULARGE_INTEGER libOffset, /* [in] */ 734 ULARGE_INTEGER cb, /* [in] */ 735 DWORD dwLockType); /* [in] */ 736 737 HRESULT WINAPI StgStreamImpl_UnlockRegion( 736 738 IStream* iface, 737 ULARGE_INTEGER libOffset, /* [in] */ 738 ULARGE_INTEGER cb, /* [in] */ 739 DWORD dwLockType); /* [in] */ 740 741 HRESULT WINAPI StgStreamImpl_Stat( 739 ULARGE_INTEGER libOffset, /* [in] */ 740 ULARGE_INTEGER cb, /* [in] */ 741 DWORD dwLockType); /* [in] */ 742 743 HRESULT WINAPI StgStreamImpl_Stat( 742 744 IStream* iface, 743 745 STATSTG* pstatstg, /* [out] */ 744 DWORD grfStatFlag); /* [in] */ 745 746 HRESULT WINAPI StgStreamImpl_Clone( 746 DWORD grfStatFlag); /* [in] */ 747 748 HRESULT WINAPI StgStreamImpl_Clone( 747 749 IStream* iface, 748 IStream** ppstm); /* [out] */ 750 IStream** ppstm); /* [out] */ 749 751 750 752 751 753 /******************************************************************************** 752 754 * The StorageUtl_ functions are miscelaneous utility functions. Most of which are 753 * abstractions used to read values from file buffers without having to worry 755 * abstractions used to read values from file buffers without having to worry 754 756 * about bit order 755 757 */ … … 785 787 */ 786 788 BlockChainStream* BlockChainStream_Construct( 787 StorageImpl* parentStorage, 789 StorageImpl* parentStorage, 788 790 ULONG* headOfStreamPlaceHolder, 789 791 ULONG propertyIndex); … … 835 837 */ 836 838 SmallBlockChainStream* SmallBlockChainStream_Construct( 837 StorageImpl* parentStorage, 839 StorageImpl* parentStorage, 838 840 ULONG propertyIndex); 839 841 … … 844 846 SmallBlockChainStream* This); 845 847 846 ULONGSmallBlockChainStream_GetNextBlockInChain(848 HRESULT SmallBlockChainStream_GetNextBlockInChain( 847 849 SmallBlockChainStream* This, 848 ULONG blockIndex); 850 ULONG blockIndex, 851 ULONG* nextBlockIndex); 849 852 850 853 void SmallBlockChainStream_SetNextBlockInChain( … … 886 889 887 890 #endif /* __STORAGE32_H__ */ 888 889 890 -
trunk/src/ole32/stubs.cpp
r7958 r9400 1 /* $Id: stubs.cpp,v 1.2 1 2002-02-19 12:34:50sandervl Exp $ */1 /* $Id: stubs.cpp,v 1.22 2002-11-12 17:06:03 sandervl Exp $ */ 2 2 /* 3 3 * Win32 COM/OLE stubs for OS/2 … … 80 80 //******************************************************************************* 81 81 //******************************************************************************* 82 HRESULT WIN32API CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy)83 {84 dprintf(("OLE32: CoRegisterMallocSpy - stub"));85 return CO_E_OBJISREG;86 }87 //*******************************************************************************88 //*******************************************************************************89 82 HRESULT WIN32API CoReleaseMarshalData(IStream *pStm) 90 83 { 91 84 dprintf(("OLE32: CoReleaseMarshalData - stub")); 92 85 return E_OUTOFMEMORY; 93 }94 //*******************************************************************************95 //*******************************************************************************96 HRESULT WIN32API CoRevokeMallocSpy()97 {98 dprintf(("OLE32: CoRevokeMallocSpy - stub"));99 return E_ACCESSDENIED;100 86 } 101 87 //******************************************************************************* … … 337 323 { 338 324 dprintf(("OLE32: CoImpersonateClient - Stub")); 339 return(S_OK);340 }341 342 //*******************************************************************************343 //*******************************************************************************344 HRESULT WIN32API CoInitializeSecurity( // DCOM - obj_clientserver.h345 PSECURITY_DESCRIPTOR pSecDesc,346 LONG cAuthSvc,347 SOLE_AUTHENTICATION_SERVICE *asAuthSvc,348 void *pReserved1,349 DWORD dwAuthnLevel,350 DWORD dwImpLevel,351 void *pReserved2,352 DWORD dwCapabilities,353 void *pReserved3 )354 {355 dprintf(("OLE32: CoInitializeSecurity - Stub"));356 325 return(S_OK); 357 326 } -
trunk/src/oleaut32/dbgwrap.cpp
r8450 r9400 303 303 NODEF_DEBUGWRAP16(VarBstrCmp) 304 304 DEBUGWRAP12(VarCat) 305 306 305 NODEF_DEBUGWRAP8(SafeArrayGetVartype) 306 NODEF_DEBUGWRAP24(VarFormat) 307 NODEF_DEBUGWRAP16(VarFormatDateTime) 308 //NODEF_DEBUGWRAP28(VarFormatNumber) 309 //NODEF_DEBUGWRAP28(VarFormatPercent) 310 NODEF_DEBUGWRAP28(VarFormatCurrency) 311 NODEF_DEBUGWRAP24(VarFormatFromTokens) 312 NODEF_DEBUGWRAP28(VarTokenizeFormatString) 313 DEBUGWRAP12(VarAnd) 314 DEBUGWRAP8(VarNot) 315 DEBUGWRAP16(VarCmp) 316 NODEF_DEBUGWRAP16(VarCyMulI4) 317 -
trunk/src/oleaut32/ole2disp.c
r8450 r9400 76 76 { 77 77 BSTR16 out; 78 78 79 79 if (!in) return 0; 80 80 81 81 out = BSTR_AllocBytes(strlen(in)+1); 82 82 if (!out) return 0; … … 95 95 { 96 96 if (!in) return 0; 97 97 98 98 /* Delegate this to the SysAllocStringLen32 method. */ 99 99 return SysAllocStringLen(in, lstrlenW(in)); … … 119 119 * Sanity check 120 120 */ 121 if (old==NULL) 121 if (old==NULL) 122 122 return 0; 123 123 … … 125 125 * Make sure we free the old string. 126 126 */ 127 if (*old!=NULL) 127 if (*old!=NULL) 128 128 SysFreeString(*old); 129 129 … … 166 166 * he describes it as a "DWORD count of characters". By experimenting with 167 167 * a windows application, this count seems to be a DWORD count of bytes in 168 * the string. Meaning that the count is double the number of wide 168 * the string. Meaning that the count is double the number of wide 169 169 * characters in the string. 170 170 */ … … 237 237 } 238 238 239 239 240 240 /****************************************************************************** 241 241 * SysReAllocStringLen [OLEAUT32.5] … … 246 246 * Sanity check 247 247 */ 248 if (old==NULL) 248 if (old==NULL) 249 249 return 0; 250 250 … … 252 252 * Make sure we free the old string. 253 253 */ 254 if (*old!=NULL) 254 if (*old!=NULL) 255 255 SysFreeString(*old); 256 256 … … 277 277 { 278 278 DWORD* bufferPointer; 279 279 280 280 /* NULL is a valid parameter */ 281 281 if(!in) return; … … 318 318 if (!str) return 0; 319 319 /* 320 * The length of the string (in bytes) is contained in a DWORD placed 320 * The length of the string (in bytes) is contained in a DWORD placed 321 321 * just before the BSTR pointer 322 322 */ … … 342 342 if (!str) return 0; 343 343 /* 344 * The length of the string (in bytes) is contained in a DWORD placed 344 * The length of the string (in bytes) is contained in a DWORD placed 345 345 * just before the BSTR pointer 346 346 */ … … 419 419 * Converts an OLE_COLOR to a COLORREF. 420 420 * See the documentation for conversion rules. 421 * pColorRef can be NULL. In that case the user only wants to test the 421 * pColorRef can be NULL. In that case the user only wants to test the 422 422 * conversion. 423 423 */ … … 430 430 BYTE b = HIBYTE(HIWORD(clr)); 431 431 432 TRACE("(%08lx, % d, %p):stub\n", clr, hpal, pColorRef);432 TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef); 433 433 434 434 /* -
trunk/src/oleaut32/oleaut32.def
r7916 r9400 1 ;/* $Id: oleaut32.def,v 1. 9 2002-02-15 15:07:37sandervl Exp $ */1 ;/* $Id: oleaut32.def,v 1.10 2002-11-12 17:07:46 sandervl Exp $ */ 2 2 LIBRARY OLAUTOS2 INITINSTANCE 3 3 DESCRIPTION 'Odin32 System DLL - OleAut32' … … 5 5 6 6 EXPORTS 7 DllGetClassObject = _OLEAUT32_DllGetClassObject@12 @1 8 SysAllocString = _SysAllocString@4 @2 9 SysReAllocString = _SysReAllocString@8 @3 10 SysAllocStringLen = _SysAllocStringLen@8 @4 11 SysReAllocStringLen = _SysReAllocStringLen@12 @5 12 SysFreeString = _SysFreeString@4 @6 13 SysStringLen = _SysStringLen@4 @7 14 VariantInit = _VariantInit@4 @8 15 VariantClear = _VariantClear@4 @9 16 VariantCopy = _VariantCopy@8 @10 17 VariantCopyInd = _VariantCopyInd@8 @11 18 VariantChangeType = _VariantChangeType@16 @12 19 VariantTimeToDosDateTime = _VariantTimeToDosDateTime@16 @13 20 DosDateTimeToVariantTime = _DosDateTimeToVariantTime@12 @14 21 SafeArrayCreate = _SafeArrayCreate@12 @15 22 SafeArrayDestroy = _SafeArrayDestroy@4 @16 23 SafeArrayGetDim = _SafeArrayGetDim@4 @17 24 SafeArrayGetElemsize = _SafeArrayGetElemsize@4 @18 25 SafeArrayGetUBound = _SafeArrayGetUBound@12 @19 26 SafeArrayGetLBound = _SafeArrayGetLBound@12 @20 27 SafeArrayLock = _SafeArrayLock@4 @21 28 SafeArrayUnlock = _SafeArrayUnlock@4 @22 29 SafeArrayAccessData = _SafeArrayAccessData@8 @23 30 SafeArrayUnaccessData = _SafeArrayUnaccessData@4 @24 31 SafeArrayGetElement = _SafeArrayGetElement@12 @25 32 SafeArrayPutElement = _SafeArrayPutElement@12 @26 33 SafeArrayCopy = _SafeArrayCopy@8 @27 34 DispGetParam = _DispGetParam@20 @28 35 DispGetIDsOfNames = _DispGetIDsOfNames@16 @29 36 DispInvoke = _DispInvoke@32 @30 37 CreateDispTypeInfo = _CreateDispTypeInfo@12 @31 38 CreateStdDispatch = _CreateStdDispatch@16 @32 39 RegisterActiveObject = _RegisterActiveObject@16 @33 40 RevokeActiveObject = _RevokeActiveObject@8 @34 41 GetActiveObject = _GetActiveObject@12 @35 42 SafeArrayAllocDescriptor = _SafeArrayAllocDescriptor@8 @36 43 SafeArrayAllocData = _SafeArrayAllocData@4 @37 44 SafeArrayDestroyDescriptor = _SafeArrayDestroyDescriptor@4 @38 45 SafeArrayDestroyData = _SafeArrayDestroyData@4 @39 46 SafeArrayRedim = _SafeArrayRedim@8 @40 47 OACreateTypeLib2 = _OACreateTypeLib2@0 @41 48 VarParseNumFromStr = _VarParseNumFromStr@20 @46 49 VarNumFromParseNum = _VarNumFromParseNum@16 @47 50 VarI2FromUI1 = _VarI2FromUI1@8 @48 51 VarI2FromI4 = _VarI2FromI4@8 @49 52 VarI2FromR4 = _VarI2FromR4@8 @50 53 VarI2FromR8 = _VarI2FromR8@12 @51 54 VarI2FromCy = _VarI2FromCy@12 @52 55 VarI2FromDate = _VarI2FromDate@12 @53 56 VarI2FromStr = _VarI2FromStr@16 @54 57 VarI2FromDisp = _VarI2FromDisp@12 @55 58 VarI2FromBool = _VarI2FromBool@8 @56 59 VarI4FromUI1 = _VarI4FromUI1@8 @58 60 VarI4FromI2 = _VarI4FromI2@8 @59 61 VarI4FromR4 = _VarI4FromR4@8 @60 62 VarI4FromR8 = _VarI4FromR8@12 @61 63 VarI4FromCy = _VarI4FromCy@12 @62 64 VarI4FromDate = _VarI4FromDate@12 @63 65 VarI4FromStr = _VarI4FromStr@16 @64 66 VarI4FromDisp = _VarI4FromDisp@12 @65 67 VarI4FromBool = _VarI4FromBool@8 @66 68 VarR4FromUI1 = _VarR4FromUI1@8 @68 69 VarR4FromI2 = _VarR4FromI2@8 @69 70 VarR4FromI4 = _VarR4FromI4@8 @70 71 VarR4FromR8 = _VarR4FromR8@12 @71 72 VarR4FromCy = _VarR4FromCy@12 @72 73 VarR4FromDate = _VarR4FromDate@12 @73 74 VarR4FromStr = _VarR4FromStr@16 @74 75 VarR4FromDisp = _VarR4FromDisp@12 @75 76 VarR4FromBool = _VarR4FromBool@8 @76 77 VarR8FromUI1 = _VarR8FromUI1@8 @78 78 VarR8FromI2 = _VarR8FromI2@8 @79 79 VarR8FromI4 = _VarR8FromI4@8 @80 80 VarR8FromR4 = _VarR8FromR4@8 @81 81 VarR8FromCy = _VarR8FromCy@12 @82 82 VarR8FromDate = _VarR8FromDate@12 @83 83 VarR8FromStr = _VarR8FromStr@16 @84 84 VarR8FromDisp = _VarR8FromDisp@12 @85 85 VarR8FromBool = _VarR8FromBool@8 @86 86 VarDateFromUI1 = _VarDateFromUI1@8 @88 87 VarDateFromI2 = _VarDateFromI2@8 @89 88 VarDateFromI4 = _VarDateFromI4@8 @90 89 VarDateFromR4 = _VarDateFromR4@8 @91 90 VarDateFromR8 = _VarDateFromR8@12 @92 91 VarDateFromCy = _VarDateFromCy@12 @93 92 VarDateFromStr = _VarDateFromStr@16 @94 93 VarDateFromDisp = _VarDateFromDisp@12 @95 94 VarDateFromBool = _VarDateFromBool@8 @96 95 VarCyFromUI1 = _VarCyFromUI1@8 @98 96 VarCyFromI2 = _VarCyFromI2@8 @99 97 VarCyFromI4 = _VarCyFromI4@8 @100 98 VarCyFromR4 = _VarCyFromR4@8 @101 99 VarCyFromR8 = _VarCyFromR8@12 @102 100 VarCyFromDate = _VarCyFromDate@12 @103 101 VarCyFromStr = _VarCyFromStr@16 @104 102 VarCyFromDisp = _VarCyFromDisp@12 @105 103 VarCyFromBool = _VarCyFromBool@8 @106 104 VarBstrFromUI1 = _VarBstrFromUI1@16 @108 105 VarBstrFromI2 = _VarBstrFromI2@16 @109 106 VarBstrFromI4 = _VarBstrFromI4@16 @110 107 VarBstrFromR4 = _VarBstrFromR4@16 @111 108 VarBstrFromR8 = _VarBstrFromR8@20 @112 109 VarBstrFromCy = _VarBstrFromCy@20 @113 110 VarBstrFromDate = _VarBstrFromDate@20 @114 111 VarBstrFromDisp = _VarBstrFromDisp@16 @115 112 VarBstrFromBool = _VarBstrFromBool@16 @116 113 VarBoolFromUI1 = _VarBoolFromUI1@8 @118 114 VarBoolFromI2 = _VarBoolFromI2@8 @119 115 VarBoolFromI4 = _VarBoolFromI4@8 @120 116 VarBoolFromR4 = _VarBoolFromR4@8 @121 117 VarBoolFromR8 = _VarBoolFromR8@12 @122 118 VarBoolFromDate = _VarBoolFromDate@12 @123 119 VarBoolFromCy = _VarBoolFromCy@12 @124 120 VarBoolFromStr = _VarBoolFromStr@16 @125 121 VarBoolFromDisp = _VarBoolFromDisp@12 @126 122 VarUI1FromI2 = _VarUI1FromI2@8 @130 123 VarUI1FromI4 = _VarUI1FromI4@8 @131 124 VarUI1FromR4 = _VarUI1FromR4@8 @132 125 VarUI1FromR8 = _VarUI1FromR8@12 @133 126 VarUI1FromCy = _VarUI1FromCy@12 @134 127 VarUI1FromDate = _VarUI1FromDate@12 @135 128 VarUI1FromStr = _VarUI1FromStr@16 @136 129 VarUI1FromDisp = _VarUI1FromDisp@12 @137 130 VarUI1FromBool = _VarUI1FromBool@8 @138 131 DispCallFunc = _DispCallFunc@32 @146 132 VariantChangeTypeEx = _VariantChangeTypeEx@20 @147 133 SafeArrayPtrOfIndex = _SafeArrayPtrOfIndex@12 @148 134 SysStringByteLen = _SysStringByteLen@4 @149 135 SysAllocStringByteLen = _SysAllocStringByteLen@8 @150 136 CreateTypeLib = _CreateTypeLib@12 @160 137 LoadTypeLib = _LoadTypeLib@8 @161 138 LoadRegTypeLib = _LoadRegTypeLib@20 @162 139 RegisterTypeLib = _RegisterTypeLib@12 @163 140 QueryPathOfRegTypeLib = _QueryPathOfRegTypeLib@20 @164 141 LHashValOfNameSys = _LHashValOfNameSys@12 @165 142 LHashValOfNameSysA = _LHashValOfNameSysA@12 @166 143 OaBuildVersion = _OaBuildVersion@0 @170 144 ClearCustData = _ClearCustData@4 @171 145 CreateTypeLib2 = _CreateTypeLib2@12 @180 146 LoadTypeLibEx = _LoadTypeLibEx@12 @183 147 SystemTimeToVariantTime = _SystemTimeToVariantTime@8 @184 148 VariantTimeToSystemTime = _VariantTimeToSystemTime@12 @185 149 UnRegisterTypeLib = _UnRegisterTypeLib@20 @186 150 VarDecFromUI1 = _VarDecFromUI1@8 @190 151 VarDecFromI2 = _VarDecFromI2@8 @191 152 VarDecFromI4 = _VarDecFromI4@8 @192 153 VarDecFromR4 = _VarDecFromR4@8 @193 154 VarDecFromR8 = _VarDecFromR8@12 @194 155 VarDecFromDate = _VarDecFromDate@12 @195 156 VarDecFromCy = _VarDecFromCy@12 @196 157 VarDecFromStr = _VarDecFromStr@16 @197 158 VarDecFromDisp = _VarDecFromDisp@12 @198 159 VarDecFromBool = _VarDecFromBool@8 @199 160 GetErrorInfo = _GetErrorInfo@8 @200 161 SetErrorInfo = _SetErrorInfo@8 @201 162 CreateErrorInfo = _CreateErrorInfo@4 @202 163 VarI2FromI1 = _VarI2FromI1@8 @205 164 VarI2FromUI2 = _VarI2FromUI2@8 @206 165 VarI2FromUI4 = _VarI2FromUI4@8 @207 166 VarI2FromDec = _VarI2FromDec@8 @208 167 VarI4FromI1 = _VarI4FromI1@8 @209 168 VarI4FromUI2 = _VarI4FromUI2@8 @210 169 VarI4FromUI4 = _VarI4FromUI4@8 @211 170 VarI4FromDec = _VarI4FromDec@8 @212 171 VarR4FromI1 = _VarR4FromI1@8 @213 172 VarR4FromUI2 = _VarR4FromUI2@8 @214 173 VarR4FromUI4 = _VarR4FromUI4@8 @215 174 VarR4FromDec = _VarR4FromDec@8 @216 175 VarR8FromI1 = _VarR8FromI1@8 @217 176 VarR8FromUI2 = _VarR8FromUI2@8 @218 177 VarR8FromUI4 = _VarR8FromUI4@8 @219 178 VarR8FromDec = _VarR8FromDec@8 @220 179 VarDateFromI1 = _VarDateFromI1@8 @221 180 VarDateFromUI2 = _VarDateFromUI2@8 @222 181 VarDateFromUI4 = _VarDateFromUI4@8 @223 182 VarDateFromDec = _VarDateFromDec@8 @224 183 VarCyFromI1 = _VarCyFromI1@8 @225 184 VarCyFromUI2 = _VarCyFromUI2@8 @226 185 VarCyFromUI4 = _VarCyFromUI4@8 @227 186 VarCyFromDec = _VarCyFromDec@8 @228 187 VarBstrFromI1 = _VarBstrFromI1@16 @229 7 DllGetClassObject = _OLEAUT32_DllGetClassObject@12 @1 8 SysAllocString = _SysAllocString@4 @2 9 SysReAllocString = _SysReAllocString@8 @3 10 SysAllocStringLen = _SysAllocStringLen@8 @4 11 SysReAllocStringLen = _SysReAllocStringLen@12 @5 12 SysFreeString = _SysFreeString@4 @6 13 SysStringLen = _SysStringLen@4 @7 14 VariantInit = _VariantInit@4 @8 15 VariantClear = _VariantClear@4 @9 16 VariantCopy = _VariantCopy@8 @10 17 VariantCopyInd = _VariantCopyInd@8 @11 18 VariantChangeType = _VariantChangeType@16 @12 19 VariantTimeToDosDateTime = _VariantTimeToDosDateTime@16 @13 20 DosDateTimeToVariantTime = _DosDateTimeToVariantTime@12 @14 21 SafeArrayCreate = _SafeArrayCreate@12 @15 22 SafeArrayDestroy = _SafeArrayDestroy@4 @16 23 SafeArrayGetDim = _SafeArrayGetDim@4 @17 24 SafeArrayGetElemsize = _SafeArrayGetElemsize@4 @18 25 SafeArrayGetUBound = _SafeArrayGetUBound@12 @19 26 SafeArrayGetLBound = _SafeArrayGetLBound@12 @20 27 SafeArrayLock = _SafeArrayLock@4 @21 28 SafeArrayUnlock = _SafeArrayUnlock@4 @22 29 SafeArrayAccessData = _SafeArrayAccessData@8 @23 30 SafeArrayUnaccessData = _SafeArrayUnaccessData@4 @24 31 SafeArrayGetElement = _SafeArrayGetElement@12 @25 32 SafeArrayPutElement = _SafeArrayPutElement@12 @26 33 SafeArrayCopy = _SafeArrayCopy@8 @27 34 DispGetParam = _DispGetParam@20 @28 35 DispGetIDsOfNames = _DispGetIDsOfNames@16 @29 36 DispInvoke = _DispInvoke@32 @30 37 CreateDispTypeInfo = _CreateDispTypeInfo@12 @31 38 CreateStdDispatch = _CreateStdDispatch@16 @32 39 RegisterActiveObject = _RegisterActiveObject@16 @33 40 RevokeActiveObject = _RevokeActiveObject@8 @34 41 GetActiveObject = _GetActiveObject@12 @35 42 SafeArrayAllocDescriptor = _SafeArrayAllocDescriptor@8 @36 43 SafeArrayAllocData = _SafeArrayAllocData@4 @37 44 SafeArrayDestroyDescriptor = _SafeArrayDestroyDescriptor@4 @38 45 SafeArrayDestroyData = _SafeArrayDestroyData@4 @39 46 SafeArrayRedim = _SafeArrayRedim@8 @40 47 OACreateTypeLib2 = _OACreateTypeLib2@0 @41 48 VarParseNumFromStr = _VarParseNumFromStr@20 @46 49 VarNumFromParseNum = _VarNumFromParseNum@16 @47 50 VarI2FromUI1 = _VarI2FromUI1@8 @48 51 VarI2FromI4 = _VarI2FromI4@8 @49 52 VarI2FromR4 = _VarI2FromR4@8 @50 53 VarI2FromR8 = _VarI2FromR8@12 @51 54 VarI2FromCy = _VarI2FromCy@12 @52 55 VarI2FromDate = _VarI2FromDate@12 @53 56 VarI2FromStr = _VarI2FromStr@16 @54 57 VarI2FromDisp = _VarI2FromDisp@12 @55 58 VarI2FromBool = _VarI2FromBool@8 @56 59 VarI4FromUI1 = _VarI4FromUI1@8 @58 60 VarI4FromI2 = _VarI4FromI2@8 @59 61 VarI4FromR4 = _VarI4FromR4@8 @60 62 VarI4FromR8 = _VarI4FromR8@12 @61 63 VarI4FromCy = _VarI4FromCy@12 @62 64 VarI4FromDate = _VarI4FromDate@12 @63 65 VarI4FromStr = _VarI4FromStr@16 @64 66 VarI4FromDisp = _VarI4FromDisp@12 @65 67 VarI4FromBool = _VarI4FromBool@8 @66 68 VarR4FromUI1 = _VarR4FromUI1@8 @68 69 VarR4FromI2 = _VarR4FromI2@8 @69 70 71 VarR4FromI4 = _VarR4FromI4@8 @70 72 VarR4FromR8 = _VarR4FromR8@12 @71 73 VarR4FromCy = _VarR4FromCy@12 @72 74 VarR4FromDate = _VarR4FromDate@12 @73 75 VarR4FromStr = _VarR4FromStr@16 @74 76 VarR4FromDisp = _VarR4FromDisp@12 @75 77 VarR4FromBool = _VarR4FromBool@8 @76 78 SafeArrayGetVartype = _SafeArrayGetVartype@8 @77 79 VarR8FromUI1 = _VarR8FromUI1@8 @78 80 VarR8FromI2 = _VarR8FromI2@8 @79 81 82 VarR8FromI4 = _VarR8FromI4@8 @80 83 VarR8FromR4 = _VarR8FromR4@8 @81 84 VarR8FromCy = _VarR8FromCy@12 @82 85 VarR8FromDate = _VarR8FromDate@12 @83 86 VarR8FromStr = _VarR8FromStr@16 @84 87 VarR8FromDisp = _VarR8FromDisp@12 @85 88 VarR8FromBool = _VarR8FromBool@8 @86 89 VarFormat = _VarFormat@24 @87 90 VarDateFromUI1 = _VarDateFromUI1@8 @88 91 VarDateFromI2 = _VarDateFromI2@8 @89 92 93 VarDateFromI4 = _VarDateFromI4@8 @90 94 VarDateFromR4 = _VarDateFromR4@8 @91 95 VarDateFromR8 = _VarDateFromR8@12 @92 96 VarDateFromCy = _VarDateFromCy@12 @93 97 VarDateFromStr = _VarDateFromStr@16 @94 98 VarDateFromDisp = _VarDateFromDisp@12 @95 99 VarDateFromBool = _VarDateFromBool@8 @96 100 VarFormatDateTime = _VarFormatDateTime@16 @97 101 VarCyFromUI1 = _VarCyFromUI1@8 @98 102 VarCyFromI2 = _VarCyFromI2@8 @99 103 104 VarCyFromI4 = _VarCyFromI4@8 @100 105 VarCyFromR4 = _VarCyFromR4@8 @101 106 VarCyFromR8 = _VarCyFromR8@12 @102 107 VarCyFromDate = _VarCyFromDate@12 @103 108 VarCyFromStr = _VarCyFromStr@16 @104 109 VarCyFromDisp = _VarCyFromDisp@12 @105 110 VarCyFromBool = _VarCyFromBool@8 @106 111 ;; VarFormatNumber = _VarFormatNumber@28 @107 112 VarBstrFromUI1 = _VarBstrFromUI1@16 @108 113 VarBstrFromI2 = _VarBstrFromI2@16 @109 114 115 VarBstrFromI4 = _VarBstrFromI4@16 @110 116 VarBstrFromR4 = _VarBstrFromR4@16 @111 117 VarBstrFromR8 = _VarBstrFromR8@20 @112 118 VarBstrFromCy = _VarBstrFromCy@20 @113 119 VarBstrFromDate = _VarBstrFromDate@20 @114 120 VarBstrFromDisp = _VarBstrFromDisp@16 @115 121 VarBstrFromBool = _VarBstrFromBool@16 @116 122 ;; VarFormatPercent = _VarFormatPercent@28 @117 123 VarBoolFromUI1 = _VarBoolFromUI1@8 @118 124 VarBoolFromI2 = _VarBoolFromI2@8 @119 125 126 VarBoolFromI4 = _VarBoolFromI4@8 @120 127 VarBoolFromR4 = _VarBoolFromR4@8 @121 128 VarBoolFromR8 = _VarBoolFromR8@12 @122 129 VarBoolFromDate = _VarBoolFromDate@12 @123 130 VarBoolFromCy = _VarBoolFromCy@12 @124 131 VarBoolFromStr = _VarBoolFromStr@16 @125 132 VarBoolFromDisp = _VarBoolFromDisp@12 @126 133 VarFormatCurrency = _VarFormatCurrency@28 @127 134 135 VarUI1FromI2 = _VarUI1FromI2@8 @130 136 VarUI1FromI4 = _VarUI1FromI4@8 @131 137 VarUI1FromR4 = _VarUI1FromR4@8 @132 138 VarUI1FromR8 = _VarUI1FromR8@12 @133 139 VarUI1FromCy = _VarUI1FromCy@12 @134 140 VarUI1FromDate = _VarUI1FromDate@12 @135 141 VarUI1FromStr = _VarUI1FromStr@16 @136 142 VarUI1FromDisp = _VarUI1FromDisp@12 @137 143 VarUI1FromBool = _VarUI1FromBool@8 @138 144 VarFormatFromTokens = _VarFormatFromTokens@24 @139 145 146 VarTokenizeFormatString = _VarTokenizeFormatString@28 @140 147 VarAnd = _VarAnd@12 @142 148 149 DispCallFunc = _DispCallFunc@32 @146 150 VariantChangeTypeEx = _VariantChangeTypeEx@20 @147 151 SafeArrayPtrOfIndex = _SafeArrayPtrOfIndex@12 @148 152 SysStringByteLen = _SysStringByteLen@4 @149 153 154 SysAllocStringByteLen = _SysAllocStringByteLen@8 @150 155 156 CreateTypeLib = _CreateTypeLib@12 @160 157 LoadTypeLib = _LoadTypeLib@8 @161 158 LoadRegTypeLib = _LoadRegTypeLib@20 @162 159 RegisterTypeLib = _RegisterTypeLib@12 @163 160 QueryPathOfRegTypeLib = _QueryPathOfRegTypeLib@20 @164 161 LHashValOfNameSys = _LHashValOfNameSys@12 @165 162 LHashValOfNameSysA = _LHashValOfNameSysA@12 @166 163 164 OaBuildVersion = _OaBuildVersion@0 @170 165 ClearCustData = _ClearCustData@4 @171 166 VarNot = _VarNot@8 @174 167 VarCmp = _VarCmp@16 @176 168 169 CreateTypeLib2 = _CreateTypeLib2@12 @180 170 LoadTypeLibEx = _LoadTypeLibEx@12 @183 171 SystemTimeToVariantTime = _SystemTimeToVariantTime@8 @184 172 VariantTimeToSystemTime = _VariantTimeToSystemTime@12 @185 173 UnRegisterTypeLib = _UnRegisterTypeLib@20 @186 174 175 VarDecFromUI1 = _VarDecFromUI1@8 @190 176 VarDecFromI2 = _VarDecFromI2@8 @191 177 VarDecFromI4 = _VarDecFromI4@8 @192 178 VarDecFromR4 = _VarDecFromR4@8 @193 179 VarDecFromR8 = _VarDecFromR8@12 @194 180 VarDecFromDate = _VarDecFromDate@12 @195 181 VarDecFromCy = _VarDecFromCy@12 @196 182 VarDecFromStr = _VarDecFromStr@16 @197 183 VarDecFromDisp = _VarDecFromDisp@12 @198 184 VarDecFromBool = _VarDecFromBool@8 @199 185 186 GetErrorInfo = _GetErrorInfo@8 @200 187 SetErrorInfo = _SetErrorInfo@8 @201 188 CreateErrorInfo = _CreateErrorInfo@4 @202 189 VarI2FromI1 = _VarI2FromI1@8 @205 190 VarI2FromUI2 = _VarI2FromUI2@8 @206 191 VarI2FromUI4 = _VarI2FromUI4@8 @207 192 VarI2FromDec = _VarI2FromDec@8 @208 193 VarI4FromI1 = _VarI4FromI1@8 @209 194 VarI4FromUI2 = _VarI4FromUI2@8 @210 195 196 VarI4FromUI4 = _VarI4FromUI4@8 @211 197 VarI4FromDec = _VarI4FromDec@8 @212 198 VarR4FromI1 = _VarR4FromI1@8 @213 199 VarR4FromUI2 = _VarR4FromUI2@8 @214 200 VarR4FromUI4 = _VarR4FromUI4@8 @215 201 VarR4FromDec = _VarR4FromDec@8 @216 202 VarR8FromI1 = _VarR8FromI1@8 @217 203 VarR8FromUI2 = _VarR8FromUI2@8 @218 204 VarR8FromUI4 = _VarR8FromUI4@8 @219 205 206 VarR8FromDec = _VarR8FromDec@8 @220 207 VarDateFromI1 = _VarDateFromI1@8 @221 208 VarDateFromUI2 = _VarDateFromUI2@8 @222 209 VarDateFromUI4 = _VarDateFromUI4@8 @223 210 VarDateFromDec = _VarDateFromDec@8 @224 211 VarCyFromI1 = _VarCyFromI1@8 @225 212 VarCyFromUI2 = _VarCyFromUI2@8 @226 213 VarCyFromUI4 = _VarCyFromUI4@8 @227 214 VarCyFromDec = _VarCyFromDec@8 @228 215 VarBstrFromI1 = _VarBstrFromI1@16 @229 216 188 217 VarBstrFromUI2 = _VarBstrFromUI2@16 @230 189 218 VarBstrFromUI4 = _VarBstrFromUI4@16 @231 … … 254 283 LPSAFEARRAY_Marshal = _LPSAFEARRAY_Marshal@0 @296 255 284 LPSAFEARRAY_Unmarshal = _LPSAFEARRAY_Unmarshal@0 @297 285 286 VarCyMulI4 = _VarCyMulI4@16 @304 287 288 VarBstrCat = _VarBstrCat@12 @313 289 VarBstrCmp = _VarBstrCmp@16 @314 290 VarCat = _VarCat@12 @318 291 256 292 DllRegisterServer = _OLEAUT32_DllRegisterServer@0 @320 257 293 DllUnregisterServer = _OLEAUT32_DllUnregisterServer@0 @321 294 258 295 VarDateFromUdate = _VarDateFromUdate@12 @330 259 296 VarUdateFromDate = _VarUdateFromDate@16 @331 … … 279 316 UserMSG_free_inst = _UserMSG_free_inst@0 @398 280 317 UserMSG_free_local = _UserMSG_free_local@0 @399 318 281 319 DllCanUnloadNow = _OLEAUT32_DllCanUnloadNow@0 @410 282 320 SafeArrayCreateVector = _SafeArrayCreateVector@12 @411 … … 303 341 SafeArrayAllocDescriptorEx = _SafeArrayAllocDescriptorEx@12 @429 304 342 305 ;430 stub SafeArrayCreateEx 306 ;431 stub SafeArrayCreateVectorEx 307 ;432 stub SafeArrayGetIID 308 ;433 stub SafeArrayGetRecordInfo 309 ;434 stub SafeArraySetIID 310 ;435 stub SafeArraySetRecordInfo 311 ;436 stub VarAbs ; stdcall (ptr ptr) 312 ;437 stub VarAdd ; stdcall (ptr ptr ptr) 313 ;438 stub VarAnd ; stdcall (ptr ptr ptr) 314 VarBstrCat = _VarBstrCat@12 @439 315 VarBstrCmp = _VarBstrCmp@16 @440 316 VarCat = _VarCat@12 @441 317 318 ;442 stub VarCmp ; stdcall (ptr ptr long long) 319 ;443 stub VarCyAbs 320 ;444 stub VarCyAdd 321 ;445 stub VarCyCmp 322 ;446 stub VarCyCmpR8 323 ;447 stub VarCyFix 324 ;448 stub VarCyInt 325 ;449 stub VarCyMul 326 ;450 stub VarCyMulI4 327 ;451 stub VarCyNeg 328 ;452 stub VarCyRound 329 ;453 stub VarCySub 330 ;454 stub VarDateFromUdateEx ; stdcall (ptr long long ptr) 331 ;455 stub VarDecAbs ; stdcall (ptr ptr) 332 ;456 stub VarDecAdd ; stdcall (ptr ptr ptr) 333 ;457 stub VarDecCmp ; stdcall (ptr ptr) 334 ;458 stub VarDecCmpR8 ; stdcall (ptr double) 335 ;459 stub VarDecDiv ; stdcall (ptr ptr ptr) 336 ;460 stub VarDecFix ; stdcall (ptr ptr) 337 ;461 stub VarDecInt ; stdcall (ptr ptr) 338 ;462 stub VarDecMul ; stdcall (ptr ptr ptr) 339 ;463 stub VarDecNeg ; stdcall (ptr ptr) 340 ;464 stub VarDecRound ; stdcall (ptr long ptr) 341 ;465 stub VarDecSub ; stdcall (ptr ptr ptr) 342 ;466 stub VarDiv ; stdcall (ptr ptr ptr) 343 ;467 stub VarEqv ; stdcall (ptr ptr ptr) 344 ;468 stub VarFix ; stdcall (ptr ptr) 345 ;469 stub VarFormat ; stdcall (ptr ptr long long long ptr) 346 ;470 stub VarFormatCurrency ; stdcall (ptr long long long long long ptr) 347 ;471 stub VarFormatDateTime ; stdcall (ptr long long ptr) 348 ;472 stub VarFormatFromTokens ; stdcall (ptr ptr ptr long ptr long) 349 ;473 stub VarFormatNumber ; stdcall (ptr long long long long long ptr) 350 ;474 stub VarFormatPercent ; stdcall (ptr long long long long long ptr) 351 ;475 stub VarIdiv ; stdcall (ptr ptr ptr) 352 ;476 stub VarImp ; stdcall (ptr ptr ptr) 353 ;477 stub VarInt ; stdcall (ptr ptr) 354 ;478 stub VarMod ; stdcall (ptr ptr ptr) 355 ;479 stub VarMonthName ; stdcall (long long long ptr) 356 ;480 stub VarMul ; stdcall (ptr ptr ptr) 357 ;481 stub VarNeg ; stdcall (ptr ptr) 358 ;482 stub VarNot ; stdcall (ptr ptr) 359 ;483 stub VarOr ; stdcall (ptr ptr ptr) 360 ;484 stub VarPow ; stdcall (ptr ptr ptr) 361 ;485 stub VarR4CmpR8 362 ;486 stub VarR8Pow ; stdcall (double double ptr) 363 ;487 stub VarR8Round ; stdcall (double long ptr) 364 ;488 stub VarRound ; stdcall (ptr long ptr) 365 ;489 stub VarSub ; stdcall (ptr ptr ptr) 366 ;490 stub VarTokenizeFormatString ; stdcall (ptr ptr long long long long ptr) 367 ;491 stub VarWeekdayName ; stdcall (long long long long ptr) 368 ;492 stub VarXor ; stdcall (ptr ptr ptr) 343 -
trunk/src/oleaut32/oleaut32dbg.def
r7919 r9400 1 ;/* $Id: oleaut32dbg.def,v 1. 2 2002-02-15 15:23:43sandervl Exp $ */1 ;/* $Id: oleaut32dbg.def,v 1.3 2002-11-12 17:07:46 sandervl Exp $ */ 2 2 LIBRARY OLAUTOS2 INITINSTANCE 3 3 DESCRIPTION 'Odin32 System DLL - OleAut32' … … 68 68 VarR4FromUI1 = _DbgVarR4FromUI1@8 @68 69 69 VarR4FromI2 = _DbgVarR4FromI2@8 @69 70 VarR4FromI4 = _DbgVarR4FromI4@8 @70 71 VarR4FromR8 = _DbgVarR4FromR8@12 @71 72 VarR4FromCy = _DbgVarR4FromCy@12 @72 73 VarR4FromDate = _DbgVarR4FromDate@12 @73 74 VarR4FromStr = _DbgVarR4FromStr@16 @74 75 VarR4FromDisp = _DbgVarR4FromDisp@12 @75 76 VarR4FromBool = _DbgVarR4FromBool@8 @76 77 VarR8FromUI1 = _DbgVarR8FromUI1@8 @78 78 VarR8FromI2 = _DbgVarR8FromI2@8 @79 79 VarR8FromI4 = _DbgVarR8FromI4@8 @80 80 VarR8FromR4 = _DbgVarR8FromR4@8 @81 81 VarR8FromCy = _DbgVarR8FromCy@12 @82 82 VarR8FromDate = _DbgVarR8FromDate@12 @83 83 VarR8FromStr = _DbgVarR8FromStr@16 @84 84 VarR8FromDisp = _DbgVarR8FromDisp@12 @85 85 VarR8FromBool = _DbgVarR8FromBool@8 @86 86 VarDateFromUI1 = _DbgVarDateFromUI1@8 @88 87 VarDateFromI2 = _DbgVarDateFromI2@8 @89 88 VarDateFromI4 = _DbgVarDateFromI4@8 @90 89 VarDateFromR4 = _DbgVarDateFromR4@8 @91 90 VarDateFromR8 = _DbgVarDateFromR8@12 @92 91 VarDateFromCy = _DbgVarDateFromCy@12 @93 92 VarDateFromStr = _DbgVarDateFromStr@16 @94 93 VarDateFromDisp = _DbgVarDateFromDisp@12 @95 94 VarDateFromBool = _DbgVarDateFromBool@8 @96 95 VarCyFromUI1 = _DbgVarCyFromUI1@8 @98 96 VarCyFromI2 = _DbgVarCyFromI2@8 @99 97 VarCyFromI4 = _DbgVarCyFromI4@8 @100 98 VarCyFromR4 = _DbgVarCyFromR4@8 @101 99 VarCyFromR8 = _DbgVarCyFromR8@12 @102 100 VarCyFromDate = _DbgVarCyFromDate@12 @103 101 VarCyFromStr = _DbgVarCyFromStr@16 @104 102 VarCyFromDisp = _DbgVarCyFromDisp@12 @105 103 VarCyFromBool = _DbgVarCyFromBool@8 @106 104 VarBstrFromUI1 = _DbgVarBstrFromUI1@16 @108 105 VarBstrFromI2 = _DbgVarBstrFromI2@16 @109 106 VarBstrFromI4 = _DbgVarBstrFromI4@16 @110 107 VarBstrFromR4 = _DbgVarBstrFromR4@16 @111 108 VarBstrFromR8 = _DbgVarBstrFromR8@20 @112 109 VarBstrFromCy = _DbgVarBstrFromCy@20 @113 110 VarBstrFromDate = _DbgVarBstrFromDate@20 @114 111 VarBstrFromDisp = _DbgVarBstrFromDisp@16 @115 112 VarBstrFromBool = _DbgVarBstrFromBool@16 @116 113 VarBoolFromUI1 = _DbgVarBoolFromUI1@8 @118 114 VarBoolFromI2 = _DbgVarBoolFromI2@8 @119 115 VarBoolFromI4 = _DbgVarBoolFromI4@8 @120 116 VarBoolFromR4 = _DbgVarBoolFromR4@8 @121 117 VarBoolFromR8 = _DbgVarBoolFromR8@12 @122 118 VarBoolFromDate = _DbgVarBoolFromDate@12 @123 119 VarBoolFromCy = _DbgVarBoolFromCy@12 @124 120 VarBoolFromStr = _DbgVarBoolFromStr@16 @125 121 VarBoolFromDisp = _DbgVarBoolFromDisp@12 @126 122 VarUI1FromI2 = _DbgVarUI1FromI2@8 @130 123 VarUI1FromI4 = _DbgVarUI1FromI4@8 @131 124 VarUI1FromR4 = _DbgVarUI1FromR4@8 @132 125 VarUI1FromR8 = _DbgVarUI1FromR8@12 @133 126 VarUI1FromCy = _DbgVarUI1FromCy@12 @134 127 VarUI1FromDate = _DbgVarUI1FromDate@12 @135 128 VarUI1FromStr = _DbgVarUI1FromStr@16 @136 129 VarUI1FromDisp = _DbgVarUI1FromDisp@12 @137 130 VarUI1FromBool = _DbgVarUI1FromBool@8 @138 131 DispCallFunc = _DbgDispCallFunc@32 @146 132 VariantChangeTypeEx = _DbgVariantChangeTypeEx@20 @147 133 SafeArrayPtrOfIndex = _DbgSafeArrayPtrOfIndex@12 @148 134 SysStringByteLen = _DbgSysStringByteLen@4 @149 135 SysAllocStringByteLen = _DbgSysAllocStringByteLen@8 @150 136 CreateTypeLib = _DbgCreateTypeLib@12 @160 137 LoadTypeLib = _DbgLoadTypeLib@8 @161 138 LoadRegTypeLib = _DbgLoadRegTypeLib@20 @162 139 RegisterTypeLib = _DbgRegisterTypeLib@12 @163 140 QueryPathOfRegTypeLib = _DbgQueryPathOfRegTypeLib@20 @164 141 LHashValOfNameSys = _DbgLHashValOfNameSys@12 @165 142 LHashValOfNameSysA = _DbgLHashValOfNameSysA@12 @166 143 OaBuildVersion = _DbgOaBuildVersion@0 @170 144 ClearCustData = _DbgClearCustData@4 @171 145 CreateTypeLib2 = _DbgCreateTypeLib2@12 @180 146 LoadTypeLibEx = _DbgLoadTypeLibEx@12 @183 147 SystemTimeToVariantTime = _DbgSystemTimeToVariantTime@8 @184 148 VariantTimeToSystemTime = _DbgVariantTimeToSystemTime@12 @185 149 UnRegisterTypeLib = _DbgUnRegisterTypeLib@20 @186 150 VarDecFromUI1 = _DbgVarDecFromUI1@8 @190 151 VarDecFromI2 = _DbgVarDecFromI2@8 @191 152 VarDecFromI4 = _DbgVarDecFromI4@8 @192 153 VarDecFromR4 = _DbgVarDecFromR4@8 @193 154 VarDecFromR8 = _DbgVarDecFromR8@12 @194 155 VarDecFromDate = _DbgVarDecFromDate@12 @195 156 VarDecFromCy = _DbgVarDecFromCy@12 @196 157 VarDecFromStr = _DbgVarDecFromStr@16 @197 158 VarDecFromDisp = _DbgVarDecFromDisp@12 @198 159 VarDecFromBool = _DbgVarDecFromBool@8 @199 70 71 VarR4FromI4 = _DbgVarR4FromI4@8 @70 72 VarR4FromR8 = _DbgVarR4FromR8@12 @71 73 VarR4FromCy = _DbgVarR4FromCy@12 @72 74 VarR4FromDate = _DbgVarR4FromDate@12 @73 75 VarR4FromStr = _DbgVarR4FromStr@16 @74 76 VarR4FromDisp = _DbgVarR4FromDisp@12 @75 77 VarR4FromBool = _DbgVarR4FromBool@8 @76 78 SafeArrayGetVartype = _DbgSafeArrayGetVartype@8 @77 79 VarR8FromUI1 = _DbgVarR8FromUI1@8 @78 80 VarR8FromI2 = _DbgVarR8FromI2@8 @79 81 82 VarR8FromI4 = _DbgVarR8FromI4@8 @80 83 VarR8FromR4 = _DbgVarR8FromR4@8 @81 84 VarR8FromCy = _DbgVarR8FromCy@12 @82 85 VarR8FromDate = _DbgVarR8FromDate@12 @83 86 VarR8FromStr = _DbgVarR8FromStr@16 @84 87 VarR8FromDisp = _DbgVarR8FromDisp@12 @85 88 VarR8FromBool = _DbgVarR8FromBool@8 @86 89 VarFormat = _DbgVarFormat@24 @87 90 VarDateFromUI1 = _DbgVarDateFromUI1@8 @88 91 VarDateFromI2 = _DbgVarDateFromI2@8 @89 92 93 VarDateFromI4 = _DbgVarDateFromI4@8 @90 94 VarDateFromR4 = _DbgVarDateFromR4@8 @91 95 VarDateFromR8 = _DbgVarDateFromR8@12 @92 96 VarDateFromCy = _DbgVarDateFromCy@12 @93 97 VarDateFromStr = _DbgVarDateFromStr@16 @94 98 VarDateFromDisp = _DbgVarDateFromDisp@12 @95 99 VarDateFromBool = _DbgVarDateFromBool@8 @96 100 VarFormatDateTime = _DbgVarFormatDateTime@16 @97 101 VarCyFromUI1 = _DbgVarCyFromUI1@8 @98 102 VarCyFromI2 = _DbgVarCyFromI2@8 @99 103 104 VarCyFromI4 = _DbgVarCyFromI4@8 @100 105 VarCyFromR4 = _DbgVarCyFromR4@8 @101 106 VarCyFromR8 = _DbgVarCyFromR8@12 @102 107 VarCyFromDate = _DbgVarCyFromDate@12 @103 108 VarCyFromStr = _DbgVarCyFromStr@16 @104 109 VarCyFromDisp = _DbgVarCyFromDisp@12 @105 110 VarCyFromBool = _DbgVarCyFromBool@8 @106 111 ;; VarFormatNumber = _DbgVarFormatNumber@28 @107 112 VarBstrFromUI1 = _DbgVarBstrFromUI1@16 @108 113 VarBstrFromI2 = _DbgVarBstrFromI2@16 @109 114 115 VarBstrFromI4 = _DbgVarBstrFromI4@16 @110 116 VarBstrFromR4 = _DbgVarBstrFromR4@16 @111 117 VarBstrFromR8 = _DbgVarBstrFromR8@20 @112 118 VarBstrFromCy = _DbgVarBstrFromCy@20 @113 119 VarBstrFromDate = _DbgVarBstrFromDate@20 @114 120 VarBstrFromDisp = _DbgVarBstrFromDisp@16 @115 121 VarBstrFromBool = _DbgVarBstrFromBool@16 @116 122 ;; VarFormatPercent = _DbgVarFormatPercent@28 @117 123 VarBoolFromUI1 = _DbgVarBoolFromUI1@8 @118 124 VarBoolFromI2 = _DbgVarBoolFromI2@8 @119 125 126 VarBoolFromI4 = _DbgVarBoolFromI4@8 @120 127 VarBoolFromR4 = _DbgVarBoolFromR4@8 @121 128 VarBoolFromR8 = _DbgVarBoolFromR8@12 @122 129 VarBoolFromDate = _DbgVarBoolFromDate@12 @123 130 VarBoolFromCy = _DbgVarBoolFromCy@12 @124 131 VarBoolFromStr = _DbgVarBoolFromStr@16 @125 132 VarBoolFromDisp = _DbgVarBoolFromDisp@12 @126 133 VarFormatCurrency = _DbgVarFormatCurrency@28 @127 134 135 VarUI1FromI2 = _DbgVarUI1FromI2@8 @130 136 VarUI1FromI4 = _DbgVarUI1FromI4@8 @131 137 VarUI1FromR4 = _DbgVarUI1FromR4@8 @132 138 VarUI1FromR8 = _DbgVarUI1FromR8@12 @133 139 VarUI1FromCy = _DbgVarUI1FromCy@12 @134 140 VarUI1FromDate = _DbgVarUI1FromDate@12 @135 141 VarUI1FromStr = _DbgVarUI1FromStr@16 @136 142 VarUI1FromDisp = _DbgVarUI1FromDisp@12 @137 143 VarUI1FromBool = _DbgVarUI1FromBool@8 @138 144 VarFormatFromTokens = _DbgVarFormatFromTokens@24 @139 145 146 VarTokenizeFormatString = _DbgVarTokenizeFormatString@28 @140 147 VarAnd = _DbgVarAnd@12 @142 148 149 DispCallFunc = _DbgDispCallFunc@32 @146 150 VariantChangeTypeEx = _DbgVariantChangeTypeEx@20 @147 151 SafeArrayPtrOfIndex = _DbgSafeArrayPtrOfIndex@12 @148 152 SysStringByteLen = _DbgSysStringByteLen@4 @149 153 154 SysAllocStringByteLen = _DbgSysAllocStringByteLen@8 @150 155 156 CreateTypeLib = _DbgCreateTypeLib@12 @160 157 LoadTypeLib = _DbgLoadTypeLib@8 @161 158 LoadRegTypeLib = _DbgLoadRegTypeLib@20 @162 159 RegisterTypeLib = _DbgRegisterTypeLib@12 @163 160 QueryPathOfRegTypeLib = _DbgQueryPathOfRegTypeLib@20 @164 161 LHashValOfNameSys = _DbgLHashValOfNameSys@12 @165 162 LHashValOfNameSysA = _DbgLHashValOfNameSysA@12 @166 163 164 OaBuildVersion = _DbgOaBuildVersion@0 @170 165 ClearCustData = _DbgClearCustData@4 @171 166 VarNot = _DbgVarNot@8 @174 167 VarCmp = _DbgVarCmp@16 @176 168 169 CreateTypeLib2 = _DbgCreateTypeLib2@12 @180 170 LoadTypeLibEx = _DbgLoadTypeLibEx@12 @183 171 SystemTimeToVariantTime = _DbgSystemTimeToVariantTime@8 @184 172 VariantTimeToSystemTime = _DbgVariantTimeToSystemTime@12 @185 173 UnRegisterTypeLib = _DbgUnRegisterTypeLib@20 @186 174 175 VarDecFromUI1 = _DbgVarDecFromUI1@8 @190 176 VarDecFromI2 = _DbgVarDecFromI2@8 @191 177 VarDecFromI4 = _DbgVarDecFromI4@8 @192 178 VarDecFromR4 = _DbgVarDecFromR4@8 @193 179 VarDecFromR8 = _DbgVarDecFromR8@12 @194 180 VarDecFromDate = _DbgVarDecFromDate@12 @195 181 VarDecFromCy = _DbgVarDecFromCy@12 @196 182 VarDecFromStr = _DbgVarDecFromStr@16 @197 183 VarDecFromDisp = _DbgVarDecFromDisp@12 @198 184 VarDecFromBool = _DbgVarDecFromBool@8 @199 185 160 186 GetErrorInfo = _GetErrorInfo@8 @200 161 187 SetErrorInfo = _SetErrorInfo@8 @201 … … 254 280 LPSAFEARRAY_Marshal = _DbgLPSAFEARRAY_Marshal@0 @296 255 281 LPSAFEARRAY_Unmarshal = _DbgLPSAFEARRAY_Unmarshal@0 @297 282 283 VarCyMulI4 = _DbgVarCyMulI4@16 @304 284 285 VarBstrCat = _DbgVarBstrCat@12 @313 286 VarBstrCmp = _DbgVarBstrCmp@16 @314 287 VarCat = _DbgVarCat@12 @318 288 256 289 DllRegisterServer = _DbgOLEAUT32_DllRegisterServer@0 @320 257 290 DllUnregisterServer = _DbgOLEAUT32_DllUnregisterServer@0 @321 … … 303 336 SafeArrayAllocDescriptorEx = _DbgSafeArrayAllocDescriptorEx@12 @429 304 337 305 ;430 stub SafeArrayCreateEx306 ;431 stub SafeArrayCreateVectorEx307 ;432 stub SafeArrayGetIID308 ;433 stub SafeArrayGetRecordInfo309 ;434 stub SafeArraySetIID310 ;435 stub SafeArraySetRecordInfo311 ;436 stub VarAbs ; stdcall (ptr ptr)312 ;437 stub VarAdd ; stdcall (ptr ptr ptr)313 ;438 stub VarAnd ; stdcall (ptr ptr ptr)314 VarBstrCat = _DbgVarBstrCat@12 @439315 VarBstrCmp = _DbgVarBstrCmp@16 @440316 VarCat = _DbgVarCat@12 @441317 318 ;442 stub VarCmp ; stdcall (ptr ptr long long)319 ;443 stub VarCyAbs320 ;444 stub VarCyAdd321 ;445 stub VarCyCmp322 ;446 stub VarCyCmpR8323 ;447 stub VarCyFix324 ;448 stub VarCyInt325 ;449 stub VarCyMul326 ;450 stub VarCyMulI4327 ;451 stub VarCyNeg328 ;452 stub VarCyRound329 ;453 stub VarCySub330 ;454 stub VarDateFromUdateEx ; stdcall (ptr long long ptr)331 ;455 stub VarDecAbs ; stdcall (ptr ptr)332 ;456 stub VarDecAdd ; stdcall (ptr ptr ptr)333 ;457 stub VarDecCmp ; stdcall (ptr ptr)334 ;458 stub VarDecCmpR8 ; stdcall (ptr double)335 ;459 stub VarDecDiv ; stdcall (ptr ptr ptr)336 ;460 stub VarDecFix ; stdcall (ptr ptr)337 ;461 stub VarDecInt ; stdcall (ptr ptr)338 ;462 stub VarDecMul ; stdcall (ptr ptr ptr)339 ;463 stub VarDecNeg ; stdcall (ptr ptr)340 ;464 stub VarDecRound ; stdcall (ptr long ptr)341 ;465 stub VarDecSub ; stdcall (ptr ptr ptr)342 ;466 stub VarDiv ; stdcall (ptr ptr ptr)343 ;467 stub VarEqv ; stdcall (ptr ptr ptr)344 ;468 stub VarFix ; stdcall (ptr ptr)345 ;469 stub VarFormat ; stdcall (ptr ptr long long long ptr)346 ;470 stub VarFormatCurrency ; stdcall (ptr long long long long long ptr)347 ;471 stub VarFormatDateTime ; stdcall (ptr long long ptr)348 ;472 stub VarFormatFromTokens ; stdcall (ptr ptr ptr long ptr long)349 ;473 stub VarFormatNumber ; stdcall (ptr long long long long long ptr)350 ;474 stub VarFormatPercent ; stdcall (ptr long long long long long ptr)351 ;475 stub VarIdiv ; stdcall (ptr ptr ptr)352 ;476 stub VarImp ; stdcall (ptr ptr ptr)353 ;477 stub VarInt ; stdcall (ptr ptr)354 ;478 stub VarMod ; stdcall (ptr ptr ptr)355 ;479 stub VarMonthName ; stdcall (long long long ptr)356 ;480 stub VarMul ; stdcall (ptr ptr ptr)357 ;481 stub VarNeg ; stdcall (ptr ptr)358 ;482 stub VarNot ; stdcall (ptr ptr)359 ;483 stub VarOr ; stdcall (ptr ptr ptr)360 ;484 stub VarPow ; stdcall (ptr ptr ptr)361 ;485 stub VarR4CmpR8362 ;486 stub VarR8Pow ; stdcall (double double ptr)363 ;487 stub VarR8Round ; stdcall (double long ptr)364 ;488 stub VarRound ; stdcall (ptr long ptr)365 ;489 stub VarSub ; stdcall (ptr ptr ptr)366 ;490 stub VarTokenizeFormatString ; stdcall (ptr ptr long long long long ptr)367 ;491 stub VarWeekdayName ; stdcall (long long long long ptr)368 ;492 stub VarXor ; stdcall (ptr ptr ptr) -
trunk/src/oleaut32/olefont.c
r8450 r9400 25 25 #include "oleaut32.h" 26 26 #endif 27 28 27 #include <assert.h> 29 28 #include <string.h> … … 59 58 { 60 59 /* 61 * This class supports many interfaces. IUnknown, IFont, 60 * This class supports many interfaces. IUnknown, IFont, 62 61 * IDispatch, IDispFont IPersistStream and IConnectionPointContainer. 63 62 * The first two are supported by the first vtable, the next two are … … 98 97 99 98 /* 100 * Here, I define utility macros to help with the casting of the 99 * Here, I define utility macros to help with the casting of the 101 100 * "this" parameter. 102 101 * There is a version to accomodate all of the VTables implemented … … 104 103 */ 105 104 #define _ICOM_THIS(class,name) class* this = (class*)name; 106 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 107 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 108 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 105 #define _ICOM_THIS_From_IDispatch(class, name) class* this = (class*)(((char*)name)-sizeof(void*)); 106 #define _ICOM_THIS_From_IPersistStream(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*)); 107 #define _ICOM_THIS_From_IConnectionPointContainer(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*)); 109 108 110 109 … … 147 146 * interface 148 147 */ 149 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 150 REFIID riid, 148 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 149 REFIID riid, 151 150 VOID** ppvoid); 152 151 static ULONG WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface); 153 152 static ULONG WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface); 154 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface, 153 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch* iface, 155 154 unsigned int* pctinfo); 156 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface, 155 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch* iface, 157 156 UINT iTInfo, 158 LCID lcid, 157 LCID lcid, 159 158 ITypeInfo** ppTInfo); 160 159 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch* iface, 161 REFIID riid, 162 LPOLESTR* rgszNames, 163 UINT cNames, 160 REFIID riid, 161 LPOLESTR* rgszNames, 162 UINT cNames, 164 163 LCID lcid, 165 164 DISPID* rgDispId); 166 165 static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch* iface, 167 DISPID dispIdMember, 168 REFIID riid, 169 LCID lcid, 166 DISPID dispIdMember, 167 REFIID riid, 168 LCID lcid, 170 169 WORD wFlags, 171 170 DISPPARAMS* pDispParams, 172 VARIANT* pVarResult, 171 VARIANT* pVarResult, 173 172 EXCEPINFO* pExepInfo, 174 UINT* puArgErr); 173 UINT* puArgErr); 175 174 176 175 /*********************************************************************** … … 178 177 * interface 179 178 */ 180 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 181 REFIID riid, 179 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 180 REFIID riid, 182 181 VOID** ppvoid); 183 182 static ULONG WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface); 184 183 static ULONG WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface); 185 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 184 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 186 185 CLSID* pClassID); 187 186 static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream* iface); … … 190 189 static HRESULT WINAPI OLEFontImpl_Save(IPersistStream* iface, 191 190 IStream* pOutStream, 192 BOOL fClearDirty); 191 BOOL fClearDirty); 193 192 static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream* iface, 194 ULARGE_INTEGER* pcbSize); 193 ULARGE_INTEGER* pcbSize); 195 194 196 195 /*********************************************************************** … … 199 198 */ 200 199 static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface( 201 IConnectionPointContainer* iface, 202 REFIID riid, 200 IConnectionPointContainer* iface, 201 REFIID riid, 203 202 VOID** ppvoid); 204 203 static ULONG WINAPI OLEFontImpl_IConnectionPointContainer_AddRef( … … 240 239 OLEFontImpl_put_Charset, 241 240 OLEFontImpl_get_hFont, 242 OLEFontImpl_Clone, 241 OLEFontImpl_Clone, 243 242 OLEFontImpl_IsEqual, 244 243 OLEFontImpl_SetRatio, … … 347 346 348 347 IConnectionPoint_EnumConnections(this->pCP, &pEnum); 349 348 350 349 while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) { 351 350 IPropertyNotifySink *sink; … … 359 358 return; 360 359 } 361 360 362 361 /************************************************************************ 363 362 * OLEFontImpl_Construct … … 380 379 if (newObject==0) 381 380 return newObject; 382 381 383 382 /* 384 383 * Initialize the virtual function table. … … 388 387 newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable; 389 388 newObject->lpvtbl4 = &OLEFontImpl_IConnectionPointContainer_VTable; 390 391 /* 392 * Start with one reference count. The caller of this function 389 390 /* 391 * Start with one reference count. The caller of this function 393 392 * must release the interface pointer when it is done. 394 393 */ … … 402 401 newObject->description.cbSizeofstruct = sizeof(FONTDESC); 403 402 newObject->description.lpstrName = HeapAlloc(GetProcessHeap(), 404 0, 403 0, 405 404 (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR)); 406 405 strcpyW(newObject->description.lpstrName, fontDesc->lpstrName); … … 464 463 if ( (this==0) || (ppvObject==0) ) 465 464 return E_INVALIDARG; 466 465 467 466 /* 468 467 * Initialize the return parameter. 469 468 */ 470 469 *ppvObject = 0; 471 470 472 471 /* 473 472 * Compare the riid with the interface IDs implemented by this object. 474 473 */ 475 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 474 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 476 475 { 477 476 *ppvObject = (IFont*)this; 478 477 } 479 else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 478 else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 480 479 { 481 480 *ppvObject = (IFont*)this; 482 481 } 483 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 482 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 484 483 { 485 484 *ppvObject = (IDispatch*)&(this->lpvtbl2); 486 485 } 487 else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 486 else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 488 487 { 489 488 *ppvObject = (IDispatch*)&(this->lpvtbl2); 490 489 } 491 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 490 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 492 491 { 493 492 *ppvObject = (IPersistStream*)&(this->lpvtbl3); 494 493 } 495 494 else if (memcmp(&IID_IConnectionPointContainer, riid, 496 sizeof(IID_IConnectionPointContainer)) == 0) 495 sizeof(IID_IConnectionPointContainer)) == 0) 497 496 { 498 497 *ppvObject = (IPersistStream*)&(this->lpvtbl4); 499 498 } 500 499 501 500 /* 502 501 * Check that we obtained an interface. … … 507 506 return E_NOINTERFACE; 508 507 } 509 508 510 509 /* 511 510 * Query Interface always increases the reference count by one when it is … … 514 513 OLEFontImpl_AddRef((IFont*)this); 515 514 516 return S_OK; ;517 } 518 515 return S_OK; 516 } 517 519 518 /************************************************************************ 520 519 * OLEFontImpl_AddRef (IUnknown) … … 522 521 * See Windows documentation for more details on IUnknown methods. 523 522 */ 524 ULONG WINAPI OLEFontImpl_AddRef( 523 ULONG WINAPI OLEFontImpl_AddRef( 525 524 IFont* iface) 526 525 { … … 531 530 return this->ref; 532 531 } 533 532 534 533 /************************************************************************ 535 534 * OLEFontImpl_Release (IUnknown) … … 537 536 * See Windows documentation for more details on IUnknown methods. 538 537 */ 539 ULONG WINAPI OLEFontImpl_Release( 538 ULONG WINAPI OLEFontImpl_Release( 540 539 IFont* iface) 541 540 { … … 557 556 return 0; 558 557 } 559 558 560 559 return this->ref; 561 560 } 562 561 563 562 /************************************************************************ 564 563 * OLEFontImpl_get_Name (IFont) … … 567 566 */ 568 567 static HRESULT WINAPI OLEFontImpl_get_Name( 569 IFont* iface, 568 IFont* iface, 570 569 BSTR* pname) 571 570 { … … 592 591 */ 593 592 static HRESULT WINAPI OLEFontImpl_put_Name( 594 IFont* iface, 593 IFont* iface, 595 594 BSTR name) 596 595 { … … 601 600 { 602 601 this->description.lpstrName = HeapAlloc(GetProcessHeap(), 603 0, 602 0, 604 603 (lstrlenW(name)+1) * sizeof(WCHAR)); 605 604 } … … 607 606 { 608 607 this->description.lpstrName = HeapReAlloc(GetProcessHeap(), 609 0, 608 0, 610 609 this->description.lpstrName, 611 610 (lstrlenW(name)+1) * sizeof(WCHAR)); … … 627 626 */ 628 627 static HRESULT WINAPI OLEFontImpl_get_Size( 629 IFont* iface, 628 IFont* iface, 630 629 CY* psize) 631 630 { … … 651 650 */ 652 651 static HRESULT WINAPI OLEFontImpl_put_Size( 653 IFont* iface, 652 IFont* iface, 654 653 CY size) 655 654 { … … 669 668 */ 670 669 static HRESULT WINAPI OLEFontImpl_get_Bold( 671 IFont* iface, 670 IFont* iface, 672 671 BOOL* pbold) 673 672 { … … 708 707 */ 709 708 static HRESULT WINAPI OLEFontImpl_get_Italic( 710 IFont* iface, 709 IFont* iface, 711 710 BOOL* pitalic) 712 711 { … … 730 729 */ 731 730 static HRESULT WINAPI OLEFontImpl_put_Italic( 732 IFont* iface, 731 IFont* iface, 733 732 BOOL italic) 734 733 { … … 748 747 */ 749 748 static HRESULT WINAPI OLEFontImpl_get_Underline( 750 IFont* iface, 749 IFont* iface, 751 750 BOOL* punderline) 752 751 { … … 789 788 */ 790 789 static HRESULT WINAPI OLEFontImpl_get_Strikethrough( 791 IFont* iface, 790 IFont* iface, 792 791 BOOL* pstrikethrough) 793 792 { … … 812 811 */ 813 812 static HRESULT WINAPI OLEFontImpl_put_Strikethrough( 814 IFont* iface, 813 IFont* iface, 815 814 BOOL strikethrough) 816 815 { … … 830 829 */ 831 830 static HRESULT WINAPI OLEFontImpl_get_Weight( 832 IFont* iface, 831 IFont* iface, 833 832 short* pweight) 834 833 { … … 853 852 */ 854 853 static HRESULT WINAPI OLEFontImpl_put_Weight( 855 IFont* iface, 854 IFont* iface, 856 855 short weight) 857 856 { … … 871 870 */ 872 871 static HRESULT WINAPI OLEFontImpl_get_Charset( 873 IFont* iface, 872 IFont* iface, 874 873 short* pcharset) 875 874 { … … 894 893 */ 895 894 static HRESULT WINAPI OLEFontImpl_put_Charset( 896 IFont* iface, 895 IFont* iface, 897 896 short charset) 898 897 { … … 928 927 INT fontHeight; 929 928 CY cySize; 930 929 931 930 /* 932 931 * The height of the font returned by the get_Size property is the … … 959 958 960 959 *phfont = this->gdiFont; 961 TRACE("Returning % 08x\n", *phfont);960 TRACE("Returning %p\n", *phfont); 962 961 return S_OK; 963 962 } … … 1001 1000 (1+strlenW(this->description.lpstrName))*2 1002 1001 ); 1002 strcpyW(newObject->description.lpstrName, this->description.lpstrName); 1003 1003 /* We need to clone the HFONT too. This is just cut & paste from above */ 1004 1004 IFont_get_Size(iface, &cySize); … … 1039 1039 */ 1040 1040 static HRESULT WINAPI OLEFontImpl_IsEqual( 1041 IFont* iface, 1041 IFont* iface, 1042 1042 IFont* pFontOther) 1043 1043 { … … 1071 1071 */ 1072 1072 static HRESULT WINAPI OLEFontImpl_QueryTextMetrics( 1073 IFont* iface, 1073 IFont* iface, 1074 1074 TEXTMETRICOLE* ptm) 1075 1075 { … … 1084 1084 */ 1085 1085 static HRESULT WINAPI OLEFontImpl_AddRefHfont( 1086 IFont* iface, 1086 IFont* iface, 1087 1087 HFONT hfont) 1088 1088 { 1089 1089 _ICOM_THIS(OLEFontImpl, iface); 1090 TRACE("(%p)->(% 08x) (lock=%ld)\n", this, hfont, this->fontLock);1090 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock); 1091 1091 1092 1092 if ( (hfont == 0) || … … 1109 1109 { 1110 1110 _ICOM_THIS(OLEFontImpl, iface); 1111 TRACE("(%p)->(% 08x) (lock=%ld)\n", this, hfont, this->fontLock);1111 TRACE("(%p)->(%p) (lock=%ld)\n", this, hfont, this->fontLock); 1112 1112 1113 1113 if ( (hfont == 0) || … … 1123 1123 { 1124 1124 DeleteObject(this->gdiFont); 1125 this->gdiFont = 0; 1125 this->gdiFont = 0; 1126 1126 } 1127 1127 … … 1139 1139 { 1140 1140 _ICOM_THIS(OLEFontImpl, iface); 1141 FIXME("(%p)->(% 08x): Stub\n", this, hdc);1141 FIXME("(%p)->(%p): Stub\n", this, hdc); 1142 1142 return E_NOTIMPL; 1143 1143 } … … 1190 1190 */ 1191 1191 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount( 1192 IDispatch* iface, 1192 IDispatch* iface, 1193 1193 unsigned int* pctinfo) 1194 1194 { … … 1205 1205 */ 1206 1206 static HRESULT WINAPI OLEFontImpl_GetTypeInfo( 1207 IDispatch* iface, 1207 IDispatch* iface, 1208 1208 UINT iTInfo, 1209 LCID lcid, 1209 LCID lcid, 1210 1210 ITypeInfo** ppTInfo) 1211 1211 { … … 1223 1223 static HRESULT WINAPI OLEFontImpl_GetIDsOfNames( 1224 1224 IDispatch* iface, 1225 REFIID riid, 1226 LPOLESTR* rgszNames, 1227 UINT cNames, 1225 REFIID riid, 1226 LPOLESTR* rgszNames, 1227 UINT cNames, 1228 1228 LCID lcid, 1229 1229 DISPID* rgDispId) … … 1242 1242 static HRESULT WINAPI OLEFontImpl_Invoke( 1243 1243 IDispatch* iface, 1244 DISPID dispIdMember, 1245 REFIID riid, 1246 LCID lcid, 1244 DISPID dispIdMember, 1245 REFIID riid, 1246 LCID lcid, 1247 1247 WORD wFlags, 1248 1248 DISPPARAMS* pDispParams, 1249 VARIANT* pVarResult, 1249 VARIANT* pVarResult, 1250 1250 EXCEPINFO* pExepInfo, 1251 1251 UINT* puArgErr) … … 1305 1305 */ 1306 1306 static HRESULT WINAPI OLEFontImpl_GetClassID( 1307 IPersistStream* iface, 1307 IPersistStream* iface, 1308 1308 CLSID* pClassID) 1309 1309 { … … 1360 1360 1361 1361 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); 1362 1362 1363 1363 /* 1364 1364 * Read the version byte … … 1389 1389 this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0; 1390 1390 this->description.fUnderline = (bAttributes & FONTPERSIST_UNDERLINE) != 0; 1391 1391 1392 1392 /* 1393 1393 * Weight … … 1428 1428 MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len ); 1429 1429 this->description.lpstrName[len] = 0; 1430 1431 /* Ensure use of this font causes a new one to be created @@@@ */ 1432 DeleteObject(this->gdiFont); 1433 this->gdiFont = 0; 1430 1434 1431 1435 return S_OK; … … 1447 1451 BYTE bAttributes; 1448 1452 BYTE bStringSize; 1449 1453 1450 1454 _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface); 1451 1455 … … 1476 1480 if (this->description.fStrikethrough) 1477 1481 bAttributes |= FONTPERSIST_STRIKETHROUGH; 1478 1482 1479 1483 if (this->description.fUnderline) 1480 1484 bAttributes |= FONTPERSIST_UNDERLINE; … … 1484 1488 if (cbWritten!=1) 1485 1489 return E_FAIL; 1486 1490 1487 1491 /* 1488 1492 * Weight … … 1652 1656 } IClassFactoryImpl; 1653 1657 1654 static HRESULT WINAPI 1658 static HRESULT WINAPI 1655 1659 SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) { 1656 1660 ICOM_THIS(IClassFactoryImpl,iface); -
trunk/src/oleaut32/olepicture.c
r8450 r9400 38 38 #include "config.h" 39 39 40 #include <unistd.h> 40 #ifdef HAVE_UNISTD_H 41 # include <unistd.h> 42 #endif 41 43 #include <stdio.h> 42 44 #include <string.h> … … 58 60 #ifdef HAVE_LIBJPEG 59 61 /* This is a hack, so jpeglib.h does not redefine INT32 and the like*/ 60 #define XMD_H 62 #define XMD_H 63 #define UINT8 JPEG_UINT8 61 64 #define UINT16 JPEG_UINT16 62 65 #ifdef HAVE_JPEGLIB_H … … 88 91 /* We own the object and must destroy it ourselves */ 89 92 BOOL fOwn; 90 93 91 94 /* Picture description */ 92 95 PICTDESC desc; … … 104 107 BOOL keepOrigFormat; 105 108 HDC hDCCur; 109 110 /* data */ 111 void* data; 112 int datalen; 106 113 } OLEPictureImpl; 107 114 … … 132 139 HDC hdcRef; 133 140 134 TRACE("bitmap handle % 08x\n", This->desc.u.bmp.hbitmap);141 TRACE("bitmap handle %p\n", This->desc.u.bmp.hbitmap); 135 142 if(GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) { 136 143 ERR("GetObject fails\n"); … … 168 175 * Allocate space for the object. 169 176 */ 170 newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEPictureImpl));177 newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl)); 171 178 172 179 if (newObject==0) 173 180 return newObject; 174 181 175 182 /* 176 183 * Initialize the virtual function table. … … 184 191 185 192 /* 186 * Start with one reference count. The caller of this function 193 * Start with one reference count. The caller of this function 187 194 * must release the interface pointer when it is done. 188 195 */ … … 208 215 209 216 case PICTYPE_METAFILE: 210 TRACE("metafile handle % 08x\n", pictDesc->u.wmf.hmeta);217 TRACE("metafile handle %p\n", pictDesc->u.wmf.hmeta); 211 218 newObject->himetricWidth = pictDesc->u.wmf.xExt; 212 219 newObject->himetricHeight = pictDesc->u.wmf.yExt; … … 223 230 newObject->desc.picType = PICTYPE_UNINITIALIZED; 224 231 } 225 232 226 233 TRACE("returning %p\n", newObject); 227 234 return newObject; … … 235 242 * this object. */ 236 243 static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj) 237 { 244 { 238 245 TRACE("(%p)\n", Obj); 239 246 … … 257 264 } 258 265 } 266 if (Obj->data) HeapFree(GetProcessHeap(), 0, Obj->data); 259 267 HeapFree(GetProcessHeap(), 0, Obj); 260 268 } … … 280 288 if ( (This==0) || (ppvObject==0) ) 281 289 return E_INVALIDARG; 282 290 283 291 /* 284 292 * Initialize the return parameter. 285 293 */ 286 294 *ppvObject = 0; 287 295 288 296 /* 289 297 * Compare the riid with the interface IDs implemented by this object. 290 298 */ 291 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 299 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 292 300 { 293 301 *ppvObject = (IPicture*)This; 294 302 } 295 else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0) 303 else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0) 296 304 { 297 305 *ppvObject = (IPicture*)This; 298 306 } 299 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 307 else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 300 308 { 301 309 *ppvObject = (IDispatch*)&(This->lpvtbl2); 302 310 } 303 else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0) 311 else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0) 304 312 { 305 313 *ppvObject = (IDispatch*)&(This->lpvtbl2); 306 314 } 307 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 315 else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 308 316 { 309 317 *ppvObject = (IPersistStream*)&(This->lpvtbl3); 310 318 } 311 else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0) 319 else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0) 312 320 { 313 321 *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4); … … 321 329 return E_NOINTERFACE; 322 330 } 323 331 324 332 /* 325 333 * Query Interface always increases the reference count by one when it is … … 328 336 OLEPictureImpl_AddRef((IPicture*)This); 329 337 330 return S_OK; ;338 return S_OK; 331 339 } 332 340 /*********************************************************************** … … 360 368 * See Windows documentation for more details on IUnknown methods. 361 369 */ 362 static ULONG WINAPI OLEPictureImpl_AddRef( 370 static ULONG WINAPI OLEPictureImpl_AddRef( 363 371 IPicture* iface) 364 372 { … … 369 377 return This->ref; 370 378 } 371 379 372 380 /************************************************************************ 373 381 * OLEPictureImpl_Release (IUnknown) … … 375 383 * See Windows documentation for more details on IUnknown methods. 376 384 */ 377 static ULONG WINAPI OLEPictureImpl_Release( 385 static ULONG WINAPI OLEPictureImpl_Release( 378 386 IPicture* iface) 379 387 { … … 395 403 return 0; 396 404 } 397 405 398 406 return This->ref; 399 407 } … … 402 410 /************************************************************************ 403 411 * OLEPictureImpl_get_Handle 404 */ 412 */ 405 413 static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface, 406 414 OLE_HANDLE *phandle) … … 410 418 switch(This->desc.picType) { 411 419 case PICTYPE_BITMAP: 412 *phandle = This->desc.u.bmp.hbitmap;420 *phandle = (OLE_HANDLE)This->desc.u.bmp.hbitmap; 413 421 break; 414 422 case PICTYPE_METAFILE: 415 *phandle = This->desc.u.wmf.hmeta;423 *phandle = (OLE_HANDLE)This->desc.u.wmf.hmeta; 416 424 break; 417 425 case PICTYPE_ICON: 418 *phandle = This->desc.u.icon.hicon;426 *phandle = (OLE_HANDLE)This->desc.u.icon.hicon; 419 427 break; 420 428 case PICTYPE_ENHMETAFILE: 421 *phandle = This->desc.u.emf.hemf;429 *phandle = (OLE_HANDLE)This->desc.u.emf.hemf; 422 430 break; 423 431 default: … … 431 439 /************************************************************************ 432 440 * OLEPictureImpl_get_hPal 433 */ 441 */ 434 442 static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface, 435 443 OLE_HANDLE *phandle) … … 442 450 /************************************************************************ 443 451 * OLEPictureImpl_get_Type 444 */ 452 */ 445 453 static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface, 446 454 short *ptype) … … 454 462 /************************************************************************ 455 463 * OLEPictureImpl_get_Width 456 */ 464 */ 457 465 static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface, 458 466 OLE_XSIZE_HIMETRIC *pwidth) … … 466 474 /************************************************************************ 467 475 * OLEPictureImpl_get_Height 468 */ 476 */ 469 477 static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface, 470 478 OLE_YSIZE_HIMETRIC *pheight) … … 478 486 /************************************************************************ 479 487 * OLEPictureImpl_Render 480 */ 488 */ 481 489 static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc, 482 490 long x, long y, long cx, long cy, … … 488 496 { 489 497 ICOM_THIS(OLEPictureImpl, iface); 490 TRACE("(%p)->(% 08x, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n",498 TRACE("(%p)->(%p, (%ld,%ld), (%ld,%ld) <- (%ld,%ld), (%ld,%ld), %p)\n", 491 499 This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds); 492 500 if(prcWBounds) … … 540 548 /************************************************************************ 541 549 * OLEPictureImpl_set_hPal 542 */ 550 */ 543 551 static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface, 544 552 OLE_HANDLE hpal) … … 552 560 /************************************************************************ 553 561 * OLEPictureImpl_get_CurDC 554 */ 562 */ 555 563 static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface, 556 564 HDC *phdc) 557 565 { 558 566 ICOM_THIS(OLEPictureImpl, iface); 559 TRACE("(%p), returning % x\n", This, This->hDCCur);567 TRACE("(%p), returning %p\n", This, This->hDCCur); 560 568 if (phdc) *phdc = This->hDCCur; 561 569 return S_OK; … … 564 572 /************************************************************************ 565 573 * OLEPictureImpl_SelectPicture 566 */ 574 */ 567 575 static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface, 568 576 HDC hdcIn, … … 571 579 { 572 580 ICOM_THIS(OLEPictureImpl, iface); 573 TRACE("(%p)->(% 08x, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut);581 TRACE("(%p)->(%p, %p, %p)\n", This, hdcIn, phdcOut, phbmpOut); 574 582 if (This->desc.picType == PICTYPE_BITMAP) { 575 583 SelectObject(hdcIn,This->desc.u.bmp.hbitmap); … … 579 587 This->hDCCur = hdcIn; 580 588 if (phbmpOut) 581 *phbmpOut = This->desc.u.bmp.hbitmap;589 *phbmpOut = (OLE_HANDLE)This->desc.u.bmp.hbitmap; 582 590 return S_OK; 583 591 } else { … … 589 597 /************************************************************************ 590 598 * OLEPictureImpl_get_KeepOriginalFormat 591 */ 599 */ 592 600 static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface, 593 601 BOOL *pfKeep) … … 603 611 /************************************************************************ 604 612 * OLEPictureImpl_put_KeepOriginalFormat 605 */ 613 */ 606 614 static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface, 607 615 BOOL keep) … … 616 624 /************************************************************************ 617 625 * OLEPictureImpl_PictureChanged 618 */ 626 */ 619 627 static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface) 620 628 { … … 627 635 /************************************************************************ 628 636 * OLEPictureImpl_SaveAsFile 629 */ 637 */ 630 638 static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface, 631 639 IStream *pstream, … … 634 642 { 635 643 ICOM_THIS(OLEPictureImpl, iface); 636 FIXME("(%p)->(%p, %d, %p) : stub\n", This, pstream, SaveMemCopy, pcbSize);637 return E_NOTIMPL;644 FIXME("(%p)->(%p, %d, %p), hacked stub.\n", This, pstream, SaveMemCopy, pcbSize); 645 return IStream_Write(pstream,This->data,This->datalen,(ULONG*)pcbSize); 638 646 } 639 647 640 648 /************************************************************************ 641 649 * OLEPictureImpl_get_Attributes 642 */ 650 */ 643 651 static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface, 644 652 DWORD *pdwAttr) … … 704 712 ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface); 705 713 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP); 706 if (!ppCP) 714 if (!ppCP) 707 715 return E_POINTER; 708 716 *ppCP = NULL; … … 824 832 } 825 833 xread = 0; 826 xbuf = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]); 834 xbuf = This->data = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,header[1]); 835 This->datalen = header[1]; 827 836 while (xread < header[1]) { 828 ULONG nread; 837 ULONG nread; 829 838 hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread); 830 839 xread+=nread; … … 998 1007 break; 999 1008 } 1000 HeapFree(GetProcessHeap(),0,xbuf);1001 1009 1002 1010 /* FIXME: this notify is not really documented */ … … 1072 1080 */ 1073 1081 static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount( 1074 IDispatch* iface, 1082 IDispatch* iface, 1075 1083 unsigned int* pctinfo) 1076 1084 { … … 1086 1094 */ 1087 1095 static HRESULT WINAPI OLEPictureImpl_GetTypeInfo( 1088 IDispatch* iface, 1096 IDispatch* iface, 1089 1097 UINT iTInfo, 1090 LCID lcid, 1098 LCID lcid, 1091 1099 ITypeInfo** ppTInfo) 1092 1100 { … … 1103 1111 static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames( 1104 1112 IDispatch* iface, 1105 REFIID riid, 1106 LPOLESTR* rgszNames, 1107 UINT cNames, 1113 REFIID riid, 1114 LPOLESTR* rgszNames, 1115 UINT cNames, 1108 1116 LCID lcid, 1109 1117 DISPID* rgDispId) … … 1121 1129 static HRESULT WINAPI OLEPictureImpl_Invoke( 1122 1130 IDispatch* iface, 1123 DISPID dispIdMember, 1124 REFIID riid, 1125 LCID lcid, 1131 DISPID dispIdMember, 1132 REFIID riid, 1133 LCID lcid, 1126 1134 WORD wFlags, 1127 1135 DISPPARAMS* pDispParams, 1128 VARIANT* pVarResult, 1136 VARIANT* pVarResult, 1129 1137 EXCEPINFO* pExepInfo, 1130 1138 UINT* puArgErr) … … 1271 1279 1272 1280 /*********************************************************************** 1273 * OleLoadPictureEx (OLEAUT32.4 25)1281 * OleLoadPictureEx (OLEAUT32.401) 1274 1282 */ 1275 1283 HRESULT WINAPI OleLoadPictureEx( LPSTREAM lpstream, LONG lSize, BOOL fRunmode, 1276 REFIID reed, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj ) 1277 { 1278 FIXME("(%p,%ld,%d,%p,%lx,%lx,%lx,%p), not implemented\n", 1279 lpstream, lSize, fRunmode, reed, xsiz, ysiz, flags, ppvObj); 1280 return S_OK; 1281 } 1282 1284 REFIID riid, DWORD xsiz, DWORD ysiz, DWORD flags, LPVOID *ppvObj ) 1285 { 1286 LPPERSISTSTREAM ps; 1287 IPicture *newpic; 1288 HRESULT hr; 1289 1290 FIXME("(%p,%ld,%d,%s,x=%ld,y=%ld,f=%lx,%p), partially implemented.\n", 1291 lpstream, lSize, fRunmode, debugstr_guid(riid), xsiz, ysiz, flags, ppvObj); 1292 1293 hr = OleCreatePictureIndirect(NULL,riid,!fRunmode,(LPVOID*)&newpic); 1294 if (hr) 1295 return hr; 1296 hr = IPicture_QueryInterface(newpic,&IID_IPersistStream, (LPVOID*)&ps); 1297 if (hr) { 1298 FIXME("Could not get IPersistStream iface from Ole Picture?\n"); 1299 IPicture_Release(newpic); 1300 *ppvObj = NULL; 1301 return hr; 1302 } 1303 IPersistStream_Load(ps,lpstream); 1304 IPersistStream_Release(ps); 1305 hr = IPicture_QueryInterface(newpic,riid,ppvObj); 1306 if (hr) 1307 FIXME("Failed to get interface %s from IPicture.\n",debugstr_guid(riid)); 1308 IPicture_Release(newpic); 1309 return hr; 1310 } -
trunk/src/oleaut32/parsedt.c
r8450 r9400 66 66 "Thursday", "Friday", "Saturday", NULL}; 67 67 68 /* those three vars are useless, and not even initialized, so 68 /* those three vars are useless, and not even initialized, so 69 69 * I'd rather remove them all (EPP) 70 70 */ 71 int DateStyle; 71 int DateStyle; 72 72 bool EuroDates; 73 73 int CTimeZone; … … 80 80 #define UTIME_MAXDAY (18) 81 81 82 /* Assumes month in 1..12. Note tm_mon is 0..11 */ 82 83 #define IS_VALID_UTIME(y,m,d) (((y > UTIME_MINYEAR) \ 83 84 || ((y == UTIME_MINYEAR) && ((m > UTIME_MINMONTH) \ … … 601 602 printf("DecodeDateTime- month field %s value is %d\n", field[i], val); 602 603 #endif 603 tm->tm_mon = val; 604 /* tm_mon is 0->11, so need to subtract one from value in table */ 605 tm->tm_mon = val-1; 604 606 break; 605 607 … … 681 683 tm->tm_hour += 12; 682 684 685 /* If parsing a time string into a date, all date parts are unset. 686 Win2k defaults these to 30 dec, 1899 so: */ 687 if (tm->tm_year == 0 && tm->tm_mon == 0 && tm->tm_mday == 0 && fmask == DTK_TIME_M) { 688 tm->tm_year = 1899; 689 tm->tm_mon = 11; /* December, as tm_mon is 0..11 */ 690 tm->tm_mday = 30; 691 } 692 693 683 694 #ifdef DATEDEBUG 684 695 printf("DecodeDateTime- mask %08x (%08x)", fmask, DTK_DATE_M); 685 printf(" set y%04d m%02d d%02d", tm->tm_year, tm->tm_mon, tm->tm_mday);696 printf(" set y%04d m%02d d%02d", tm->tm_year, (tm->tm_mon+1), tm->tm_mday); 686 697 printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec); 687 698 #endif … … 702 713 return -1; 703 714 704 if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon , tm->tm_mday))715 if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon+1, tm->tm_mday)) 705 716 { 706 717 /* FIXME: The code below is not correct */ … … 910 921 printf("DecodeDate- month field %s value is %d\n", field[i], val); 911 922 #endif 912 tm->tm_mon = val; 923 /* tm_mon is 0->11, so need to subtract one from value in table */ 924 tm->tm_mon = val-1; 913 925 break; 914 926 … … 1076 1088 #endif 1077 1089 *tmask = DTK_M(MONTH); 1078 tm->tm_mon = val; 1090 /* tm_mon is 0..11 */ 1091 tm->tm_mon = val-1; 1079 1092 1080 1093 /* no year and EuroDates enabled? then could be day */ … … 1098 1111 #endif 1099 1112 *tmask = DTK_M(MONTH); 1100 tm->tm_mon = val; 1113 /* tm_mon is 0..11 */ 1114 tm->tm_mon = val-1; 1101 1115 1102 1116 } … … 1150 1164 tm->tm_mday = atoi(str + 6); 1151 1165 *(str + 6) = '\0'; 1152 tm->tm_mon = atoi(str + 4) ;1166 tm->tm_mon = atoi(str + 4) - 1; /* tm_mon is 0..11 */ 1153 1167 *(str + 4) = '\0'; 1154 1168 tm->tm_year = atoi(str + 0); … … 1182 1196 tm->tm_mday = atoi(str + 4); 1183 1197 *(str + 4) = '\0'; 1184 tm->tm_mon = atoi(str + 2) ;1198 tm->tm_mon = atoi(str + 2) - 1; /* tm_mon is 0..11 */ 1185 1199 *(str + 2) = '\0'; 1186 1200 tm->tm_year = atoi(str + 0); … … 1331 1345 return NULL; 1332 1346 } 1333 1334 1335 -
trunk/src/oleaut32/safearray.c
r8450 r9400 25 25 #define WINE_LARGE_INTEGER 26 26 #include "oleaut32.h" 27 28 27 #endif 29 28 … … 42 41 43 42 /* Locally used methods */ 44 static INT 43 static INT 45 44 endOfDim(LONG *coor, SAFEARRAYBOUND *mat, LONG dim, LONG realDim); 46 45 47 static ULONG 46 static ULONG 48 47 calcDisplacement(LONG *coor, SAFEARRAYBOUND *mat, LONG dim); 49 48 50 static BOOL 49 static BOOL 51 50 isPointer(USHORT feature); 52 51 53 static INT 52 static INT 54 53 getFeatures(VARTYPE vt); 55 54 56 static BOOL 55 static BOOL 57 56 validCoordinate(LONG *coor, SAFEARRAY *psa); 58 57 59 static BOOL 58 static BOOL 60 59 resizeSafeArray(SAFEARRAY *psa, LONG lDelta); 61 60 62 static BOOL 61 static BOOL 63 62 validArg(SAFEARRAY *psa); 64 63 65 static ULONG 64 static ULONG 66 65 getArraySize(SAFEARRAY *psa); 67 66 68 static HRESULT 67 static HRESULT 69 68 duplicateData(SAFEARRAY *psa, SAFEARRAY **ppsaOut); 70 69 … … 129 128 * Allocate the appropriate amount of memory for the SafeArray descriptor 130 129 */ 131 HRESULT WINAPI SafeArrayAllocDescriptor( 132 UINT cDims, 133 SAFEARRAY **ppsaOut) 130 HRESULT WINAPI SafeArrayAllocDescriptor( 131 UINT cDims, 132 SAFEARRAY **ppsaOut) 134 133 { 135 134 SAFEARRAYBOUND *sab; … … 141 140 142 141 /* Allocate memory for SAFEARRAY struc */ 143 if(( (*ppsaOut)=HeapAlloc( 142 if(( (*ppsaOut)=HeapAlloc( 144 143 GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){ 145 144 return(E_UNEXPECTED); … … 151 150 152 151 /************************************************************************* 153 * SafeArrayAllocDescriptorEx (OLEAUT32.4 29)152 * SafeArrayAllocDescriptorEx (OLEAUT32.41) 154 153 * Allocate the appropriate amount of memory for the SafeArray descriptor 155 154 * … … 158 157 * The MSDN documentation on this doesn't tell us much. 159 158 */ 160 HRESULT WINAPI SafeArrayAllocDescriptorEx( 159 HRESULT WINAPI SafeArrayAllocDescriptorEx( 161 160 VARTYPE vt, 162 UINT cDims, 163 SAFEARRAY **ppsaOut) 161 UINT cDims, 162 SAFEARRAY **ppsaOut) 164 163 { 165 164 if ( (vt >= LAST_VARTYPE) || … … 175 174 */ 176 175 HRESULT WINAPI SafeArrayAllocData( 177 SAFEARRAY *psa) 176 SAFEARRAY *psa) 178 177 { 179 178 ULONG ulWholeArraySize; /* to store the size of the whole thing */ 180 179 181 if(! validArg(psa)) 180 if(! validArg(psa)) 182 181 return E_INVALIDARG; 183 182 … … 185 184 186 185 /* Allocate memory for the data itself */ 187 if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 186 if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 188 187 psa->cbElements*ulWholeArraySize)) == NULL) 189 188 return(E_UNEXPECTED); 190 189 191 TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n", 190 TRACE("SafeArray: %lu bytes allocated for data at %p (%lu objects).\n", 192 191 psa->cbElements*ulWholeArraySize, psa->pvData, ulWholeArraySize); 193 192 … … 197 196 /************************************************************************* 198 197 * SafeArrayCreate (OLEAUT32.15) 199 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData 198 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData 200 199 */ 201 200 SAFEARRAY* WINAPI SafeArrayCreate( 202 VARTYPE vt, 203 UINT cDims, 201 VARTYPE vt, 202 UINT cDims, 204 203 SAFEARRAYBOUND *rgsabound) 205 204 { … … 217 216 return NULL; 218 217 219 /* setup data members... */ 218 /* setup data members... */ 220 219 psa->cDims = cDims; 221 220 psa->fFeatures = getFeatures(vt); … … 230 229 } 231 230 232 /* allocate memory for the data... */ 231 /* allocate memory for the data... */ 233 232 if( FAILED( hRes = SafeArrayAllocData(psa))) { 234 SafeArrayDestroyDescriptor(psa); 233 SafeArrayDestroyDescriptor(psa); 235 234 ERR("() : Failed to allocate the Safe Array data\n"); 236 235 return NULL; 237 236 } 238 237 239 return(psa); 238 return(psa); 240 239 } 241 240 … … 248 247 { 249 248 /* Check for lockness before to free... */ 250 if(psa->cLocks > 0) 249 if(psa->cLocks > 0) 251 250 return DISP_E_ARRAYISLOCKED; 252 251 253 252 /* The array is unlocked, then, deallocate memory */ 254 if(HeapFree( GetProcessHeap(), 0, psa) == FALSE) 253 if(HeapFree( GetProcessHeap(), 0, psa) == FALSE) 255 254 return E_UNEXPECTED; 256 255 257 256 return(S_OK); 258 257 } … … 264 263 * 265 264 * Doc says (MSDN Library ) that psa->pvData should be made available (!= NULL) 266 * only when psa->cLocks is > 0... I don't get it since pvData is allocated 267 * before the array is locked, therefore 265 * only when psa->cLocks is > 0... I don't get it since pvData is allocated 266 * before the array is locked, therefore 268 267 */ 269 268 HRESULT WINAPI SafeArrayLock( 270 269 SAFEARRAY *psa) 271 270 { 272 if(! validArg(psa)) 271 if(! validArg(psa)) 273 272 return E_INVALIDARG; 274 273 … … 285 284 SAFEARRAY *psa) 286 285 { 287 if(! validArg(psa)) 288 return E_INVALIDARG; 289 290 if (psa->cLocks > 0) 286 if(! validArg(psa)) 287 return E_INVALIDARG; 288 289 if (psa->cLocks > 0) 291 290 psa->cLocks--; 292 291 … … 300 299 */ 301 300 HRESULT WINAPI SafeArrayPutElement( 302 SAFEARRAY *psa, 303 LONG *rgIndices, 301 SAFEARRAY *psa, 302 LONG *rgIndices, 304 303 void *pv) 305 304 { 306 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 305 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 307 306 the desired one... */ 308 307 PVOID elementStorageAddress = NULL; /* Adress to store the data */ 309 308 310 309 /* Validate the index given */ 311 if(! validCoordinate(rgIndices, psa)) 310 if(! validCoordinate(rgIndices, psa)) 312 311 return DISP_E_BADINDEX; 313 312 if(! validArg(psa)) … … 318 317 /* Figure out the number of items to skip */ 319 318 stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims); 320 319 321 320 /* Figure out the number of byte to skip ... */ 322 321 elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements); 323 322 324 323 if(isPointer(psa->fFeatures)) { /* increment ref count for this pointer */ 325 324 326 *((PVOID*)elementStorageAddress) = *(PVOID*)pv; 325 *((PVOID*)elementStorageAddress) = *(PVOID*)pv; 327 326 IUnknown_AddRef( *(IUnknown**)pv); 328 327 329 } else { 328 } else { 330 329 331 330 if(psa->fFeatures == FADF_BSTR) { /* Create a new object */ … … 333 332 if(pv && 334 333 ((pbstrReAllocStr = SYSDUPSTRING( (OLECHAR*)pv )) == NULL)) { 335 SafeArrayUnlock(psa); 334 SafeArrayUnlock(psa); 336 335 return E_OUTOFMEMORY; 337 } else 336 } else 338 337 *((BSTR*)elementStorageAddress) = pbstrReAllocStr; 339 338 } … … 355 354 356 355 TRACE("SafeArray: item put at adress %p.\n",elementStorageAddress); 357 return SafeArrayUnlock(psa); 356 return SafeArrayUnlock(psa); 358 357 } 359 358 … … 364 363 */ 365 364 HRESULT WINAPI SafeArrayGetElement( 366 SAFEARRAY *psa, 367 LONG *rgIndices, 365 SAFEARRAY *psa, 366 LONG *rgIndices, 368 367 void *pv) 369 368 { 370 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 369 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 371 370 the desired one... */ 372 371 PVOID elementStorageAddress = NULL; /* Adress to store the data */ 373 372 374 if(! validArg(psa)) 375 return E_INVALIDARG; 376 373 if(! validArg(psa)) 374 return E_INVALIDARG; 375 377 376 if(! validCoordinate(rgIndices, psa)) /* Validate the index given */ 378 377 return(DISP_E_BADINDEX); … … 382 381 /* Figure out the number of items to skip */ 383 382 stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims); 384 383 385 384 /* Figure out the number of byte to skip ... */ 386 385 elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements); 387 386 388 387 if( psa->fFeatures == FADF_BSTR) { /* reallocate the obj */ 389 388 BSTR pbstrStoredStr = *(OLECHAR**)elementStorageAddress; … … 393 392 SafeArrayUnlock(psa); 394 393 return E_OUTOFMEMORY; 395 } else 396 *((BSTR*)pv) = pbstrReturnedStr; 394 } else 395 *((BSTR*)pv) = pbstrReturnedStr; 397 396 } 398 397 else if( psa->fFeatures == FADF_VARIANT) { … … 406 405 } 407 406 else if( isPointer(psa->fFeatures) ) /* simply copy the pointer */ 408 *(PVOID*)pv = *((PVOID*)elementStorageAddress); 407 *(PVOID*)pv = *((PVOID*)elementStorageAddress); 409 408 else /* copy the bytes */ 410 409 memcpy(pv, elementStorageAddress, psa->cbElements ); … … 415 414 } 416 415 417 return( SafeArrayUnlock(psa) ); 416 return( SafeArrayUnlock(psa) ); 418 417 } 419 418 … … 423 422 */ 424 423 HRESULT WINAPI SafeArrayGetUBound( 425 SAFEARRAY *psa, 424 SAFEARRAY *psa, 426 425 UINT nDim, 427 426 LONG *plUbound) 428 427 { 429 if(! validArg(psa)) 430 return E_INVALIDARG; 431 432 if(nDim > psa->cDims) 428 if(! validArg(psa)) 429 return E_INVALIDARG; 430 431 if(nDim > psa->cDims) 433 432 return DISP_E_BADINDEX; 434 433 … … 436 435 return DISP_E_BADINDEX; 437 436 438 *plUbound = psa->rgsabound[nDim-1].lLbound + 437 *plUbound = psa->rgsabound[nDim-1].lLbound + 439 438 psa->rgsabound[nDim-1].cElements - 1; 440 439 … … 444 443 /************************************************************************* 445 444 * SafeArrayGetLBound (OLEAUT32.20) 446 * Return the LO bound for a given array dimension 445 * Return the LO bound for a given array dimension 447 446 */ 448 447 HRESULT WINAPI SafeArrayGetLBound( 449 448 SAFEARRAY *psa, 450 UINT nDim, 449 UINT nDim, 451 450 LONG *plLbound) 452 451 { 453 if(! validArg(psa)) 454 return E_INVALIDARG; 455 456 if(nDim > psa->cDims) 452 if(! validArg(psa)) 453 return E_INVALIDARG; 454 455 if(nDim > psa->cDims) 457 456 return DISP_E_BADINDEX; 458 457 459 458 if(0 == nDim) 460 459 return DISP_E_BADINDEX; 461 460 462 461 *plLbound = psa->rgsabound[nDim-1].lLbound; 463 462 return S_OK; … … 470 469 UINT WINAPI SafeArrayGetDim( 471 470 SAFEARRAY * psa) 472 { 471 { 473 472 /* 474 473 * A quick test in Windows shows that the behavior here for an invalid 475 474 * pointer is to return 0. 476 475 */ 477 if(! validArg(psa)) 476 if(! validArg(psa)) 478 477 return 0; 479 478 … … 487 486 UINT WINAPI SafeArrayGetElemsize( 488 487 SAFEARRAY * psa) 489 { 488 { 490 489 /* 491 490 * A quick test in Windows shows that the behavior here for an invalid 492 491 * pointer is to return 0. 493 492 */ 494 if(! validArg(psa)) 493 if(! validArg(psa)) 495 494 return 0; 496 495 … … 500 499 /************************************************************************* 501 500 * SafeArrayAccessData (OLEAUT32.23) 502 * increment the access count and return the data 501 * increment the access count and return the data 503 502 */ 504 503 HRESULT WINAPI SafeArrayAccessData( 505 SAFEARRAY *psa, 504 SAFEARRAY *psa, 506 505 void **ppvData) 507 { 506 { 508 507 HRESULT hRes; 509 508 510 if(! validArg(psa)) 509 if(! validArg(psa)) 511 510 return E_INVALIDARG; 512 511 … … 514 513 515 514 switch (hRes) { 516 case S_OK: 515 case S_OK: 517 516 (*ppvData) = psa->pvData; 518 517 break; … … 521 520 return E_INVALIDARG; 522 521 } 523 522 524 523 return S_OK; 525 524 } … … 532 531 HRESULT WINAPI SafeArrayUnaccessData( 533 532 SAFEARRAY * psa) 534 { 535 if(! validArg(psa)) 533 { 534 if(! validArg(psa)) 536 535 return E_INVALIDARG; 537 536 … … 539 538 } 540 539 541 /************************************************************************ 540 /************************************************************************ 542 541 * SafeArrayPtrOfIndex (OLEAUT32.148) 543 542 * Return a pointer to the element at rgIndices 544 543 */ 545 544 HRESULT WINAPI SafeArrayPtrOfIndex( 546 SAFEARRAY *psa, 547 LONG *rgIndices, 545 SAFEARRAY *psa, 546 LONG *rgIndices, 548 547 void **ppvData) 549 { 550 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 548 { 549 ULONG stepCountInSAData = 0; /* Number of array item to skip to get to 551 550 the desired one... */ 552 551 553 if(! validArg(psa)) 554 return E_INVALIDARG; 555 556 if(! validCoordinate(rgIndices, psa)) 552 if(! validArg(psa)) 553 return E_INVALIDARG; 554 555 if(! validCoordinate(rgIndices, psa)) 557 556 return DISP_E_BADINDEX; 558 557 … … 563 562 /* Figure out the number of items to skip */ 564 563 stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims); 565 564 566 565 *ppvData = (char *) psa->pvData+(stepCountInSAData*psa->cbElements); 567 566 … … 569 568 } 570 569 571 /************************************************************************ 570 /************************************************************************ 572 571 * SafeArrayDestroyData (OLEAUT32.39) 573 572 * Frees the memory data bloc … … 575 574 HRESULT WINAPI SafeArrayDestroyData( 576 575 SAFEARRAY *psa) 577 { 576 { 578 577 HRESULT hRes; 579 578 ULONG ulWholeArraySize; /* count spot in array */ 580 579 ULONG ulDataIter; /* to iterate the data space */ 581 580 582 if(! validArg(psa)) 583 return E_INVALIDARG; 584 585 if(psa->cLocks > 0) 581 if(! validArg(psa)) 582 return E_INVALIDARG; 583 584 if(psa->cLocks > 0) 586 585 return DISP_E_ARRAYISLOCKED; 587 586 … … 592 591 593 592 for(ulDataIter=0; ulDataIter < ulWholeArraySize; ulDataIter++) { 594 punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements))); 595 596 if( punk != NULL) 593 punk = *(IUnknown**)((char *) psa->pvData+(ulDataIter*(psa->cbElements))); 594 595 if( punk != NULL) 597 596 IUnknown_Release(punk); 598 597 } … … 605 604 bstr = *(BSTR*)((char *) psa->pvData+(ulDataIter*(psa->cbElements))); 606 605 607 if( bstr != NULL) 606 if( bstr != NULL) 608 607 SysFreeString( bstr ); 609 608 } … … 615 614 } 616 615 } 617 618 /* check if this array is a Vector, in which case do not free the data 616 617 /* check if this array is a Vector, in which case do not free the data 619 618 block since it has been allocated by AllocDescriptor and therefore 620 619 deserve to be freed by DestroyDescriptor */ … … 627 626 psa->pvData = NULL; 628 627 } 629 628 630 629 return S_OK; 631 630 } 632 631 633 /************************************************************************ 632 /************************************************************************ 634 633 * SafeArrayCopyData (OLEAUT32.412) 635 634 * Copy the psaSource's data block into psaTarget if dimension and size … … 639 638 SAFEARRAY *psaSource, 640 639 SAFEARRAY **psaTarget) 641 { 640 { 642 641 USHORT cDimCount; /* looper */ 643 642 LONG lDelta; /* looper */ 644 IUnknown *punk; 643 IUnknown *punk; 645 644 ULONG ulWholeArraySize; /* Number of item in SA */ 646 645 BSTR bstr; 647 646 648 if(! (validArg(psaSource) && validArg(*psaTarget)) ) 647 if(! (validArg(psaSource) && validArg(*psaTarget)) ) 649 648 return E_INVALIDARG; 650 649 … … 652 651 return E_INVALIDARG; 653 652 654 ulWholeArraySize = getArraySize(psaSource); 653 ulWholeArraySize = getArraySize(psaSource); 655 654 656 655 /* The two arrays boundaries must be of same lenght */ 657 656 for(cDimCount=0;cDimCount < psaSource->cDims; cDimCount++) 658 if( psaSource->rgsabound[cDimCount].cElements != 657 if( psaSource->rgsabound[cDimCount].cElements != 659 658 (*psaTarget)->rgsabound[cDimCount].cElements) 660 659 return E_INVALIDARG; 661 660 662 if( isPointer((*psaTarget)->fFeatures) ) { /* the target contains ptr 661 if( isPointer((*psaTarget)->fFeatures) ) { /* the target contains ptr 663 662 that must be released */ 664 663 for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) { … … 666 665 ((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements)); 667 666 668 if( punk != NULL) 667 if( punk != NULL) 669 668 IUnknown_Release(punk); 670 669 } … … 672 671 } 673 672 else if( (*psaTarget)->fFeatures & FADF_BSTR) { /* the target contain BSTR 674 that must be freed */ 673 that must be freed */ 675 674 for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) { 676 bstr = 675 bstr = 677 676 *(BSTR*)((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements)); 678 677 679 if( bstr != NULL) 678 if( bstr != NULL) 680 679 SysFreeString( bstr ); 681 680 } … … 691 690 } 692 691 693 /************************************************************************ 692 /************************************************************************ 694 693 * SafeArrayDestroy (OLEAUT32.16) 695 694 * Deallocates all memory reserved for the SafeArray … … 697 696 HRESULT WINAPI SafeArrayDestroy( 698 697 SAFEARRAY * psa) 699 { 698 { 700 699 HRESULT hRes; 701 700 702 if(! validArg(psa)) 703 return E_INVALIDARG; 704 705 if(psa->cLocks > 0) 701 if(! validArg(psa)) 702 return E_INVALIDARG; 703 704 if(psa->cLocks > 0) 706 705 return DISP_E_ARRAYISLOCKED; 707 706 … … 713 712 } 714 713 715 /************************************************************************ 714 /************************************************************************ 716 715 * SafeArrayCopy (OLEAUT32.27) 717 716 * Make a dupplicate of a SafeArray 718 717 */ 719 718 HRESULT WINAPI SafeArrayCopy( 720 SAFEARRAY *psa, 719 SAFEARRAY *psa, 721 720 SAFEARRAY **ppsaOut) 722 { 721 { 723 722 HRESULT hRes; 724 723 DWORD dAllocSize; 725 724 ULONG ulWholeArraySize; /* size of the thing */ 726 725 727 if(! validArg(psa)) 726 if(! validArg(psa)) 728 727 return E_INVALIDARG; 729 728 … … 731 730 732 731 /* Duplicate the SAFEARRAY struc */ 733 memcpy(*ppsaOut, psa, 732 memcpy(*ppsaOut, psa, 734 733 sizeof(*psa)+(sizeof(*(psa->rgsabound))*(psa->cDims-1))); 735 734 … … 738 737 /* make sure the new safe array doesn't have the FADF_CREATEVECTOR flag, 739 738 because the data has not been allocated with the descriptor. */ 740 (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR; 741 742 /* Get the allocated memory size for source and allocate it for target */ 739 (*ppsaOut)->fFeatures &= ~FADF_CREATEVECTOR; 740 741 /* Get the allocated memory size for source and allocate it for target */ 743 742 ulWholeArraySize = getArraySize(psa); /* Number of item in SA */ 744 743 dAllocSize = ulWholeArraySize*psa->cbElements; 745 744 746 (*ppsaOut)->pvData = 745 (*ppsaOut)->pvData = 747 746 HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dAllocSize); 748 747 if( (*ppsaOut)->pvData != NULL) { /* HeapAlloc succeed */ … … 754 753 return hRes; 755 754 } 756 755 757 756 } else { /* failed to allocate or dupplicate... */ 758 757 SafeArrayDestroyDescriptor(*ppsaOut); … … 766 765 } 767 766 768 /************************************************************************ 767 /************************************************************************ 769 768 * SafeArrayCreateVector (OLEAUT32.411) 770 * Creates a one dimension safearray where the data is next to the 769 * Creates a one dimension safearray where the data is next to the 771 770 * SAFEARRAY structure. 772 771 */ 773 772 SAFEARRAY* WINAPI SafeArrayCreateVector( 774 VARTYPE vt, 775 LONG lLbound, 776 ULONG cElements) 777 { 773 VARTYPE vt, 774 LONG lLbound, 775 ULONG cElements) 776 { 778 777 SAFEARRAY *psa; 779 778 … … 784 783 785 784 /* Allocate memory for the array descriptor and data contiguously */ 786 if( FAILED( psa = HeapAlloc( GetProcessHeap(), 787 HEAP_ZERO_MEMORY, 785 if( FAILED( psa = HeapAlloc( GetProcessHeap(), 786 HEAP_ZERO_MEMORY, 788 787 (sizeof(*psa) + (VARTYPE_SIZE[vt] * cElements))))) { 789 788 return NULL; 790 789 } 791 792 /* setup data members... */ 790 791 /* setup data members... */ 793 792 psa->cDims = 1; /* always and forever */ 794 793 psa->fFeatures = getFeatures(vt) | FADF_CREATEVECTOR; /* undocumented flag used by Microsoft */ … … 800 799 psa->rgsabound[0].lLbound = lLbound; 801 800 802 return(psa); 803 } 804 805 /************************************************************************ 801 return(psa); 802 } 803 804 /************************************************************************ 806 805 * SafeArrayRedim (OLEAUT32.40) 807 806 * Changes the caracteristics of the last dimension of the SafeArray 808 807 */ 809 808 HRESULT WINAPI SafeArrayRedim( 810 SAFEARRAY *psa, 809 SAFEARRAY *psa, 811 810 SAFEARRAYBOUND *psaboundNew) 812 { 811 { 813 812 LONG lDelta; /* hold difference in size */ 814 813 USHORT cDims=1; /* dims counter */ 815 814 816 if( !validArg(psa) ) 817 return E_INVALIDARG; 818 819 if( psa->cLocks > 0 ) 815 if( !validArg(psa) ) 816 return E_INVALIDARG; 817 818 if( psa->cLocks > 0 ) 820 819 return DISP_E_ARRAYISLOCKED; 821 820 822 if( psa->fFeatures & FADF_FIXEDSIZE ) 823 return E_INVALIDARG; 824 825 if( SafeArrayLock(psa)==E_UNEXPECTED ) 821 if( psa->fFeatures & FADF_FIXEDSIZE ) 822 return E_INVALIDARG; 823 824 if( SafeArrayLock(psa)==E_UNEXPECTED ) 826 825 return E_UNEXPECTED;/* UNDOC error condition */ 827 826 … … 837 836 838 837 } else /* need to enlarge (lDelta +) reduce (lDelta -) */ 839 if(! resizeSafeArray(psa, lDelta)) 838 if(! resizeSafeArray(psa, lDelta)) 840 839 return E_UNEXPECTED; /* UNDOC error condition */ 841 840 842 /* the only modifyable dimension sits in [0] as the dimensions were reversed 841 /* the only modifyable dimension sits in [0] as the dimensions were reversed 843 842 at array creation time... */ 844 843 psa->rgsabound[0].cElements = psaboundNew->cElements; … … 852 851 ************************************************************************/ 853 852 854 /************************************************************************ 853 /************************************************************************ 855 854 * Used to validate the SAFEARRAY type of arg 856 855 */ 857 856 static BOOL validArg( 858 SAFEARRAY *psa) 857 SAFEARRAY *psa) 859 858 { 860 859 SAFEARRAYBOUND *sab; … … 886 885 } 887 886 888 /************************************************************************ 887 /************************************************************************ 889 888 * Used to reallocate memory 890 889 */ 891 890 static BOOL resizeSafeArray( 892 SAFEARRAY *psa, 891 SAFEARRAY *psa, 893 892 LONG lDelta) 894 893 { 895 894 ULONG ulWholeArraySize; /* use as multiplicator */ 896 PVOID pvNewBlock = NULL; 895 PVOID pvNewBlock = NULL; 897 896 IUnknown *punk; 898 897 BSTR bstr; … … 905 904 punk = *(IUnknown**) 906 905 ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements)); 907 906 908 907 if( punk != NULL ) 909 908 IUnknown_Release(punk); … … 926 925 if (!(psa->fFeatures & FADF_CREATEVECTOR)) 927 926 { 928 /* Ok now, if we are enlarging the array, we *MUST* move the whole block 927 /* Ok now, if we are enlarging the array, we *MUST* move the whole block 929 928 pointed to by pvData. If we are shorthening the array, this move is 930 optional but we do it anyway becuase the benefit is that we are 929 optional but we do it anyway becuase the benefit is that we are 931 930 releasing to the system the unused memory */ 932 931 933 if((pvNewBlock = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, psa->pvData, 934 (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL) 932 if((pvNewBlock = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, psa->pvData, 933 (ulWholeArraySize + lDelta) * psa->cbElements)) == NULL) 935 934 return FALSE; /* TODO If we get here it means: 936 935 SHRINK situation : we've deleted the undesired … … 941 940 else 942 941 { 943 /* Allocate a new block, because the previous data has been allocated with 942 /* Allocate a new block, because the previous data has been allocated with 944 943 the descriptor in SafeArrayCreateVector function. */ 945 944 946 945 if((pvNewBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 947 ulWholeArraySize * psa->cbElements)) == NULL) 946 ulWholeArraySize * psa->cbElements)) == NULL) 948 947 return FALSE; 949 948 … … 955 954 } 956 955 957 /************************************************************************ 958 * Used to set the fFeatures data member of the SAFEARRAY structure. 956 /************************************************************************ 957 * Used to set the fFeatures data member of the SAFEARRAY structure. 959 958 */ 960 959 static INT getFeatures( 961 VARTYPE vt) 960 VARTYPE vt) 962 961 { 963 962 switch(vt) { … … 970 969 } 971 970 972 /************************************************************************ 973 * Used to figure out if the fFeatures data member of the SAFEARRAY 974 * structure contain any information about the type of data stored... 971 /************************************************************************ 972 * Used to figure out if the fFeatures data member of the SAFEARRAY 973 * structure contain any information about the type of data stored... 975 974 */ 976 975 static BOOL isPointer( 977 USHORT feature) 976 USHORT feature) 978 977 { 979 978 switch(feature) { … … 984 983 } 985 984 986 /************************************************************************ 987 * Used to calculate the displacement when accessing or modifying 985 /************************************************************************ 986 * Used to calculate the displacement when accessing or modifying 988 987 * safearray data set. 989 988 * … … 995 994 */ 996 995 static ULONG calcDisplacement( 997 LONG *coor, 998 SAFEARRAYBOUND *mat, 999 LONG dim) 996 LONG *coor, 997 SAFEARRAYBOUND *mat, 998 LONG dim) 1000 999 { 1001 1000 ULONG res = 0; 1002 1001 LONG iterDim; 1003 1002 1004 for(iterDim=0; iterDim<dim; iterDim++) 1003 for(iterDim=0; iterDim<dim; iterDim++) 1005 1004 /* the -mat[dim] bring coor[dim] relative to 0 for calculation */ 1006 res += ((coor[iterDim]-mat[iterDim].lLbound) * 1005 res += ((coor[iterDim]-mat[iterDim].lLbound) * 1007 1006 endOfDim(coor, mat, iterDim+1, dim)); 1008 1007 … … 1011 1010 } 1012 1011 1013 /************************************************************************ 1014 * Recursivity agent for calcDisplacement method. Used within Put and 1012 /************************************************************************ 1013 * Recursivity agent for calcDisplacement method. Used within Put and 1015 1014 * Get methods. 1016 1015 */ 1017 1016 static INT endOfDim( 1018 LONG *coor, 1019 SAFEARRAYBOUND *mat, 1020 LONG dim, 1021 LONG realDim) 1022 { 1023 if(dim==realDim) 1017 LONG *coor, 1018 SAFEARRAYBOUND *mat, 1019 LONG dim, 1020 LONG realDim) 1021 { 1022 if(dim==realDim) 1024 1023 return 1; 1025 else 1024 else 1026 1025 return (endOfDim(coor, mat, dim+1, realDim) * mat[dim].cElements); 1027 1026 } 1028 1027 1029 1028 1030 /************************************************************************ 1031 * Method used to validate the coordinate received in Put and Get 1029 /************************************************************************ 1030 * Method used to validate the coordinate received in Put and Get 1032 1031 * methods. 1033 1032 */ 1034 1033 static BOOL validCoordinate( 1035 LONG *coor, 1036 SAFEARRAY *psa) 1034 LONG *coor, 1035 SAFEARRAY *psa) 1037 1036 { 1038 1037 INT iter=0; … … 1048 1047 if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK) 1049 1048 return FALSE; 1050 1051 if(lLBound > lUBound) 1052 return FALSE; 1049 1050 if(lLBound > lUBound) 1051 return FALSE; 1053 1052 1054 1053 if((coor[iter] < lLBound) || (coor[iter] > lUBound)) … … 1056 1055 } 1057 1056 return TRUE; 1058 } 1059 1060 /************************************************************************ 1057 } 1058 1059 /************************************************************************ 1061 1060 * Method used to calculate the number of cells of the SA 1062 1061 */ 1063 1062 static ULONG getArraySize( 1064 SAFEARRAY *psa) 1065 { 1066 USHORT cCount; 1063 SAFEARRAY *psa) 1064 { 1065 USHORT cCount; 1067 1066 ULONG ulWholeArraySize = 1; 1068 1067 … … 1070 1069 ulWholeArraySize *= psa->rgsabound[cCount].cElements; 1071 1070 1072 return ulWholeArraySize; 1073 } 1074 1075 1076 /************************************************************************ 1071 return ulWholeArraySize; 1072 } 1073 1074 1075 /************************************************************************ 1077 1076 * Method used to handle data space dupplication for Copy32 and CopyData32 1078 1077 */ 1079 1078 static HRESULT duplicateData( 1080 SAFEARRAY *psa, 1081 SAFEARRAY **ppsaOut) 1079 SAFEARRAY *psa, 1080 SAFEARRAY **ppsaOut) 1082 1081 { 1083 1082 ULONG ulWholeArraySize; /* size of the thing */ … … 1085 1084 1086 1085 ulWholeArraySize = getArraySize(psa); /* Number of item in SA */ 1087 1086 1088 1087 SafeArrayLock(*ppsaOut); 1089 1088 1090 if( isPointer(psa->fFeatures) ) { /* If datatype is object increment 1089 if( isPointer(psa->fFeatures) ) { /* If datatype is object increment 1091 1090 object's reference count */ 1092 1091 IUnknown *punk; … … 1100 1099 1101 1100 /* Copy the source array data into target array */ 1102 memcpy((*ppsaOut)->pvData, psa->pvData, 1101 memcpy((*ppsaOut)->pvData, psa->pvData, 1103 1102 ulWholeArraySize*psa->cbElements); 1104 1103 1105 1104 } 1106 else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate 1105 else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate 1107 1106 the BSTR in the new array */ 1108 1107 BSTR pbstrReAllocStr = NULL; … … 1116 1115 } 1117 1116 1118 *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) = 1117 *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) = 1119 1118 pbstrReAllocStr; 1120 1119 } … … 1131 1130 else { /* Simply copy the source array data into target array */ 1132 1131 1133 memcpy((*ppsaOut)->pvData, psa->pvData, 1132 memcpy((*ppsaOut)->pvData, psa->pvData, 1134 1133 ulWholeArraySize*psa->cbElements); 1135 1134 } … … 1141 1140 1142 1141 1143 /************************************************************************ 1144 * SafeArrayGetVar Type (OLEAUT32.77)1142 /************************************************************************ 1143 * SafeArrayGetVartype (OLEAUT32.77) 1145 1144 * Returns the VARTYPE stored in the given safearray 1146 1145 */ 1147 HRESULT WINAPI SafeArrayGetVar Type(1146 HRESULT WINAPI SafeArrayGetVartype( 1148 1147 SAFEARRAY* psa, 1149 1148 VARTYPE* pvt) -
trunk/src/oleaut32/stubs.cpp
r8450 r9400 1 /* $Id: stubs.cpp,v 1.1 5 2002-05-17 10:17:00sandervl Exp $ */1 /* $Id: stubs.cpp,v 1.16 2002-11-12 17:07:47 sandervl Exp $ */ 2 2 /* 3 3 * Win32 COM/OLE stubs for OS/2 … … 96 96 } 97 97 98 //*****************************************************************************99 //*****************************************************************************100 HRESULT WINAPI DispCallFunc(void* pvInstance, ULONG oVft, CALLCONV cc,101 VARTYPE vtReturn, UINT cActuals, VARTYPE* prgvt,102 VARIANTARG** prgpvarg, VARIANT* pvargResult)103 {104 dprintf(("OLEAUT32: DispCallFunc - stub"));105 return S_OK;106 }107 98 108 99 //***************************************************************************** -
trunk/src/oleaut32/tmarshal.c
r8663 r9400 41 41 #include "typelib.h" 42 42 #include "wine/debug.h" 43 #include " ntddk.h"43 #include "winternl.h" 44 44 45 45 static const WCHAR riidW[5] = {'r','i','i','d',0}; … … 367 367 368 368 /* how much space do we use on stack in DWORD steps. */ 369 staticint const369 int const 370 370 _argsize(DWORD vt) { 371 371 switch (vt) { -
trunk/src/oleaut32/typelib.c
r8640 r9400 20 20 * License along with this library; if not, write to the Free Software 21 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 22 * 23 23 * -------------------------------------------------------------------------------------- 24 24 * Known problems (2000, Francois Jacques) 25 25 * 26 26 * - Tested using OLEVIEW (Platform SDK tool) only. 27 * 28 * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are 29 * creating by doing a straight copy of the dispinterface instance and just changing 27 * 28 * - dual interface dispinterfaces. vtable-interface ITypeInfo instances are 29 * creating by doing a straight copy of the dispinterface instance and just changing 30 30 * its typekind. Pointed structures aren't copied - only the address of the pointers. 31 31 * So when you release the dispinterface, you delete the vtable-interface structures 32 32 * as well... fortunately, clean up of structures is not implemented. 33 * 33 * 34 34 * - locale stuff is partially implemented but hasn't been tested. 35 35 * … … 50 50 * -. some methods just return pointers to internal data structures, this is 51 51 * partly laziness, partly I want to check how windows does it. 52 * 52 * 53 53 */ 54 54 55 55 #include "config.h" 56 #include "wine/port.h" 56 57 57 58 #include <stdlib.h> … … 71 72 #include "typelib.h" 72 73 #include "wine/debug.h" 73 #include " ntddk.h"74 #include "parsedt.h" 74 75 75 76 WINE_DEFAULT_DEBUG_CHANNEL(ole); 76 77 WINE_DECLARE_DEBUG_CHANNEL(typelib); 78 79 /**************************************************************************** 80 * FromLExxx 81 * 82 * Takes p_iVal (which is in little endian) and returns it 83 * in the host machine's byte order. 84 */ 85 #ifdef WORDS_BIGENDIAN 86 static WORD FromLEWord(WORD p_iVal) 87 { 88 return (((p_iVal & 0x00FF) << 8) | 89 ((p_iVal & 0xFF00) >> 8)); 90 } 91 92 93 static DWORD FromLEDWord(DWORD p_iVal) 94 { 95 return (((p_iVal & 0x000000FF) << 24) | 96 ((p_iVal & 0x0000FF00) << 8) | 97 ((p_iVal & 0x00FF0000) >> 8) | 98 ((p_iVal & 0xFF000000) >> 24)); 99 } 100 #else 101 #define FromLEWord(X) (X) 102 #define FromLEDWord(X) (X) 103 #endif 104 105 106 /**************************************************************************** 107 * FromLExxx 108 * 109 * Fix byte order in any structure if necessary 110 */ 111 #ifdef WORDS_BIGENDIAN 112 static void FromLEWords(void *p_Val, int p_iSize) 113 { 114 WORD *Val = p_Val; 115 116 p_iSize /= sizeof(WORD); 117 118 while (p_iSize) { 119 *Val = FromLEWord(*Val); 120 Val++; 121 p_iSize--; 122 } 123 } 124 125 126 static void FromLEDWords(void *p_Val, int p_iSize) 127 { 128 DWORD *Val = p_Val; 129 130 p_iSize /= sizeof(DWORD); 131 132 while (p_iSize) { 133 *Val = FromLEDWord(*Val); 134 Val++; 135 p_iSize--; 136 } 137 } 138 #else 139 #define FromLEWords(X,Y) /*nothing*/ 140 #define FromLEDWords(X,Y) /*nothing*/ 141 #endif 142 77 143 78 144 /**************************************************************************** … … 84 150 */ 85 151 HRESULT WINAPI 86 QueryPathOfRegTypeLib16( 152 QueryPathOfRegTypeLib16( 87 153 REFGUID guid, /* [in] referenced guid */ 88 154 WORD wMaj, /* [in] major version */ … … 119 185 return S_OK; 120 186 } 121 187 122 188 /**************************************************************************** 123 189 * QueryPathOfRegTypeLib [OLEAUT32.164] … … 126 192 */ 127 193 HRESULT WINAPI 128 QueryPathOfRegTypeLib( 194 QueryPathOfRegTypeLib( 129 195 REFGUID guid, /* [in] referenced guid */ 130 196 WORD wMaj, /* [in] major version */ … … 160 226 "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win32", 161 227 guid->Data1, guid->Data2, guid->Data3, 162 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], 228 guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], 163 229 guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7], 164 230 wMaj, … … 200 266 } 201 267 } 202 268 203 269 if (hr != S_OK) 204 270 TRACE_(typelib)("%s not found\n", szTypeLibKey); 205 271 206 272 return hr; 207 273 } … … 281 347 INT index = 1; 282 348 TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib); 283 349 284 350 if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath, 285 351 NULL)) { … … 288 354 pIndexStr = strrchrW(szFile, '\\'); 289 355 if(pIndexStr && pIndexStr != szFile && *++pIndexStr != '\0') { 290 index = wcstol(pIndexStr, NULL, 10);356 index = atoiW(pIndexStr); 291 357 memcpy(szFileCopy, szFile, 292 358 (pIndexStr - szFile - 1) * sizeof(WCHAR)); … … 333 399 * LoadRegTypeLib [OLEAUT32.162] 334 400 */ 335 HRESULT WINAPI LoadRegTypeLib( 401 HRESULT WINAPI LoadRegTypeLib( 336 402 REFGUID rguid, /* [in] referenced guid */ 337 403 WORD wVerMajor, /* [in] major version */ … … 352 418 353 419 return res; 354 } 420 } 355 421 356 422 357 423 /****************************************************************************** 358 424 * RegisterTypeLib [OLEAUT32.163] 359 * Adds information about a type library to the System Registry 425 * Adds information about a type library to the System Registry 360 426 * NOTES 361 427 * Docs: ITypeLib FAR * ptlib … … 556 622 /****************************************************************************** 557 623 * UnRegisterTypeLib [OLEAUT32.186] 558 * Removes information about a type library from the System Registry 624 * Removes information about a type library from the System Registry 559 625 * NOTES 560 626 * … … 569 635 LCID lcid, /* [in] locale id */ 570 636 SYSKIND syskind) 571 { 637 { 572 638 TRACE("(IID: %s): stub\n",debugstr_guid(libid)); 573 639 return S_OK; /* FIXME: pretend everything is OK */ … … 594 660 * to retrieve the "versionForced" info from misc/version.c :( 595 661 * (this would be useful in other places, too) */ 596 FIXME(" Please report to a.mohr@mailto.de if you get version error messages !\n");662 FIXME("If you get version error messages, please report them\n"); 597 663 switch(GetVersion() & 0x8000ffff) /* mask off build number */ 598 664 { … … 616 682 /*======================= ITypeLib implementation =======================*/ 617 683 618 typedef struct tagTLBCustData 684 typedef struct tagTLBCustData 619 685 { 620 686 GUID guid; … … 649 715 UINT ref; 650 716 TLIBATTR LibAttr; /* guid,lcid,syskind,version,flags */ 651 717 652 718 /* strings can be stored in tlb as multibyte strings BUT they are *always* 653 719 * exported to the application as a UNICODE string. … … 690 756 TLB_REF_INTERNAL for internal refs 691 757 TLB_REF_NOT_FOUND for broken refs */ 692 758 693 759 struct tagTLBRefType * next; 694 760 } TLBRefType; … … 719 785 int ctCustData; 720 786 TLBCustData * pCustData; /* linked list to cust data; */ 721 struct tagTLBFuncDesc * next; 787 struct tagTLBFuncDesc * next; 722 788 } TLBFuncDesc; 723 789 … … 732 798 int ctCustData; 733 799 TLBCustData * pCustData;/* linked list to cust data; */ 734 struct tagTLBVarDesc * next; 800 struct tagTLBVarDesc * next; 735 801 } TLBVarDesc; 736 802 … … 753 819 ITypeLibImpl * pTypeLib; /* back pointer to typelib */ 754 820 int index; /* index in this typelib; */ 755 /* type libs seem to store the doc strings in ascii 821 /* type libs seem to store the doc strings in ascii 756 822 * so why should we do it in unicode? 757 823 */ … … 880 946 } 881 947 882 staticvoid dump_ELEMDESC(ELEMDESC *edesc) {948 void dump_ELEMDESC(ELEMDESC *edesc) { 883 949 char buf[200]; 884 950 dump_TypeDesc(&edesc->tdesc,buf); … … 887 953 MESSAGE("\t\tu.parmadesc.lpex %p\n",edesc->u.paramdesc.pparamdescex); 888 954 } 889 staticvoid dump_FUNCDESC(FUNCDESC *funcdesc) {955 void dump_FUNCDESC(FUNCDESC *funcdesc) { 890 956 int i; 891 957 MESSAGE("memid is %08lx\n",funcdesc->memid); … … 922 988 MESSAGE("\twFlags: %x\n", funcdesc->wFuncFlags); 923 989 } 924 static void dump_TLBFuncDescOne(TLBFuncDesc * pfd) 925 { 926 int i; 927 if (!TRACE_ON(typelib)) 928 return; 929 MESSAGE("%s(%u)\n", debugstr_w(pfd->Name), pfd->funcdesc.cParams); 930 for (i=0;i<pfd->funcdesc.cParams;i++) 931 MESSAGE("\tparm%d: %s\n",i,debugstr_w(pfd->pParamDesc[i].Name)); 932 933 934 dump_FUNCDESC(&(pfd->funcdesc)); 935 936 MESSAGE("\thelpstring: %s\n", debugstr_w(pfd->HelpString)); 937 MESSAGE("\tentry: %s\n", debugstr_w(pfd->Entry)); 938 } 939 static void dump_TLBFuncDesc(TLBFuncDesc * pfd) 940 { 941 while (pfd) 942 { 943 dump_TLBFuncDescOne(pfd); 944 pfd = pfd->next; 945 }; 946 } 947 static void dump_TLBVarDesc(TLBVarDesc * pvd) 948 { 949 while (pvd) 950 { 951 TRACE_(typelib)("%s\n", debugstr_w(pvd->Name)); 952 pvd = pvd->next; 953 }; 954 } 955 956 static void dump_TLBImpLib(TLBImpLib *import) 957 { 958 TRACE_(typelib)("%s %s\n", debugstr_guid(&(import->guid)), 959 debugstr_w(import->name)); 960 TRACE_(typelib)("v%d.%d lcid=%lx offset=%x\n", import->wVersionMajor, 961 import->wVersionMinor, import->lcid, import->offset); 962 } 963 964 static void dump_TLBRefType(TLBRefType * prt) 965 { 966 while (prt) 967 { 968 TRACE_(typelib)("href:0x%08lx\n", prt->reference); 969 if(prt->index == -1) 970 TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid))); 971 else 972 TRACE_(typelib)("type no: %d\n", prt->index); 973 974 if(prt->pImpTLInfo != TLB_REF_INTERNAL && 975 prt->pImpTLInfo != TLB_REF_NOT_FOUND) { 976 TRACE_(typelib)("in lib\n"); 977 dump_TLBImpLib(prt->pImpTLInfo); 978 } 979 prt = prt->next; 980 }; 981 } 982 983 static void dump_TLBImplType(TLBImplType * impl) 984 { 985 while (impl) { 986 TRACE_(typelib)( 987 "implementing/inheriting interface hRef = %lx implflags %x\n", 988 impl->hRef, impl->implflags); 989 impl = impl->next; 990 } 991 } 992 993 static void dump_Variant(VARIANT * pvar) 994 { 995 char szVarType[32]; 996 LPVOID ref; 997 998 TRACE("(%p)\n", pvar); 999 1000 if (!pvar) return; 1001 1002 ZeroMemory(szVarType, sizeof(szVarType)); 1003 1004 /* FIXME : we could have better trace here, depending on the VARTYPE 1005 * of the variant 1006 */ 1007 dump_VarType(V_VT(pvar),szVarType); 1008 1009 TRACE("VARTYPE: %s\n", szVarType); 1010 1011 if (V_VT(pvar) & VT_BYREF) { 1012 ref = V_UNION(pvar, byref); 1013 TRACE("%p\n", ref); 1014 } 1015 else ref = &V_UNION(pvar, cVal); 1016 1017 if (V_VT(pvar) & VT_ARRAY) { 1018 /* FIXME */ 1019 return; 1020 } 1021 if (V_VT(pvar) & VT_VECTOR) { 1022 /* FIXME */ 1023 return; 1024 } 1025 1026 switch (V_VT(pvar)) 1027 { 1028 case VT_I2: 1029 TRACE("%d\n", *(short*)ref); 1030 break; 1031 1032 case VT_I4: 1033 TRACE("%d\n", *(INT*)ref); 1034 break; 1035 1036 case VT_R4: 1037 TRACE("%3.3e\n", *(float*)ref); 1038 break; 1039 1040 case VT_R8: 1041 TRACE("%3.3e\n", *(double*)ref); 1042 break; 1043 1044 case VT_BOOL: 1045 TRACE("%s\n", *(VARIANT_BOOL*)ref ? "TRUE" : "FALSE"); 1046 break; 1047 1048 case VT_BSTR: 1049 TRACE("%s\n", debugstr_w(*(BSTR*)ref)); 1050 break; 1051 1052 case VT_UNKNOWN: 1053 case VT_DISPATCH: 1054 TRACE("%p\n", *(LPVOID*)ref); 1055 break; 1056 1057 case VT_VARIANT: 1058 if (V_VT(pvar) & VT_BYREF) dump_Variant(ref); 1059 break; 1060 1061 default: 1062 TRACE("(?)%ld\n", *(long*)ref); 1063 break; 1064 } 1065 } 1066 1067 static void dump_DispParms(DISPPARAMS * pdp) 1068 { 1069 int index = 0; 1070 1071 TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs); 1072 1073 while (index < pdp->cArgs) 1074 { 1075 dump_Variant( &pdp->rgvarg[index] ); 1076 ++index; 1077 } 990 991 void dump_IDLDESC(IDLDESC *idl) { 992 MESSAGE("\t\twIdlflags: %d\n",idl->wIDLFlags); 1078 993 } 1079 994 … … 1091 1006 }; 1092 1007 1008 void dump_TYPEATTR(TYPEATTR *tattr) { 1009 char buf[200]; 1010 MESSAGE("\tguid: %s\n",debugstr_guid(&tattr->guid)); 1011 MESSAGE("\tlcid: %ld\n",tattr->lcid); 1012 MESSAGE("\tmemidConstructor: %ld\n",tattr->memidConstructor); 1013 MESSAGE("\tmemidDestructor: %ld\n",tattr->memidDestructor); 1014 MESSAGE("\tschema: %s\n",debugstr_w(tattr->lpstrSchema)); 1015 MESSAGE("\tsizeInstance: %ld\n",tattr->cbSizeInstance); 1016 MESSAGE("\tkind:%s\n", typekind_desc[tattr->typekind]); 1017 MESSAGE("\tcFuncs: %d\n", tattr->cFuncs); 1018 MESSAGE("\tcVars: %d\n", tattr->cVars); 1019 MESSAGE("\tcImplTypes: %d\n", tattr->cImplTypes); 1020 MESSAGE("\tcbSizeVft: %d\n", tattr->cbSizeVft); 1021 MESSAGE("\tcbAlignment: %d\n", tattr->cbAlignment); 1022 MESSAGE("\twTypeFlags: %d\n", tattr->wTypeFlags); 1023 MESSAGE("\tVernum: %d.%d\n", tattr->wMajorVerNum,tattr->wMinorVerNum); 1024 dump_TypeDesc(&tattr->tdescAlias,buf); 1025 MESSAGE("\ttypedesc: %s\n", buf); 1026 dump_IDLDESC(&tattr->idldescType); 1027 } 1028 1029 static void dump_TLBFuncDescOne(TLBFuncDesc * pfd) 1030 { 1031 int i; 1032 if (!TRACE_ON(typelib)) 1033 return; 1034 MESSAGE("%s(%u)\n", debugstr_w(pfd->Name), pfd->funcdesc.cParams); 1035 for (i=0;i<pfd->funcdesc.cParams;i++) 1036 MESSAGE("\tparm%d: %s\n",i,debugstr_w(pfd->pParamDesc[i].Name)); 1037 1038 1039 dump_FUNCDESC(&(pfd->funcdesc)); 1040 1041 MESSAGE("\thelpstring: %s\n", debugstr_w(pfd->HelpString)); 1042 MESSAGE("\tentry: %s\n", debugstr_w(pfd->Entry)); 1043 } 1044 static void dump_TLBFuncDesc(TLBFuncDesc * pfd) 1045 { 1046 while (pfd) 1047 { 1048 dump_TLBFuncDescOne(pfd); 1049 pfd = pfd->next; 1050 }; 1051 } 1052 static void dump_TLBVarDesc(TLBVarDesc * pvd) 1053 { 1054 while (pvd) 1055 { 1056 TRACE_(typelib)("%s\n", debugstr_w(pvd->Name)); 1057 pvd = pvd->next; 1058 }; 1059 } 1060 1061 static void dump_TLBImpLib(TLBImpLib *import) 1062 { 1063 TRACE_(typelib)("%s %s\n", debugstr_guid(&(import->guid)), 1064 debugstr_w(import->name)); 1065 TRACE_(typelib)("v%d.%d lcid=%lx offset=%x\n", import->wVersionMajor, 1066 import->wVersionMinor, import->lcid, import->offset); 1067 } 1068 1069 static void dump_TLBRefType(TLBRefType * prt) 1070 { 1071 while (prt) 1072 { 1073 TRACE_(typelib)("href:0x%08lx\n", prt->reference); 1074 if(prt->index == -1) 1075 TRACE_(typelib)("%s\n", debugstr_guid(&(prt->guid))); 1076 else 1077 TRACE_(typelib)("type no: %d\n", prt->index); 1078 1079 if(prt->pImpTLInfo != TLB_REF_INTERNAL && 1080 prt->pImpTLInfo != TLB_REF_NOT_FOUND) { 1081 TRACE_(typelib)("in lib\n"); 1082 dump_TLBImpLib(prt->pImpTLInfo); 1083 } 1084 prt = prt->next; 1085 }; 1086 } 1087 1088 static void dump_TLBImplType(TLBImplType * impl) 1089 { 1090 while (impl) { 1091 TRACE_(typelib)( 1092 "implementing/inheriting interface hRef = %lx implflags %x\n", 1093 impl->hRef, impl->implflags); 1094 impl = impl->next; 1095 } 1096 } 1097 1098 void dump_Variant(VARIANT * pvar) 1099 { 1100 char szVarType[32]; 1101 LPVOID ref; 1102 1103 TRACE("(%p)\n", pvar); 1104 1105 if (!pvar) return; 1106 1107 ZeroMemory(szVarType, sizeof(szVarType)); 1108 1109 /* FIXME : we could have better trace here, depending on the VARTYPE 1110 * of the variant 1111 */ 1112 dump_VarType(V_VT(pvar),szVarType); 1113 1114 TRACE("VARTYPE: %s\n", szVarType); 1115 1116 if (V_VT(pvar) & VT_BYREF) { 1117 ref = V_UNION(pvar, byref); 1118 TRACE("%p\n", ref); 1119 } 1120 else ref = &V_UNION(pvar, cVal); 1121 1122 if (V_VT(pvar) & VT_ARRAY) { 1123 /* FIXME */ 1124 return; 1125 } 1126 if (V_VT(pvar) & VT_VECTOR) { 1127 /* FIXME */ 1128 return; 1129 } 1130 1131 switch (V_VT(pvar) & VT_TYPEMASK) 1132 { 1133 case VT_I2: 1134 TRACE("%d\n", *(short*)ref); 1135 break; 1136 1137 case VT_I4: 1138 TRACE("%d\n", *(INT*)ref); 1139 break; 1140 1141 case VT_R4: 1142 TRACE("%3.3e\n", *(float*)ref); 1143 break; 1144 1145 case VT_R8: 1146 TRACE("%3.3e\n", *(double*)ref); 1147 break; 1148 1149 case VT_BOOL: 1150 TRACE("%s\n", *(VARIANT_BOOL*)ref ? "TRUE" : "FALSE"); 1151 break; 1152 1153 case VT_BSTR: 1154 TRACE("%s\n", debugstr_w(*(BSTR*)ref)); 1155 break; 1156 1157 case VT_UNKNOWN: 1158 case VT_DISPATCH: 1159 TRACE("%p\n", *(LPVOID*)ref); 1160 break; 1161 1162 case VT_VARIANT: 1163 if (V_VT(pvar) & VT_BYREF) dump_Variant(ref); 1164 break; 1165 1166 case VT_DATE: 1167 { 1168 struct tm TM; 1169 memset( &TM, 0, sizeof(TM) ); 1170 1171 if( DateToTm( *(DATE*)ref, 0, &TM ) == FALSE ) { 1172 TRACE("invalid date? (?)%ld %f\n", *(long*)ref, *(double *)ref); 1173 } else { 1174 TRACE("(yyyymmdd) %4.4d-%2.2d-%2.2d (time) %2.2d:%2.2d:%2.2d [%f]\n", 1175 TM.tm_year, TM.tm_mon+1, TM.tm_mday, 1176 TM.tm_hour, TM.tm_min, TM.tm_sec, *(double *)ref); 1177 } 1178 break; 1179 } 1180 1181 case VT_CY: 1182 TRACE("%ld (hi), %lu (lo)\n", ((CY *)ref)->s.Hi, ((CY *)ref)->s.Lo); 1183 break; 1184 1185 1186 default: 1187 TRACE("(?)%ld\n", *(long*)ref); 1188 break; 1189 } 1190 } 1191 1192 static void dump_DispParms(DISPPARAMS * pdp) 1193 { 1194 int index = 0; 1195 1196 TRACE("args=%u named args=%u\n", pdp->cArgs, pdp->cNamedArgs); 1197 1198 while (index < pdp->cArgs) 1199 { 1200 dump_Variant( &pdp->rgvarg[index] ); 1201 ++index; 1202 } 1203 } 1204 1093 1205 static void dump_TypeInfo(ITypeInfoImpl * pty) 1094 1206 { … … 1103 1215 dump_TLBVarDesc(pty->varlist); 1104 1216 dump_TLBImplType(pty->impltypelist); 1217 } 1218 1219 void dump_VARDESC(VARDESC *v) 1220 { 1221 MESSAGE("memid %ld\n",v->memid); 1222 MESSAGE("lpstrSchema %s\n",debugstr_w(v->lpstrSchema)); 1223 MESSAGE("oInst %ld\n",v->u.oInst); 1224 dump_ELEMDESC(&(v->elemdescVar)); 1225 MESSAGE("wVarFlags %x\n",v->wVarFlags); 1226 MESSAGE("varkind %d\n",v->varkind); 1105 1227 } 1106 1228 #else … … 1124 1246 #define dump_TLBFuncDesc(a) 1125 1247 #define dump_TypeDesc(a,b) 1126 #define dump_V ariant(a)1248 #define dump_VARDESC(a) 1127 1249 #define debugstr_an(a,b) NULL 1128 1250 #endif … … 1188 1310 } 1189 1311 1312 static DWORD MSFT_ReadLEDWords(void *buffer, DWORD count, TLBContext *pcx, 1313 long where ) 1314 { 1315 DWORD ret; 1316 1317 ret = MSFT_Read(buffer, count, pcx, where); 1318 FromLEDWords(buffer, ret); 1319 1320 return ret; 1321 } 1322 1323 static DWORD MSFT_ReadLEWords(void *buffer, DWORD count, TLBContext *pcx, 1324 long where ) 1325 { 1326 DWORD ret; 1327 1328 ret = MSFT_Read(buffer, count, pcx, where); 1329 FromLEWords(buffer, ret); 1330 1331 return ret; 1332 } 1333 1190 1334 static void MSFT_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx) 1191 1335 { 1192 TRACE_(typelib)("%s\n", debugstr_guid(pGuid));1193 1194 1336 if(offset<0 || pcx->pTblDir->pGuidTab.offset <0){ 1195 1337 memset(pGuid,0, sizeof(GUID)); … … 1197 1339 } 1198 1340 MSFT_Read(pGuid, sizeof(GUID), pcx, pcx->pTblDir->pGuidTab.offset+offset ); 1341 pGuid->Data1 = FromLEDWord(pGuid->Data1); 1342 pGuid->Data2 = FromLEWord(pGuid->Data2); 1343 pGuid->Data3 = FromLEWord(pGuid->Data3); 1344 TRACE_(typelib)("%s\n", debugstr_guid(pGuid)); 1199 1345 } 1200 1346 … … 1207 1353 BSTR bstrName = NULL; 1208 1354 1209 MSFT_Read (&niName, sizeof(niName), pcx,1210 1355 MSFT_ReadLEDWords(&niName, sizeof(niName), pcx, 1356 pcx->pTblDir->pNametab.offset+offset); 1211 1357 niName.namelen &= 0xFF; /* FIXME: correct ? */ 1212 1358 name=TLB_Alloc((niName.namelen & 0xff) +1); … … 1242 1388 1243 1389 if(offset<0) return NULL; 1244 MSFT_Read (&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset);1390 MSFT_ReadLEWords(&length, sizeof(INT16), pcx, pcx->pTblDir->pStringtab.offset+offset); 1245 1391 if(length <= 0) return 0; 1246 1392 string=TLB_Alloc(length +1); … … 1268 1414 } 1269 1415 /* 1270 * read a value and fill a VARIANT structure 1416 * read a value and fill a VARIANT structure 1271 1417 */ 1272 1418 static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx ) … … 1281 1427 return; 1282 1428 } 1283 MSFT_Read (&(V_VT(pVar)), sizeof(VARTYPE), pcx,1284 pcx->pTblDir->pCustData.offset + offset );1429 MSFT_ReadLEWords(&(V_VT(pVar)), sizeof(VARTYPE), pcx, 1430 pcx->pTblDir->pCustData.offset + offset ); 1285 1431 TRACE_(typelib)("Vartype = %x\n", V_VT(pVar)); 1286 1432 switch (V_VT(pVar)){ … … 1290 1436 case VT_I4 : 1291 1437 case VT_R4 : 1292 case VT_ERROR : 1293 case VT_BOOL : 1294 case VT_I1 : 1295 case VT_UI1 : 1296 case VT_UI2 : 1297 case VT_UI4 : 1298 case VT_INT : 1299 case VT_UINT : 1438 case VT_ERROR : 1439 case VT_BOOL : 1440 case VT_I1 : 1441 case VT_UI1 : 1442 case VT_UI2 : 1443 case VT_UI4 : 1444 case VT_INT : 1445 case VT_UINT : 1300 1446 case VT_VOID : /* FIXME: is this right? */ 1301 case VT_HRESULT : 1447 case VT_HRESULT : 1302 1448 size=4; break; 1303 1449 case VT_R8 : 1304 1450 case VT_CY : 1305 case VT_DATE : 1306 case VT_I8 : 1307 case VT_UI8 : 1451 case VT_DATE : 1452 case VT_I8 : 1453 case VT_UI8 : 1308 1454 case VT_DECIMAL : /* FIXME: is this right? */ 1309 1455 case VT_FILETIME : … … 1312 1458 case VT_BSTR :{ 1313 1459 char * ptr; 1314 MSFT_Read (&size, sizeof(INT), pcx, DO_NOT_SEEK );1460 MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK ); 1315 1461 if(size <= 0) { 1316 1462 FIXME("BSTR length = %d?\n", size); … … 1328 1474 /* FIXME: this will not work AT ALL when the variant contains a pointer */ 1329 1475 case VT_DISPATCH : 1330 case VT_VARIANT : 1331 case VT_UNKNOWN : 1332 case VT_PTR : 1476 case VT_VARIANT : 1477 case VT_UNKNOWN : 1478 case VT_PTR : 1333 1479 case VT_SAFEARRAY : 1334 case VT_CARRAY : 1335 case VT_USERDEFINED : 1336 case VT_LPSTR : 1337 case VT_LPWSTR : 1338 case VT_BLOB : 1339 case VT_STREAM : 1340 case VT_STORAGE : 1341 case VT_STREAMED_OBJECT : 1342 case VT_STORED_OBJECT : 1343 case VT_BLOB_OBJECT : 1344 case VT_CF : 1345 case VT_CLSID : 1346 default: 1347 size=0; 1480 case VT_CARRAY : 1481 case VT_USERDEFINED : 1482 case VT_LPSTR : 1483 case VT_LPWSTR : 1484 case VT_BLOB : 1485 case VT_STREAM : 1486 case VT_STORAGE : 1487 case VT_STREAMED_OBJECT : 1488 case VT_STORED_OBJECT : 1489 case VT_BLOB_OBJECT : 1490 case VT_CF : 1491 case VT_CLSID : 1492 default: 1493 size=0; 1348 1494 FIXME("VARTYPE %d is not supported, setting pointer to NULL\n", 1349 1495 V_VT(pVar)); … … 1368 1514 count++; 1369 1515 pNew=TLB_Alloc(sizeof(TLBCustData)); 1370 MSFT_Read(&entry, sizeof(entry), pcx, 1371 pcx->pTblDir->pCDGuids.offset+offset); 1516 MSFT_ReadLEDWords(&entry, sizeof(entry), pcx, pcx->pTblDir->pCDGuids.offset+offset); 1372 1517 MSFT_ReadGuid(&(pNew->guid), entry.GuidOffset , pcx); 1373 1518 MSFT_ReadValue(&(pNew->data), entry.DataOffset, pcx); … … 1394 1539 } 1395 1540 1396 static void 1541 static void 1397 1542 MSFT_DoFuncs(TLBContext* pcx, 1398 1543 ITypeInfoImpl* pTI, 1399 int cFuncs, 1544 int cFuncs, 1400 1545 int cVars, 1401 int offset, 1546 int offset, 1402 1547 TLBFuncDesc** pptfd) 1403 1548 { 1404 /* 1549 /* 1405 1550 * member information is stored in a data structure at offset 1406 1551 * indicated by the memoffset field of the typeinfo structure 1407 1552 * There are several distinctive parts. 1408 * the first part starts with a field that holds the total length 1553 * the first part starts with a field that holds the total length 1409 1554 * of this (first) part excluding this field. Then follow the records, 1410 1555 * for each member there is one record. 1411 1556 * 1412 1557 * First entry is always the length of the record (excluding this 1413 * length word). 1414 * Rest of the record depends on the type of the member. If there is 1558 * length word). 1559 * Rest of the record depends on the type of the member. If there is 1415 1560 * a field indicating the member type (function variable intereface etc) 1416 1561 * I have not found it yet. At this time we depend on the information … … 1419 1564 * Second follows an array sized nrMEM*sizeof(INT) with a memeber id 1420 1565 * for each member; 1421 * 1422 * Third is a equal sized array with file offsets to the name entry 1566 * 1567 * Third is a equal sized array with file offsets to the name entry 1423 1568 * of each member. 1424 * 1569 * 1425 1570 * Forth and last (?) part is an array with offsets to the records in the 1426 1571 * first part of this file segment. … … 1435 1580 TRACE_(typelib)("\n"); 1436 1581 1437 MSFT_Read (&infolen, sizeof(INT), pcx, offset);1582 MSFT_ReadLEDWords(&infolen, sizeof(INT), pcx, offset); 1438 1583 1439 1584 for ( i = 0; i < cFuncs ; i++ ) … … 1442 1587 1443 1588 /* name, eventually add to a hash table */ 1444 MSFT_Read(&nameoffset, 1445 sizeof(INT), 1446 pcx, 1447 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT)); 1589 MSFT_ReadLEDWords(&nameoffset, sizeof(INT), pcx, 1590 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT)); 1448 1591 1449 1592 (*pptfd)->Name = MSFT_ReadName(pcx, nameoffset); 1450 1593 1451 1594 /* read the function information record */ 1452 MSFT_Read (&reclength, sizeof(INT), pcx, recoffset);1453 1595 MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset); 1596 1454 1597 reclength &= 0x1ff; 1455 1598 1456 MSFT_Read (pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;1599 MSFT_ReadLEDWords(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK); 1457 1600 1458 1601 /* do the attributes */ … … 1463 1606 { 1464 1607 (*pptfd)->helpcontext = pFuncRec->OptAttr[0] ; 1465 1608 1466 1609 if ( nrattributes > 1 ) 1467 1610 { … … 1486 1629 if ( nrattributes > 6 && pFuncRec->FKCCIC & 0x80 ) 1487 1630 { 1488 MSFT_CustData(pcx, 1631 MSFT_CustData(pcx, 1489 1632 pFuncRec->OptAttr[6], 1490 1633 &(*pptfd)->pCustData); … … 1496 1639 1497 1640 /* fill the FuncDesc Structure */ 1498 MSFT_Read( & (*pptfd)->funcdesc.memid, 1499 sizeof(INT), pcx, 1500 offset + infolen + ( i + 1) * sizeof(INT)); 1641 MSFT_ReadLEDWords( & (*pptfd)->funcdesc.memid, sizeof(INT), pcx, 1642 offset + infolen + ( i + 1) * sizeof(INT)); 1501 1643 1502 1644 (*pptfd)->funcdesc.funckind = (pFuncRec->FKCCIC) & 0x7; … … 1508 1650 (*pptfd)->funcdesc.wFuncFlags = LOWORD(pFuncRec->Flags) ; 1509 1651 1510 MSFT_GetTdesc(pcx, 1511 pFuncRec->DataType, 1652 MSFT_GetTdesc(pcx, 1653 pFuncRec->DataType, 1512 1654 &(*pptfd)->funcdesc.elemdescFunc.tdesc, 1513 1655 pTI); … … 1519 1661 MSFT_ParameterInfo paraminfo; 1520 1662 1521 (*pptfd)->funcdesc.lprgelemdescParam = 1663 (*pptfd)->funcdesc.lprgelemdescParam = 1522 1664 TLB_Alloc(pFuncRec->nrargs * sizeof(ELEMDESC)); 1523 1665 1524 (*pptfd)->pParamDesc = 1666 (*pptfd)->pParamDesc = 1525 1667 TLB_Alloc(pFuncRec->nrargs * sizeof(TLBParDesc)); 1526 1668 1527 MSFT_Read(¶minfo, 1528 sizeof(paraminfo), 1529 pcx, 1530 recoffset + reclength - 1531 pFuncRec->nrargs * sizeof(MSFT_ParameterInfo)); 1669 MSFT_ReadLEDWords(¶minfo, sizeof(paraminfo), pcx, 1670 recoffset + reclength - pFuncRec->nrargs * sizeof(MSFT_ParameterInfo)); 1532 1671 1533 1672 for ( j = 0 ; j < pFuncRec->nrargs ; j++ ) … … 1535 1674 TYPEDESC* lpArgTypeDesc = 0; 1536 1675 1537 MSFT_GetTdesc(pcx, 1538 paraminfo.DataType, 1676 MSFT_GetTdesc(pcx, 1677 paraminfo.DataType, 1539 1678 &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc, 1540 1679 pTI); … … 1544 1683 (*pptfd)->pParamDesc[j].Name = (void *) paraminfo.oName; 1545 1684 1546 /* SEEK value = jump to offset, 1685 /* SEEK value = jump to offset, 1547 1686 * from there jump to the end of record, 1548 1687 * go back by (j-1) arguments 1549 1688 */ 1550 MSFT_Read ( ¶minfo ,1689 MSFT_ReadLEDWords( ¶minfo , 1551 1690 sizeof(MSFT_ParameterInfo), pcx, 1552 recoffset + reclength - ((pFuncRec->nrargs - j - 1) 1691 recoffset + reclength - ((pFuncRec->nrargs - j - 1) 1553 1692 * sizeof(MSFT_ParameterInfo))); 1554 lpArgTypeDesc = 1693 lpArgTypeDesc = 1555 1694 & ((*pptfd)->funcdesc.lprgelemdescParam[j].tdesc); 1556 1695 … … 1568 1707 1569 1708 case VT_USERDEFINED: 1570 MSFT_DoRefType(pcx, pTI, 1709 MSFT_DoRefType(pcx, pTI, 1571 1710 lpArgTypeDesc->u.hreftype); 1572 1711 … … 1586 1725 TYPEDESC* lpArgTypeDesc; 1587 1726 1588 (*pptfd)->funcdesc.elemdescFunc = 1727 (*pptfd)->funcdesc.elemdescFunc = 1589 1728 (*pptfd)->funcdesc.lprgelemdescParam[j]; 1590 1729 … … 1599 1738 break; 1600 1739 case VT_CARRAY: 1601 lpArgTypeDesc = 1740 lpArgTypeDesc = 1602 1741 & (lpArgTypeDesc->u.lpadesc->tdescElem); 1603 1742 … … 1605 1744 1606 1745 case VT_USERDEFINED: 1607 MSFT_DoRefType(pcx, 1746 MSFT_DoRefType(pcx, 1608 1747 pTI, 1609 1748 lpArgTypeDesc->u.hreftype); … … 1626 1765 1627 1766 /* default value */ 1628 if ( (PARAMFLAG_FHASDEFAULT & 1767 if ( (PARAMFLAG_FHASDEFAULT & 1629 1768 (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) && 1630 1769 ((pFuncRec->FKCCIC) & 0x1000) ) 1631 1770 { 1632 INT* pInt = (INT *)((char *)pFuncRec + 1633 reclength - 1771 INT* pInt = (INT *)((char *)pFuncRec + 1772 reclength - 1634 1773 (pFuncRec->nrargs * 4 + 1) * sizeof(INT) ); 1635 1774 … … 1639 1778 pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX); 1640 1779 1641 MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 1780 MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 1642 1781 pInt[j], pcx); 1643 1782 } … … 1645 1784 if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 ) 1646 1785 { 1647 MSFT_CustData(pcx, 1786 MSFT_CustData(pcx, 1648 1787 pFuncRec->OptAttr[7+j], 1649 1788 &(*pptfd)->pParamDesc[j].pCustData); … … 1671 1810 TRACE_(typelib)("\n"); 1672 1811 1673 MSFT_Read (&infolen,sizeof(INT), pcx, offset);1674 MSFT_Read (&recoffset,sizeof(INT), pcx, offset + infolen +1675 ((cFuncs+cVars)*2+cFuncs + 1)*sizeof(INT));1812 MSFT_ReadLEDWords(&infolen,sizeof(INT), pcx, offset); 1813 MSFT_ReadLEDWords(&recoffset,sizeof(INT), pcx, offset + infolen + 1814 ((cFuncs+cVars)*2+cFuncs + 1)*sizeof(INT)); 1676 1815 recoffset += offset+sizeof(INT); 1677 1816 for(i=0;i<cVars;i++){ 1678 1817 *pptvd=TLB_Alloc(sizeof(TLBVarDesc)); 1679 1818 /* name, eventually add to a hash table */ 1680 MSFT_Read (&nameoffset, sizeof(INT), pcx,1681 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT));1819 MSFT_ReadLEDWords(&nameoffset, sizeof(INT), pcx, 1820 offset + infolen + (cFuncs + cVars + i + 1) * sizeof(INT)); 1682 1821 (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset); 1683 1822 /* read the variable information record */ 1684 MSFT_Read (&reclength, sizeof(INT), pcx, recoffset);1823 MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset); 1685 1824 reclength &=0xff; 1686 MSFT_Read (pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;1825 MSFT_ReadLEDWords(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK); 1687 1826 /* Optional data */ 1688 1827 if(reclength >(6*sizeof(INT)) ) … … 1694 1833 (*pptvd)->HelpStringContext=pVarRec->HelpStringContext; 1695 1834 /* fill the VarDesc Structure */ 1696 MSFT_Read (&(*pptvd)->vardesc.memid, sizeof(INT), pcx,1697 offset + infolen + ( i + 1) * sizeof(INT));1835 MSFT_ReadLEDWords(&(*pptvd)->vardesc.memid, sizeof(INT), pcx, 1836 offset + infolen + ( i + 1) * sizeof(INT)); 1698 1837 (*pptvd)->vardesc.varkind = pVarRec->VarKind; 1699 1838 (*pptvd)->vardesc.wVarFlags = pVarRec->Flags; 1700 MSFT_GetTdesc(pcx, pVarRec->DataType, 1839 MSFT_GetTdesc(pcx, pVarRec->DataType, 1701 1840 &(*pptvd)->vardesc.elemdescVar.tdesc, pTI); 1702 1841 /* (*pptvd)->vardesc.lpstrSchema; is reserved (SDK) FIXME?? */ … … 1739 1878 TRACE_(typelib)("offset %x, masked offset %x\n", offset, offset + (offset & 0xfffffffc)); 1740 1879 1741 MSFT_Read (&impinfo, sizeof(impinfo), pcx,1742 pcx->pTblDir->pImpInfo.offset + (offset & 0xfffffffc));1880 MSFT_ReadLEDWords(&impinfo, sizeof(impinfo), pcx, 1881 pcx->pTblDir->pImpInfo.offset + (offset & 0xfffffffc)); 1743 1882 for(j=0;pImpLib;j++){ /* search the known offsets of all import libraries */ 1744 1883 if(pImpLib->offset==impinfo.oImpFile) break; … … 1776 1915 if(offset<0) break; /* paranoia */ 1777 1916 *ppImpl=TLB_Alloc(sizeof(**ppImpl)); 1778 MSFT_Read (&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset);1779 MSFT_DoRefType(pcx, pTI, refrec.reftype); 1917 MSFT_ReadLEDWords(&refrec,sizeof(refrec),pcx,offset+pcx->pTblDir->pRefTab.offset); 1918 MSFT_DoRefType(pcx, pTI, refrec.reftype); 1780 1919 (*ppImpl)->hRef = refrec.reftype; 1781 1920 (*ppImpl)->implflags=refrec.flags; … … 1800 1939 1801 1940 ptiRet = (ITypeInfoImpl*) ITypeInfo_Constructor(); 1802 MSFT_Read (&tiBase, sizeof(tiBase) ,pcx ,1803 pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase));1941 MSFT_ReadLEDWords(&tiBase, sizeof(tiBase) ,pcx , 1942 pcx->pTblDir->pTypeInfoTab.offset+count*sizeof(tiBase)); 1804 1943 /* this is where we are coming from */ 1805 1944 ptiRet->pTypeLib = pLibInfo; … … 1825 1964 ptiRet->TypeAttr.cbSizeVft=tiBase.cbSizeVft; /* FIXME: this is only the non inherited part */ 1826 1965 if(ptiRet->TypeAttr.typekind == TKIND_ALIAS) 1827 MSFT_GetTdesc(pcx, tiBase.datatype1, 1966 MSFT_GetTdesc(pcx, tiBase.datatype1, 1828 1967 &ptiRet->TypeAttr.tdescAlias, ptiRet); 1829 1968 … … 1844 1983 if(ptiRet->TypeAttr.cFuncs >0 ) 1845 1984 MSFT_DoFuncs(pcx, ptiRet, ptiRet->TypeAttr.cFuncs, 1846 ptiRet->TypeAttr.cVars, 1985 ptiRet->TypeAttr.cVars, 1847 1986 tiBase.memoffset, & ptiRet->funclist); 1848 1987 /* variables */ 1849 1988 if(ptiRet->TypeAttr.cVars >0 ) 1850 1989 MSFT_DoVars(pcx, ptiRet, ptiRet->TypeAttr.cFuncs, 1851 ptiRet->TypeAttr.cVars, 1990 ptiRet->TypeAttr.cVars, 1852 1991 tiBase.memoffset, & ptiRet->varlist); 1853 1992 if(ptiRet->TypeAttr.cImplTypes >0 ) { … … 1855 1994 { 1856 1995 case TKIND_COCLASS: 1857 MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes , 1996 MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes , 1858 1997 tiBase.datatype1); 1859 1998 break; 1860 1999 case TKIND_DISPATCH: 1861 2000 ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType)); 1862 2001 1863 2002 if (tiBase.datatype1 != -1) 1864 2003 { … … 1883 2022 (*ppRef)->index = TLB_REF_USE_GUID; 1884 2023 (*ppRef)->pImpTLInfo = TLB_Alloc(sizeof(TLBImpLib)); 1885 (*ppRef)->pImpTLInfo->guid = IID_StdOle; 2024 (*ppRef)->pImpTLInfo->guid = IID_StdOle; 1886 2025 (*ppRef)->pImpTLInfo->name = SysAllocStringLen(NULL, 1887 2026 nStdOleLen + 1); 1888 2027 1889 2028 MultiByteToWideChar(CP_ACP, 1890 2029 MB_PRECOMPOSED, … … 1893 2032 (*ppRef)->pImpTLInfo->name, 1894 2033 SysStringLen((*ppRef)->pImpTLInfo->name)); 1895 2034 1896 2035 (*ppRef)->pImpTLInfo->lcid = 0; 1897 2036 (*ppRef)->pImpTLInfo->wVersionMajor = 2; … … 1930 2069 int ret = TYPE_E_CANTLOADLIBRARY; 1931 2070 DWORD dwSignature = 0; 1932 H FILE hFile;2071 HANDLE hFile; 1933 2072 1934 2073 TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index); … … 1950 2089 1951 2090 /* first try to load as *.tlb */ 1952 dwSignature = *((DWORD*) pBase);2091 dwSignature = FromLEDWord(*((DWORD*) pBase)); 1953 2092 if ( dwSignature == MSFT_SIGNATURE) 1954 2093 { … … 1982 2121 LPVOID pBase = LockResource(hGlobal); 1983 2122 DWORD dwTLBLength = SizeofResource(hinstDLL, hrsrc); 1984 2123 1985 2124 if (pBase) 1986 2125 { 1987 2126 /* try to load as incore resource */ 1988 dwSignature = *((DWORD*) pBase);2127 dwSignature = FromLEDWord(*((DWORD*) pBase)); 1989 2128 if ( dwSignature == MSFT_SIGNATURE) 1990 2129 { … … 2045 2184 cx.pLibInfo = pTypeLibImpl; 2046 2185 cx.length = dwTLBLength; 2047 2186 2048 2187 /* read header */ 2049 MSFT_Read ((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);2188 MSFT_ReadLEDWords((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0); 2050 2189 TRACE("header:\n"); 2051 2190 TRACE("\tmagic1=0x%08x ,magic2=0x%08x\n",tlbHeader.magic1,tlbHeader.magic2 ); 2052 if ( memcmp(&tlbHeader.magic1,TLBMAGIC2,4)) {2191 if (tlbHeader.magic1 != MSFT_SIGNATURE) { 2053 2192 FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1); 2054 2193 return NULL; … … 2061 2200 /* now read the segment directory */ 2062 2201 TRACE("read segment directory (at %ld)\n",lPSegDir); 2063 MSFT_Read ((void*)&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir);2202 MSFT_ReadLEDWords(&tlbSegDir, sizeof(tlbSegDir), &cx, lPSegDir); 2064 2203 cx.pTblDir = &tlbSegDir; 2065 2204 … … 2098 2237 { 2099 2238 int offset; 2100 MSFT_Read (&offset, sizeof(offset), &cx, sizeof(tlbHeader));2239 MSFT_ReadLEDWords(&offset, sizeof(offset), &cx, sizeof(tlbHeader)); 2101 2240 pTypeLibImpl->HelpStringDll = MSFT_ReadString(&cx, offset); 2102 2241 } … … 2116 2255 INT16 td[4]; 2117 2256 pTypeLibImpl->pTypeDesc = TLB_Alloc( cTD * sizeof(TYPEDESC)); 2118 MSFT_Read (td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset);2257 MSFT_ReadLEWords(td, sizeof(td), &cx, tlbSegDir.pTypdescTab.offset); 2119 2258 for(i=0; i<cTD; ) 2120 2259 { … … 2138 2277 pTypeLibImpl->pTypeDesc[i].u.hreftype = MAKELONG(td[2],td[3]); 2139 2278 } 2140 if(++i<cTD) MSFT_Read (td, sizeof(td), &cx, DO_NOT_SEEK);2279 if(++i<cTD) MSFT_ReadLEWords(td, sizeof(td), &cx, DO_NOT_SEEK); 2141 2280 } 2142 2281 … … 2147 2286 if(tlbSegDir.pArrayDescriptions.offset>0) 2148 2287 { 2149 MSFT_Read (td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc);2288 MSFT_ReadLEWords(td, sizeof(td), &cx, tlbSegDir.pArrayDescriptions.offset + (int) pTypeLibImpl->pTypeDesc[i].u.lpadesc); 2150 2289 pTypeLibImpl->pTypeDesc[i].u.lpadesc = TLB_Alloc(sizeof(ARRAYDESC)+sizeof(SAFEARRAYBOUND)*(td[3]-1)); 2151 2290 … … 2159 2298 for(j = 0; j<td[2]; j++) 2160 2299 { 2161 MSFT_Read (& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements,2162 sizeof(INT), &cx, DO_NOT_SEEK);2163 MSFT_Read (& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound,2164 sizeof(INT), &cx, DO_NOT_SEEK);2300 MSFT_ReadLEDWords(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].cElements, 2301 sizeof(INT), &cx, DO_NOT_SEEK); 2302 MSFT_ReadLEDWords(& pTypeLibImpl->pTypeDesc[i].u.lpadesc->rgbounds[j].lLbound, 2303 sizeof(INT), &cx, DO_NOT_SEEK); 2165 2304 } 2166 2305 } … … 2184 2323 *ppImpLib = TLB_Alloc(sizeof(TLBImpLib)); 2185 2324 (*ppImpLib)->offset = offset - tlbSegDir.pImpFiles.offset; 2186 MSFT_Read (&oGuid, sizeof(INT), &cx, offset);2187 2188 MSFT_Read(&(*ppImpLib)->lcid,sizeof(LCID), &cx, DO_NOT_SEEK);2189 MSFT_Read (&(*ppImpLib)->wVersionMajor, sizeof(WORD), &cx, DO_NOT_SEEK);2190 MSFT_Read (&(*ppImpLib)->wVersionMinor, sizeof(WORD), &cx, DO_NOT_SEEK);2191 MSFT_Read (& size, sizeof(UINT16), &cx, DO_NOT_SEEK);2325 MSFT_ReadLEDWords(&oGuid, sizeof(INT), &cx, offset); 2326 2327 MSFT_ReadLEDWords(&(*ppImpLib)->lcid, sizeof(LCID), &cx, DO_NOT_SEEK); 2328 MSFT_ReadLEWords(&(*ppImpLib)->wVersionMajor, sizeof(WORD), &cx, DO_NOT_SEEK); 2329 MSFT_ReadLEWords(&(*ppImpLib)->wVersionMinor, sizeof(WORD), &cx, DO_NOT_SEEK); 2330 MSFT_ReadLEWords(& size, sizeof(UINT16), &cx, DO_NOT_SEEK); 2192 2331 2193 2332 size >>= 2; … … 2656 2795 } 2657 2796 } 2658 2797 2659 2798 ppFuncDesc = &((*ppFuncDesc)->next); 2660 2799 if(pFunc->next == 0xffff) break; … … 2802 2941 2803 2942 pHeader = pLib; 2804 2943 2805 2944 TRACE("header:\n"); 2806 2945 TRACE("\tmagic=0x%08lx, file blocks = %d\n", pHeader->SLTG_magic, 2807 2946 pHeader->nrOfFileBlks ); 2808 if ( memcmp(&pHeader->SLTG_magic, TLBMAGIC1, 4)) {2947 if (pHeader->SLTG_magic != SLTG_SIGNATURE) { 2809 2948 FIXME("Header type magic 0x%08lx not supported.\n", 2810 2949 pHeader->SLTG_magic); 2811 2950 return NULL; 2812 2951 } 2813 2952 2814 2953 /* There are pHeader->nrOfFileBlks - 2 TypeInfo records in this typelib */ 2815 2954 pTypeLibImpl->TypeInfoCount = pHeader->nrOfFileBlks - 2; … … 2844 2983 pBlkEntry[order].next != 0; 2845 2984 order = pBlkEntry[order].next - 1, i++) { 2846 #ifdef __WIN32OS2__ 2847 pBlk = (LPBYTE)pBlk + pBlkEntry[order].len; 2848 #else 2849 pBlk += pBlkEntry[order].len; 2850 #endif 2985 pBlk = (char*)pBlk + pBlkEntry[order].len; 2851 2986 } 2852 2987 pLibBlk = pBlk; … … 2867 3002 2868 3003 ptr = (char*)pLibBlk + len; 2869 3004 2870 3005 for(i = 0; i < pTypeLibImpl->TypeInfoCount; i++) { 2871 3006 WORD w, extra; … … 2917 3052 dust and we should be pointing at the beginning of the name 2918 3053 table */ 2919 3054 2920 3055 pNameTable = (char*)pLibBlk + len; 2921 3056 … … 2930 3065 break; 2931 3066 } 2932 3067 2933 3068 pNameTable += 0x216; 2934 3069 … … 2980 3115 (*ppTypeInfoImpl)->TypeAttr.wTypeFlags = 2981 3116 (pTIHeader->typeflags1 >> 3) | (pTIHeader->typeflags2 << 5); 2982 3117 2983 3118 if((pTIHeader->typeflags1 & 7) != 2) 2984 3119 FIXME("typeflags1 = %02x\n", pTIHeader->typeflags1); … … 2994 3129 switch(pTIHeader->typekind) { 2995 3130 case TKIND_ENUM: 2996 pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable); 3131 pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable); 2997 3132 break; 2998 3133 2999 3134 case TKIND_RECORD: 3000 pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable); 3135 pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable); 3001 3136 break; 3002 3137 … … 3023 3158 } 3024 3159 ppTypeInfoImpl = &((*ppTypeInfoImpl)->next); 3025 #ifdef __WIN32OS2__ 3026 pBlk = (LPBYTE)pBlk + pBlkEntry[order].len; 3027 #else 3028 pBlk += pBlkEntry[order].len; 3029 #endif 3160 pBlk = (char*)pBlk + pBlkEntry[order].len; 3030 3161 } 3031 3162 … … 3051 3182 3052 3183 *ppvObject=NULL; 3053 if(IsEqualIID(riid, &IID_IUnknown) || 3184 if(IsEqualIID(riid, &IID_IUnknown) || 3054 3185 IsEqualIID(riid,&IID_ITypeLib)|| 3055 3186 IsEqualIID(riid,&IID_ITypeLib2)) … … 3086 3217 3087 3218 --(This->ref); 3088 3219 3089 3220 TRACE("(%p)->(%u)\n",This, This->ref); 3090 3221 … … 3118 3249 This->HelpStringDll = NULL; 3119 3250 } 3120 3251 3121 3252 ITypeInfo_Release((ITypeInfo*) This->pTypeInfo); 3122 3253 HeapFree(GetProcessHeap(),0,This); … … 3128 3259 3129 3260 /* ITypeLib::GetTypeInfoCount 3130 * 3261 * 3131 3262 * Returns the number of type descriptions in the type library 3132 3263 */ … … 3144 3275 static HRESULT WINAPI ITypeLib2_fnGetTypeInfo( 3145 3276 ITypeLib2 *iface, 3146 UINT index, 3277 UINT index, 3147 3278 ITypeInfo **ppTInfo) 3148 3279 { 3149 3280 int i; 3150 3281 3151 3282 ICOM_THIS( ITypeLibImpl, iface); 3152 3283 ITypeInfoImpl *pTypeInfo = This->pTypeInfo; … … 3155 3286 3156 3287 if (!ppTInfo) return E_INVALIDARG; 3157 3288 3158 3289 /* search element n in list */ 3159 3290 for(i=0; i < index; i++) … … 3165 3296 return TYPE_E_ELEMENTNOTFOUND; 3166 3297 } 3167 } 3298 } 3168 3299 3169 3300 *ppTInfo = (ITypeInfo *) pTypeInfo; 3170 3301 3171 3302 ITypeInfo_AddRef(*ppTInfo); 3172 3303 TRACE("-- found (%p)\n",*ppTInfo); … … 3191 3322 3192 3323 if(!pTKind) return E_INVALIDARG; 3193 3324 3194 3325 /* search element n in list */ 3195 3326 for(i=0; i < index; i++) … … 3238 3369 } 3239 3370 3240 TRACE("-- found (%p, %s)\n", 3241 pTypeInfo, 3371 TRACE("-- found (%p, %s)\n", 3372 pTypeInfo, 3242 3373 debugstr_w(pTypeInfo->Name)); 3243 3374 … … 3253 3384 */ 3254 3385 static HRESULT WINAPI ITypeLib2_fnGetLibAttr( 3255 ITypeLib2 *iface, 3386 ITypeLib2 *iface, 3256 3387 LPTLIBATTR *ppTLibAttr) 3257 3388 { … … 3292 3423 BSTR *pBstrName, 3293 3424 BSTR *pBstrDocString, 3294 DWORD *pdwHelpContext, 3425 DWORD *pdwHelpContext, 3295 3426 BSTR *pBstrHelpFile) 3296 3427 { 3297 3428 ICOM_THIS( ITypeLibImpl, iface); 3298 3429 3299 3430 HRESULT result = E_INVALIDARG; 3300 3431 3301 3432 ITypeInfo *pTInfo; 3302 3433 3303 3434 3304 3435 TRACE("(%p) index %d Name(%p) DocString(%p) HelpContext(%p) HelpFile(%p)\n", 3305 3436 This, index, 3306 pBstrName, pBstrDocString, 3437 pBstrName, pBstrDocString, 3307 3438 pdwHelpContext, pBstrHelpFile); 3308 3439 3309 3440 if(index<0) 3310 { 3441 { 3311 3442 /* documentation for the typelib */ 3312 3443 if(pBstrName) … … 3340 3471 result = S_OK; 3341 3472 } 3342 else 3473 else 3343 3474 { 3344 3475 /* for a typeinfo */ … … 3347 3478 if(SUCCEEDED(result)) 3348 3479 { 3349 result = ITypeInfo_GetDocumentation(pTInfo, 3350 MEMBERID_NIL, 3480 result = ITypeInfo_GetDocumentation(pTInfo, 3481 MEMBERID_NIL, 3351 3482 pBstrName, 3352 pBstrDocString, 3483 pBstrDocString, 3353 3484 pdwHelpContext, pBstrHelpFile); 3354 3485 3355 3486 ITypeInfo_Release(pTInfo); 3356 3487 } … … 3398 3529 for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next) 3399 3530 if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit; 3400 3531 3401 3532 } 3402 3533 *pfName=FALSE; … … 3405 3536 TRACE("(%p)slow! search for %s: %s found!\n", This, 3406 3537 debugstr_w(szNameBuf), *pfName?"NOT":""); 3407 3538 3408 3539 return S_OK; 3409 3540 } … … 3428 3559 TLBVarDesc *pVInfo; 3429 3560 int i,j = 0; 3430 3561 3431 3562 UINT nNameBufLen = SysStringLen(szNameBuf); 3432 3563 … … 3451 3582 3452 3583 *pcFound=j; 3453 3584 3454 3585 return S_OK; 3455 3586 } … … 3476 3607 static HRESULT WINAPI ITypeLib2_fnGetCustData( 3477 3608 ITypeLib2 * iface, 3478 REFGUID guid, 3609 REFGUID guid, 3479 3610 VARIANT *pVarVal) 3480 3611 { … … 3486 3617 if( IsEqualIID(guid, &pCData->guid)) break; 3487 3618 } 3488 3619 3489 3620 TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT"); 3490 3621 … … 3505 3636 */ 3506 3637 static HRESULT WINAPI ITypeLib2_fnGetLibStatistics( 3507 ITypeLib2 * iface, 3638 ITypeLib2 * iface, 3508 3639 ULONG *pcUniqueNames, 3509 3640 ULONG *pcchUniqueNames) … … 3526 3657 */ 3527 3658 static HRESULT WINAPI ITypeLib2_fnGetDocumentation2( 3528 ITypeLib2 * iface, 3659 ITypeLib2 * iface, 3529 3660 INT index, 3530 3661 LCID lcid, … … 3559 3690 /* for a typeinfo */ 3560 3691 result=ITypeLib2_GetTypeInfo(iface, index, &pTInfo); 3561 3692 3562 3693 if(SUCCEEDED(result)) 3563 { 3694 { 3564 3695 ITypeInfo2 * pTInfo2; 3565 result = ITypeInfo_QueryInterface(pTInfo, 3566 &IID_ITypeInfo2, 3696 result = ITypeInfo_QueryInterface(pTInfo, 3697 &IID_ITypeInfo2, 3567 3698 (LPVOID*) &pTInfo2); 3568 3699 3569 3700 if(SUCCEEDED(result)) 3570 3701 { 3571 result = ITypeInfo2_GetDocumentation2(pTInfo2, 3572 MEMBERID_NIL, 3702 result = ITypeInfo2_GetDocumentation2(pTInfo2, 3703 MEMBERID_NIL, 3573 3704 lcid, 3574 pbstrHelpString, 3575 pdwHelpStringContext, 3705 pbstrHelpString, 3706 pdwHelpStringContext, 3576 3707 pbstrHelpStringDll); 3577 3708 3578 3709 ITypeInfo2_Release(pTInfo2); 3579 3710 } 3580 3711 3581 3712 ITypeInfo_Release(pTInfo); 3582 3713 } … … 3587 3718 /* ITypeLib2::GetAllCustData 3588 3719 * 3589 * Gets all custom data items for the library. 3720 * Gets all custom data items for the library. 3590 3721 * 3591 3722 */ … … 3597 3728 TLBCustData *pCData; 3598 3729 int i; 3599 TRACE("(%p) returning %d items\n", This, This->ctCustData); 3730 TRACE("(%p) returning %d items\n", This, This->ctCustData); 3600 3731 pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM)); 3601 3732 if(pCustData->prgCustData ){ … … 3661 3792 3662 3793 *ppvObject=NULL; 3663 if(IsEqualIID(riid, &IID_IUnknown) || 3794 if(IsEqualIID(riid, &IID_IUnknown) || 3664 3795 IsEqualIID(riid,&IID_ITypeInfo)|| 3665 3796 IsEqualIID(riid,&IID_ITypeInfo2)) … … 3694 3825 3695 3826 --(This->ref); 3696 3827 3697 3828 TRACE("(%p)->(%u)\n",This, This->ref); 3698 3829 … … 3701 3832 FIXME("destroy child objects\n"); 3702 3833 3703 TRACE("destroying ITypeInfo(%p)\n",This); 3834 TRACE("destroying ITypeInfo(%p)\n",This); 3704 3835 if (This->Name) 3705 3836 { … … 3707 3838 This->Name = 0; 3708 3839 } 3709 3840 3710 3841 if (This->DocString) 3711 3842 { … … 3766 3897 ICOM_THIS( ITypeInfoImpl, iface); 3767 3898 int i; 3768 TLBFuncDesc * pFDesc; 3899 TLBFuncDesc * pFDesc; 3769 3900 TRACE("(%p) index %d\n", This, index); 3770 3901 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next) … … 3780 3911 /* ITypeInfo::GetVarDesc 3781 3912 * 3782 * Retrieves a VARDESC structure that describes the specified variable. 3913 * Retrieves a VARDESC structure that describes the specified variable. 3783 3914 * 3784 3915 */ … … 3788 3919 ICOM_THIS( ITypeInfoImpl, iface); 3789 3920 int i; 3790 TLBVarDesc * pVDesc; 3921 TLBVarDesc * pVDesc; 3791 3922 TRACE("(%p) index %d\n", This, index); 3792 3923 for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next) … … 3810 3941 { 3811 3942 ICOM_THIS( ITypeInfoImpl, iface); 3812 TLBFuncDesc * pFDesc; 3813 TLBVarDesc * pVDesc; 3943 TLBFuncDesc * pFDesc; 3944 TLBVarDesc * pVDesc; 3814 3945 int i; 3815 3946 TRACE("(%p) memid=0x%08lx Maxname=%d\n", This, memid, cMaxNames); … … 3890 4021 */ 3891 4022 if( This->TypeAttr.typekind != TKIND_DISPATCH) return E_INVALIDARG; 3892 4023 3893 4024 if (This->TypeAttr.wTypeFlags & TYPEFLAG_FDISPATCHABLE && 3894 4025 This->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL ) … … 3909 4040 pImpl = pImpl->next; 3910 4041 } 3911 4042 3912 4043 if (!pImpl) return TYPE_E_ELEMENTNOTFOUND; 3913 4044 3914 4045 *pRefType = pImpl->hRef; 3915 4046 3916 4047 TRACE("-- 0x%08lx\n", pImpl->hRef ); 3917 4048 } 3918 4049 3919 4050 return S_OK; 3920 4051 3921 4052 } 3922 4053 3923 4054 /* ITypeInfo::GetImplTypeFlags 3924 * 3925 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 4055 * 4056 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 3926 4057 * or base interface in a type description. 3927 4058 */ … … 3953 4084 { 3954 4085 ICOM_THIS( ITypeInfoImpl, iface); 3955 TLBFuncDesc * pFDesc; 3956 TLBVarDesc * pVDesc; 4086 TLBFuncDesc * pFDesc; 4087 TLBVarDesc * pVDesc; 3957 4088 HRESULT ret=S_OK; 3958 4089 … … 3974 4105 return ret; 3975 4106 } 3976 } 4107 } 3977 4108 for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) { 3978 4109 if(!lstrcmpiW(*rgszNames, pVDesc->Name)) { … … 3981 4112 } 3982 4113 } 3983 /* not found, see if this is and interface with an inheritance */ 3984 if(This->TypeAttr.typekind==TKIND_INTERFACE && 4114 /* not found, see if this is and interface with an inheritance */ 4115 if(This->TypeAttr.typekind==TKIND_INTERFACE && 3985 4116 This->TypeAttr.cImplTypes ){ 3986 4117 /* recursive search */ 3987 4118 ITypeInfo *pTInfo; 3988 ret=ITypeInfo_GetRefTypeInfo(iface, 4119 ret=ITypeInfo_GetRefTypeInfo(iface, 3989 4120 This->impltypelist->hRef, &pTInfo); 3990 4121 if(SUCCEEDED(ret)){ … … 4000 4131 4001 4132 /* ITypeInfo::Invoke 4002 * 4133 * 4003 4134 * Invokes a method, or accesses a property of an object, that implements the 4004 4135 * interface described by the type description. … … 4018 4149 case CC_STDCALL: 4019 4150 4151 #ifdef __WIN32OS2__ 4020 4152 switch (nrargs) { 4021 #ifdef __WIN32OS2__4022 4153 case 0: { 4023 4154 DWORD (* WINAPI xfunc)() = func; … … 4071 4202 } 4072 4203 #else 4204 switch (nrargs) { 4073 4205 case 0: { 4074 4206 DWORD (WINAPI *xfunc)() = func; … … 4110 4242 res = xfunc(args[0],args[1],args[2],args[3],args[4],args[5],args[6]); 4111 4243 break; 4112 4244 } 4113 4245 case 8: { 4114 4246 DWORD (WINAPI *xfunc)(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD) = func; … … 4137 4269 } 4138 4270 4271 extern int const _argsize(DWORD vt); 4272 4273 /*********************************************************************** 4274 * DispCallFunc (OLEAUT32.@) 4275 */ 4276 HRESULT WINAPI 4277 DispCallFunc( 4278 void* pvInstance, ULONG oVft, CALLCONV cc, VARTYPE vtReturn, UINT cActuals, 4279 VARTYPE* prgvt, VARIANTARG** prgpvarg, VARIANT* pvargResult 4280 ) { 4281 int i, argsize, argspos; 4282 DWORD *args; 4283 HRESULT hres; 4284 4285 FIXME("(%p, %ld, %d, %d, %d, %p, %p, %p)\n", 4286 pvInstance, oVft, cc, vtReturn, cActuals, prgvt, prgpvarg, pvargResult 4287 ); 4288 argsize = 0; 4289 for (i=0;i<cActuals;i++) { 4290 FIXME("arg %d: type %d\n",i,prgvt[i]); 4291 dump_Variant(prgpvarg[i]); 4292 argsize += _argsize(prgvt[i]); 4293 } 4294 args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*argsize); 4295 argspos = 0; 4296 for (i=0;i<cActuals;i++) { 4297 int arglen; 4298 VARIANT *arg = prgpvarg[i]; 4299 4300 arglen = _argsize(prgvt[i]); 4301 if (V_VT(arg) == prgvt[i]) { 4302 memcpy(&args[argspos],&V_UNION(arg,lVal), arglen*sizeof(DWORD)); 4303 } else { 4304 if (prgvt[i] == VT_VARIANT) { 4305 memcpy(&args[argspos],arg, arglen*sizeof(DWORD)); 4306 } else { 4307 ERR("Set arg %d to disparg type %d vs %d\n",i, 4308 V_VT(arg),prgvt[i] 4309 ); 4310 } 4311 } 4312 argspos += arglen; 4313 } 4314 4315 FIXME("Do not know how to handle pvargResult %p. Expect crash ...\n",pvargResult); 4316 4317 hres = _invoke((*(DWORD***)pvInstance)[oVft/4],cc,argsize/4,args); 4318 HeapFree(GetProcessHeap(),0,args); 4319 return hres; 4320 } 4321 4139 4322 static HRESULT WINAPI ITypeInfo_fnInvoke( 4140 4323 ITypeInfo2 *iface, … … 4148 4331 { 4149 4332 ICOM_THIS( ITypeInfoImpl, iface); 4150 TLBFuncDesc * pFDesc; 4151 TLBVarDesc * pVDesc; 4333 TLBFuncDesc * pFDesc; 4334 TLBVarDesc * pVDesc; 4152 4335 int i; 4153 4336 … … 4164 4347 if (pFDesc) { 4165 4348 dump_TLBFuncDescOne(pFDesc); 4349 /* dump_FUNCDESC(&pFDesc->funcdesc);*/ 4166 4350 switch (pFDesc->funcdesc.funckind) { 4167 4351 case FUNC_PUREVIRTUAL: 4168 4352 case FUNC_VIRTUAL: { 4169 4353 DWORD res; 4170 DWORD *args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*(pFDesc->funcdesc.cParams+1)); 4171 DWORD *args2 = (DWORD*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(DWORD)*(pFDesc->funcdesc.cParams)); 4354 int numargs, numargs2, argspos, args2pos; 4355 DWORD *args , *args2; 4356 4357 4358 numargs = 1; numargs2 = 0; 4359 for (i=0;i<pFDesc->funcdesc.cParams;i++) { 4360 if (i<pDispParams->cArgs) 4361 numargs += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); 4362 else { 4363 numargs += 1; /* sizeof(lpvoid) */ 4364 numargs2 += _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); 4365 } 4366 } 4367 4368 args = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*numargs); 4369 args2 = (DWORD*)HeapAlloc(GetProcessHeap(),0,sizeof(DWORD)*numargs2); 4370 4172 4371 args[0] = (DWORD)pIUnk; 4173 4372 argspos = 1; args2pos = 0; 4174 4373 for (i=0;i<pFDesc->funcdesc.cParams;i++) { 4374 int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); 4175 4375 if (i<pDispParams->cArgs) { 4176 TRACE("set %d to disparg type %d vs %d\n",i, 4177 V_VT(&pDispParams->rgvarg[pDispParams->cArgs-i-1]), 4178 pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt 4179 ); 4180 args[i+1] = V_UNION(&pDispParams->rgvarg[pDispParams->cArgs-i-1],lVal); 4376 VARIANT *arg = &pDispParams->rgvarg[pDispParams->cArgs-i-1]; 4377 TYPEDESC *tdesc = &pFDesc->funcdesc.lprgelemdescParam[i].tdesc; 4378 4379 if (V_VT(arg) == tdesc->vt) { 4380 memcpy(&args[argspos],&V_UNION(arg,lVal), arglen*sizeof(DWORD)); 4381 } else { 4382 if (tdesc->vt == VT_VARIANT) { 4383 memcpy(&args[argspos],arg, arglen*sizeof(DWORD)); 4384 } else { 4385 ERR("Set arg %d to disparg type %d vs %d\n",i, 4386 V_VT(arg),tdesc->vt 4387 ); 4388 } 4389 } 4390 argspos += arglen; 4181 4391 } else { 4182 4392 TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i].tdesc); 4183 TRACE("set %d to pointer for get (type is %d)\n",i,tdesc->vt); 4393 if (tdesc->vt != VT_PTR) 4394 FIXME("set %d to pointer for get (type is %d)\n",i,tdesc->vt); 4184 4395 /*FIXME: give pointers for the rest, so propertyget works*/ 4185 args[i+1] = (DWORD)&args2[i]; 4186 4187 /* If pointer to variant, pass reference to variant 4188 * in result variant array. 4189 */ 4396 args[argspos] = (DWORD)&args2[args2pos]; 4397 4398 /* If pointer to variant, pass reference it. */ 4190 4399 if ((tdesc->vt == VT_PTR) && 4191 4400 (tdesc->u.lptdesc->vt == VT_VARIANT) && 4192 4401 pVarResult 4193 4402 ) 4194 args[i+1] = (DWORD)(pVarResult+(i-pDispParams->cArgs)); 4403 args[argspos]= (DWORD)pVarResult; 4404 argspos += 1; 4405 args2pos += arglen; 4195 4406 } 4196 4407 } … … 4202 4413 res = _invoke((*(DWORD***)pIUnk)[pFDesc->funcdesc.oVft/4], 4203 4414 pFDesc->funcdesc.callconv, 4204 pFDesc->funcdesc.cParams+1,4415 numargs, 4205 4416 args 4206 4417 ); 4207 4418 if (pVarResult && (dwFlags & (DISPATCH_PROPERTYGET))) { 4419 args2pos = 0; 4208 4420 for (i=0;i<pFDesc->funcdesc.cParams-pDispParams->cArgs;i++) { 4421 int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt); 4209 4422 TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i+pDispParams->cArgs].tdesc); 4210 4423 /* If we are a pointer to a variant, we are done already */ … … 4212 4425 continue; 4213 4426 4214 VariantInit( &pVarResult[i]);4215 V_UNION(pVarResult+i,intVal) = args2[i+pDispParams->cArgs];4427 VariantInit(pVarResult); 4428 memcpy(&V_UNION(pVarResult,intVal),&args2[args2pos],arglen*sizeof(DWORD)); 4216 4429 4217 4430 if (tdesc->vt == VT_PTR) 4218 4431 tdesc = tdesc->u.lptdesc; 4219 V_VT(pVarResult +i) = tdesc->vt;4432 V_VT(pVarResult) = tdesc->vt; 4220 4433 4221 4434 /* HACK: VB5 likes this. … … 4225 4438 */ 4226 4439 if ((tdesc->vt == VT_PTR) && (dwFlags & DISPATCH_METHOD)) 4227 V_VT(pVarResult+i) = VT_DISPATCH; 4228 TRACE("storing into variant: [%d]\n", i); 4229 dump_Variant(pVarResult+i); 4440 V_VT(pVarResult) = VT_DISPATCH; 4441 TRACE("storing into variant:\n"); 4442 dump_Variant(pVarResult); 4443 args2pos += arglen; 4230 4444 } 4231 4445 } … … 4284 4498 4285 4499 /* ITypeInfo::GetDocumentation 4286 * 4500 * 4287 4501 * Retrieves the documentation string, the complete Help file name and path, 4288 4502 * and the context ID for the Help topic for a specified type description. 4503 * 4504 * (Can be tested by the Visual Basic Editor in Word for instance.) 4289 4505 */ 4290 4506 static HRESULT WINAPI ITypeInfo_fnGetDocumentation( ITypeInfo2 *iface, … … 4293 4509 { 4294 4510 ICOM_THIS( ITypeInfoImpl, iface); 4295 TLBFuncDesc * pFDesc; 4296 TLBVarDesc * pVDesc; 4511 TLBFuncDesc * pFDesc; 4512 TLBVarDesc * pVDesc; 4297 4513 TRACE("(%p) memid %ld Name(%p) DocString(%p)" 4298 4514 " HelpContext(%p) HelpFile(%p)\n", … … 4321 4537 for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) 4322 4538 if(pVDesc->vardesc.memid==memid){ 4323 FIXME("Not implemented\n"); 4324 return S_OK; 4539 if(pBstrName) 4540 *pBstrName = SysAllocString(pVDesc->Name); 4541 if(pBstrDocString) 4542 *pBstrDocString=SysAllocString(pVDesc->HelpString); 4543 if(pdwHelpContext) 4544 *pdwHelpContext=pVDesc->HelpContext; 4545 return S_OK; 4325 4546 } 4326 4547 } … … 4329 4550 4330 4551 /* ITypeInfo::GetDllEntry 4331 * 4552 * 4332 4553 * Retrieves a description or specification of an entry point for a function 4333 4554 * in a DLL. … … 4338 4559 { 4339 4560 ICOM_THIS( ITypeInfoImpl, iface); 4340 FIXME("(%p) stub!\n", This); 4561 TLBFuncDesc *pFDesc; 4562 4563 FIXME("(%p, memid %lx, %d, %p, %p, %p), partial stub!\n", This, memid, invKind, pBstrDllName, pBstrName, pwOrdinal); 4564 4565 for(pFDesc=This->funclist; pFDesc; pFDesc=pFDesc->next) 4566 if(pFDesc->funcdesc.memid==memid){ 4567 dump_TypeInfo(This); 4568 dump_TLBFuncDescOne(pFDesc); 4569 4570 /* FIXME: This is wrong, but how do you find that out? */ 4571 if (pBstrDllName) { 4572 const WCHAR oleaut32W[] = {'O','L','E','A','U','T','3','2','.','D','L','L',0}; 4573 *pBstrDllName = SysAllocString(oleaut32W); 4574 } 4575 4576 if (HIWORD(pFDesc->Entry) && (pFDesc->Entry != (void*)-1)) { 4577 if (pBstrName) 4578 *pBstrName = SysAllocString(pFDesc->Entry); 4579 if (pwOrdinal) 4580 *pwOrdinal = -1; 4581 return S_OK; 4582 } 4583 if (pBstrName) 4584 *pBstrName = NULL; 4585 if (pwOrdinal) 4586 *pwOrdinal = (DWORD)pFDesc->Entry; 4587 return S_OK; 4588 } 4341 4589 return E_FAIL; 4342 4590 } 4343 4591 4344 4592 /* ITypeInfo::GetRefTypeInfo 4345 * 4593 * 4346 4594 * If a type description references other type descriptions, it retrieves 4347 4595 * the referenced type descriptions. … … 4356 4604 4357 4605 4358 if (hRefType == -1 && 4606 if (hRefType == -1 && 4359 4607 (((ITypeInfoImpl*) This)->TypeAttr.typekind == TKIND_DISPATCH) && 4360 4608 (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL)) 4361 4609 { 4362 /* when we meet a DUAL dispinterface, we must create the interface 4610 /* when we meet a DUAL dispinterface, we must create the interface 4363 4611 * version of it. 4364 4612 */ 4365 4613 ITypeInfoImpl* pTypeInfoImpl = (ITypeInfoImpl*) ITypeInfo_Constructor(); 4366 4614 4367 4615 4368 4616 /* the interface version contains the same information as the dispinterface 4369 4617 * copy the contents of the structs. … … 4371 4619 *pTypeInfoImpl = *This; 4372 4620 pTypeInfoImpl->ref = 1; 4373 4621 4374 4622 /* change the type to interface */ 4375 4623 pTypeInfoImpl->TypeAttr.typekind = TKIND_INTERFACE; 4376 4624 4377 4625 *ppTInfo = (ITypeInfo*) pTypeInfoImpl; 4378 4626 … … 4422 4670 if(SUCCEEDED(result)) { 4423 4671 if(pRefType->index == TLB_REF_USE_GUID) 4424 result = ITypeLib2_GetTypeInfoOfGuid(pTLib, 4425 &pRefType->guid, 4672 result = ITypeLib2_GetTypeInfoOfGuid(pTLib, 4673 &pRefType->guid, 4426 4674 ppTInfo); 4427 4675 else … … 4440 4688 4441 4689 /* ITypeInfo::AddressOfMember 4442 * 4690 * 4443 4691 * Retrieves the addresses of static functions or variables, such as those 4444 4692 * defined in a DLL. … … 4453 4701 4454 4702 /* ITypeInfo::CreateInstance 4455 * 4456 * Creates a new instance of a type that describes a component object class 4703 * 4704 * Creates a new instance of a type that describes a component object class 4457 4705 * (coclass). 4458 4706 */ 4459 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 4460 IUnknown *pUnk, REFIID riid, VOID **ppvObj) 4707 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 4708 IUnknown *pUnk, REFIID riid, VOID **ppvObj) 4461 4709 { 4462 4710 ICOM_THIS( ITypeInfoImpl, iface); … … 4478 4726 4479 4727 /* ITypeInfo::GetContainingTypeLib 4480 * 4728 * 4481 4729 * Retrieves the containing type library and the index of the type description 4482 4730 * within that type library. … … 4551 4799 * Returns the type flags without any allocations. This returns a DWORD type 4552 4800 * flag, which expands the type flags without growing the TYPEATTR (type 4553 * attribute). 4801 * attribute). 4554 4802 * 4555 4803 */ … … 4576 4824 HRESULT result; 4577 4825 /* FIXME: should check for invKind??? */ 4578 for(i=0, pFuncInfo=This->funclist;pFuncInfo && 4826 for(i=0, pFuncInfo=This->funclist;pFuncInfo && 4579 4827 memid != pFuncInfo->funcdesc.memid; i++, pFuncInfo=pFuncInfo->next); 4580 4828 if(pFuncInfo){ … … 4593 4841 * 4594 4842 * Binds to a specific member based on a known DISPID, where the member name 4595 * is not known (for example, when binding to a default member). 4843 * is not known (for example, when binding to a default member). 4596 4844 * 4597 4845 */ … … 4603 4851 int i; 4604 4852 HRESULT result; 4605 for(i=0, pVarInfo=This->varlist; pVarInfo && 4853 for(i=0, pVarInfo=This->varlist; pVarInfo && 4606 4854 memid != pVarInfo->vardesc.memid; i++, pVarInfo=pVarInfo->next) 4607 4855 ; … … 4656 4904 ICOM_THIS( ITypeInfoImpl, iface); 4657 4905 TLBCustData *pCData=NULL; 4658 TLBFuncDesc * pFDesc; 4906 TLBFuncDesc * pFDesc; 4659 4907 int i; 4660 4908 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, … … 4685 4933 REFGUID guid, 4686 4934 VARIANT *pVarVal) 4687 { 4935 { 4688 4936 ICOM_THIS( ITypeInfoImpl, iface); 4689 4937 TLBCustData *pCData=NULL; 4690 TLBFuncDesc * pFDesc; 4938 TLBFuncDesc * pFDesc; 4691 4939 int i; 4692 4940 … … 4694 4942 4695 4943 if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams) 4696 for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 4944 for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 4697 4945 pCData = pCData->next) 4698 4946 if( IsEqualIID(guid, &pCData->guid)) break; … … 4718 4966 REFGUID guid, 4719 4967 VARIANT *pVarVal) 4720 { 4968 { 4721 4969 ICOM_THIS( ITypeInfoImpl, iface); 4722 4970 TLBCustData *pCData=NULL; 4723 TLBVarDesc * pVDesc; 4971 TLBVarDesc * pVDesc; 4724 4972 int i; 4725 4973 … … 4754 5002 REFGUID guid, 4755 5003 VARIANT *pVarVal) 4756 { 5004 { 4757 5005 ICOM_THIS( ITypeInfoImpl, iface); 4758 5006 TLBCustData *pCData=NULL; 4759 TLBImplType * pRDesc; 5007 TLBImplType * pRDesc; 4760 5008 int i; 4761 5009 … … 4769 5017 } 4770 5018 } 4771 5019 4772 5020 TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT"); 4773 5021 … … 4782 5030 4783 5031 /* ITypeInfo2::GetDocumentation2 4784 * 5032 * 4785 5033 * Retrieves the documentation string, the complete Help file name and path, 4786 5034 * the localization context to use, and the context ID for the library Help … … 4797 5045 { 4798 5046 ICOM_THIS( ITypeInfoImpl, iface); 4799 TLBFuncDesc * pFDesc; 4800 TLBVarDesc * pVDesc; 5047 TLBFuncDesc * pFDesc; 5048 TLBVarDesc * pVDesc; 4801 5049 TRACE("(%p) memid %ld lcid(0x%lx) HelpString(%p) " 4802 5050 "HelpStringContext(%p) HelpStringDll(%p)\n", … … 4845 5093 /* ITypeInfo2::GetAllCustData 4846 5094 * 4847 * Gets all custom data items for the Type info. 5095 * Gets all custom data items for the Type info. 4848 5096 * 4849 5097 */ … … 4856 5104 int i; 4857 5105 4858 TRACE("(%p) returning %d items\n", This, This->ctCustData); 5106 TRACE("(%p) returning %d items\n", This, This->ctCustData); 4859 5107 4860 5108 pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM)); … … 4884 5132 ICOM_THIS( ITypeInfoImpl, iface); 4885 5133 TLBCustData *pCData; 4886 TLBFuncDesc * pFDesc; 5134 TLBFuncDesc * pFDesc; 4887 5135 int i; 4888 TRACE("(%p) index %d\n", This, index); 5136 TRACE("(%p) index %d\n", This, index); 4889 5137 for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, 4890 5138 pFDesc=pFDesc->next) … … 4920 5168 ICOM_THIS( ITypeInfoImpl, iface); 4921 5169 TLBCustData *pCData=NULL; 4922 TLBFuncDesc * pFDesc; 5170 TLBFuncDesc * pFDesc; 4923 5171 int i; 4924 TRACE("(%p) index %d\n", This, indexFunc); 5172 TRACE("(%p) index %d\n", This, indexFunc); 4925 5173 for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++, 4926 5174 pFDesc=pFDesc->next) 4927 5175 ; 4928 5176 if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams){ 4929 pCustData->prgCustData = 5177 pCustData->prgCustData = 4930 5178 TLB_Alloc(pFDesc->pParamDesc[indexParam].ctCustData * 4931 5179 sizeof(CUSTDATAITEM)); … … 4957 5205 ICOM_THIS( ITypeInfoImpl, iface); 4958 5206 TLBCustData *pCData; 4959 TLBVarDesc * pVDesc; 5207 TLBVarDesc * pVDesc; 4960 5208 int i; 4961 TRACE("(%p) index %d\n", This, index); 5209 TRACE("(%p) index %d\n", This, index); 4962 5210 for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, 4963 5211 pVDesc=pVDesc->next) … … 4995 5243 ICOM_THIS( ITypeInfoImpl, iface); 4996 5244 TLBCustData *pCData; 4997 TLBImplType * pRDesc; 5245 TLBImplType * pRDesc; 4998 5246 int i; 4999 TRACE("(%p) index %d\n", This, index); 5247 TRACE("(%p) index %d\n", This, index); 5000 5248 for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++, 5001 5249 pRDesc=pRDesc->next) … … 5021 5269 } 5022 5270 5023 static ICOM_VTABLE(ITypeInfo2) tinfvt = 5271 static ICOM_VTABLE(ITypeInfo2) tinfvt = 5024 5272 { 5025 5273 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE -
trunk/src/oleaut32/typelib.h
r8640 r9400 25 25 #include "wine/windef16.h" 26 26 27 #define TLBMAGIC2 "MSFT"28 #define TLBMAGIC1 "SLTG"29 27 #define HELPDLLFLAG (0x0100) 30 28 #define DO_NOT_SEEK (-1) … … 138 136 INT helpcontext; /* */ 139 137 INT oCustData; /* offset in customer data table */ 138 #ifdef WORDS_BIGENDIAN 139 INT16 cbSizeVft; /* virtual table size, not including inherits */ 140 INT16 cImplTypes; /* nr of implemented interfaces */ 141 #else 140 142 INT16 cImplTypes; /* nr of implemented interfaces */ 141 143 INT16 cbSizeVft; /* virtual table size, not including inherits */ 144 #endif 142 145 /*050*/ INT size; /* size in bytes, at least for structures */ 143 146 /* FIXME: name of this field */ … … 165 168 INT DataType; /* data type of the memeber, eg return of function */ 166 169 INT Flags; /* something to do with attribute flags (LOWORD) */ 170 #ifdef WORDS_BIGENDIAN 171 INT16 res3; /* some offset into dunno what */ 172 INT16 VtableOffset; /* offset in vtable */ 173 #else 167 174 INT16 VtableOffset; /* offset in vtable */ 168 175 INT16 res3; /* some offset into dunno what */ 176 #endif 169 177 INT FKCCIC; /* bit string with the following */ 170 178 /* meaning (bit 0 is the msb): */ … … 175 183 /* Invokation kind (bits 9-12 ) */ 176 184 /* function kind (eg virtual), bits 13-15 */ 185 #ifdef WORDS_BIGENDIAN 186 INT16 nroargs; /* nr of optional arguments */ 187 INT16 nrargs; /* number of arguments (including optional ????) */ 188 #else 177 189 INT16 nrargs; /* number of arguments (including optional ????) */ 178 190 INT16 nroargs; /* nr of optional arguments */ 191 #endif 179 192 /* optional attribute fields, the number of them is variable */ 180 193 INT OptAttr[1]; … … 209 222 INT DataType; /* data type of the variable */ 210 223 INT Flags; /* VarFlags (LOWORD) */ 224 #ifdef WORDS_BIGENDIAN 225 INT16 res3; /* some offset into dunno what */ 226 INT16 VarKind; /* VarKind */ 227 #else 211 228 INT16 VarKind; /* VarKind */ 212 229 INT16 res3; /* some offset into dunno what */ 230 #endif 213 231 INT OffsValue; /* value of the variable or the offset */ 214 232 /* in the data structure */ … … 558 576 extern DWORD _invoke(LPVOID func,CALLCONV callconv, int nrargs, DWORD *args); 559 577 578 #ifdef __WIN32OS2__ 579 #ifdef DEBUG 580 extern void dump_Variant(VARIANT * pvar); 581 #else 582 #define dump_Variant(a) 583 #endif 584 #else 585 extern void dump_Variant(VARIANT * pvar); 586 #endif 587 560 588 #include "poppack.h" 561 589 562 590 /*---------------------------END--------------------------------------------*/ 563 591 #endif 564 565 -
trunk/src/oleaut32/variant.c
r8450 r9400 36 36 37 37 #include "config.h" 38 38 39 39 #include <string.h> 40 40 #include <stdlib.h> … … 53 53 #include "winerror.h" 54 54 #include "parsedt.h" 55 #include "typelib.h" 55 56 56 57 WINE_DEFAULT_DEBUG_CHANNEL(ole); … … 100 101 * 400 then it is a leap year. 101 102 */ 102 /* According to postgreSQL date parsing functions there is 103 * a leap year when this expression is true. 104 * (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0))) 105 * So according to this there is 365.2515 days in one year. 106 * One + every four years: 1/4 -> 365.25 107 * One - every 100 years: 1/100 -> 365.01 108 * One + every 400 years: 1/400 -> 365.0025 109 */ 110 /* static const double DAYS_IN_ONE_YEAR = 365.2515; 103 104 /* 105 * Use 365 days/year and a manual calculation for leap year days 106 * to keep arithmetic simple 107 */ 108 static const double DAYS_IN_ONE_YEAR = 365.0; 109 110 /* 111 * Token definitions for Varient Formatting 112 * Worked out by experimentation on a w2k machine. Doesnt appear to be 113 * documented anywhere obviously so keeping definitions internally 111 114 * 112 * ^^ Might this be the key to an easy way to factor large prime numbers? 113 * Let's try using arithmetic. <lawson_whitney@juno.com> 7 Mar 2000 114 */ 115 static const double DAYS_IN_ONE_YEAR = 365.2425; 116 115 */ 116 /* Pre defined tokens */ 117 #define TOK_COPY 0x00 118 #define TOK_END 0x02 119 #define LARGEST_TOKENID 6 120 121 /* Mapping of token name to id put into the tokenized form 122 Note testing on W2K shows aaaa and oooo are not parsed??!! */ 123 #define TOK_COLON 0x03 124 #define TOK_SLASH 0x04 125 #define TOK_c 0x05 126 #define TOK_d 0x08 127 #define TOK_dd 0x09 128 #define TOK_ddd 0x0a 129 #define TOK_dddd 0x0b 130 #define TOK_ddddd 0x0c 131 #define TOK_dddddd 0x0d 132 #define TOK_w 0x0f 133 #define TOK_ww 0x10 134 #define TOK_m 0x11 135 #define TOK_mm 0x12 136 #define TOK_mmm 0x13 137 #define TOK_mmmm 0x14 138 #define TOK_q 0x06 139 #define TOK_y 0x15 140 #define TOK_yy 0x16 141 #define TOK_yyyy 0x18 142 #define TOK_h 0x1e 143 #define TOK_Hh 0x1f 144 #define TOK_N 0x1a 145 #define TOK_Nn 0x1b 146 #define TOK_S 0x1c 147 #define TOK_Ss 0x1d 148 #define TOK_ttttt 0x07 149 #define TOK_AMsPM 0x2f 150 #define TOK_amspm 0x32 151 #define TOK_AsP 0x30 152 #define TOK_asp 0x33 153 #define TOK_AMPM 0x2e 154 155 typedef struct tagFORMATTOKEN { 156 char *str; 157 BYTE tokenSize; 158 BYTE tokenId; 159 int varTypeRequired; 160 } FORMATTOKEN; 161 162 typedef struct tagFORMATHDR { 163 BYTE len; 164 BYTE hex3; 165 BYTE hex6; 166 BYTE reserved[8]; 167 } FORMATHDR; 168 169 FORMATTOKEN formatTokens[] = { /* FIXME: Only date formats so far */ 170 {":" , 1, TOK_COLON , 0}, 171 {"/" , 1, TOK_SLASH , 0}, 172 {"c" , 1, TOK_c , VT_DATE}, 173 {"dddddd", 6, TOK_dddddd , VT_DATE}, 174 {"ddddd" , 5, TOK_ddddd , VT_DATE}, 175 {"dddd" , 4, TOK_dddd , VT_DATE}, 176 {"ddd" , 3, TOK_ddd , VT_DATE}, 177 {"dd" , 2, TOK_dd , VT_DATE}, 178 {"d" , 1, TOK_d , VT_DATE}, 179 {"ww" , 2, TOK_ww , VT_DATE}, 180 {"w" , 1, TOK_w , VT_DATE}, 181 {"mmmm" , 4, TOK_mmmm , VT_DATE}, 182 {"mmm" , 3, TOK_mmm , VT_DATE}, 183 {"mm" , 2, TOK_mm , VT_DATE}, 184 {"m" , 1, TOK_m , VT_DATE}, 185 {"q" , 1, TOK_q , VT_DATE}, 186 {"yyyy" , 4, TOK_yyyy , VT_DATE}, 187 {"yy" , 2, TOK_yy , VT_DATE}, 188 {"y" , 1, TOK_y , VT_DATE}, 189 {"h" , 1, TOK_h , VT_DATE}, 190 {"Hh" , 2, TOK_Hh , VT_DATE}, 191 {"Nn" , 2, TOK_Nn , VT_DATE}, 192 {"N" , 1, TOK_N , VT_DATE}, 193 {"S" , 1, TOK_S , VT_DATE}, 194 {"Ss" , 2, TOK_Ss , VT_DATE}, 195 {"ttttt" , 5, TOK_ttttt , VT_DATE}, 196 {"AM/PM" , 5, TOK_AMsPM , VT_DATE}, 197 {"am/pm" , 5, TOK_amspm , VT_DATE}, 198 {"A/P" , 3, TOK_AsP , VT_DATE}, 199 {"a/p" , 3, TOK_asp , VT_DATE}, 200 {"AMPM" , 4, TOK_AMPM , VT_DATE}, 201 {0x00 , 0, 0 , VT_NULL} 202 }; 117 203 118 204 /****************************************************************************** … … 248 334 int leapYear = 0; 249 335 250 if( (pTm->tm_year - 1900) < 0 ) return FALSE; 336 /* Hmmm... An uninitialized Date in VB is December 30 1899 so 337 Start at 0. This is the way DATE is defined. */ 251 338 252 339 /* Start at 1. This is the way DATE is defined. … … 257 344 *pDateOut = 1; 258 345 259 /* Add the number of days corresponding to 260 * tm_year. 261 */ 262 *pDateOut += (pTm->tm_year - 1900) * 365; 263 264 /* Add the leap days in the previous years between now and 1900. 265 * Note a leap year is one that is a multiple of 4 266 * but not of a 100. Except if it is a multiple of 267 * 400 then it is a leap year. 268 */ 269 *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 ); 270 *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 ); 271 *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 ); 272 273 /* Set the leap year flag if the 274 * current year specified by tm_year is a 275 * leap year. This will be used to add a day 276 * to the day count. 277 */ 278 if( isleap( pTm->tm_year ) ) 279 leapYear = 1; 280 281 /* Add the number of days corresponding to 282 * the month. 283 */ 284 switch( pTm->tm_mon ) 285 { 286 case 2: 287 *pDateOut += 31; 288 break; 289 case 3: 290 *pDateOut += ( 59 + leapYear ); 291 break; 292 case 4: 293 *pDateOut += ( 90 + leapYear ); 294 break; 295 case 5: 296 *pDateOut += ( 120 + leapYear ); 297 break; 298 case 6: 299 *pDateOut += ( 151 + leapYear ); 300 break; 301 case 7: 302 *pDateOut += ( 181 + leapYear ); 303 break; 304 case 8: 305 *pDateOut += ( 212 + leapYear ); 306 break; 307 case 9: 308 *pDateOut += ( 243 + leapYear ); 309 break; 310 case 10: 311 *pDateOut += ( 273 + leapYear ); 312 break; 313 case 11: 314 *pDateOut += ( 304 + leapYear ); 315 break; 316 case 12: 317 *pDateOut += ( 334 + leapYear ); 318 break; 346 if( (pTm->tm_year - 1900) >= 0 ) { 347 348 /* Add the number of days corresponding to 349 * tm_year. 350 */ 351 *pDateOut += (pTm->tm_year - 1900) * 365; 352 353 /* Add the leap days in the previous years between now and 1900. 354 * Note a leap year is one that is a multiple of 4 355 * but not of a 100. Except if it is a multiple of 356 * 400 then it is a leap year. 357 * Copied + reversed functionality into TmToDate 358 */ 359 *pDateOut += ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 ); 360 *pDateOut -= ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 ); 361 *pDateOut += ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 ); 362 363 /* Set the leap year flag if the 364 * current year specified by tm_year is a 365 * leap year. This will be used to add a day 366 * to the day count. 367 */ 368 if( isleap( pTm->tm_year ) ) 369 leapYear = 1; 370 371 /* Add the number of days corresponding to 372 * the month. (remember tm_mon is 0..11) 373 */ 374 switch( pTm->tm_mon ) 375 { 376 case 1: 377 *pDateOut += 31; 378 break; 379 case 2: 380 *pDateOut += ( 59 + leapYear ); 381 break; 382 case 3: 383 *pDateOut += ( 90 + leapYear ); 384 break; 385 case 4: 386 *pDateOut += ( 120 + leapYear ); 387 break; 388 case 5: 389 *pDateOut += ( 151 + leapYear ); 390 break; 391 case 6: 392 *pDateOut += ( 181 + leapYear ); 393 break; 394 case 7: 395 *pDateOut += ( 212 + leapYear ); 396 break; 397 case 8: 398 *pDateOut += ( 243 + leapYear ); 399 break; 400 case 9: 401 *pDateOut += ( 273 + leapYear ); 402 break; 403 case 10: 404 *pDateOut += ( 304 + leapYear ); 405 break; 406 case 11: 407 *pDateOut += ( 334 + leapYear ); 408 break; 409 } 410 /* Add the number of days in this month. 411 */ 412 *pDateOut += pTm->tm_mday; 413 414 /* Add the number of seconds, minutes, and hours 415 * to the DATE. Note these are the fracionnal part 416 * of the DATE so seconds / number of seconds in a day. 417 */ 418 } else { 419 *pDateOut = 0; 319 420 } 320 /* Add the number of days in this month. 321 */ 322 *pDateOut += pTm->tm_mday; 323 324 /* Add the number of seconds, minutes, and hours 325 * to the DATE. Note these are the fracionnal part 326 * of the DATE so seconds / number of seconds in a day. 327 */ 421 328 422 *pDateOut += pTm->tm_hour / 24.0; 329 423 *pDateOut += pTm->tm_min / 1440.0; … … 346 440 * Returns TRUE if successful. 347 441 */ 348 staticBOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )442 BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm ) 349 443 { 350 444 double decimalPart = 0.0; 351 445 double wholePart = 0.0; 352 353 /* Do not process dates smaller than January 1, 1900.354 * Which corresponds to 2.0 in the windows DATE format.355 */356 if( dateIn < 2.0 ) return FALSE;357 446 358 447 memset(pTm,0,sizeof(*pTm)); … … 365 454 * This simplifies the processing of the DATE value. 366 455 */ 456 decimalPart = fmod( dateIn, 1.0 ); /* Do this before the -1, otherwise 0.xx goes negative */ 367 457 dateIn -= 1.0; 368 369 458 wholePart = (double) floor( dateIn ); 370 decimalPart = fmod( dateIn, wholePart );371 459 372 460 if( !(dwFlags & VAR_TIMEVALUEONLY) ) 373 461 { 374 int nDay = 0;462 unsigned int nDay = 0; 375 463 int leapYear = 0; 376 464 double yearsSince1900 = 0; 377 /* Start at 1900, this is where the DATE time 0.0 starts. 378 */ 379 pTm->tm_year = 1900; 380 /* find in what year the day in the "wholePart" falls into. 381 * add the value to the year field. 382 */ 383 yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 ); 384 pTm->tm_year += yearsSince1900; 385 /* determine if this is a leap year. 386 */ 387 if( isleap( pTm->tm_year ) ) 388 { 389 leapYear = 1; 390 wholePart++; 391 } 392 393 /* find what day of that year the "wholePart" corresponds to. 394 * Note: nDay is in [1-366] format 395 */ 396 nDay = (int) ( wholePart - floor( yearsSince1900 * DAYS_IN_ONE_YEAR ) ); 397 /* Set the tm_yday value. 398 * Note: The day must be converted from [1-366] to [0-365] 399 */ 400 /*pTm->tm_yday = nDay - 1;*/ 401 /* find which month this day corresponds to. 402 */ 403 if( nDay <= 31 ) 404 { 405 pTm->tm_mday = nDay; 406 pTm->tm_mon = 0; 407 } 408 else if( nDay <= ( 59 + leapYear ) ) 409 { 410 pTm->tm_mday = nDay - 31; 411 pTm->tm_mon = 1; 412 } 413 else if( nDay <= ( 90 + leapYear ) ) 414 { 415 pTm->tm_mday = nDay - ( 59 + leapYear ); 416 pTm->tm_mon = 2; 417 } 418 else if( nDay <= ( 120 + leapYear ) ) 419 { 420 pTm->tm_mday = nDay - ( 90 + leapYear ); 421 pTm->tm_mon = 3; 422 } 423 else if( nDay <= ( 151 + leapYear ) ) 424 { 425 pTm->tm_mday = nDay - ( 120 + leapYear ); 426 pTm->tm_mon = 4; 427 } 428 else if( nDay <= ( 181 + leapYear ) ) 429 { 430 pTm->tm_mday = nDay - ( 151 + leapYear ); 431 pTm->tm_mon = 5; 432 } 433 else if( nDay <= ( 212 + leapYear ) ) 434 { 435 pTm->tm_mday = nDay - ( 181 + leapYear ); 436 pTm->tm_mon = 6; 437 } 438 else if( nDay <= ( 243 + leapYear ) ) 439 { 440 pTm->tm_mday = nDay - ( 212 + leapYear ); 441 pTm->tm_mon = 7; 442 } 443 else if( nDay <= ( 273 + leapYear ) ) 444 { 445 pTm->tm_mday = nDay - ( 243 + leapYear ); 446 pTm->tm_mon = 8; 447 } 448 else if( nDay <= ( 304 + leapYear ) ) 449 { 450 pTm->tm_mday = nDay - ( 273 + leapYear ); 451 pTm->tm_mon = 9; 452 } 453 else if( nDay <= ( 334 + leapYear ) ) 454 { 455 pTm->tm_mday = nDay - ( 304 + leapYear ); 456 pTm->tm_mon = 10; 457 } 458 else if( nDay <= ( 365 + leapYear ) ) 459 { 460 pTm->tm_mday = nDay - ( 334 + leapYear ); 461 pTm->tm_mon = 11; 465 466 /* Hard code dates smaller than January 1, 1900. */ 467 if( dateIn < 2.0 ) { 468 pTm->tm_year = 1899; 469 pTm->tm_mon = 11; /* December as tm_mon is 0..11 */ 470 if( dateIn < 1.0 ) { 471 pTm->tm_mday = 30; 472 dateIn = dateIn * -1.0; /* Ensure +ve for time calculation */ 473 decimalPart = decimalPart * -1.0; /* Ensure +ve for time calculation */ 474 } else { 475 pTm->tm_mday = 31; 476 } 477 478 } else { 479 480 /* Start at 1900, this is where the DATE time 0.0 starts. 481 */ 482 pTm->tm_year = 1900; 483 /* find in what year the day in the "wholePart" falls into. 484 * add the value to the year field. 485 */ 486 yearsSince1900 = floor( (wholePart / DAYS_IN_ONE_YEAR) + 0.001 ); 487 pTm->tm_year += yearsSince1900; 488 /* determine if this is a leap year. 489 */ 490 if( isleap( pTm->tm_year ) ) 491 { 492 leapYear = 1; 493 wholePart++; 494 } 495 496 /* find what day of that year the "wholePart" corresponds to. 497 * Note: nDay is in [1-366] format 498 */ 499 nDay = (((unsigned int) wholePart) - ((pTm->tm_year-1900) * DAYS_IN_ONE_YEAR )); 500 501 /* Remove the leap days in the previous years between now and 1900. 502 * Note a leap year is one that is a multiple of 4 503 * but not of a 100. Except if it is a multiple of 504 * 400 then it is a leap year. 505 * Copied + reversed functionality from TmToDate 506 */ 507 nDay -= ( (pTm->tm_year - 1) / 4 ) - ( 1900 / 4 ); 508 nDay += ( (pTm->tm_year - 1) / 100 ) - ( 1900 / 100 ); 509 nDay -= ( (pTm->tm_year - 1) / 400 ) - ( 1900 / 400 ); 510 511 /* Set the tm_yday value. 512 * Note: The day must be converted from [1-366] to [0-365] 513 */ 514 /*pTm->tm_yday = nDay - 1;*/ 515 /* find which month this day corresponds to. 516 */ 517 if( nDay <= 31 ) 518 { 519 pTm->tm_mday = nDay; 520 pTm->tm_mon = 0; 521 } 522 else if( nDay <= ( 59 + leapYear ) ) 523 { 524 pTm->tm_mday = nDay - 31; 525 pTm->tm_mon = 1; 526 } 527 else if( nDay <= ( 90 + leapYear ) ) 528 { 529 pTm->tm_mday = nDay - ( 59 + leapYear ); 530 pTm->tm_mon = 2; 531 } 532 else if( nDay <= ( 120 + leapYear ) ) 533 { 534 pTm->tm_mday = nDay - ( 90 + leapYear ); 535 pTm->tm_mon = 3; 536 } 537 else if( nDay <= ( 151 + leapYear ) ) 538 { 539 pTm->tm_mday = nDay - ( 120 + leapYear ); 540 pTm->tm_mon = 4; 541 } 542 else if( nDay <= ( 181 + leapYear ) ) 543 { 544 pTm->tm_mday = nDay - ( 151 + leapYear ); 545 pTm->tm_mon = 5; 546 } 547 else if( nDay <= ( 212 + leapYear ) ) 548 { 549 pTm->tm_mday = nDay - ( 181 + leapYear ); 550 pTm->tm_mon = 6; 551 } 552 else if( nDay <= ( 243 + leapYear ) ) 553 { 554 pTm->tm_mday = nDay - ( 212 + leapYear ); 555 pTm->tm_mon = 7; 556 } 557 else if( nDay <= ( 273 + leapYear ) ) 558 { 559 pTm->tm_mday = nDay - ( 243 + leapYear ); 560 pTm->tm_mon = 8; 561 } 562 else if( nDay <= ( 304 + leapYear ) ) 563 { 564 pTm->tm_mday = nDay - ( 273 + leapYear ); 565 pTm->tm_mon = 9; 566 } 567 else if( nDay <= ( 334 + leapYear ) ) 568 { 569 pTm->tm_mday = nDay - ( 304 + leapYear ); 570 pTm->tm_mon = 10; 571 } 572 else if( nDay <= ( 365 + leapYear ) ) 573 { 574 pTm->tm_mday = nDay - ( 334 + leapYear ); 575 pTm->tm_mon = 11; 576 } 462 577 } 463 578 } … … 466 581 /* find the number of seconds in this day. 467 582 * fractional part times, hours, minutes, seconds. 583 * Note: 0.1 is hack to ensure figures come out in whole numbers 584 * due to floating point inaccuracies 468 585 */ 469 586 pTm->tm_hour = (int) ( decimalPart * 24 ); 470 587 pTm->tm_min = (int) ( ( ( decimalPart * 24 ) - pTm->tm_hour ) * 60 ); 471 pTm->tm_sec = (int) ( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 ); 588 /* Note: 0.1 is hack to ensure seconds come out in whole numbers 589 due to floating point inaccuracies */ 590 pTm->tm_sec = (int) (( ( ( decimalPart * 24 * 60 ) - ( pTm->tm_hour * 60 ) - pTm->tm_min ) * 60 ) + 0.1); 472 591 } 473 592 return TRUE; … … 521 640 break; 522 641 case( VT_BSTR ): 642 case( VT_DISPATCH ): 643 case( VT_UNKNOWN ): 523 644 size = sizeof(void*); 524 645 break; 525 646 case( VT_CY ): 526 case( VT_DISPATCH ): 527 case( VT_UNKNOWN ): 528 case( VT_DECIMAL ): 647 size = sizeof(CY); 648 break; 649 case( VT_DECIMAL ): /* hmm, tricky, DECIMAL is only VT_BYREF */ 529 650 default: 530 651 FIXME("Add size information for type vt=%d\n", V_VT(parg) & VT_TYPEMASK ); … … 536 657 /****************************************************************************** 537 658 * StringDupAtoBstr [INTERNAL] 538 * 659 * 539 660 */ 540 661 static BSTR StringDupAtoBstr( char* strIn ) … … 563 684 nSign = (d >= 0.0) ? 1 : -1; 564 685 d = fabs( d ); 565 686 566 687 /* Remove the decimals. 567 688 */ … … 630 751 str[0] = '\0'; 631 752 strToken = strtok( pNewString, strOfCharToRemove ); 632 while( strToken != NULL ) { 753 while( strToken != NULL ) { 633 754 strcat( str, strToken ); 634 755 strToken = strtok( NULL, strOfCharToRemove ); … … 671 792 int nTokens = 0; 672 793 LPSTR pChar = NULL; 673 794 674 795 /* Check if we have a valid argument 675 796 */ … … 684 805 */ 685 806 strToken = strtok( strRealString, " " ); 686 while( strToken != NULL ) { 687 nTokens++; 688 strToken = strtok( NULL, " " ); 807 while( strToken != NULL ) { 808 nTokens++; 809 strToken = strtok( NULL, " " ); 689 810 } 690 811 … … 778 899 case '7': 779 900 case '8': 780 case '9': 901 case '9': 781 902 if( bFirstDigitsProcessed == FALSE ) 782 903 { … … 824 945 /* If DecimalPoint... 825 946 */ 826 case '.': 947 case '.': 827 948 if( bDecimalPointProcessed || 828 949 bSecondDigitsProcessed || … … 894 1015 vtFrom = V_VT(ps) & VT_TYPEMASK; 895 1016 896 1017 897 1018 /* Note: Since "long" and "int" values both have 4 bytes and are 898 1019 * both signed integers "int" will be treated as "long" in the … … 901 1022 */ 902 1023 903 /* Trivial Case: If the coercion is from two types that are 1024 /* Trivial Case: If the coercion is from two types that are 904 1025 * identical then we can blindly copy from one argument to another.*/ 905 1026 if ((vt==vtFrom)) … … 1247 1368 } 1248 1369 break; 1249 1370 1250 1371 case( VT_R4 ): 1251 1372 switch( vtFrom ) … … 1610 1731 break; 1611 1732 } 1612 1733 1613 1734 return res; 1614 1735 } … … 1656 1777 res = DISP_E_BADVARTYPE; 1657 1778 } 1658 1779 1659 1780 } 1660 1781 else … … 1662 1783 res = ValidateVtRange( vt ); 1663 1784 } 1664 1785 1665 1786 return res; 1666 1787 } … … 1689 1810 res = DISP_E_BADVARTYPE; 1690 1811 } 1691 1812 1692 1813 } 1693 1814 else … … 1695 1816 res = ValidateVtRange( vt ); 1696 1817 } 1697 1818 1698 1819 return res; 1699 1820 } … … 1770 1891 } 1771 1892 } 1772 1893 1773 1894 /* 1774 1895 * Empty all the fields and mark the type as empty. … … 1800 1921 { 1801 1922 res = VariantClear( pvargDest ); 1802 1923 1803 1924 if( res == S_OK ) 1804 1925 { … … 1854 1975 } 1855 1976 } 1856 1977 1857 1978 V_VT(pvargDest) = V_VT(pvargSrc); 1858 } 1979 } 1859 1980 } 1860 1981 } … … 1880 2001 if( res != S_OK ) 1881 2002 return res; 1882 2003 1883 2004 if( V_VT(pvargSrc) & VT_BYREF ) 1884 2005 { … … 1931 2052 * If the inner Variant itself contains an 1932 2053 * other inner variant the E_INVALIDARG error is 1933 * returned. 2054 * returned. 1934 2055 */ 1935 2056 if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT ) … … 1948 2069 */ 1949 2070 (V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT; 1950 2071 1951 2072 /* Dereference the inner variant. 1952 2073 */ … … 2011 2132 VARIANTARG varg; 2012 2133 VariantInit( &varg ); 2013 2134 2014 2135 TRACE("(%p, %p, %ld, %u, %u) vt=%d\n", pvargDest, pvargSrc, lcid, wFlags, vt, V_VT(pvargSrc)); 2136 TRACE("Src Var:\n"); 2137 dump_Variant(pvargSrc); 2015 2138 2016 2139 /* validate our source argument. … … 2056 2179 VariantClear( &Variant ); 2057 2180 } 2058 2181 2059 2182 } 2060 2183 else … … 2068 2191 */ 2069 2192 VariantClear( &varg ); 2070 2193 2071 2194 /* set the type of the destination 2072 2195 */ … … 2074 2197 V_VT(pvargDest) = vt; 2075 2198 2199 TRACE("Dest Var:\n"); 2200 dump_Variant(pvargDest); 2201 2076 2202 return res; 2077 2203 } … … 2095 2221 2096 2222 *pbOut = (BYTE) sIn; 2097 2223 2098 2224 return S_OK; 2099 2225 } … … 2114 2240 2115 2241 *pbOut = (BYTE) lIn; 2116 2242 2117 2243 return S_OK; 2118 2244 } … … 2135 2261 2136 2262 *pbOut = (BYTE) fltIn; 2137 2263 2138 2264 return S_OK; 2139 2265 } … … 2264 2390 */ 2265 2391 dValue = atof( pNewString ); 2266 2392 2267 2393 /* We don't need the string anymore so free it. 2268 2394 */ … … 2288 2414 HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) { 2289 2415 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 2290 2416 2291 2417 if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW; 2292 2418 2293 2419 *pbOut = (BYTE)t; 2294 2420 return S_OK; … … 2303 2429 2304 2430 *psOut = (short) bIn; 2305 2431 2306 2432 return S_OK; 2307 2433 } … … 2322 2448 2323 2449 *psOut = (short) lIn; 2324 2450 2325 2451 return S_OK; 2326 2452 } … … 2470 2596 */ 2471 2597 dValue = atof( pNewString ); 2472 2598 2473 2599 /* We don't need the string anymore so free it. 2474 2600 */ … … 2494 2620 HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) { 2495 2621 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 2496 2622 2497 2623 if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW; 2498 2624 2499 2625 *psOut = (SHORT)t; 2500 2626 return S_OK; … … 2663 2789 */ 2664 2790 dValue = atof( pNewString ); 2665 2791 2666 2792 /* We don't need the string anymore so free it. 2667 2793 */ … … 2687 2813 HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) { 2688 2814 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 2689 2815 2690 2816 if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW; 2691 2817 2692 2818 *plOut = (LONG)t; 2693 2819 return S_OK; … … 2838 2964 */ 2839 2965 dValue = atof( pNewString ); 2840 2966 2841 2967 /* We don't need the string anymore so free it. 2842 2968 */ … … 2861 2987 HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) { 2862 2988 *pfltOut = (FLOAT)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 2863 2989 2864 2990 return S_OK; 2865 2991 } … … 2981 3107 LPSTR pNewString = NULL; 2982 3108 2983 TRACE("( %p, %ld, %ld, %p ), stub\n", strIn, lcid, dwFlags, pdblOut ); 3109 pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn ); 3110 TRACE("( %s, %ld, %ld, %p ), stub\n", pNewString, lcid, dwFlags, pdblOut ); 2984 3111 2985 3112 /* Check if we have a valid argument 2986 3113 */ 2987 pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );2988 3114 RemoveCharacterFromString( pNewString, "," ); 2989 3115 if( IsValidRealString( pNewString ) == FALSE ) … … 2995 3121 */ 2996 3122 dValue = atof( pNewString ); 2997 3123 2998 3124 /* We don't need the string anymore so free it. 2999 3125 */ … … 3011 3137 HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) { 3012 3138 *pdblOut = (double)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 3013 3139 TRACE("%lu %ld -> %f\n", cyIn.s.Hi, cyIn.s.Lo, *pdblOut); 3014 3140 return S_OK; 3015 3141 } … … 3100 3226 * 3101 3227 * The formats for the date part are has follows: 3102 * mm/[dd/][yy]yy 3228 * mm/[dd/][yy]yy 3103 3229 * [dd/]mm/[yy]yy 3104 * [yy]yy/mm/dd 3230 * [yy]yy/mm/dd 3105 3231 * January dd[,] [yy]yy 3106 3232 * dd January [yy]yy … … 3109 3235 * 3110 3236 * The formats for the date and time string are has follows. 3111 * date[whitespace][time] 3237 * date[whitespace][time] 3112 3238 * [time][whitespace]date 3113 3239 * … … 3135 3261 ret = DISP_E_TYPEMISMATCH; 3136 3262 } 3137 3138 3263 TRACE("Return value %f\n", *pdateOut); 3139 3264 return ret; 3140 3265 } … … 3218 3343 3219 3344 *pbstrOut = StringDupAtoBstr( pBuffer ); 3220 3345 3221 3346 return S_OK; 3222 3347 } … … 3277 3402 */ 3278 3403 HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut) { 3279 FIXME("([cyIn], %08lx, %08lx, %p), stub.\n", lcid, dwFlags, pbstrOut); 3280 return E_NOTIMPL; 3281 } 3282 3283 3404 HRESULT rc = S_OK; 3405 double curVal = 0.0; 3406 3407 TRACE("([cyIn], %08lx, %08lx, %p), partial stub (no flags handled).\n", lcid, dwFlags, pbstrOut); 3408 3409 /* Firstly get the currency in a double, then put it in a buffer */ 3410 rc = VarR8FromCy(cyIn, &curVal); 3411 if (rc == S_OK) { 3412 sprintf(pBuffer, "%g", curVal); 3413 *pbstrOut = StringDupAtoBstr( pBuffer ); 3414 } 3415 return rc; 3416 } 3417 3418 3284 3419 /****************************************************************************** 3285 3420 * VarBstrFromDate [OLEAUT32.114] … … 3316 3451 memset( &TM, 0, sizeof(TM) ); 3317 3452 3318 TRACE("( % f, %ld, %ld, %p ), stub\n", dateIn, lcid, dwFlags, pbstrOut );3453 TRACE("( %20.20f, %ld, %ld, %p ), stub\n", dateIn, lcid, dwFlags, pbstrOut ); 3319 3454 3320 3455 if( DateToTm( dateIn, dwFlags, &TM ) == FALSE ) … … 3330 3465 strftime( pBuffer, BUFFER_MAX, "%x %X", &TM ); 3331 3466 3467 TRACE("result: %s\n", pBuffer); 3332 3468 *pbstrOut = StringDupAtoBstr( pBuffer ); 3333 3334 3469 return S_OK; 3335 3470 } … … 3508 3643 3509 3644 HeapFree( GetProcessHeap(), 0, pNewString ); 3510 3645 3511 3646 return ret; 3512 3647 } … … 3555 3690 if (cyIn.s.Hi || cyIn.s.Lo) *pboolOut = -1; 3556 3691 else *pboolOut = 0; 3557 3692 3558 3693 return S_OK; 3559 3694 } … … 3688 3823 */ 3689 3824 dValue = atof( pNewString ); 3690 3825 3691 3826 /* We don't need the string anymore so free it. 3692 3827 */ … … 3758 3893 HRESULT WINAPI VarI1FromCy(CY cyIn, CHAR* pcOut) { 3759 3894 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 3760 3895 3761 3896 if (t > CHAR_MAX || t < CHAR_MIN) return DISP_E_OVERFLOW; 3762 3897 3763 3898 *pcOut = (CHAR)t; 3764 3899 return S_OK; … … 3887 4022 */ 3888 4023 dValue = atof( pNewString ); 3889 4024 3890 4025 /* We don't need the string anymore so free it. 3891 4026 */ … … 3936 4071 TRACE("( %ld, %p ), stub\n", ulIn, puiOut ); 3937 4072 3938 if( ulIn < UI2_MIN || ulIn> UI2_MAX )4073 if( ulIn > UI2_MAX ) 3939 4074 { 3940 4075 return DISP_E_OVERFLOW; … … 3968 4103 */ 3969 4104 dValue = atof( pNewString ); 3970 4105 3971 4106 /* We don't need the string anymore so free it. 3972 4107 */ … … 3992 4127 HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) { 3993 4128 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 3994 4129 3995 4130 if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW; 3996 4131 3997 4132 *pusOut = (USHORT)t; 3998 4133 3999 4134 return S_OK; 4000 4135 } … … 4036 4171 TRACE("( %ld, %p ), stub\n", lIn, pulOut ); 4037 4172 4038 if( lIn < UI4_MIN)4173 if( lIn < 0 ) 4039 4174 { 4040 4175 return DISP_E_OVERFLOW; … … 4140 4275 HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) { 4141 4276 double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000); 4142 4277 4143 4278 if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW; 4144 4279 … … 4180 4315 pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0); 4181 4316 if (lIn < 0) pcyOut->s.Hi--; 4182 4317 4183 4318 return S_OK; 4184 4319 } … … 4193 4328 pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0); 4194 4329 if (fltIn < 0) pcyOut->s.Hi--; 4195 4330 4196 4331 return S_OK; 4197 4332 } … … 4225 4360 /********************************************************************** 4226 4361 * VarCyFromStr [OLEAUT32.104] 4362 * FIXME: Never tested with decimal seperator other than '.' 4227 4363 */ 4228 4364 HRESULT WINAPI VarCyFromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, CY *pcyOut) { 4229 FIXME("(%p, %08lx, %08lx, %p), stub.\n", strIn, lcid, dwFlags, pcyOut); 4230 return E_NOTIMPL; 4231 } 4232 4233 4365 4366 LPSTR pNewString = NULL; 4367 char *decSep = NULL; 4368 char *strPtr,*curPtr = NULL; 4369 int size, rc; 4370 double currencyVal = 0.0; 4371 4372 4373 pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn ); 4374 TRACE("( '%s', 0x%08lx, 0x%08lx, %p )\n", pNewString, lcid, dwFlags, pcyOut ); 4375 4376 /* Get locale information - Decimal Seperator (size includes 0x00) */ 4377 size = GetLocaleInfoA(lcid, LOCALE_SDECIMAL, NULL, 0); 4378 decSep = (char *) malloc(size); 4379 rc = GetLocaleInfoA(lcid, LOCALE_SDECIMAL, decSep, size); 4380 TRACE("Decimal Seperator is '%s'\n", decSep); 4381 4382 /* Now copy to temporary buffer, skipping any character except 0-9 and 4383 the decimal seperator */ 4384 curPtr = pBuffer; /* Current position in string being built */ 4385 strPtr = pNewString; /* Current position in supplied currenct string */ 4386 4387 while (*strPtr) { 4388 /* If decimal seperator, skip it and put '.' in string */ 4389 if (strncmp(strPtr, decSep, (size-1)) == 0) { 4390 strPtr = strPtr + (size-1); 4391 *curPtr = '.'; 4392 curPtr++; 4393 } else if ((*strPtr == '+' || *strPtr == '-') || 4394 (*strPtr >= '0' && *strPtr <= '9')) { 4395 *curPtr = *strPtr; 4396 strPtr++; 4397 curPtr++; 4398 } else strPtr++; 4399 } 4400 *curPtr = 0x00; 4401 4402 /* Try to get currency into a double */ 4403 currencyVal = atof(pBuffer); 4404 TRACE("Converted string '%s' to %f\n", pBuffer, currencyVal); 4405 4406 /* Free allocated storage */ 4407 HeapFree( GetProcessHeap(), 0, pNewString ); 4408 free(decSep); 4409 4410 /* Convert double -> currency using internal routine */ 4411 return VarCyFromR8(currencyVal, pcyOut); 4412 } 4413 4414 4234 4415 /********************************************************************** 4235 4416 * VarCyFromBool [OLEAUT32.106] … … 4240 4421 else pcyOut->s.Hi = 0; 4241 4422 pcyOut->s.Lo = (ULONG)boolIn * (ULONG)10000; 4242 4423 4243 4424 return S_OK; 4244 4425 } … … 4252 4433 else pcyOut->s.Hi = 0; 4253 4434 pcyOut->s.Lo = (ULONG)cIn * (ULONG)10000; 4254 4435 4255 4436 return S_OK; 4256 4437 } … … 4263 4444 pcyOut->s.Hi = 0; 4264 4445 pcyOut->s.Lo = (ULONG)usIn * (ULONG)10000; 4265 4446 4266 4447 return S_OK; 4267 4448 } … … 4275 4456 pcyOut->s.Hi = (LONG)(t / (double)4294967296.0); 4276 4457 pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0); 4277 4458 4278 4459 return S_OK; 4279 4460 } … … 4291 4472 4292 4473 TRACE("( 0x%x, 0x%x, %p ), stub\n", wDosDate, wDosTime, pvtime ); 4293 4474 4294 4475 t.tm_sec = (wDosTime & 0x001f) * 2; 4295 4476 t.tm_min = (wDosTime & 0x07e0) >> 5; 4296 4477 t.tm_hour = (wDosTime & 0xf800) >> 11; 4297 4478 4298 4479 t.tm_mday = (wDosDate & 0x001f); 4299 4480 t.tm_mon = (wDosDate & 0x01e0) >> 5; … … 4312 4493 int i,lastent=0; 4313 4494 int cDig; 4495 BOOL foundNum=FALSE; 4496 4314 4497 FIXME("(%s,flags=%lx,....), partial stub!\n",debugstr_w(strIn),dwFlags); 4315 4498 FIXME("numparse: cDig=%d, InFlags=%lx\n",pnumprs->cDig,pnumprs->dwInFlags); 4316 4499 4317 4500 /* The other struct components are to be set by us */ 4318 4319 4501 memset(rgbDig,0,pnumprs->cDig); 4502 4503 /* FIXME: Just patching some values in */ 4504 pnumprs->nPwr10 = 0; 4505 pnumprs->nBaseShift = 0; 4506 pnumprs->cchUsed = lastent; 4507 pnumprs->dwOutFlags = NUMPRS_DECIMAL; 4320 4508 4321 4509 cDig = 0; 4322 4510 for (i=0; strIn[i] ;i++) { 4323 4511 if ((strIn[i]>='0') && (strIn[i]<='9')) { 4512 foundNum = TRUE; 4324 4513 if (pnumprs->cDig > cDig) { 4325 4514 *(rgbDig++)=strIn[i]-'0'; … … 4327 4516 lastent = i; 4328 4517 } 4329 } 4518 } else if ((strIn[i]=='-') && (foundNum==FALSE)) { 4519 pnumprs->dwOutFlags |= NUMPRS_NEG; 4520 } 4330 4521 } 4331 4522 pnumprs->cDig = cDig; 4332 4333 /* FIXME: Just patching some values in */ 4334 pnumprs->nPwr10 = 0; 4335 pnumprs->nBaseShift = 0; 4336 pnumprs->cchUsed = lastent; 4337 pnumprs->dwOutFlags = NUMPRS_DECIMAL; 4523 TRACE("numparse out: cDig=%d, OutFlags=%lx\n",pnumprs->cDig,pnumprs->dwOutFlags); 4338 4524 return S_OK; 4339 4525 } … … 4348 4534 DWORD xint; 4349 4535 int i; 4350 FIXME("( ,dwVtBits=%lx,....), partial stub!\n",dwVtBits);4536 FIXME("(..,dwVtBits=%lx,....), partial stub!\n",dwVtBits); 4351 4537 4352 4538 xint = 0; 4353 4539 for (i=0;i<pnumprs->cDig;i++) 4354 4540 xint = xint*10 + rgbDig[i]; 4541 4542 if (pnumprs->dwOutFlags & NUMPRS_NEG) { 4543 xint = xint * -1; 4544 } 4355 4545 4356 4546 VariantInit(pvar); … … 4364 4554 V_UNION(pvar,dblVal) = xint; 4365 4555 return S_OK; 4366 } else { 4367 FIXME("vtbitmask is unsupported %lx\n",dwVtBits); 4556 } 4557 if (dwVtBits & VTBIT_R4) { 4558 V_VT(pvar) = VT_R4; 4559 V_UNION(pvar,fltVal) = xint; 4560 return S_OK; 4561 } 4562 if (dwVtBits & VTBIT_I2) { 4563 V_VT(pvar) = VT_I2; 4564 V_UNION(pvar,iVal) = xint; 4565 return S_OK; 4566 } 4567 /* FIXME: Currency should be from a double */ 4568 if (dwVtBits & VTBIT_CY) { 4569 V_VT(pvar) = VT_CY; 4570 TRACE("Calculated currency is xint=%ld\n", xint); 4571 VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) ); 4572 TRACE("Calculated cy is %ld,%lu\n", V_UNION(pvar,cyVal).s.Hi, V_UNION(pvar,cyVal).s.Lo); 4573 return VarCyFromInt( (int) xint, &V_UNION(pvar,cyVal) ); 4574 } 4575 4576 FIXME("vtbitmask is unsupported %lx, int=%d\n",dwVtBits, (int) xint); 4368 4577 return E_FAIL; 4369 } 4370 } 4371 4578 } 4579 4580 4581 /********************************************************************** 4582 * VarFormatDateTime [OLEAUT32.97] 4583 */ 4584 HRESULT WINAPI VarFormatDateTime(LPVARIANT var, INT format, ULONG dwFlags, BSTR *out) 4585 { 4586 FIXME("%p %d %lx %p\n", var, format, dwFlags, out); 4587 return E_NOTIMPL; 4588 } 4589 4590 /********************************************************************** 4591 * VarFormatCurrency [OLEAUT32.127] 4592 */ 4593 HRESULT WINAPI VarFormatCurrency(LPVARIANT var, INT digits, INT lead, INT paren, INT group, ULONG dwFlags, BSTR *out) 4594 { 4595 FIXME("%p %d %d %d %d %lx %p\n", var, digits, lead, paren, group, dwFlags, out); 4596 return E_NOTIMPL; 4597 } 4372 4598 4373 4599 /********************************************************************** … … 4403 4629 HRESULT WINAPI SystemTimeToVariantTime( LPSYSTEMTIME lpSystemTime, double *pvtime ) 4404 4630 { 4405 static const BYTE Days_Per_Month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};4406 static const BYTE Days_Per_Month_LY[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};4407 4408 4631 struct tm t; 4409 4632 … … 4420 4643 4421 4644 t.tm_mday = lpSystemTime->wDay; 4422 t.tm_mon = lpSystemTime->wMonth ;4645 t.tm_mon = lpSystemTime->wMonth - 1; /* tm_mon is 0..11, wMonth is 1..12 */ 4423 4646 t.tm_year = lpSystemTime->wYear; 4424 4647 … … 4427 4650 else 4428 4651 { 4652 double tmpDate; 4653 long firstDayOfNextYear; 4654 long thisDay; 4655 long leftInYear; 4656 long result; 4657 4658 double decimalPart = 0.0; 4659 4429 4660 t.tm_sec = lpSystemTime->wSecond; 4430 4661 t.tm_min = lpSystemTime->wMinute; 4431 4662 t.tm_hour = lpSystemTime->wHour; 4432 4663 4433 if (isleap(lpSystemTime->wYear) ) 4434 t.tm_mday = Days_Per_Month_LY[13 - lpSystemTime->wMonth] - lpSystemTime->wDay; 4435 else 4436 t.tm_mday = Days_Per_Month[13 - lpSystemTime->wMonth] - lpSystemTime->wDay; 4437 4438 t.tm_mon = 13 - lpSystemTime->wMonth; 4664 /* Step year forward the same number of years before 1900 */ 4439 4665 t.tm_year = 1900 + 1899 - lpSystemTime->wYear; 4440 4666 t.tm_mon = lpSystemTime->wMonth - 1; 4667 t.tm_mday = lpSystemTime->wDay; 4668 4669 /* Calculate date */ 4441 4670 TmToDATE( &t, pvtime ); 4442 4671 4443 *pvtime *= -1; 4672 thisDay = (double) floor( *pvtime ); 4673 decimalPart = fmod( *pvtime, thisDay ); 4674 4675 /* Now, calculate the same time for the first of Jan that year */ 4676 t.tm_mon = 0; 4677 t.tm_mday = 1; 4678 t.tm_sec = 0; 4679 t.tm_min = 0; 4680 t.tm_hour = 0; 4681 t.tm_year = t.tm_year+1; 4682 TmToDATE( &t, &tmpDate ); 4683 firstDayOfNextYear = (long) floor(tmpDate); 4684 4685 /* Finally since we know the size of the year, subtract the two to get 4686 remaining time in the year */ 4687 leftInYear = firstDayOfNextYear - thisDay; 4688 4689 /* Now we want full years up to the year in question, and remainder of year 4690 of the year in question */ 4691 if (isleap(lpSystemTime->wYear) ) { 4692 TRACE("Extra day due to leap year\n"); 4693 result = 2.0 - ((firstDayOfNextYear - 366) + leftInYear - 2.0); 4694 } else { 4695 result = 2.0 - ((firstDayOfNextYear - 365) + leftInYear - 2.0); 4696 } 4697 *pvtime = (double) result + decimalPart; 4698 TRACE("<1899 support: returned %f, 1st day %ld, thisday %ld, left %ld\n", *pvtime, firstDayOfNextYear, thisDay, leftInYear); 4444 4699 4445 4700 return 1; … … 4468 4723 struct tm r; 4469 4724 4470 TRACE(" Variant = %f SYSTEMTIME ptr %p ", vtime, lpSystemTime);4725 TRACE(" Variant = %f SYSTEMTIME ptr %p\n", vtime, lpSystemTime); 4471 4726 4472 4727 if (vtime >= 0) … … 4619 4874 *datein = t; 4620 4875 4621 if (i) dwFlags = 0; /*VAR_VALIDDATE*/ 4622 else dwFlags = 0; 4623 4624 return i; 4876 if (i) return S_OK; 4877 else return E_INVALIDARG; 4625 4878 } 4626 4879 4627 4880 4628 4881 /********************************************************************** 4629 * VarBstrCmp [OLEAUT32. 440]4882 * VarBstrCmp [OLEAUT32.314] 4630 4883 * 4631 * flags can be: 4884 * flags can be: 4632 4885 * NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS 4633 4886 * NORM_IGNORESTRINGWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA … … 4636 4889 HRESULT WINAPI VarBstrCmp(BSTR left, BSTR right, LCID lcid, DWORD flags) 4637 4890 { 4638 DWORD r; 4639 4640 FIXME("( %s %s %ld %lx ) partial stub\n", debugstr_w(left), debugstr_w(right), lcid, flags); 4641 4642 if((!left) || (!right)) 4643 return VARCMP_NULL; 4891 INT r; 4892 4893 TRACE("( %s %s %ld %lx ) partial stub\n", debugstr_w(left), debugstr_w(right), lcid, flags); 4894 4895 /* Contrary to the MSDN, this returns eq for null vs null, null vs L"" and L"" vs NULL */ 4896 if((!left) || (!right)) { 4897 4898 if (!left && (!right || *right==0)) return VARCMP_EQ; 4899 else if (!right && (!left || *left==0)) return VARCMP_EQ; 4900 else return VARCMP_NULL; 4901 } 4644 4902 4645 4903 if(flags&NORM_IGNORECASE) … … 4657 4915 4658 4916 /********************************************************************** 4659 * VarBstrCat [OLEAUT32. 439]4917 * VarBstrCat [OLEAUT32.313] 4660 4918 */ 4661 4919 HRESULT WINAPI VarBstrCat(BSTR left, BSTR right, BSTR *out) 4662 4920 { 4663 4921 BSTR result; 4922 int size = 0; 4664 4923 4665 4924 TRACE("( %s %s %p )\n", debugstr_w(left), debugstr_w(right), out); 4666 4925 4667 if( (!left) || (!right) || (!out) ) 4668 return 0; 4669 4670 result = SysAllocStringLen(left, lstrlenW(left)+lstrlenW(right)); 4671 lstrcatW(result,right); 4672 4673 *out = result; 4674 4675 return 1; 4926 /* On Windows, NULL parms are still handled (as empty strings) */ 4927 if (left) size=size + lstrlenW(left); 4928 if (right) size=size + lstrlenW(right); 4929 4930 if (out) { 4931 result = SysAllocStringLen(NULL, size); 4932 *out = result; 4933 if (left) lstrcatW(result,left); 4934 if (right) lstrcatW(result,right); 4935 TRACE("result = %s, [%p]\n", debugstr_w(result), result); 4936 } 4937 return S_OK; 4676 4938 } 4677 4939 4678 4940 /********************************************************************** 4679 * VarCat [OLEAUT32. 441]4941 * VarCat [OLEAUT32.318] 4680 4942 */ 4681 4943 HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out) … … 4699 4961 return S_OK; 4700 4962 } 4963 4964 /********************************************************************** 4965 * VarCmp [OLEAUT32.176] 4966 * 4967 * flags can be: 4968 * NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS 4969 * NORM_IGNOREWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA 4970 * 4971 */ 4972 HRESULT WINAPI VarCmp(LPVARIANT left, LPVARIANT right, LCID lcid, DWORD flags) 4973 { 4974 4975 4976 BOOL lOk = TRUE; 4977 BOOL rOk = TRUE; 4978 LONGLONG lVal = -1; 4979 LONGLONG rVal = -1; 4980 4981 TRACE("Left Var:\n"); 4982 dump_Variant(left); 4983 TRACE("Right Var:\n"); 4984 dump_Variant(right); 4985 4986 /* If either are null, then return VARCMP_NULL */ 4987 if ((V_VT(left)&VT_TYPEMASK) == VT_NULL || 4988 (V_VT(right)&VT_TYPEMASK) == VT_NULL) 4989 return VARCMP_NULL; 4990 4991 /* Strings - use VarBstrCmp */ 4992 if ((V_VT(left)&VT_TYPEMASK) == VT_BSTR && 4993 (V_VT(right)&VT_TYPEMASK) == VT_BSTR) { 4994 return VarBstrCmp(V_BSTR(left), V_BSTR(right), lcid, flags); 4995 } 4996 4997 /* Integers - Ideally like to use VarDecCmp, but no Dec support yet 4998 Use LONGLONG to maximize ranges */ 4999 lOk = TRUE; 5000 switch (V_VT(left)&VT_TYPEMASK) { 5001 case VT_I1 : lVal = V_UNION(left,cVal); break; 5002 case VT_I2 : lVal = V_UNION(left,iVal); break; 5003 case VT_I4 : lVal = V_UNION(left,lVal); break; 5004 case VT_INT : lVal = V_UNION(left,lVal); break; 5005 case VT_UI1 : lVal = V_UNION(left,bVal); break; 5006 case VT_UI2 : lVal = V_UNION(left,uiVal); break; 5007 case VT_UI4 : lVal = V_UNION(left,ulVal); break; 5008 case VT_UINT : lVal = V_UNION(left,ulVal); break; 5009 default: lOk = FALSE; 5010 } 5011 5012 rOk = TRUE; 5013 switch (V_VT(right)&VT_TYPEMASK) { 5014 case VT_I1 : rVal = V_UNION(right,cVal); break; 5015 case VT_I2 : rVal = V_UNION(right,iVal); break; 5016 case VT_I4 : rVal = V_UNION(right,lVal); break; 5017 case VT_INT : rVal = V_UNION(right,lVal); break; 5018 case VT_UI1 : rVal = V_UNION(right,bVal); break; 5019 case VT_UI2 : rVal = V_UNION(right,uiVal); break; 5020 case VT_UI4 : rVal = V_UNION(right,ulVal); break; 5021 case VT_UINT : rVal = V_UNION(right,ulVal); break; 5022 default: rOk = FALSE; 5023 } 5024 5025 if (lOk && rOk) { 5026 if (lVal < rVal) { 5027 return VARCMP_LT; 5028 } else if (lVal > rVal) { 5029 return VARCMP_GT; 5030 } else { 5031 return VARCMP_EQ; 5032 } 5033 } 5034 5035 /* Strings - use VarBstrCmp */ 5036 if ((V_VT(left)&VT_TYPEMASK) == VT_DATE && 5037 (V_VT(right)&VT_TYPEMASK) == VT_DATE) { 5038 5039 if (floor(V_UNION(left,date)) == floor(V_UNION(right,date))) { 5040 /* Due to floating point rounding errors, calculate varDate in whole numbers) */ 5041 double wholePart = 0.0; 5042 double leftR; 5043 double rightR; 5044 5045 /* Get the fraction * 24*60*60 to make it into whole seconds */ 5046 wholePart = (double) floor( V_UNION(left,date) ); 5047 if (wholePart == 0) wholePart = 1; 5048 leftR = floor(fmod( V_UNION(left,date), wholePart ) * (24*60*60)); 5049 5050 wholePart = (double) floor( V_UNION(right,date) ); 5051 if (wholePart == 0) wholePart = 1; 5052 rightR = floor(fmod( V_UNION(right,date), wholePart ) * (24*60*60)); 5053 5054 if (leftR < rightR) { 5055 return VARCMP_LT; 5056 } else if (leftR > rightR) { 5057 return VARCMP_GT; 5058 } else { 5059 return VARCMP_EQ; 5060 } 5061 5062 } else if (V_UNION(left,date) < V_UNION(right,date)) { 5063 return VARCMP_LT; 5064 } else if (V_UNION(left,date) > V_UNION(right,date)) { 5065 return VARCMP_GT; 5066 } 5067 } 5068 5069 5070 FIXME("VarCmp partial implementation, doesnt support these pair of variant types"); 5071 return E_FAIL; 5072 } 5073 5074 /********************************************************************** 5075 * VarAnd [OLEAUT32.142] 5076 * 5077 */ 5078 HRESULT WINAPI VarAnd(LPVARIANT left, LPVARIANT right, LPVARIANT result) 5079 { 5080 HRESULT rc = E_FAIL; 5081 5082 5083 TRACE("Left Var:\n"); 5084 dump_Variant(left); 5085 TRACE("Right Var:\n"); 5086 dump_Variant(right); 5087 5088 if ((V_VT(left)&VT_TYPEMASK) == VT_BOOL && 5089 (V_VT(right)&VT_TYPEMASK) == VT_BOOL) { 5090 5091 V_VT(result) = VT_BOOL; 5092 if (V_BOOL(left) && V_BOOL(right)) { 5093 V_BOOL(result) = VARIANT_TRUE; 5094 } else { 5095 V_BOOL(result) = VARIANT_FALSE; 5096 } 5097 rc = S_OK; 5098 5099 } else { 5100 FIXME("VarAnd stub\n"); 5101 } 5102 5103 TRACE("rc=%d, Result:\n", (int) rc); 5104 dump_Variant(result); 5105 return rc; 5106 } 5107 5108 /********************************************************************** 5109 * VarNot [OLEAUT32.174] 5110 * 5111 */ 5112 HRESULT WINAPI VarNot(LPVARIANT in, LPVARIANT result) 5113 { 5114 HRESULT rc = E_FAIL; 5115 5116 TRACE("Var In:\n"); 5117 dump_Variant(in); 5118 5119 if ((V_VT(in)&VT_TYPEMASK) == VT_BOOL) { 5120 5121 V_VT(result) = VT_BOOL; 5122 if (V_BOOL(in)) { 5123 V_BOOL(result) = VARIANT_FALSE; 5124 } else { 5125 V_BOOL(result) = VARIANT_TRUE; 5126 } 5127 rc = S_OK; 5128 5129 } else { 5130 FIXME("VarNot stub\n"); 5131 } 5132 5133 TRACE("rc=%d, Result:\n", (int) rc); 5134 dump_Variant(result); 5135 return rc; 5136 } 5137 5138 /********************************************************************** 5139 * VarTokenizeFormatString [OLEAUT32.140] 5140 * 5141 * From investigation on W2K, a list is built up which is: 5142 * 5143 * <0x00> AA BB - Copy from AA for BB chars (Note 1 byte with wrap!) 5144 * <token> - Insert appropriate token 5145 * 5146 */ 5147 HRESULT WINAPI VarTokenizeFormatString(LPOLESTR format, LPBYTE rgbTok, 5148 int cbTok, int iFirstDay, int iFirstWeek, 5149 LCID lcid, int *pcbActual) { 5150 5151 FORMATHDR *hdr; 5152 int realLen, formatLeft; 5153 BYTE *pData; 5154 LPSTR pFormatA, pStart; 5155 int checkStr; 5156 BOOL insertCopy = FALSE; 5157 LPSTR copyFrom = NULL; 5158 5159 TRACE("'%s', %p %d %d %d only date support\n", debugstr_w(format), rgbTok, cbTok, 5160 iFirstDay, iFirstWeek); 5161 5162 /* Big enough for header? */ 5163 if (cbTok < sizeof(FORMATHDR)) { 5164 return TYPE_E_BUFFERTOOSMALL; 5165 } 5166 5167 /* Insert header */ 5168 hdr = (FORMATHDR *) rgbTok; 5169 memset(hdr, 0x00, sizeof(FORMATHDR)); 5170 hdr->hex3 = 0x03; /* No idea what these are */ 5171 hdr->hex6 = 0x06; 5172 5173 /* Start parsing string */ 5174 realLen = sizeof(FORMATHDR); 5175 pData = rgbTok + realLen; 5176 pFormatA = HEAP_strdupWtoA( GetProcessHeap(), 0, format ); 5177 pStart = pFormatA; 5178 formatLeft = strlen(pFormatA); 5179 5180 /* Work through the format */ 5181 while (*pFormatA != 0x00) { 5182 5183 checkStr = 0; 5184 while (checkStr>=0 && (formatTokens[checkStr].tokenSize != 0x00)) { 5185 if (formatLeft >= formatTokens[checkStr].tokenSize && 5186 strncmp(formatTokens[checkStr].str, pFormatA, 5187 formatTokens[checkStr].tokenSize) == 0) { 5188 TRACE("match on '%s'\n", formatTokens[checkStr].str); 5189 5190 /* Found Match! */ 5191 5192 /* If we have skipped chars, insert the copy */ 5193 if (insertCopy == TRUE) { 5194 5195 if ((realLen + 3) > cbTok) { 5196 HeapFree( GetProcessHeap(), 0, pFormatA ); 5197 return TYPE_E_BUFFERTOOSMALL; 5198 } 5199 insertCopy = FALSE; 5200 *pData = TOK_COPY; 5201 pData++; 5202 *pData = (BYTE)(copyFrom - pStart); 5203 pData++; 5204 *pData = (BYTE)(pFormatA - copyFrom); 5205 pData++; 5206 realLen = realLen + 3; 5207 } 5208 5209 5210 /* Now insert the token itself */ 5211 if ((realLen + 1) > cbTok) { 5212 HeapFree( GetProcessHeap(), 0, pFormatA ); 5213 return TYPE_E_BUFFERTOOSMALL; 5214 } 5215 *pData = formatTokens[checkStr].tokenId; 5216 pData = pData + 1; 5217 realLen = realLen + 1; 5218 5219 pFormatA = pFormatA + formatTokens[checkStr].tokenSize; 5220 formatLeft = formatLeft - formatTokens[checkStr].tokenSize; 5221 checkStr = -1; /* Flag as found and break out of while loop */ 5222 } else { 5223 checkStr++; 5224 } 5225 } 5226 5227 /* Did we ever match a token? */ 5228 if (checkStr != -1 && insertCopy == FALSE) { 5229 TRACE("No match - need to insert copy from %p [%p]\n", pFormatA, pStart); 5230 insertCopy = TRUE; 5231 copyFrom = pFormatA; 5232 } else if (checkStr != -1) { 5233 pFormatA = pFormatA + 1; 5234 } 5235 5236 } 5237 5238 /* Finally, if we have skipped chars, insert the copy */ 5239 if (insertCopy == TRUE) { 5240 5241 TRACE("Chars left over, so still copy %p,%p,%p\n", copyFrom, pStart, pFormatA); 5242 if ((realLen + 3) > cbTok) { 5243 HeapFree( GetProcessHeap(), 0, pFormatA ); 5244 return TYPE_E_BUFFERTOOSMALL; 5245 } 5246 insertCopy = FALSE; 5247 *pData = TOK_COPY; 5248 pData++; 5249 *pData = (BYTE)(copyFrom - pStart); 5250 pData++; 5251 *pData = (BYTE)(pFormatA - copyFrom); 5252 pData++; 5253 realLen = realLen + 3; 5254 } 5255 5256 /* Finally insert the terminator */ 5257 if ((realLen + 1) > cbTok) { 5258 HeapFree( GetProcessHeap(), 0, pFormatA ); 5259 return TYPE_E_BUFFERTOOSMALL; 5260 } 5261 *pData++ = TOK_END; 5262 realLen = realLen + 1; 5263 5264 /* Finally fill in the length */ 5265 hdr->len = realLen; 5266 *pcbActual = realLen; 5267 5268 #if 0 5269 { int i,j; 5270 for (i=0; i<realLen; i=i+0x10) { 5271 printf(" %4.4x : ", i); 5272 for (j=0; j<0x10 && (i+j < realLen); j++) { 5273 printf("%2.2x ", rgbTok[i+j]); 5274 } 5275 printf("\n"); 5276 } 5277 } 5278 #endif 5279 HeapFree( GetProcessHeap(), 0, pFormatA ); 5280 5281 return S_OK; 5282 } 5283 5284 /********************************************************************** 5285 * VarFormatFromTokens [OLEAUT32.139] 5286 * FIXME: No account of flags or iFirstDay etc 5287 */ 5288 HRESULT WINAPI VarFormatFromTokens(LPVARIANT varIn, LPOLESTR format, 5289 LPBYTE pbTokCur, ULONG dwFlags, BSTR *pbstrOut, 5290 LCID lcid) { 5291 5292 FORMATHDR *hdr = (FORMATHDR *)pbTokCur; 5293 BYTE *pData = pbTokCur + sizeof (FORMATHDR); 5294 LPSTR pFormatA = HEAP_strdupWtoA( GetProcessHeap(), 0, format ); 5295 char output[BUFFER_MAX]; 5296 char *pNextPos; 5297 int size, whichToken; 5298 VARIANTARG Variant; 5299 struct tm TM; 5300 5301 5302 5303 TRACE("'%s', %p %lx %p only date support\n", pFormatA, pbTokCur, dwFlags, pbstrOut); 5304 TRACE("varIn:\n"); 5305 dump_Variant(varIn); 5306 5307 memset(output, 0x00, BUFFER_MAX); 5308 pNextPos = output; 5309 5310 while (*pData != TOK_END && ((pData - pbTokCur) <= (hdr->len))) { 5311 5312 TRACE("Output looks like : '%s'\n", output); 5313 5314 /* Convert varient to appropriate data type */ 5315 whichToken = 0; 5316 while ((formatTokens[whichToken].tokenSize != 0x00) && 5317 (formatTokens[whichToken].tokenId != *pData)) { 5318 whichToken++; 5319 } 5320 5321 /* Use Variant local from here downwards as always correct type */ 5322 if (formatTokens[whichToken].tokenSize > 0 && 5323 formatTokens[whichToken].varTypeRequired != 0) { 5324 VariantInit( &Variant ); 5325 if (Coerce( &Variant, lcid, dwFlags, varIn, 5326 formatTokens[whichToken].varTypeRequired ) != S_OK) { 5327 HeapFree( GetProcessHeap(), 0, pFormatA ); 5328 return DISP_E_TYPEMISMATCH; 5329 } else if (formatTokens[whichToken].varTypeRequired == VT_DATE) { 5330 if( DateToTm( V_UNION(&Variant,date), dwFlags, &TM ) == FALSE ) { 5331 HeapFree( GetProcessHeap(), 0, pFormatA ); 5332 return E_INVALIDARG; 5333 } 5334 } 5335 } 5336 5337 TRACE("Looking for match on token '%x'\n", *pData); 5338 switch (*pData) { 5339 case TOK_COPY: 5340 TRACE("Copy from %d for %d bytes\n", *(pData+1), *(pData+2)); 5341 memcpy(pNextPos, &pFormatA[*(pData+1)], *(pData+2)); 5342 pNextPos = pNextPos + *(pData+2); 5343 pData = pData + 3; 5344 break; 5345 5346 case TOK_COLON : 5347 /* Get locale information - Time Seperator */ 5348 size = GetLocaleInfoA(lcid, LOCALE_STIME, NULL, 0); 5349 GetLocaleInfoA(lcid, LOCALE_STIME, pNextPos, size); 5350 TRACE("TOK_COLON Time seperator is '%s'\n", pNextPos); 5351 pNextPos = pNextPos + size; 5352 pData = pData + 1; 5353 break; 5354 5355 case TOK_SLASH : 5356 /* Get locale information - Date Seperator */ 5357 size = GetLocaleInfoA(lcid, LOCALE_SDATE, NULL, 0); 5358 GetLocaleInfoA(lcid, LOCALE_SDATE, pNextPos, size); 5359 TRACE("TOK_COLON Time seperator is '%s'\n", pNextPos); 5360 pNextPos = pNextPos + size; 5361 pData = pData + 1; 5362 break; 5363 5364 case TOK_d : 5365 sprintf(pNextPos, "%d", TM.tm_mday); 5366 pNextPos = pNextPos + strlen(pNextPos); 5367 pData = pData + 1; 5368 break; 5369 5370 case TOK_dd : 5371 sprintf(pNextPos, "%2.2d", TM.tm_mday); 5372 pNextPos = pNextPos + strlen(pNextPos); 5373 pData = pData + 1; 5374 break; 5375 5376 case TOK_w : 5377 sprintf(pNextPos, "%d", TM.tm_wday+1); 5378 pNextPos = pNextPos + strlen(pNextPos); 5379 pData = pData + 1; 5380 break; 5381 5382 case TOK_m : 5383 sprintf(pNextPos, "%d", TM.tm_mon+1); 5384 pNextPos = pNextPos + strlen(pNextPos); 5385 pData = pData + 1; 5386 break; 5387 5388 case TOK_mm : 5389 sprintf(pNextPos, "%2.2d", TM.tm_mon+1); 5390 pNextPos = pNextPos + strlen(pNextPos); 5391 pData = pData + 1; 5392 break; 5393 5394 case TOK_q : 5395 sprintf(pNextPos, "%d", ((TM.tm_mon+1)/4)+1); 5396 pNextPos = pNextPos + strlen(pNextPos); 5397 pData = pData + 1; 5398 break; 5399 5400 case TOK_y : 5401 sprintf(pNextPos, "%2.2d", TM.tm_yday+1); 5402 pNextPos = pNextPos + strlen(pNextPos); 5403 pData = pData + 1; 5404 break; 5405 5406 case TOK_yy : 5407 sprintf(pNextPos, "%2.2d", TM.tm_year); 5408 pNextPos = pNextPos + strlen(pNextPos); 5409 pData = pData + 1; 5410 break; 5411 5412 case TOK_yyyy : 5413 sprintf(pNextPos, "%4.4d", TM.tm_year); 5414 pNextPos = pNextPos + strlen(pNextPos); 5415 pData = pData + 1; 5416 break; 5417 5418 case TOK_h : 5419 sprintf(pNextPos, "%d", TM.tm_hour); 5420 pNextPos = pNextPos + strlen(pNextPos); 5421 pData = pData + 1; 5422 break; 5423 5424 case TOK_Hh : 5425 sprintf(pNextPos, "%2.2d", TM.tm_hour); 5426 pNextPos = pNextPos + strlen(pNextPos); 5427 pData = pData + 1; 5428 break; 5429 5430 case TOK_N : 5431 sprintf(pNextPos, "%d", TM.tm_min); 5432 pNextPos = pNextPos + strlen(pNextPos); 5433 pData = pData + 1; 5434 break; 5435 5436 case TOK_Nn : 5437 sprintf(pNextPos, "%2.2d", TM.tm_min); 5438 pNextPos = pNextPos + strlen(pNextPos); 5439 pData = pData + 1; 5440 break; 5441 5442 case TOK_S : 5443 sprintf(pNextPos, "%d", TM.tm_sec); 5444 pNextPos = pNextPos + strlen(pNextPos); 5445 pData = pData + 1; 5446 break; 5447 5448 case TOK_Ss : 5449 sprintf(pNextPos, "%2.2d", TM.tm_sec); 5450 pNextPos = pNextPos + strlen(pNextPos); 5451 pData = pData + 1; 5452 break; 5453 5454 /* FIXME: To Do! */ 5455 case TOK_ttttt : 5456 case TOK_AMsPM : 5457 case TOK_amspm : 5458 case TOK_AsP : 5459 case TOK_asp : 5460 case TOK_AMPM : 5461 case TOK_c : 5462 case TOK_ddd : 5463 case TOK_dddd : 5464 case TOK_ddddd : 5465 case TOK_dddddd : 5466 case TOK_ww : 5467 case TOK_mmm : 5468 case TOK_mmmm : 5469 default: 5470 FIXME("Unhandled token for VarFormat %d\n", *pData); 5471 HeapFree( GetProcessHeap(), 0, pFormatA ); 5472 return E_INVALIDARG; 5473 } 5474 5475 } 5476 5477 *pbstrOut = StringDupAtoBstr( output ); 5478 HeapFree( GetProcessHeap(), 0, pFormatA ); 5479 return S_OK; 5480 } 5481 5482 /********************************************************************** 5483 * VarFormat [OLEAUT32.87] 5484 * 5485 */ 5486 HRESULT WINAPI VarFormat(LPVARIANT varIn, LPOLESTR format, 5487 int firstDay, int firstWeek, ULONG dwFlags, 5488 BSTR *pbstrOut) { 5489 5490 LPSTR pNewString = NULL; 5491 HRESULT rc = S_OK; 5492 5493 TRACE("mostly stub! format='%s' day=%d, wk=%d, flags=%ld\n", 5494 debugstr_w(format), firstDay, firstWeek, dwFlags); 5495 TRACE("varIn:\n"); 5496 dump_Variant(varIn); 5497 5498 /* Note: Must Handle references type Variants (contain ptrs 5499 to values rather than values */ 5500 5501 /* Get format string */ 5502 pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, format ); 5503 5504 /* FIXME: Handle some simple pre-definted format strings : */ 5505 if (((V_VT(varIn)&VT_TYPEMASK) == VT_CY) && (lstrcmpiA(pNewString, "Currency") == 0)) { 5506 5507 /* Can't use VarBstrFromCy as it does not put currency sign on nor decimal places */ 5508 double curVal; 5509 5510 5511 /* Handle references type Variants (contain ptrs to values rather than values */ 5512 if (V_VT(varIn)&VT_BYREF) { 5513 rc = VarR8FromCy(*(CY *)V_UNION(varIn,byref), &curVal); 5514 } else { 5515 rc = VarR8FromCy(V_UNION(varIn,cyVal), &curVal); 5516 } 5517 5518 if (rc == S_OK) { 5519 char tmpStr[BUFFER_MAX]; 5520 sprintf(tmpStr, "%f", curVal); 5521 if (GetCurrencyFormatA(GetUserDefaultLCID(), dwFlags, tmpStr, NULL, pBuffer, BUFFER_MAX) == 0) { 5522 return E_FAIL; 5523 } else { 5524 *pbstrOut = StringDupAtoBstr( pBuffer ); 5525 } 5526 } 5527 5528 } else if ((V_VT(varIn)&VT_TYPEMASK) == VT_DATE) { 5529 5530 /* Attempt to do proper formatting! */ 5531 int firstToken = -1; 5532 5533 rc = VarTokenizeFormatString(format, pBuffer, sizeof(pBuffer), firstDay, 5534 firstWeek, GetUserDefaultLCID(), &firstToken); 5535 if (rc==S_OK) { 5536 rc = VarFormatFromTokens(varIn, format, pBuffer, dwFlags, pbstrOut, GetUserDefaultLCID()); 5537 } 5538 5539 } else if ((V_VT(varIn)&VT_TYPEMASK) == VT_R8) { 5540 if (V_VT(varIn)&VT_BYREF) { 5541 sprintf(pBuffer, "%f", *(double *)V_UNION(varIn,byref)); 5542 } else { 5543 sprintf(pBuffer, "%f", V_UNION(varIn,dblVal)); 5544 } 5545 5546 *pbstrOut = StringDupAtoBstr( pBuffer ); 5547 5548 } else { 5549 FIXME("VarFormat: Unsupported format %d!\n", V_VT(varIn)&VT_TYPEMASK); 5550 *pbstrOut = StringDupAtoBstr( "??" ); 5551 } 5552 5553 /* Free allocated storage */ 5554 HeapFree( GetProcessHeap(), 0, pNewString ); 5555 TRACE("result: '%s'\n", debugstr_w(*pbstrOut)); 5556 return rc; 5557 } 5558 5559 /********************************************************************** 5560 * VarCyMulI4 [OLEAUT32.304] 5561 * Multiply currency value by integer 5562 */ 5563 HRESULT WINAPI VarCyMulI4(CY cyIn, LONG mulBy, CY *pcyOut) { 5564 5565 double cyVal = 0; 5566 HRESULT rc = S_OK; 5567 5568 rc = VarR8FromCy(cyIn, &cyVal); 5569 if (rc == S_OK) { 5570 rc = VarCyFromR8((cyVal * (double) mulBy), pcyOut); 5571 TRACE("Multiply %f by %ld = %f [%ld,%lu]\n", cyVal, mulBy, (cyVal * (double) mulBy), 5572 pcyOut->s.Hi, pcyOut->s.Lo); 5573 } 5574 return rc; 5575 }
Note:
See TracChangeset
for help on using the changeset viewer.