Changeset 9400 for trunk/src


Ignore:
Timestamp:
Nov 12, 2002, 6:07:48 PM (23 years ago)
Author:
sandervl
Message:

Wine resync

Location:
trunk/src
Files:
2 added
1 deleted
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/compobj.c

    r8620 r9400  
    4646#include "wine/obj_storage.h"
    4747#include "wine/obj_channel.h"
    48 #include "wine/winbase16.h"
    4948#include "compobj_private.h"
    50 #include "ifs.h"
    5149
    5250#include "wine/debug.h"
    5351
    5452WINE_DEFAULT_DEBUG_CHANNEL(ole);
    55 
    56 /****************************************************************************
    57  *  COM External Lock structures and methods declaration
    58  *
    59  *  This api provides a linked list to managed external references to
    60  *  COM objects.
    61  *
    62  *  The public interface consists of three calls:
    63  *      COM_ExternalLockAddRef
    64  *      COM_ExternalLockRelease
    65  *      COM_ExternalLockFreeList
    66  */
    67 
    68 #define EL_END_OF_LIST 0
    69 #define EL_NOT_FOUND   0
    70 
    71 /*
    72  * Declaration of the static structure that manage the
    73  * external lock to COM  objects.
    74  */
    75 typedef struct COM_ExternalLock     COM_ExternalLock;
    76 typedef struct COM_ExternalLockList COM_ExternalLockList;
    77 
    78 struct COM_ExternalLock
    79 {
    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_ExternalLockList
    86 {
    87   COM_ExternalLock *head;     /* head of list */
    88 };
    89 
    90 /*
    91  * Declaration and initialization of the static structure that manages
    92  * 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 list
    98  */
    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 list
    106  */
    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);
    11953
    12054/****************************************************************************
     
    12357 * TODO: Most of these things will have to be made thread-safe.
    12458 */
    125 HINSTANCE16     COMPOBJ_hInstance = 0;
    12659HINSTANCE       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
     61static HRESULT COM_GetRegisteredClassObject(REFCLSID rclsid, DWORD dwClsContext, LPUNKNOWN*  ppUnk);
     62static void COM_RevokeAllClasses();
     63static 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
     75typedef struct {
     76        unsigned char           threadingModell;        /* we use the COINIT flags */
     77        unsigned long           threadID;
     78        long                    AppartmentLockCount;
     79} OleAppartmentData;
     80
     81typedef struct {
     82        OleAppartmentData       *AppartmentData;
     83} OleThreadData;
     84
     85/* not jet used
     86static 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
     93static OleAppartmentData * mainSTA;
     94*/
     95
     96/*
     97 * a Process can only have one MTA
     98 */
     99
     100/* not jet used
     101static OleAppartmentData * processMTA;
     102*/
     103
    134104
    135105/*
     
    159129} RegisteredClass;
    160130
    161 static CRITICAL_SECTION csRegisteredClassList;
     131static CRITICAL_SECTION csRegisteredClassList = CRITICAL_SECTION_INIT("csRegisteredClassList");
    162132static RegisteredClass* firstRegisteredClass = NULL;
    163133
    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
    168145typedef struct tagOpenDll {
    169146  HINSTANCE hLibrary;
     
    171148} OpenDll;
    172149
    173 static CRITICAL_SECTION csOpenDllList;
     150static CRITICAL_SECTION csOpenDllList = CRITICAL_SECTION_INIT("csOpenDllList");
    174151static OpenDll *openDllList = NULL; /* linked list of open dlls */
    175152
    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();
     153static void COMPOBJ_DLLList_Add(HANDLE hLibrary);
     154static void COMPOBJ_DllList_FreeUnused(int Timeout);
    185155
    186156
     
    190160void COMPOBJ_InitProcess( void )
    191161{
    192     InitializeCriticalSection( &csRegisteredClassList );
    193     InitializeCriticalSection( &csOpenDllList );
    194162}
    195163
    196164void COMPOBJ_UninitProcess( void )
    197165{
    198     DeleteCriticalSection( &csRegisteredClassList );
    199     DeleteCriticalSection( &csOpenDllList );
     166}
     167
     168/*****************************************************************************
     169 * This section contains OpenDllList implemantation
     170 */
     171
     172static 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
     207static 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 );
    200241}
    201242
     
    211252    TRACE("Returning version %d, build %d.\n", rmm, rup);
    212253    return (rmm<<16)+rup;
    213 }
    214 
    215 /******************************************************************************
    216  *              CoInitialize    [COMPOBJ.2]
    217  * Set the win16 IMalloc used for memory management
    218  */
    219 HRESULT WINAPI CoInitialize16(
    220         LPVOID lpReserved       /* [in] pointer to win16 malloc interface */
    221 ) {
    222     currentMalloc16 = (LPMALLOC16)lpReserved;
    223     return S_OK;
    224254}
    225255
     
    306336
    307337  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 I
    314  *   believe is the correct spelling
    315  */
    316 void WINAPI CoUninitialize16(void)
    317 {
    318   TRACE("()\n");
    319   CoFreeAllLibraries();
    320338}
    321339
     
    368386}
    369387
    370 #ifndef __WIN32OS2__
    371 /***********************************************************************
    372  *           CoGetMalloc    [COMPOBJ.4]
    373  * RETURNS
    374  *      The current win16 IMalloc
    375  */
    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 #endif
    386 /******************************************************************************
    387  *              CoGetMalloc     [OLE32.20]
    388  *
    389  * RETURNS
    390  *      The current win32 IMalloc
    391  */
    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 in
    409      * CoGetMalloc16 */
    410     *lpMalloc = IMalloc16_Constructor();
    411     return S_OK;
    412 }
    413 #endif
    414388/******************************************************************************
    415389 *              CoDisconnectObject      [COMPOBJ.15]
     
    420394    TRACE("(%p, %lx)\n",lpUnk,reserved);
    421395    return S_OK;
    422 }
    423 
    424 /***********************************************************************
    425  *           IsEqualGUID [COMPOBJ.18]
    426  *
    427  * Compares two Unique Identifiers.
    428  *
    429  * RETURNS
    430  *      TRUE if equal
    431  */
    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 into
    442  * the GUID struct.
    443  *
    444  * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
    445  *
    446  * RETURNS
    447  *      the converted GUID
    448  */
    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;
    531396}
    532397
     
    553418 *      the converted GUID
    554419 */
     420HRESULT 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
    555482HRESULT WINAPI CLSIDFromString(
    556483        LPCOLESTR idstr,        /* [in] string representation of GUID */
     
    562489    if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL ))
    563490        return CO_E_CLASSSTRING;
    564     ret = CLSIDFromString16(xid,id);
     491
     492
     493    ret = __CLSIDFromStringA(xid,id);
    565494    if(ret != S_OK) { /* It appears a ProgID is also valid */
    566495        ret = CLSIDFromProgID(idstr, id);
     
    610539  return S_OK;
    611540}
    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
    655543/******************************************************************************
    656544 *              StringFromCLSID [OLE32.151]
     
    755643
    756644/******************************************************************************
    757  *              CLSIDFromProgID [COMPOBJ.61]
    758  * Converts a program id into the respective GUID. (By using a registry lookup)
    759  * RETURNS
    760  *      riid associated with the progid
    761  */
    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 /******************************************************************************
    788645 *              CLSIDFromProgID [OLE32.2]
    789646 * Converts a program id into the respective GUID. (By using a registry lookup)
     
    816673    }
    817674    RegCloseKey(xhkey);
    818     return CLSIDFromString16(buf2,riid);
     675    return __CLSIDFromStringA(buf2,riid);
    819676}
    820677
     
    877734    /* We have the CLSid we want back from the registry as a string, so
    878735       lets convert it into a CLSID structure */
    879     if ( (CLSIDFromString16(buf2,pclsid)) != NOERROR)
    880     {
     736    if ( (__CLSIDFromStringA(buf2,pclsid)) != NOERROR) {
    881737       return E_INVALIDARG;
    882738    }
     
    928784        return S_OK;
    929785}
    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
    1011788/***
    1012789 * COM_GetRegisteredClassObject
     
    12961073
    12971074/***********************************************************************
     1075 *      compobj_RegReadPath     [internal]
     1076 *
     1077 *      Reads a registry value and expands it when nessesary
     1078 */
     1079HRESULT 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/***********************************************************************
    12981101 *           CoGetClassObject [COMPOBJ.7]
    12991102 *           CoGetClassObject [OLE32.16]
     
    13111114    HRESULT     hres = E_UNEXPECTED;
    13121115    char        xclsid[80];
    1313     WCHAR ProviderName[MAX_PATH+1];
    1314     DWORD ProviderNameLen = sizeof(ProviderName);
    13151116    HINSTANCE hLibrary;
    13161117#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);
    13191119#else
    1320     typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid,
    1321                              REFIID iid, LPVOID *ppv);
     1120    typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid, REFIID iid, LPVOID *ppv);
    13221121#endif
    13231122    DllGetClassObjectFunc DllGetClassObject;
     
    13251124    WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
    13261125
    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));
    13311127
    13321128    if (pServerInfo) {
     
    13561152    }
    13571153
    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);
    13691164            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          }
    13761180        }
    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    }
    13921182
    13931183    /* Next try out of process */
     
    14261216    IStorage *pstg=0;
    14271217    HRESULT res;
    1428     int nbElm=0,length=0,i=0;
    1429     LONG sizeProgId=20;
     1218    int nbElm, length, i;
     1219    LONG sizeProgId;
    14301220    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);
    14341226
    14351227    /* if the file contain a storage object the return the CLSID writen by IStorage_SetClass method*/
     
    14751267
    14761268    /* failed if the path represente a directory and not an absolute file name*/
    1477     if (lstrcmpW(absFile,(LPOLESTR)"\\"))
     1269    if (!lstrcmpW(absFile, bkslashW))
    14781270        return MK_E_INVALIDEXTENSION;
    14791271
    14801272    /* get the extension of the file */
     1273    extension = NULL;
    14811274    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);
    14831282
    14841283    /* 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
    14941287    if (res==ERROR_SUCCESS)
    14951288        /* return the clsid associated to the progId */
     
    15071300    return MK_E_INVALIDEXTENSION;
    15081301}
    1509 /******************************************************************************
    1510  *              CoRegisterMessageFilter [COMPOBJ.27]
    1511  */
    1512 HRESULT WINAPI CoRegisterMessageFilter16(
    1513         LPMESSAGEFILTER lpMessageFilter,
    1514         LPMESSAGEFILTER *lplpMessageFilter
    1515 ) {
    1516         FIXME("(%p,%p),stub!\n",lpMessageFilter,lplpMessageFilter);
    1517         return 0;
    1518 }
    1519 
    15201302/***********************************************************************
    15211303 *           CoCreateInstance [COMPOBJ.13]
     
    16441426
    16451427/***********************************************************************
     1428 *           CoLoadLibrary (OLE32.30)
     1429 */
     1430HINSTANCE 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/***********************************************************************
    16461438 *           CoFreeLibrary [OLE32.13]
     1439 *
     1440 * NOTES: don't belive the docu
    16471441 */
    16481442void WINAPI CoFreeLibrary(HINSTANCE hLibrary)
    16491443{
    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);
    16831445}
    16841446
     
    16861448/***********************************************************************
    16871449 *           CoFreeAllLibraries [OLE32.12]
     1450 *
     1451 * NOTES: don't belive the docu
    16881452 */
    16891453void WINAPI CoFreeAllLibraries(void)
    16901454{
    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}
    17041457
    17051458
     
    17071460 *           CoFreeUnusedLibraries [COMPOBJ.17]
    17081461 *           CoFreeUnusedLibraries [OLE32.14]
     1462 *
     1463 * FIXME: Calls to CoFreeUnusedLibraries from any thread always route
     1464 * through the main apartment's thread to call DllCanUnloadNow
    17091465 */
    17101466void WINAPI CoFreeUnusedLibraries(void)
    17111467{
    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);
    17331469}
    17341470
     
    17471483
    17481484/***********************************************************************
    1749  *           CoTaskMemAlloc (OLE32.43)
    1750  * RETURNS
    1751  *      pointer to newly allocated block
    1752  */
    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  * RETURNS
    1782  *      pointer to newly allocated block
    1783  */
    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 /***********************************************************************
    17981485 *           CoLoadLibrary (OLE32.30)
    17991486 */
    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;
     1487static 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 */
     1518typedef struct COM_ExternalLock     COM_ExternalLock;
     1519typedef struct COM_ExternalLockList COM_ExternalLockList;
     1520
     1521struct 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
     1528struct 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 */
     1537static COM_ExternalLockList elList = { EL_END_OF_LIST };
     1538
     1539/*
     1540 * Private methods used to managed the linked list
     1541 */
     1542
     1543
     1544static COM_ExternalLock* COM_ExternalLockLocate(
     1545  COM_ExternalLock *element,
     1546  IUnknown         *pUnk);
     1547
     1548/****************************************************************************
     1549 * Internal - Insert a new IUnknown* to the linked list
     1550 */
     1551static 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 */
    18201565    } 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 */
     1584static 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 */
     1613static 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 */
     1627static 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 */
     1652static 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 */
     1674static 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 */
     1688void 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  }
    18611700}
    18621701
     
    18701709{
    18711710
    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 */
     1731HRESULT WINAPI CoInitializeWOW(DWORD x,DWORD y) {
     1732    FIXME("(0x%08lx,0x%08lx),stub!\n",x,y);
     1733    return 0;
     1734}
     1735
     1736static IUnknown * pUnkState = 0; /* FIXME: thread local */
     1737static int nStatCounter = 0;     /* global */
     1738static HMODULE hOleAut32 = 0;    /* global */
     1739
     1740/***********************************************************************
     1741 *           CoGetState [OLE32.24]
     1742 *
     1743 * NOTES: might be incomplete
     1744 */
     1745HRESULT 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
    19011760/***********************************************************************
    19021761 *           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 */
     1765HRESULT 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
    21571785
    21581786/******************************************************************************
     
    21841812    CLSIDFromString(wbuf,pClsidNew);
    21851813done:
    2186   if (hkey) RegCloseKey(hkey);
    2187 
    2188   return res;
     1814    if (hkey) RegCloseKey(hkey);
     1815    return res;
    21891816}
    21901817
     
    22621889    return !memcmp(rguid1,rguid2,sizeof(GUID));
    22631890}
     1891
     1892/***********************************************************************
     1893 *           CoInitializeSecurity [OLE32.164]
     1894 */
     1895HRESULT 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  
    125125int WINAPI FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable);
    126126
     127HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
     128
    127129#endif /* __WINE_OLE_COMPOBJ_H */
  • trunk/src/ole32/datacache.c

    r8620 r9400  
    827827
    828828  if (FAILED(hres))
    829     return hres;
     829    return (HMETAFILE)hres;
    830830
    831831  /*
  • trunk/src/ole32/filemoniker.c

    r8620 r9400  
    871871
    872872    if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
    873 
    874873        return S_FALSE;
    875874
    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
    888885}
    889886
     
    11001097    int len=lstrlenW(str);
    11011098
     1099    TRACE("%s, %p\n", debugstr_w(str), *stringTable);
     1100
    11021101    strgtable =CoTaskMemAlloc(len*sizeof(LPOLESTR));
    11031102
  • trunk/src/ole32/hglobalstream.c

    r8620 r9400  
    3434#include "winbase.h"
    3535#include "winerror.h"
     36#include "winternl.h"
    3637
    3738#include "wine/debug.h"
     
    574575
    575576  /*
    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 cases
    578    * in the code below.
    579    */
    580   if (plibNewPosition == 0)
    581   {
    582     plibNewPosition = &newPosition;
    583   }
    584 
    585   /*
    586577   * The file pointer is moved depending on the given "function"
    587578   * parameter.
     
    590581  {
    591582    case STREAM_SEEK_SET:
    592       plibNewPosition->s.HighPart = 0;
    593       plibNewPosition->s.LowPart = 0;
     583      newPosition.s.HighPart = 0;
     584      newPosition.s.LowPart = 0;
    594585      break;
    595586    case STREAM_SEEK_CUR:
    596       *plibNewPosition = This->currentPosition;
     587      newPosition = This->currentPosition;
    597588      break;
    598589    case STREAM_SEEK_END:
    599       *plibNewPosition = This->streamSize;
     590      newPosition = This->streamSize;
    600591      break;
    601592    default:
     
    604595
    605596  /*
    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 an
    612    * 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   /*
    623597   * Move the actual file pointer
    624598   * If the file pointer ends-up after the end of the stream, the next Write operation will
    625599   * make the file larger. This is how it is documented.
    626600   */
    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;
    629610
    630611  return S_OK;
     
    844825                  IStream**    ppstm) /* [out] */
    845826{
    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  
    2828#include "ole2.h"
    2929#include "windef.h"
     30#include "winbase.h"
    3031#include "winerror.h"
    3132
    3233#include "wine/obj_base.h"
    33 #include "wine/winbase16.h"
    34 #include "ifs.h"
    3534
    3635#include "wine/debug.h"
    3736
    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
     41WINE_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 */
     52extern ICOM_VTABLE(IMalloc) VT_IMalloc32;
     53
     54typedef 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 */
     68static CRITICAL_SECTION IMalloc32_SpyCS = CRITICAL_SECTION_INIT("IMalloc32_SpyCS");
     69
     70/* resize the old table */
     71static 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 */
     79static 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
     105static 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 */
     125static 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 */
     139static ULONG WINAPI IMalloc_fnAddRefRelease (LPMALLOC iface) {
     140        return 1;
     141}
     142
     143/******************************************************************************
     144 *      IMalloc32_Alloc                 [VTABLE]
     145 */
     146static 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 */
     178static 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 */
     222static 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 */
     258static 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 */
     283static 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 */
     307static 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
     324static ICOM_VTABLE(IMalloc) VT_IMalloc32 =
     325#endif
    87326{
    88327        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
    92337};
    93338
    94339/******************************************************************************
    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 */
     344extern ICOM_VTABLE(IMallocSpy) VT_IMallocSpy;
     345
     346typedef 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 */
     357static 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 */
     372static 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 */
     388static 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 */
    241397    }
    242     ICOM_VTBL(This) = (ICOM_VTABLE(IMalloc16)*)msegvt16;
    243     This->ref = 1;
    244     return (LPMALLOC16)MapLS( This );
    245 }
     398    return This->ref;
     399}
     400
     401static 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}
     407static 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
     414static 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}
     420static void  WINAPI IMallocSpy_fnPostFree(LPMALLOCSPY iface, BOOL fSpyed)
     421{
     422    ICOM_THIS (_MallocSpy, iface);
     423    TRACE ("(%p)->(%u)\n", This, fSpyed);
     424}
     425
     426static 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
     434static 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
     441static 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
     448static 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
     455static 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
     462static 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
     469static int WINAPI IMallocSpy_fnPreHeapMinimize(LPMALLOCSPY iface)
     470{
     471    ICOM_THIS (_MallocSpy, iface);
     472    TRACE ("(%p)->()\n", This);
     473    return 0;
     474}
     475
     476static int WINAPI IMallocSpy_fnPostHeapMinimize(LPMALLOCSPY iface)
     477{
     478    ICOM_THIS (_MallocSpy, iface);
     479    TRACE ("(%p)->()\n", This);
     480    return 0;
     481}
     482
     483static void MallocSpyDumpLeaks() {
     484        TRACE("leaks: %lu\n", Malloc32.SpyedAllocationsLeft);
     485}
     486
     487#ifdef __WIN32OS2__
     488       ICOM_VTABLE(IMallocSpy) VT_IMallocSpy =
     489#else
     490static ICOM_VTABLE(IMallocSpy) VT_IMallocSpy =
    246491#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
    358509};
    359510
    360511/******************************************************************************
    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 */
     517HRESULT 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 */
     528LPVOID WINAPI CoTaskMemAlloc(ULONG size)
     529{
     530        return IMalloc_Alloc((LPMALLOC)&Malloc32,size);
     531}
     532/***********************************************************************
     533 *           CoTaskMemFree      [OLE32.44]
     534 */
     535VOID 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 */
     545LPVOID 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 */
     557HRESULT 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 */
     588HRESULT 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}
    376612
    377613/******************************************************************************
  • trunk/src/ole32/itemmoniker.c

    r8620 r9400  
    388388    if (!This->itemName)
    389389        return E_OUTOFMEMORY;
    390     strcpyW(This->itemName,lpszItem);
     390    lstrcpyW(This->itemName,lpszItem);
    391391
    392392    if (!lpszDelim)
     
    395395    delim = lpszDelim ? lpszDelim : emptystr;
    396396
    397     sizeStr2=strlenW(delim);
     397    sizeStr2=lstrlenW(delim);
    398398    This->itemDelimiter=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(sizeStr2+1));
    399399    if (!This->itemDelimiter) {
     
    401401        return E_OUTOFMEMORY;
    402402    }
    403     strcpyW(This->itemDelimiter,delim);
     403    lstrcpyW(This->itemDelimiter,delim);
    404404    return S_OK;
    405405}
     
    612612    LPOLESTR dispName1,dispName2;
    613613    IBindCtx* bind;
    614     HRESULT res;
     614    HRESULT res = S_FALSE;
    615615
    616616    TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
    617617
    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;
    640636}
    641637
     
    843839        return E_OUTOFMEMORY;
    844840
    845     strcpyW(*ppszDisplayName,This->itemDelimiter);
    846     strcatW(*ppszDisplayName,This->itemName);
     841    lstrcpyW(*ppszDisplayName,This->itemDelimiter);
     842    lstrcatW(*ppszDisplayName,This->itemName);
    847843
    848844    return S_OK;
  • trunk/src/ole32/marshal.c

    r8620 r9400  
    317317  }
    318318  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  }
    323325  IPSFactoryBuffer_Release(psfacbuf);
    324   return S_OK;
     326  return hres;
    325327}
    326328
     
    483485        MESSAGE("       Wine registry by running: `regedit winedefault.reg'\n\n");
    484486    } 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        }
    486492    }
    487493    goto release_marshal;
  • trunk/src/ole32/ole2stubs.c

    r8620 r9400  
    9898  FIXME("\n\t%s\n\t%s stub!\n", debugstr_guid(rclsid), debugstr_guid(riid));
    9999
    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))))
    101101  {
    102102    if (pClientSite)
  • trunk/src/ole32/ole32.def

    r8553 r9400  
    168168    WriteStringStream          = _WriteStringStream@0        @162
    169169    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
    171171    CoCreateInstanceEx         = _CoCreateInstanceEx@24      @165
    172172    PropVariantClear           = _PropVariantClear@4         @166
  • trunk/src/ole32/ole32.mak

    r8445 r9400  
    1 # $Id: ole32.mak,v 1.20 2002-05-16 19:26:29 sandervl Exp $
     1# $Id: ole32.mak,v 1.21 2002-11-12 17:06:02 sandervl Exp $
    22
    33#
     
    3939$(OBJDIR)\bindctx.obj \
    4040$(OBJDIR)\compositemoniker.obj \
     41$(OBJDIR)\compobj.obj \
    4142$(OBJDIR)\datacache.obj \
    4243$(OBJDIR)\defaulthandler.obj \
    4344$(OBJDIR)\errorinfo.obj \
    4445$(OBJDIR)\filemoniker.obj \
     46$(OBJDIR)\ftmarshal.obj \
    4547$(OBJDIR)\hglobalstream.obj \
    4648$(OBJDIR)\initialise.obj \
     
    5254$(OBJDIR)\ole2.obj \
    5355$(OBJDIR)\oleobj.obj \
    54 $(OBJDIR)\compobj.obj \
    5556$(OBJDIR)\clipboard.obj \
    5657$(OBJDIR)\ole2stubs.obj \
  • trunk/src/ole32/ole32dbg.def

    r8553 r9400  
    169169
    170170    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
    172172    CoCreateInstanceEx         = _DbgCoCreateInstanceEx@24      @165
    173173    PropVariantClear           = _DbgPropVariantClear@4         @166
  • trunk/src/ole32/stg_stream.c

    r8636 r9400  
    3030#include "winbase.h"
    3131#include "winerror.h"
    32 #include "ntddk.h"
     32#include "winternl.h"
    3333#include "wine/debug.h"
    3434
     
    565565  plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart, dlibMove.QuadPart );
    566566#endif
    567 
    568567  /*
    569568   * tell the caller what we calculated
  • trunk/src/ole32/storage32.c

    r8620 r9400  
    23212321   * Create the block chain abstractions.
    23222322   */
    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;
    23302331
    23312332  /*
     
    23812382  {
    23822383    /* TODO CLEANUP */
    2383     return E_FAIL;
     2384    return STG_E_READFAULT;
    23842385  }
    23852386
     
    23872388   * Create the block chain abstraction for the small block root chain.
    23882389   */
    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;
    23932393
    23942394  return hr;
     
    27312731 *          blockIndex - Index of the block to retrieve the chain
    27322732 *                       for.
     2733 *          nextBlockIndex - receives the return value.
    27332734 *
    27342735 * Returns: This method returns the index of the next block in the chain.
     
    27452746 * See Windows documentation for more details on IStorage methods.
    27462747 */
    2747 ULONG StorageImpl_GetNextBlockInChain(
     2748HRESULT StorageImpl_GetNextBlockInChain(
    27482749  StorageImpl* This,
    2749   ULONG          blockIndex)
     2750  ULONG        blockIndex,
     2751  ULONG*       nextBlockIndex)
    27502752{
    27512753  ULONG offsetInDepot    = blockIndex * sizeof (ULONG);
    27522754  ULONG depotBlockCount  = offsetInDepot / This->bigBlockSize;
    27532755  ULONG depotBlockOffset = offsetInDepot % This->bigBlockSize;
    2754   ULONG nextBlockIndex   = BLOCK_SPECIAL;
    27552756  void* depotBuffer;
    27562757  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  }
    27592768
    27602769  /*
     
    27792788    depotBuffer = StorageImpl_GetROBigBlock(This, depotBlockIndexPos);
    27802789
    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;
    27982804}
    27992805
     
    30443050    StorageUtl_WriteWord(headerBigBlock,  0x1c, (WORD)-2);
    30453051    StorageUtl_WriteDWord(headerBigBlock, 0x38, (DWORD)0x1000);
    3046     StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);
    30473052  }
    30483053
     
    30503055   * Write the information to the header.
    30513056   */
    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  {
    30643100    StorageUtl_WriteDWord(
    30653101      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]));
    30963104  }
    30973105
     
    33823390                                           &bbHeadOfChain,
    33833391                                           PROPERTY_NULL);
    3384 
     3392  if(!bbTempChain) return NULL;
    33853393  /*
    33863394   * Grow the big block chain.
     
    41634171    newStream->tailIndex = blockIndex;
    41644172
    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    }
    41684181  }
    41694182
     
    42264239    count++;
    42274240
    4228     blockIndex = StorageImpl_GetNextBlockInChain(
     4241    if(FAILED(StorageImpl_GetNextBlockInChain(
    42294242                   This->parentStorage,
    4230                    blockIndex);
     4243                   blockIndex,
     4244                   &blockIndex)))
     4245      return 0;
    42314246  }
    42324247
     
    42754290  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    42764291  {
    4277     blockIndex =
    4278       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4279 
     4292    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex)))
     4293      return FALSE;
    42804294    blockNoInSequence--;
    42814295  }
     
    43104324     * Step to the next big block.
    43114325     */
    4312     blockIndex    =
    4313       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
     4326    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex, &blockIndex)))
     4327      return FALSE;
    43144328
    43154329    bufferWalker += bytesToReadInBuffer;
     
    43644378  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    43654379  {
    4366     blockIndex =
    4367       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4368 
     4380    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4381                                              &blockIndex)))
     4382      return FALSE;
    43694383    blockNoInSequence--;
    43704384  }
     
    43994413     * Step to the next big block.
    44004414     */
    4401     blockIndex    =
    4402       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4403 
     4415    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4416                                              &blockIndex)))
     4417      return FALSE;
    44044418    bufferWalker  += bytesToWrite;
    44054419    size          -= bytesToWrite;
     
    44444458  while (count < numBlocks)
    44454459  {
    4446     blockIndex =
    4447       StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4448 
     4460    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex,
     4461                                              &blockIndex)))
     4462      return FALSE;
    44494463    count++;
    44504464  }
    44514465
    44524466  /* 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;
    44554470
    44564471  /* Mark the new end of chain */
     
    44684483  while (extraBlock != BLOCK_END_OF_CHAIN)
    44694484  {
    4470     blockIndex =
    4471       StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock);
    4472 
     4485    if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock,
     4486                                              &blockIndex)))
     4487      return FALSE;
    44734488    StorageImpl_FreeBigBlock(This->parentStorage, extraBlock);
    44744489    extraBlock = blockIndex;
     
    45484563      currentBlock = blockIndex;
    45494564
    4550       blockIndex =
    4551         StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock);
     4565      if(FAILED(StorageImpl_GetNextBlockInChain(This->parentStorage, currentBlock,
     4566                                                &blockIndex)))
     4567        return FALSE;
    45524568    }
    45534569
     
    47364752 *    - BLOCK_UNUSED: small block 'blockIndex' is free
    47374753 */
    4738 ULONG SmallBlockChainStream_GetNextBlockInChain(
     4754HRESULT SmallBlockChainStream_GetNextBlockInChain(
    47394755  SmallBlockChainStream* This,
    4740   ULONG                  blockIndex)
     4756  ULONG                  blockIndex,
     4757  ULONG*                 nextBlockInChain)
    47414758{
    47424759  ULARGE_INTEGER offsetOfBlockInDepot;
    47434760  DWORD  buffer;
    4744   ULONG  nextBlockInChain = BLOCK_END_OF_CHAIN;
    47454761  ULONG  bytesRead;
    47464762  BOOL success;
     4763
     4764  *nextBlockInChain = BLOCK_END_OF_CHAIN;
    47474765
    47484766  offsetOfBlockInDepot.s.HighPart = 0;
     
    47614779  if (success)
    47624780  {
    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;
    47674786}
    47684787
     
    48694888      {
    48704889        sbdIndex = nextBlock;
    4871         nextBlock =
    4872           StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex);
     4890        StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex, &nextBlock);
    48734891      }
    48744892
     
    50075025  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    50085026  {
    5009     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    5010 
     5027    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5028                                                        &blockIndex)))
     5029      return FALSE;
    50115030    blockNoInSequence--;
    50125031  }
     
    50495068     * Step to the next big block.
    50505069     */
    5051     blockIndex    = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5070    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5071      return FALSE;
    50525072    bufferWalker += bytesToReadInBuffer;
    50535073    size         -= bytesToReadInBuffer;
     
    50955115  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    50965116  {
    5097     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    5098 
     5117    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5118      return FALSE;
    50995119    blockNoInSequence--;
    51005120  }
     
    51395159     * Step to the next big block.
    51405160     */
    5141     blockIndex    = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5161    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5162                                                        &blockIndex)))
     5163      return FALSE;
    51425164    bufferWalker  += bytesToWriteInBuffer;
    51435165    size          -= bytesToWriteInBuffer;
     
    51745196  while (count < numBlocks)
    51755197  {
    5176     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5198    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex,
     5199                                                        &blockIndex)))
     5200      return FALSE;
    51775201    count++;
    51785202  }
     
    52045228  {
    52055229    /* 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;
    52075233
    52085234    /* Mark the new end of chain */
     
    52185244  while (extraBlock != BLOCK_END_OF_CHAIN)
    52195245  {
    5220     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, extraBlock);
     5246    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, extraBlock,
     5247                                                        &blockIndex)))
     5248      return FALSE;
    52215249    SmallBlockChainStream_FreeBlock(This, extraBlock);
    52225250    extraBlock = blockIndex;
     
    52815309    oldNumBlocks++;
    52825310    currentBlock = blockIndex;
    5283     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, currentBlock);
     5311    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, currentBlock, &blockIndex)))
     5312      return FALSE;
    52845313  }
    52855314
     
    53215350    count++;
    53225351
    5323     blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
     5352    if(FAILED(SmallBlockChainStream_GetNextBlockInChain(This, blockIndex, &blockIndex)))
     5353      return 0;
    53245354  }
    53255355
     
    57445774         newStorage,
    57455775         0,
    5746         0,
     5776         0,
    57475777         plkbyt,
    57485778         grfMode,
  • trunk/src/ole32/storage32.h

    r8441 r9400  
    77 *
    88 * 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
    1010 * storage functionality
    1111 *
     
    4343static const ULONG OFFSET_ROOTSTARTBLOCK     = 0x00000030;
    4444static const ULONG OFFSET_SBDEPOTSTART       = 0x0000003C;
     45static const ULONG OFFSET_SBDEPOTCOUNT       = 0x00000040;
    4546static const ULONG OFFSET_EXTBBDEPOTSTART    = 0x00000044;
    4647static const ULONG OFFSET_EXTBBDEPOTCOUNT    = 0x00000048;
     
    5051static const ULONG OFFSET_PS_PROPERTYTYPE    = 0x00000042;
    5152static const ULONG OFFSET_PS_PREVIOUSPROP    = 0x00000044;
    52 static const ULONG OFFSET_PS_NEXTPROP        = 0x00000048;   
     53static const ULONG OFFSET_PS_NEXTPROP        = 0x00000048;
    5354static const ULONG OFFSET_PS_DIRPROP         = 0x0000004C;
    5455static const ULONG OFFSET_PS_GUID            = 0x00000050;
     
    5758static const ULONG OFFSET_PS_TSS2            = 0x0000006C;
    5859static const ULONG OFFSET_PS_TSD2            = 0x00000070;
    59 static const ULONG OFFSET_PS_STARTBLOCK      = 0x00000074; 
    60 static const ULONG OFFSET_PS_SIZE            = 0x00000078; 
     60static const ULONG OFFSET_PS_STARTBLOCK      = 0x00000074;
     61static const ULONG OFFSET_PS_SIZE            = 0x00000078;
    6162static const WORD  DEF_BIG_BLOCK_SIZE_BITS   = 0x0009;
    6263static const WORD  DEF_SMALL_BLOCK_SIZE_BITS = 0x0006;
     
    7071
    7172#define PROPERTY_NAME_MAX_LEN    0x20
    72 #define PROPERTY_NAME_BUFFER_LEN 0x40             
     73#define PROPERTY_NAME_BUFFER_LEN 0x40
    7374
    7475#define PROPSET_BLOCK_SIZE 0x00000080
     
    142143 *
    143144 * 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
    145146 * this section appear in stg_bigblockfile.c
    146147 */
     
    209210   */
    210211  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
    217218  /*
    218219   * Index of the property for the root of
     
    220221   */
    221222  ULONG rootPropertySetIndex;
    222  
    223   /* 
     223
     224  /*
    224225   * virtual Destructor method.
    225226   */
     
    235236            REFIID             riid,
    236237            void**             ppvObject);
    237        
    238 ULONG WINAPI StorageBaseImpl_AddRef( 
     238
     239ULONG WINAPI StorageBaseImpl_AddRef(
    239240            IStorage*        iface);
    240        
    241 ULONG WINAPI StorageBaseImpl_Release( 
     241
     242ULONG WINAPI StorageBaseImpl_Release(
    242243            IStorage*        iface);
    243        
    244 HRESULT WINAPI StorageBaseImpl_OpenStream( 
     244
     245HRESULT WINAPI StorageBaseImpl_OpenStream(
    245246            IStorage*        iface,
    246247            const OLECHAR*   pwcsName,  /* [string][in] */
    247248            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
     253HRESULT WINAPI StorageBaseImpl_OpenStorage(
    253254            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
     262HRESULT WINAPI StorageBaseImpl_EnumElements(
    262263            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
     269HRESULT WINAPI StorageBaseImpl_Stat(
    269270            IStorage*        iface,
    270             STATSTG*           pstatstg,     /* [out] */ 
    271             DWORD              grfStatFlag); /* [in] */ 
     271            STATSTG*           pstatstg,     /* [out] */
     272            DWORD              grfStatFlag); /* [in] */
    272273
    273274HRESULT WINAPI StorageBaseImpl_RenameElement(
     
    304305   */
    305306  ULONG                 ref;
    306   struct StorageImpl* ancestorStorage;           
     307  struct StorageImpl* ancestorStorage;
    307308  ULONG                 rootPropertySetIndex;
    308309  void (*v_destructor)(struct StorageImpl*);
    309  
     310
    310311  /*
    311312   * The following data members are specific to the Storage32Impl
     
    341342  BlockChainStream* rootBlockChain;
    342343  BlockChainStream* smallBlockDepotChain;
    343   BlockChainStream* smallBlockRootChain; 
     344  BlockChainStream* smallBlockRootChain;
    344345
    345346  /*
    346347   * Pointer to the big block file abstraction
    347348   */
    348   BigBlockFile* bigBlockFile; 
     349  BigBlockFile* bigBlockFile;
    349350};
    350351
    351352/*
    352353 * Method declaration for the Storage32Impl class
    353  */       
    354 
    355 HRESULT WINAPI StorageImpl_CreateStorage( 
     354 */
     355
     356HRESULT WINAPI StorageImpl_CreateStorage(
    356357            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
     364HRESULT WINAPI StorageImpl_CopyTo(
    364365            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
     371HRESULT WINAPI StorageImpl_MoveElementTo(
    371372            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
     378HRESULT WINAPI StorageImpl_Commit(
    378379            IStorage*      iface,
    379             DWORD          grfCommitFlags); /* [in] */ 
    380        
    381 HRESULT WINAPI StorageImpl_Revert( 
     380            DWORD          grfCommitFlags); /* [in] */
     381
     382HRESULT WINAPI StorageImpl_Revert(
    382383            IStorage*      iface);
    383        
    384 HRESULT WINAPI StorageImpl_DestroyElement( 
     384
     385HRESULT WINAPI StorageImpl_DestroyElement(
    385386            IStorage*      iface,
    386             const OLECHAR* pwcsName); /* [string][in] */ 
    387        
    388 HRESULT WINAPI StorageImpl_SetElementTimes( 
     387            const OLECHAR* pwcsName); /* [string][in] */
     388
     389HRESULT WINAPI StorageImpl_SetElementTimes(
    389390            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
     396HRESULT WINAPI StorageImpl_SetStateBits(
    396397            IStorage*      iface,
    397             DWORD          grfStateBits, /* [in] */ 
    398             DWORD          grfMask);     /* [in] */ 
     398            DWORD          grfStateBits, /* [in] */
     399            DWORD          grfMask);     /* [in] */
    399400
    400401HRESULT WINAPI StorageImpl_Stat(IStorage* iface,
     
    443444            ULONG blockIndex);
    444445
    445 ULONG StorageImpl_GetNextBlockInChain(
    446             StorageImpl* This,
    447             ULONG blockIndex);
     446HRESULT StorageImpl_GetNextBlockInChain(
     447            StorageImpl* This,
     448            ULONG blockIndex,
     449            ULONG* nextBlockIndex);
    448450
    449451void StorageImpl_SetNextBlockInChain(
    450452            StorageImpl* This,
    451453            ULONG blockIndex,
    452       ULONG nextBlock);
     454            ULONG nextBlock);
    453455
    454456HRESULT StorageImpl_LoadFileHeader(
     
    503505   */
    504506  ULONG                      ref;
    505   struct StorageImpl* ancestorStorage;           
     507  struct StorageImpl* ancestorStorage;
    506508  ULONG                    rootPropertySetIndex;
    507509  void (*v_destructor)(struct StorageInternalImpl*);
     
    516518 */
    517519StorageInternalImpl* StorageInternalImpl_Construct(
    518             StorageImpl* ancestorStorage,       
     520            StorageImpl* ancestorStorage,
    519521            ULONG          rootTropertyIndex);
    520522
     
    522524            StorageInternalImpl* This);
    523525
    524 HRESULT WINAPI StorageInternalImpl_Commit( 
     526HRESULT WINAPI StorageInternalImpl_Commit(
    525527            IStorage*            iface,
    526             DWORD                  grfCommitFlags); /* [in] */ 
    527 
    528 HRESULT WINAPI StorageInternalImpl_Revert( 
     528            DWORD                  grfCommitFlags); /* [in] */
     529
     530HRESULT WINAPI StorageInternalImpl_Revert(
    529531            IStorage*            iface);
    530532
     
    541543  ICOM_VFIELD(IEnumSTATSTG);    /* Needs to be the first item in the struct
    542544                                         * since we want to cast this in a IEnumSTATSTG pointer */
    543  
     545
    544546  ULONG          ref;                   /* Reference count */
    545547  StorageImpl* parentStorage;         /* Reference to the parent storage */
     
    565567            REFIID            riid,
    566568            void**            ppvObject);
    567        
     569
    568570ULONG WINAPI IEnumSTATSTGImpl_AddRef(
    569             IEnumSTATSTG*     iface); 
    570        
     571            IEnumSTATSTG*     iface);
     572
    571573ULONG WINAPI IEnumSTATSTGImpl_Release(
    572574            IEnumSTATSTG*     iface);
    573        
     575
    574576HRESULT WINAPI IEnumSTATSTGImpl_Next(
    575577            IEnumSTATSTG*     iface,
     
    577579            STATSTG*          rgelt,
    578580            ULONG*            pceltFetched);
    579        
     581
    580582HRESULT WINAPI IEnumSTATSTGImpl_Skip(
    581583            IEnumSTATSTG*     iface,
    582584            ULONG             celt);
    583        
     585
    584586HRESULT WINAPI IEnumSTATSTGImpl_Reset(
    585587            IEnumSTATSTG* iface);
    586        
     588
    587589HRESULT WINAPI IEnumSTATSTGImpl_Clone(
    588590            IEnumSTATSTG*     iface,
     
    626628  ICOM_VFIELD(IStream);  /* Needs to be the first item in the struct
    627629                                    * since we want to cast this in a IStream pointer */
    628  
     630
    629631  /*
    630632   * Reference count
     
    656658   */
    657659  ULARGE_INTEGER     currentPosition;
    658  
     660
    659661  /*
    660662   * The information in the stream is represented by a chain of small blocks
     
    682684HRESULT WINAPI StgStreamImpl_QueryInterface(
    683685                IStream*      iface,
    684                 REFIID         riid,            /* [in] */         
    685                 void**         ppvObject);  /* [iid_is][out] */ 
    686        
     686                REFIID         riid,            /* [in] */
     687                void**         ppvObject);  /* [iid_is][out] */
     688
    687689ULONG WINAPI StgStreamImpl_AddRef(
    688690                IStream*      iface);
    689        
     691
    690692ULONG WINAPI StgStreamImpl_Release(
    691693                IStream*      iface);
    692        
    693 HRESULT WINAPI StgStreamImpl_Read( 
     694
     695HRESULT WINAPI StgStreamImpl_Read(
    694696                IStream*      iface,
    695697                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
    699701HRESULT WINAPI StgStreamImpl_Write(
    700702                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
     707HRESULT WINAPI StgStreamImpl_Seek(
    706708                IStream*      iface,
    707                 LARGE_INTEGER   dlibMove,         /* [in] */ 
    708                 DWORD           dwOrigin,         /* [in] */ 
     709                LARGE_INTEGER   dlibMove,         /* [in] */
     710                DWORD           dwOrigin,         /* [in] */
    709711                ULARGE_INTEGER* plibNewPosition); /* [out] */
    710        
    711 HRESULT WINAPI StgStreamImpl_SetSize( 
     712
     713HRESULT WINAPI StgStreamImpl_SetSize(
    712714                IStream*      iface,
    713                 ULARGE_INTEGER  libNewSize);  /* [in] */ 
    714        
    715 HRESULT WINAPI StgStreamImpl_CopyTo( 
     715                ULARGE_INTEGER  libNewSize);  /* [in] */
     716
     717HRESULT WINAPI StgStreamImpl_CopyTo(
    716718                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
     724HRESULT WINAPI StgStreamImpl_Commit(
    723725                IStream*      iface,
    724                 DWORD           grfCommitFlags); /* [in] */ 
    725        
    726 HRESULT WINAPI StgStreamImpl_Revert( 
     726                DWORD           grfCommitFlags); /* [in] */
     727
     728HRESULT WINAPI StgStreamImpl_Revert(
    727729                IStream*  iface);
    728        
    729 HRESULT WINAPI StgStreamImpl_LockRegion( 
     730
     731HRESULT WINAPI StgStreamImpl_LockRegion(
    730732                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
     737HRESULT WINAPI StgStreamImpl_UnlockRegion(
    736738                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
     743HRESULT WINAPI StgStreamImpl_Stat(
    742744                IStream*     iface,
    743745                STATSTG*       pstatstg,     /* [out] */
    744                 DWORD          grfStatFlag); /* [in] */ 
    745        
    746 HRESULT WINAPI StgStreamImpl_Clone( 
     746                DWORD          grfStatFlag); /* [in] */
     747
     748HRESULT WINAPI StgStreamImpl_Clone(
    747749                IStream*     iface,
    748                 IStream**    ppstm);       /* [out] */ 
     750                IStream**    ppstm);       /* [out] */
    749751
    750752
    751753/********************************************************************************
    752754 * 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
    754756 * about bit order
    755757 */
     
    785787 */
    786788BlockChainStream* BlockChainStream_Construct(
    787                 StorageImpl* parentStorage,     
     789                StorageImpl* parentStorage,
    788790                ULONG*         headOfStreamPlaceHolder,
    789791                ULONG          propertyIndex);
     
    835837 */
    836838SmallBlockChainStream* SmallBlockChainStream_Construct(
    837                StorageImpl* parentStorage,     
     839               StorageImpl* parentStorage,
    838840               ULONG          propertyIndex);
    839841
     
    844846               SmallBlockChainStream* This);
    845847
    846 ULONG SmallBlockChainStream_GetNextBlockInChain(
     848HRESULT SmallBlockChainStream_GetNextBlockInChain(
    847849               SmallBlockChainStream* This,
    848                ULONG                  blockIndex);
     850               ULONG                  blockIndex,
     851               ULONG*                 nextBlockIndex);
    849852
    850853void SmallBlockChainStream_SetNextBlockInChain(
     
    886889
    887890#endif /* __STORAGE32_H__ */
    888 
    889 
    890 
  • trunk/src/ole32/stubs.cpp

    r7958 r9400  
    1 /* $Id: stubs.cpp,v 1.21 2002-02-19 12:34:50 sandervl Exp $ */
     1/* $Id: stubs.cpp,v 1.22 2002-11-12 17:06:03 sandervl Exp $ */
    22/*
    33 * Win32 COM/OLE stubs for OS/2
     
    8080//*******************************************************************************
    8181//*******************************************************************************
    82 HRESULT WIN32API CoRegisterMallocSpy(LPMALLOCSPY pMallocSpy)
    83 {
    84     dprintf(("OLE32: CoRegisterMallocSpy - stub"));
    85     return CO_E_OBJISREG;
    86 }
    87 //*******************************************************************************
    88 //*******************************************************************************
    8982HRESULT WIN32API CoReleaseMarshalData(IStream *pStm)
    9083{
    9184    dprintf(("OLE32: CoReleaseMarshalData - stub"));
    9285    return E_OUTOFMEMORY;
    93 }
    94 //*******************************************************************************
    95 //*******************************************************************************
    96 HRESULT WIN32API CoRevokeMallocSpy()
    97 {
    98     dprintf(("OLE32: CoRevokeMallocSpy - stub"));
    99     return E_ACCESSDENIED;
    10086}
    10187//*******************************************************************************
     
    337323{
    338324    dprintf(("OLE32: CoImpersonateClient - Stub"));
    339     return(S_OK);
    340 }
    341 
    342 //*******************************************************************************
    343 //*******************************************************************************
    344 HRESULT WIN32API CoInitializeSecurity(          // DCOM - obj_clientserver.h
    345     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"));
    356325    return(S_OK);
    357326}
  • trunk/src/oleaut32/dbgwrap.cpp

    r8450 r9400  
    303303NODEF_DEBUGWRAP16(VarBstrCmp)
    304304DEBUGWRAP12(VarCat)
    305 
    306 
     305NODEF_DEBUGWRAP8(SafeArrayGetVartype)
     306NODEF_DEBUGWRAP24(VarFormat)
     307NODEF_DEBUGWRAP16(VarFormatDateTime)
     308//NODEF_DEBUGWRAP28(VarFormatNumber)
     309//NODEF_DEBUGWRAP28(VarFormatPercent)
     310NODEF_DEBUGWRAP28(VarFormatCurrency)
     311NODEF_DEBUGWRAP24(VarFormatFromTokens)
     312NODEF_DEBUGWRAP28(VarTokenizeFormatString)
     313DEBUGWRAP12(VarAnd)
     314DEBUGWRAP8(VarNot)
     315DEBUGWRAP16(VarCmp)
     316NODEF_DEBUGWRAP16(VarCyMulI4)
     317
  • trunk/src/oleaut32/ole2disp.c

    r8450 r9400  
    7676{
    7777        BSTR16 out;
    78    
     78
    7979        if (!in) return 0;
    80    
     80
    8181        out = BSTR_AllocBytes(strlen(in)+1);
    8282        if (!out) return 0;
     
    9595{
    9696    if (!in) return 0;
    97    
     97
    9898    /* Delegate this to the SysAllocStringLen32 method. */
    9999    return SysAllocStringLen(in, lstrlenW(in));
     
    119119     * Sanity check
    120120     */
    121     if (old==NULL) 
     121    if (old==NULL)
    122122      return 0;
    123123
     
    125125     * Make sure we free the old string.
    126126     */
    127     if (*old!=NULL)     
     127    if (*old!=NULL)
    128128      SysFreeString(*old);
    129129
     
    166166 * he describes it as a "DWORD count of characters". By experimenting with
    167167 * 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
    169169 * characters in the string.
    170170 */
     
    237237}
    238238
    239  
     239
    240240/******************************************************************************
    241241 *             SysReAllocStringLen   [OLEAUT32.5]
     
    246246     * Sanity check
    247247     */
    248     if (old==NULL) 
     248    if (old==NULL)
    249249      return 0;
    250250
     
    252252     * Make sure we free the old string.
    253253     */
    254     if (*old!=NULL)     
     254    if (*old!=NULL)
    255255      SysFreeString(*old);
    256256
     
    277277{
    278278    DWORD* bufferPointer;
    279    
     279
    280280    /* NULL is a valid parameter */
    281281    if(!in) return;
     
    318318     if (!str) return 0;
    319319    /*
    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
    321321     * just before the BSTR pointer
    322322     */
     
    342342     if (!str) return 0;
    343343    /*
    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
    345345     * just before the BSTR pointer
    346346     */
     
    419419 * Converts an OLE_COLOR to a COLORREF.
    420420 * 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
    422422 * conversion.
    423423 */
     
    430430  BYTE b = HIBYTE(HIWORD(clr));
    431431
    432   TRACE("(%08lx, %d, %p):stub\n", clr, hpal, pColorRef);
     432  TRACE("(%08lx, %p, %p):stub\n", clr, hpal, pColorRef);
    433433
    434434  /*
  • trunk/src/oleaut32/oleaut32.def

    r7916 r9400  
    1 ;/* $Id: oleaut32.def,v 1.9 2002-02-15 15:07:37 sandervl Exp $ */
     1;/* $Id: oleaut32.def,v 1.10 2002-11-12 17:07:46 sandervl Exp $ */
    22LIBRARY OLAUTOS2 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - OleAut32'
     
    55
    66EXPORTS
    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
    188217VarBstrFromUI2 = _VarBstrFromUI2@16  @230
    189218VarBstrFromUI4 = _VarBstrFromUI4@16  @231
     
    254283LPSAFEARRAY_Marshal = _LPSAFEARRAY_Marshal@0  @296
    255284LPSAFEARRAY_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
    256292DllRegisterServer = _OLEAUT32_DllRegisterServer@0  @320
    257293DllUnregisterServer = _OLEAUT32_DllUnregisterServer@0  @321
     294
    258295VarDateFromUdate = _VarDateFromUdate@12  @330
    259296VarUdateFromDate = _VarUdateFromDate@16  @331
     
    279316UserMSG_free_inst = _UserMSG_free_inst@0  @398
    280317UserMSG_free_local = _UserMSG_free_local@0  @399
     318
    281319DllCanUnloadNow = _OLEAUT32_DllCanUnloadNow@0  @410
    282320SafeArrayCreateVector = _SafeArrayCreateVector@12  @411
     
    303341SafeArrayAllocDescriptorEx = _SafeArrayAllocDescriptorEx@12 @429
    304342
    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:43 sandervl Exp $ */
     1;/* $Id: oleaut32dbg.def,v 1.3 2002-11-12 17:07:46 sandervl Exp $ */
    22LIBRARY OLAUTOS2 INITINSTANCE
    33DESCRIPTION 'Odin32 System DLL - OleAut32'
     
    6868VarR4FromUI1 = _DbgVarR4FromUI1@8  @68
    6969VarR4FromI2 = _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
    160186GetErrorInfo = _GetErrorInfo@8  @200
    161187SetErrorInfo = _SetErrorInfo@8  @201
     
    254280LPSAFEARRAY_Marshal = _DbgLPSAFEARRAY_Marshal@0  @296
    255281LPSAFEARRAY_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
    256289DllRegisterServer = _DbgOLEAUT32_DllRegisterServer@0  @320
    257290DllUnregisterServer = _DbgOLEAUT32_DllUnregisterServer@0  @321
     
    303336SafeArrayAllocDescriptorEx = _DbgSafeArrayAllocDescriptorEx@12 @429
    304337
    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          = _DbgVarBstrCat@12                    @439
    315 VarBstrCmp          = _DbgVarBstrCmp@16                    @440
    316 VarCat              = _DbgVarCat@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)
  • trunk/src/oleaut32/olefont.c

    r8450 r9400  
    2525#include "oleaut32.h"
    2626#endif
    27 
    2827#include <assert.h>
    2928#include <string.h>
     
    5958{
    6059  /*
    61    * This class supports many interfaces. IUnknown, IFont, 
     60   * This class supports many interfaces. IUnknown, IFont,
    6261   * IDispatch, IDispFont IPersistStream and IConnectionPointContainer.
    6362   * The first two are supported by the first vtable, the next two are
     
    9897
    9998/*
    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
    101100 * "this" parameter.
    102101 * There is a version to accomodate all of the VTables implemented
     
    104103 */
    105104#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*));
    109108
    110109
     
    147146 * interface
    148147 */
    149 static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface, 
    150                                                     REFIID     riid, 
     148static HRESULT WINAPI OLEFontImpl_IDispatch_QueryInterface(IDispatch* iface,
     149                                                    REFIID     riid,
    151150                                                    VOID**     ppvoid);
    152151static ULONG   WINAPI OLEFontImpl_IDispatch_AddRef(IDispatch* iface);
    153152static ULONG   WINAPI OLEFontImpl_IDispatch_Release(IDispatch* iface);
    154 static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface, 
     153static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(IDispatch*    iface,
    155154                                                   unsigned int* pctinfo);
    156 static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface, 
     155static HRESULT WINAPI OLEFontImpl_GetTypeInfo(IDispatch*  iface,
    157156                                              UINT      iTInfo,
    158                                               LCID        lcid, 
     157                                              LCID        lcid,
    159158                                              ITypeInfo** ppTInfo);
    160159static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(IDispatch*  iface,
    161                                                 REFIID      riid, 
    162                                                 LPOLESTR* rgszNames, 
    163                                                 UINT      cNames, 
     160                                                REFIID      riid,
     161                                                LPOLESTR* rgszNames,
     162                                                UINT      cNames,
    164163                                                LCID        lcid,
    165164                                                DISPID*     rgDispId);
    166165static HRESULT WINAPI OLEFontImpl_Invoke(IDispatch*  iface,
    167                                          DISPID      dispIdMember, 
    168                                          REFIID      riid, 
    169                                          LCID        lcid, 
     166                                         DISPID      dispIdMember,
     167                                         REFIID      riid,
     168                                         LCID        lcid,
    170169                                         WORD        wFlags,
    171170                                         DISPPARAMS* pDispParams,
    172                                          VARIANT*    pVarResult, 
     171                                         VARIANT*    pVarResult,
    173172                                         EXCEPINFO*  pExepInfo,
    174                                          UINT*     puArgErr); 
     173                                         UINT*     puArgErr);
    175174
    176175/***********************************************************************
     
    178177 * interface
    179178 */
    180 static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface, 
    181                                                     REFIID     riid, 
     179static HRESULT WINAPI OLEFontImpl_IPersistStream_QueryInterface(IPersistStream* iface,
     180                                                    REFIID     riid,
    182181                                                    VOID**     ppvoid);
    183182static ULONG   WINAPI OLEFontImpl_IPersistStream_AddRef(IPersistStream* iface);
    184183static ULONG   WINAPI OLEFontImpl_IPersistStream_Release(IPersistStream* iface);
    185 static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface, 
     184static HRESULT WINAPI OLEFontImpl_GetClassID(IPersistStream* iface,
    186185                                             CLSID*                pClassID);
    187186static HRESULT WINAPI OLEFontImpl_IsDirty(IPersistStream*  iface);
     
    190189static HRESULT WINAPI OLEFontImpl_Save(IPersistStream*  iface,
    191190                                       IStream*         pOutStream,
    192                                        BOOL             fClearDirty); 
     191                                       BOOL             fClearDirty);
    193192static HRESULT WINAPI OLEFontImpl_GetSizeMax(IPersistStream*  iface,
    194                                              ULARGE_INTEGER*  pcbSize); 
     193                                             ULARGE_INTEGER*  pcbSize);
    195194
    196195/***********************************************************************
     
    199198 */
    200199static HRESULT WINAPI OLEFontImpl_IConnectionPointContainer_QueryInterface(
    201                                             IConnectionPointContainer* iface, 
    202                                             REFIID     riid, 
     200                                            IConnectionPointContainer* iface,
     201                                            REFIID     riid,
    203202                                            VOID**     ppvoid);
    204203static ULONG   WINAPI OLEFontImpl_IConnectionPointContainer_AddRef(
     
    240239  OLEFontImpl_put_Charset,
    241240  OLEFontImpl_get_hFont,
    242   OLEFontImpl_Clone, 
     241  OLEFontImpl_Clone,
    243242  OLEFontImpl_IsEqual,
    244243  OLEFontImpl_SetRatio,
     
    347346
    348347  IConnectionPoint_EnumConnections(this->pCP, &pEnum);
    349  
     348
    350349  while(IEnumConnections_Next(pEnum, 1, &CD, NULL) == S_OK) {
    351350    IPropertyNotifySink *sink;
     
    359358  return;
    360359}
    361  
     360
    362361/************************************************************************
    363362 * OLEFontImpl_Construct
     
    380379  if (newObject==0)
    381380    return newObject;
    382  
     381
    383382  /*
    384383   * Initialize the virtual function table.
     
    388387  newObject->lpvtbl3 = &OLEFontImpl_IPersistStream_VTable;
    389388  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
    393392   * must release the interface pointer when it is done.
    394393   */
     
    402401  newObject->description.cbSizeofstruct = sizeof(FONTDESC);
    403402  newObject->description.lpstrName = HeapAlloc(GetProcessHeap(),
    404                                                0, 
     403                                               0,
    405404                                               (lstrlenW(fontDesc->lpstrName)+1) * sizeof(WCHAR));
    406405  strcpyW(newObject->description.lpstrName, fontDesc->lpstrName);
     
    464463  if ( (this==0) || (ppvObject==0) )
    465464    return E_INVALIDARG;
    466  
     465
    467466  /*
    468467   * Initialize the return parameter.
    469468   */
    470469  *ppvObject = 0;
    471  
     470
    472471  /*
    473472   * Compare the riid with the interface IDs implemented by this object.
    474473   */
    475   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
     474  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
    476475  {
    477476    *ppvObject = (IFont*)this;
    478477  }
    479   else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0) 
     478  else if (memcmp(&IID_IFont, riid, sizeof(IID_IFont)) == 0)
    480479  {
    481480    *ppvObject = (IFont*)this;
    482481  }
    483   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
     482  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
    484483  {
    485484    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    486485  }
    487   else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0) 
     486  else if (memcmp(&IID_IFontDisp, riid, sizeof(IID_IFontDisp)) == 0)
    488487  {
    489488    *ppvObject = (IDispatch*)&(this->lpvtbl2);
    490489  }
    491   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
     490  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    492491  {
    493492    *ppvObject = (IPersistStream*)&(this->lpvtbl3);
    494493  }
    495494  else if (memcmp(&IID_IConnectionPointContainer, riid,
    496                   sizeof(IID_IConnectionPointContainer)) == 0) 
     495                  sizeof(IID_IConnectionPointContainer)) == 0)
    497496  {
    498497    *ppvObject = (IPersistStream*)&(this->lpvtbl4);
    499498  }
    500  
     499
    501500  /*
    502501   * Check that we obtained an interface.
     
    507506    return E_NOINTERFACE;
    508507  }
    509  
     508
    510509  /*
    511510   * Query Interface always increases the reference count by one when it is
     
    514513  OLEFontImpl_AddRef((IFont*)this);
    515514
    516   return S_OK;;
    517 }
    518        
     515  return S_OK;
     516}
     517
    519518/************************************************************************
    520519 * OLEFontImpl_AddRef (IUnknown)
     
    522521 * See Windows documentation for more details on IUnknown methods.
    523522 */
    524 ULONG WINAPI OLEFontImpl_AddRef( 
     523ULONG WINAPI OLEFontImpl_AddRef(
    525524  IFont* iface)
    526525{
     
    531530  return this->ref;
    532531}
    533        
     532
    534533/************************************************************************
    535534 * OLEFontImpl_Release (IUnknown)
     
    537536 * See Windows documentation for more details on IUnknown methods.
    538537 */
    539 ULONG WINAPI OLEFontImpl_Release( 
     538ULONG WINAPI OLEFontImpl_Release(
    540539      IFont* iface)
    541540{
     
    557556    return 0;
    558557  }
    559  
     558
    560559  return this->ref;
    561560}
    562        
     561
    563562/************************************************************************
    564563 * OLEFontImpl_get_Name (IFont)
     
    567566 */
    568567static HRESULT WINAPI OLEFontImpl_get_Name(
    569   IFont*  iface, 
     568  IFont*  iface,
    570569  BSTR* pname)
    571570{
     
    592591 */
    593592static HRESULT WINAPI OLEFontImpl_put_Name(
    594   IFont* iface, 
     593  IFont* iface,
    595594  BSTR name)
    596595{
     
    601600  {
    602601    this->description.lpstrName = HeapAlloc(GetProcessHeap(),
    603                                             0, 
     602                                            0,
    604603                                            (lstrlenW(name)+1) * sizeof(WCHAR));
    605604  }
     
    607606  {
    608607    this->description.lpstrName = HeapReAlloc(GetProcessHeap(),
    609                                               0, 
     608                                              0,
    610609                                              this->description.lpstrName,
    611610                                              (lstrlenW(name)+1) * sizeof(WCHAR));
     
    627626 */
    628627static HRESULT WINAPI OLEFontImpl_get_Size(
    629   IFont* iface, 
     628  IFont* iface,
    630629  CY*    psize)
    631630{
     
    651650 */
    652651static HRESULT WINAPI OLEFontImpl_put_Size(
    653   IFont* iface, 
     652  IFont* iface,
    654653  CY     size)
    655654{
     
    669668 */
    670669static HRESULT WINAPI OLEFontImpl_get_Bold(
    671   IFont*  iface, 
     670  IFont*  iface,
    672671  BOOL* pbold)
    673672{
     
    708707 */
    709708static HRESULT WINAPI OLEFontImpl_get_Italic(
    710   IFont*  iface, 
     709  IFont*  iface,
    711710  BOOL* pitalic)
    712711{
     
    730729 */
    731730static HRESULT WINAPI OLEFontImpl_put_Italic(
    732   IFont* iface, 
     731  IFont* iface,
    733732  BOOL italic)
    734733{
     
    748747 */
    749748static HRESULT WINAPI OLEFontImpl_get_Underline(
    750   IFont*  iface, 
     749  IFont*  iface,
    751750  BOOL* punderline)
    752751{
     
    789788 */
    790789static HRESULT WINAPI OLEFontImpl_get_Strikethrough(
    791   IFont*  iface, 
     790  IFont*  iface,
    792791  BOOL* pstrikethrough)
    793792{
     
    812811 */
    813812static HRESULT WINAPI OLEFontImpl_put_Strikethrough(
    814  IFont* iface, 
     813 IFont* iface,
    815814 BOOL strikethrough)
    816815{
     
    830829 */
    831830static HRESULT WINAPI OLEFontImpl_get_Weight(
    832   IFont* iface, 
     831  IFont* iface,
    833832  short* pweight)
    834833{
     
    853852 */
    854853static HRESULT WINAPI OLEFontImpl_put_Weight(
    855   IFont* iface, 
     854  IFont* iface,
    856855  short  weight)
    857856{
     
    871870 */
    872871static HRESULT WINAPI OLEFontImpl_get_Charset(
    873   IFont* iface, 
     872  IFont* iface,
    874873  short* pcharset)
    875874{
     
    894893 */
    895894static HRESULT WINAPI OLEFontImpl_put_Charset(
    896   IFont* iface, 
     895  IFont* iface,
    897896  short charset)
    898897{
     
    928927    INT      fontHeight;
    929928    CY       cySize;
    930    
     929
    931930    /*
    932931     * The height of the font returned by the get_Size property is the
     
    959958
    960959  *phfont = this->gdiFont;
    961   TRACE("Returning %08x\n", *phfont);
     960  TRACE("Returning %p\n", *phfont);
    962961  return S_OK;
    963962}
     
    10011000        (1+strlenW(this->description.lpstrName))*2
    10021001  );
     1002  strcpyW(newObject->description.lpstrName, this->description.lpstrName);
    10031003  /* We need to clone the HFONT too. This is just cut & paste from above */
    10041004  IFont_get_Size(iface, &cySize);
     
    10391039 */
    10401040static HRESULT WINAPI OLEFontImpl_IsEqual(
    1041   IFont* iface, 
     1041  IFont* iface,
    10421042  IFont* pFontOther)
    10431043{
     
    10711071 */
    10721072static HRESULT      WINAPI OLEFontImpl_QueryTextMetrics(
    1073   IFont*         iface, 
     1073  IFont*         iface,
    10741074  TEXTMETRICOLE* ptm)
    10751075{
     
    10841084 */
    10851085static HRESULT WINAPI OLEFontImpl_AddRefHfont(
    1086   IFont*  iface, 
     1086  IFont*  iface,
    10871087  HFONT hfont)
    10881088{
    10891089  _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);
    10911091
    10921092  if ( (hfont == 0) ||
     
    11091109{
    11101110  _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);
    11121112
    11131113  if ( (hfont == 0) ||
     
    11231123  {
    11241124    DeleteObject(this->gdiFont);
    1125     this->gdiFont = 0; 
     1125    this->gdiFont = 0;
    11261126  }
    11271127
     
    11391139{
    11401140  _ICOM_THIS(OLEFontImpl, iface);
    1141   FIXME("(%p)->(%08x): Stub\n", this, hdc);
     1141  FIXME("(%p)->(%p): Stub\n", this, hdc);
    11421142  return E_NOTIMPL;
    11431143}
     
    11901190 */
    11911191static HRESULT WINAPI OLEFontImpl_GetTypeInfoCount(
    1192   IDispatch*    iface, 
     1192  IDispatch*    iface,
    11931193  unsigned int* pctinfo)
    11941194{
     
    12051205 */
    12061206static HRESULT WINAPI OLEFontImpl_GetTypeInfo(
    1207   IDispatch*  iface, 
     1207  IDispatch*  iface,
    12081208  UINT      iTInfo,
    1209   LCID        lcid, 
     1209  LCID        lcid,
    12101210  ITypeInfo** ppTInfo)
    12111211{
     
    12231223static HRESULT WINAPI OLEFontImpl_GetIDsOfNames(
    12241224  IDispatch*  iface,
    1225   REFIID      riid, 
    1226   LPOLESTR* rgszNames, 
    1227   UINT      cNames, 
     1225  REFIID      riid,
     1226  LPOLESTR* rgszNames,
     1227  UINT      cNames,
    12281228  LCID        lcid,
    12291229  DISPID*     rgDispId)
     
    12421242static HRESULT WINAPI OLEFontImpl_Invoke(
    12431243  IDispatch*  iface,
    1244   DISPID      dispIdMember, 
    1245   REFIID      riid, 
    1246   LCID        lcid, 
     1244  DISPID      dispIdMember,
     1245  REFIID      riid,
     1246  LCID        lcid,
    12471247  WORD        wFlags,
    12481248  DISPPARAMS* pDispParams,
    1249   VARIANT*    pVarResult, 
     1249  VARIANT*    pVarResult,
    12501250  EXCEPINFO*  pExepInfo,
    12511251  UINT*     puArgErr)
     
    13051305 */
    13061306static HRESULT WINAPI OLEFontImpl_GetClassID(
    1307   IPersistStream* iface, 
     1307  IPersistStream* iface,
    13081308  CLSID*                pClassID)
    13091309{
     
    13601360
    13611361  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    1362  
     1362
    13631363  /*
    13641364   * Read the version byte
     
    13891389  this->description.fStrikethrough = (bAttributes & FONTPERSIST_STRIKETHROUGH) != 0;
    13901390  this->description.fUnderline     = (bAttributes & FONTPERSIST_UNDERLINE) != 0;
    1391    
     1391
    13921392  /*
    13931393   * Weight
     
    14281428  MultiByteToWideChar( CP_ACP, 0, readBuffer, bStringSize, this->description.lpstrName, len );
    14291429  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;
    14301434
    14311435  return S_OK;
     
    14471451  BYTE  bAttributes;
    14481452  BYTE  bStringSize;
    1449  
     1453
    14501454  _ICOM_THIS_From_IPersistStream(OLEFontImpl, iface);
    14511455
     
    14761480  if (this->description.fStrikethrough)
    14771481    bAttributes |= FONTPERSIST_STRIKETHROUGH;
    1478  
     1482
    14791483  if (this->description.fUnderline)
    14801484    bAttributes |= FONTPERSIST_UNDERLINE;
     
    14841488  if (cbWritten!=1)
    14851489    return E_FAIL;
    1486  
     1490
    14871491  /*
    14881492   * Weight
     
    16521656} IClassFactoryImpl;
    16531657
    1654 static HRESULT WINAPI 
     1658static HRESULT WINAPI
    16551659SFCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
    16561660        ICOM_THIS(IClassFactoryImpl,iface);
  • trunk/src/oleaut32/olepicture.c

    r8450 r9400  
    3838#include "config.h"
    3939
    40 #include <unistd.h>
     40#ifdef HAVE_UNISTD_H
     41# include <unistd.h>
     42#endif
    4143#include <stdio.h>
    4244#include <string.h>
     
    5860#ifdef HAVE_LIBJPEG
    5961/* 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
    6164#define UINT16 JPEG_UINT16
    6265#ifdef HAVE_JPEGLIB_H
     
    8891  /* We own the object and must destroy it ourselves */
    8992    BOOL fOwn;
    90  
     93
    9194  /* Picture description */
    9295    PICTDESC desc;
     
    104107    BOOL keepOrigFormat;
    105108    HDC hDCCur;
     109
     110  /* data */
     111    void* data;
     112    int datalen;
    106113} OLEPictureImpl;
    107114
     
    132139  HDC hdcRef;
    133140
    134   TRACE("bitmap handle %08x\n", This->desc.u.bmp.hbitmap);
     141  TRACE("bitmap handle %p\n", This->desc.u.bmp.hbitmap);
    135142  if(GetObjectA(This->desc.u.bmp.hbitmap, sizeof(bm), &bm) != sizeof(bm)) {
    136143    ERR("GetObject fails\n");
     
    168175   * Allocate space for the object.
    169176   */
    170   newObject = HeapAlloc(GetProcessHeap(), 0, sizeof(OLEPictureImpl));
     177  newObject = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(OLEPictureImpl));
    171178
    172179  if (newObject==0)
    173180    return newObject;
    174  
     181
    175182  /*
    176183   * Initialize the virtual function table.
     
    184191
    185192  /*
    186    * Start with one reference count. The caller of this function 
     193   * Start with one reference count. The caller of this function
    187194   * must release the interface pointer when it is done.
    188195   */
     
    208215
    209216      case PICTYPE_METAFILE:
    210         TRACE("metafile handle %08x\n", pictDesc->u.wmf.hmeta);
     217        TRACE("metafile handle %p\n", pictDesc->u.wmf.hmeta);
    211218        newObject->himetricWidth = pictDesc->u.wmf.xExt;
    212219        newObject->himetricHeight = pictDesc->u.wmf.yExt;
     
    223230      newObject->desc.picType = PICTYPE_UNINITIALIZED;
    224231  }
    225    
     232
    226233  TRACE("returning %p\n", newObject);
    227234  return newObject;
     
    235242 * this object.  */
    236243static void OLEPictureImpl_Destroy(OLEPictureImpl* Obj)
    237 { 
     244{
    238245  TRACE("(%p)\n", Obj);
    239246
     
    257264    }
    258265  }
     266  if (Obj->data) HeapFree(GetProcessHeap(), 0, Obj->data);
    259267  HeapFree(GetProcessHeap(), 0, Obj);
    260268}
     
    280288  if ( (This==0) || (ppvObject==0) )
    281289    return E_INVALIDARG;
    282  
     290
    283291  /*
    284292   * Initialize the return parameter.
    285293   */
    286294  *ppvObject = 0;
    287  
     295
    288296  /*
    289297   * Compare the riid with the interface IDs implemented by this object.
    290298   */
    291   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
     299  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
    292300  {
    293301    *ppvObject = (IPicture*)This;
    294302  }
    295   else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0) 
     303  else if (memcmp(&IID_IPicture, riid, sizeof(IID_IPicture)) == 0)
    296304  {
    297305    *ppvObject = (IPicture*)This;
    298306  }
    299   else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0) 
     307  else if (memcmp(&IID_IDispatch, riid, sizeof(IID_IDispatch)) == 0)
    300308  {
    301309    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    302310  }
    303   else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0) 
     311  else if (memcmp(&IID_IPictureDisp, riid, sizeof(IID_IPictureDisp)) == 0)
    304312  {
    305313    *ppvObject = (IDispatch*)&(This->lpvtbl2);
    306314  }
    307   else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0) 
     315  else if (memcmp(&IID_IPersistStream, riid, sizeof(IID_IPersistStream)) == 0)
    308316  {
    309317  *ppvObject = (IPersistStream*)&(This->lpvtbl3);
    310318  }
    311   else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0) 
     319  else if (memcmp(&IID_IConnectionPointContainer, riid, sizeof(IID_IConnectionPointContainer)) == 0)
    312320  {
    313321  *ppvObject = (IConnectionPointContainer*)&(This->lpvtbl4);
     
    321329    return E_NOINTERFACE;
    322330  }
    323  
     331
    324332  /*
    325333   * Query Interface always increases the reference count by one when it is
     
    328336  OLEPictureImpl_AddRef((IPicture*)This);
    329337
    330   return S_OK;;
     338  return S_OK;
    331339}
    332340/***********************************************************************
     
    360368 * See Windows documentation for more details on IUnknown methods.
    361369 */
    362 static ULONG WINAPI OLEPictureImpl_AddRef( 
     370static ULONG WINAPI OLEPictureImpl_AddRef(
    363371  IPicture* iface)
    364372{
     
    369377  return This->ref;
    370378}
    371        
     379
    372380/************************************************************************
    373381 * OLEPictureImpl_Release (IUnknown)
     
    375383 * See Windows documentation for more details on IUnknown methods.
    376384 */
    377 static ULONG WINAPI OLEPictureImpl_Release( 
     385static ULONG WINAPI OLEPictureImpl_Release(
    378386      IPicture* iface)
    379387{
     
    395403    return 0;
    396404  }
    397  
     405
    398406  return This->ref;
    399407}
     
    402410/************************************************************************
    403411 * OLEPictureImpl_get_Handle
    404  */ 
     412 */
    405413static HRESULT WINAPI OLEPictureImpl_get_Handle(IPicture *iface,
    406414                                                OLE_HANDLE *phandle)
     
    410418  switch(This->desc.picType) {
    411419  case PICTYPE_BITMAP:
    412     *phandle = This->desc.u.bmp.hbitmap;
     420    *phandle = (OLE_HANDLE)This->desc.u.bmp.hbitmap;
    413421    break;
    414422  case PICTYPE_METAFILE:
    415     *phandle = This->desc.u.wmf.hmeta;
     423    *phandle = (OLE_HANDLE)This->desc.u.wmf.hmeta;
    416424    break;
    417425  case PICTYPE_ICON:
    418     *phandle = This->desc.u.icon.hicon;
     426    *phandle = (OLE_HANDLE)This->desc.u.icon.hicon;
    419427    break;
    420428  case PICTYPE_ENHMETAFILE:
    421     *phandle = This->desc.u.emf.hemf;
     429    *phandle = (OLE_HANDLE)This->desc.u.emf.hemf;
    422430    break;
    423431  default:
     
    431439/************************************************************************
    432440 * OLEPictureImpl_get_hPal
    433  */ 
     441 */
    434442static HRESULT WINAPI OLEPictureImpl_get_hPal(IPicture *iface,
    435443                                              OLE_HANDLE *phandle)
     
    442450/************************************************************************
    443451 * OLEPictureImpl_get_Type
    444  */ 
     452 */
    445453static HRESULT WINAPI OLEPictureImpl_get_Type(IPicture *iface,
    446454                                              short *ptype)
     
    454462/************************************************************************
    455463 * OLEPictureImpl_get_Width
    456  */ 
     464 */
    457465static HRESULT WINAPI OLEPictureImpl_get_Width(IPicture *iface,
    458466                                               OLE_XSIZE_HIMETRIC *pwidth)
     
    466474/************************************************************************
    467475 * OLEPictureImpl_get_Height
    468  */ 
     476 */
    469477static HRESULT WINAPI OLEPictureImpl_get_Height(IPicture *iface,
    470478                                                OLE_YSIZE_HIMETRIC *pheight)
     
    478486/************************************************************************
    479487 * OLEPictureImpl_Render
    480  */ 
     488 */
    481489static HRESULT WINAPI OLEPictureImpl_Render(IPicture *iface, HDC hdc,
    482490                                            long x, long y, long cx, long cy,
     
    488496{
    489497  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",
    491499        This, hdc, x, y, cx, cy, xSrc, ySrc, cxSrc, cySrc, prcWBounds);
    492500  if(prcWBounds)
     
    540548/************************************************************************
    541549 * OLEPictureImpl_set_hPal
    542  */ 
     550 */
    543551static HRESULT WINAPI OLEPictureImpl_set_hPal(IPicture *iface,
    544552                                              OLE_HANDLE hpal)
     
    552560/************************************************************************
    553561 * OLEPictureImpl_get_CurDC
    554  */ 
     562 */
    555563static HRESULT WINAPI OLEPictureImpl_get_CurDC(IPicture *iface,
    556564                                               HDC *phdc)
    557565{
    558566  ICOM_THIS(OLEPictureImpl, iface);
    559   TRACE("(%p), returning %x\n", This, This->hDCCur);
     567  TRACE("(%p), returning %p\n", This, This->hDCCur);
    560568  if (phdc) *phdc = This->hDCCur;
    561569  return S_OK;
     
    564572/************************************************************************
    565573 * OLEPictureImpl_SelectPicture
    566  */ 
     574 */
    567575static HRESULT WINAPI OLEPictureImpl_SelectPicture(IPicture *iface,
    568576                                                   HDC hdcIn,
     
    571579{
    572580  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);
    574582  if (This->desc.picType == PICTYPE_BITMAP) {
    575583      SelectObject(hdcIn,This->desc.u.bmp.hbitmap);
     
    579587      This->hDCCur = hdcIn;
    580588      if (phbmpOut)
    581           *phbmpOut = This->desc.u.bmp.hbitmap;
     589          *phbmpOut = (OLE_HANDLE)This->desc.u.bmp.hbitmap;
    582590      return S_OK;
    583591  } else {
     
    589597/************************************************************************
    590598 * OLEPictureImpl_get_KeepOriginalFormat
    591  */ 
     599 */
    592600static HRESULT WINAPI OLEPictureImpl_get_KeepOriginalFormat(IPicture *iface,
    593601                                                            BOOL *pfKeep)
     
    603611/************************************************************************
    604612 * OLEPictureImpl_put_KeepOriginalFormat
    605  */ 
     613 */
    606614static HRESULT WINAPI OLEPictureImpl_put_KeepOriginalFormat(IPicture *iface,
    607615                                                            BOOL keep)
     
    616624/************************************************************************
    617625 * OLEPictureImpl_PictureChanged
    618  */ 
     626 */
    619627static HRESULT WINAPI OLEPictureImpl_PictureChanged(IPicture *iface)
    620628{
     
    627635/************************************************************************
    628636 * OLEPictureImpl_SaveAsFile
    629  */ 
     637 */
    630638static HRESULT WINAPI OLEPictureImpl_SaveAsFile(IPicture *iface,
    631639                                                IStream *pstream,
     
    634642{
    635643  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);
    638646}
    639647
    640648/************************************************************************
    641649 * OLEPictureImpl_get_Attributes
    642  */ 
     650 */
    643651static HRESULT WINAPI OLEPictureImpl_get_Attributes(IPicture *iface,
    644652                                                    DWORD *pdwAttr)
     
    704712  ICOM_THIS_From_IConnectionPointContainer(OLEPictureImpl, iface);
    705713  TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppCP);
    706   if (!ppCP) 
     714  if (!ppCP)
    707715      return E_POINTER;
    708716  *ppCP = NULL;
     
    824832  }
    825833  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];
    827836  while (xread < header[1]) {
    828     ULONG nread; 
     837    ULONG nread;
    829838    hr = IStream_Read(pStm,xbuf+xread,header[1]-xread,&nread);
    830839    xread+=nread;
     
    9981007    break;
    9991008  }
    1000   HeapFree(GetProcessHeap(),0,xbuf);
    10011009
    10021010  /* FIXME: this notify is not really documented */
     
    10721080 */
    10731081static HRESULT WINAPI OLEPictureImpl_GetTypeInfoCount(
    1074   IDispatch*    iface, 
     1082  IDispatch*    iface,
    10751083  unsigned int* pctinfo)
    10761084{
     
    10861094 */
    10871095static HRESULT WINAPI OLEPictureImpl_GetTypeInfo(
    1088   IDispatch*  iface, 
     1096  IDispatch*  iface,
    10891097  UINT      iTInfo,
    1090   LCID        lcid, 
     1098  LCID        lcid,
    10911099  ITypeInfo** ppTInfo)
    10921100{
     
    11031111static HRESULT WINAPI OLEPictureImpl_GetIDsOfNames(
    11041112  IDispatch*  iface,
    1105   REFIID      riid, 
    1106   LPOLESTR* rgszNames, 
    1107   UINT      cNames, 
     1113  REFIID      riid,
     1114  LPOLESTR* rgszNames,
     1115  UINT      cNames,
    11081116  LCID        lcid,
    11091117  DISPID*     rgDispId)
     
    11211129static HRESULT WINAPI OLEPictureImpl_Invoke(
    11221130  IDispatch*  iface,
    1123   DISPID      dispIdMember, 
    1124   REFIID      riid, 
    1125   LCID        lcid, 
     1131  DISPID      dispIdMember,
     1132  REFIID      riid,
     1133  LCID        lcid,
    11261134  WORD        wFlags,
    11271135  DISPPARAMS* pDispParams,
    1128   VARIANT*    pVarResult, 
     1136  VARIANT*    pVarResult,
    11291137  EXCEPINFO*  pExepInfo,
    11301138  UINT*     puArgErr)
     
    12711279
    12721280/***********************************************************************
    1273  * OleLoadPictureEx (OLEAUT32.425)
     1281 * OleLoadPictureEx (OLEAUT32.401)
    12741282 */
    12751283HRESULT 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  
    6666"Thursday", "Friday", "Saturday", NULL};
    6767
    68 /* those three vars are useless, and not even initialized, so 
     68/* those three vars are useless, and not even initialized, so
    6969 * I'd rather remove them all (EPP)
    7070 */
    71 int     DateStyle; 
     71int     DateStyle;
    7272bool    EuroDates;
    7373int     CTimeZone;
     
    8080#define UTIME_MAXDAY (18)
    8181
     82/* Assumes month in 1..12. Note tm_mon is 0..11 */
    8283#define IS_VALID_UTIME(y,m,d) (((y > UTIME_MINYEAR) \
    8384 || ((y == UTIME_MINYEAR) && ((m > UTIME_MINMONTH) \
     
    601602                                                printf("DecodeDateTime- month field %s value is %d\n", field[i], val);
    602603#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;
    604606                                                break;
    605607
     
    681683                tm->tm_hour += 12;
    682684
     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
    683694#ifdef DATEDEBUG
    684695        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);
    686697        printf(" %02d:%02d:%02d\n", tm->tm_hour, tm->tm_min, tm->tm_sec);
    687698#endif
     
    702713                        return -1;
    703714
    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))
    705716                {
    706717                        /* FIXME: The code below is not correct */
     
    910921                                        printf("DecodeDate- month field %s value is %d\n", field[i], val);
    911922#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;
    913925                                        break;
    914926
     
    10761088#endif
    10771089                *tmask = DTK_M(MONTH);
    1078                 tm->tm_mon = val;
     1090        /* tm_mon is 0..11 */
     1091                tm->tm_mon = val-1;
    10791092
    10801093                /* no year and EuroDates enabled? then could be day */
     
    10981111#endif
    10991112                *tmask = DTK_M(MONTH);
    1100                 tm->tm_mon = val;
     1113        /* tm_mon is 0..11 */
     1114                tm->tm_mon = val-1;
    11011115
    11021116        }
     
    11501164                tm->tm_mday = atoi(str + 6);
    11511165                *(str + 6) = '\0';
    1152                 tm->tm_mon = atoi(str + 4);
     1166                tm->tm_mon = atoi(str + 4) - 1;  /* tm_mon is 0..11 */
    11531167                *(str + 4) = '\0';
    11541168                tm->tm_year = atoi(str + 0);
     
    11821196                        tm->tm_mday = atoi(str + 4);
    11831197                        *(str + 4) = '\0';
    1184                         tm->tm_mon = atoi(str + 2);
     1198                        tm->tm_mon = atoi(str + 2) - 1; /* tm_mon is 0..11 */
    11851199                        *(str + 2) = '\0';
    11861200                        tm->tm_year = atoi(str + 0);
     
    13311345        return NULL;
    13321346}
    1333 
    1334 
    1335 
  • trunk/src/oleaut32/safearray.c

    r8450 r9400  
    2525#define WINE_LARGE_INTEGER
    2626#include "oleaut32.h"
    27 
    2827#endif
    2928
     
    4241
    4342/* Locally used methods */
    44 static INT 
     43static INT
    4544endOfDim(LONG *coor, SAFEARRAYBOUND *mat, LONG dim, LONG realDim);
    4645
    47 static ULONG   
     46static ULONG
    4847calcDisplacement(LONG *coor, SAFEARRAYBOUND *mat, LONG dim);
    4948
    50 static BOOL 
     49static BOOL
    5150isPointer(USHORT feature);
    5251
    53 static INT   
     52static INT
    5453getFeatures(VARTYPE vt);
    5554
    56 static BOOL 
     55static BOOL
    5756validCoordinate(LONG *coor, SAFEARRAY *psa);
    5857
    59 static BOOL 
     58static BOOL
    6059resizeSafeArray(SAFEARRAY *psa, LONG lDelta);
    6160
    62 static BOOL 
     61static BOOL
    6362validArg(SAFEARRAY *psa);
    6463
    65 static ULONG   
     64static ULONG
    6665getArraySize(SAFEARRAY *psa);
    6766
    68 static HRESULT 
     67static HRESULT
    6968duplicateData(SAFEARRAY *psa, SAFEARRAY **ppsaOut);
    7069
     
    129128 * Allocate the appropriate amount of memory for the SafeArray descriptor
    130129 */
    131 HRESULT WINAPI SafeArrayAllocDescriptor( 
    132   UINT    cDims, 
    133   SAFEARRAY **ppsaOut) 
     130HRESULT WINAPI SafeArrayAllocDescriptor(
     131  UINT    cDims,
     132  SAFEARRAY **ppsaOut)
    134133{
    135134  SAFEARRAYBOUND *sab;
     
    141140
    142141  /* Allocate memory for SAFEARRAY struc */
    143   if(( (*ppsaOut)=HeapAlloc( 
     142  if(( (*ppsaOut)=HeapAlloc(
    144143        GetProcessHeap(), HEAP_ZERO_MEMORY, allocSize)) == NULL){
    145144    return(E_UNEXPECTED);
     
    151150
    152151/*************************************************************************
    153  *              SafeArrayAllocDescriptorEx (OLEAUT32.429)
     152 *              SafeArrayAllocDescriptorEx (OLEAUT32.41)
    154153 * Allocate the appropriate amount of memory for the SafeArray descriptor
    155154 *
     
    158157 * The MSDN documentation on this doesn't tell us much.
    159158 */
    160 HRESULT WINAPI SafeArrayAllocDescriptorEx( 
     159HRESULT WINAPI SafeArrayAllocDescriptorEx(
    161160  VARTYPE vt,
    162   UINT    cDims, 
    163   SAFEARRAY **ppsaOut) 
     161  UINT    cDims,
     162  SAFEARRAY **ppsaOut)
    164163{
    165164  if ( (vt >= LAST_VARTYPE) ||
     
    175174 */
    176175HRESULT WINAPI SafeArrayAllocData(
    177   SAFEARRAY *psa) 
     176  SAFEARRAY *psa)
    178177{
    179178  ULONG  ulWholeArraySize;   /* to store the size of the whole thing */
    180179
    181   if(! validArg(psa)) 
     180  if(! validArg(psa))
    182181    return E_INVALIDARG;
    183182
     
    185184
    186185  /* Allocate memory for the data itself */
    187   if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 
     186  if((psa->pvData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
    188187        psa->cbElements*ulWholeArraySize)) == NULL)
    189188    return(E_UNEXPECTED);
    190189
    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",
    192191    psa->cbElements*ulWholeArraySize, psa->pvData, ulWholeArraySize);
    193192
     
    197196/*************************************************************************
    198197 *              SafeArrayCreate (OLEAUT32.15)
    199  * Create a SafeArray object by encapsulating AllocDescriptor and AllocData 
     198 * Create a SafeArray object by encapsulating AllocDescriptor and AllocData
    200199 */
    201200SAFEARRAY* WINAPI SafeArrayCreate(
    202   VARTYPE        vt, 
    203   UINT         cDims, 
     201  VARTYPE        vt,
     202  UINT         cDims,
    204203  SAFEARRAYBOUND *rgsabound)
    205204{
     
    217216    return NULL;
    218217
    219   /* setup data members... */ 
     218  /* setup data members... */
    220219  psa->cDims     = cDims;
    221220  psa->fFeatures = getFeatures(vt);
     
    230229  }
    231230
    232   /* allocate memory for the data... */ 
     231  /* allocate memory for the data... */
    233232  if( FAILED( hRes = SafeArrayAllocData(psa))) {
    234     SafeArrayDestroyDescriptor(psa); 
     233    SafeArrayDestroyDescriptor(psa);
    235234    ERR("() : Failed to allocate the Safe Array data\n");
    236235    return NULL;
    237236  }
    238237
    239   return(psa); 
     238  return(psa);
    240239}
    241240
     
    248247{
    249248  /* Check for lockness before to free... */
    250   if(psa->cLocks > 0) 
     249  if(psa->cLocks > 0)
    251250    return DISP_E_ARRAYISLOCKED;
    252251
    253252  /* The array is unlocked, then, deallocate memory */
    254   if(HeapFree( GetProcessHeap(), 0, psa) == FALSE) 
     253  if(HeapFree( GetProcessHeap(), 0, psa) == FALSE)
    255254    return E_UNEXPECTED;
    256  
     255
    257256  return(S_OK);
    258257}
     
    264263 *
    265264 * 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
    268267 */
    269268HRESULT WINAPI SafeArrayLock(
    270269  SAFEARRAY *psa)
    271270{
    272   if(! validArg(psa))     
     271  if(! validArg(psa))
    273272    return E_INVALIDARG;
    274273
     
    285284  SAFEARRAY *psa)
    286285{
    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)
    291290    psa->cLocks--;
    292291
     
    300299 */
    301300HRESULT WINAPI SafeArrayPutElement(
    302   SAFEARRAY *psa, 
    303   LONG      *rgIndices, 
     301  SAFEARRAY *psa,
     302  LONG      *rgIndices,
    304303  void      *pv)
    305304{
    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
    307306                                         the desired one... */
    308307  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    309308
    310309  /* Validate the index given */
    311   if(! validCoordinate(rgIndices, psa)) 
     310  if(! validCoordinate(rgIndices, psa))
    312311    return DISP_E_BADINDEX;
    313312  if(! validArg(psa))
     
    318317    /* Figure out the number of items to skip */
    319318    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    320  
     319
    321320    /* Figure out the number of byte to skip ... */
    322321    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    323  
     322
    324323    if(isPointer(psa->fFeatures)) { /* increment ref count for this pointer */
    325324
    326       *((PVOID*)elementStorageAddress) = *(PVOID*)pv; 
     325      *((PVOID*)elementStorageAddress) = *(PVOID*)pv;
    327326      IUnknown_AddRef( *(IUnknown**)pv);
    328327
    329     } else { 
     328    } else {
    330329
    331330      if(psa->fFeatures == FADF_BSTR) { /* Create a new object */
     
    333332        if(pv &&
    334333           ((pbstrReAllocStr = SYSDUPSTRING( (OLECHAR*)pv )) == NULL)) {
    335           SafeArrayUnlock(psa); 
     334          SafeArrayUnlock(psa);
    336335          return E_OUTOFMEMORY;
    337         } else 
     336        } else
    338337          *((BSTR*)elementStorageAddress) = pbstrReAllocStr;
    339338      }
     
    355354
    356355  TRACE("SafeArray: item put at adress %p.\n",elementStorageAddress);
    357   return SafeArrayUnlock(psa); 
     356  return SafeArrayUnlock(psa);
    358357}
    359358
     
    364363 */
    365364HRESULT WINAPI SafeArrayGetElement(
    366   SAFEARRAY *psa, 
    367   LONG      *rgIndices, 
     365  SAFEARRAY *psa,
     366  LONG      *rgIndices,
    368367  void      *pv)
    369368{
    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
    371370                                         the desired one... */
    372371  PVOID elementStorageAddress = NULL; /* Adress to store the data */
    373372
    374   if(! validArg(psa)) 
    375     return E_INVALIDARG;
    376  
     373  if(! validArg(psa))
     374    return E_INVALIDARG;
     375
    377376  if(! validCoordinate(rgIndices, psa)) /* Validate the index given */
    378377    return(DISP_E_BADINDEX);
     
    382381    /* Figure out the number of items to skip */
    383382    stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    384  
     383
    385384    /* Figure out the number of byte to skip ... */
    386385    elementStorageAddress = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    387  
     386
    388387    if( psa->fFeatures == FADF_BSTR) {           /* reallocate the obj */
    389388      BSTR pbstrStoredStr = *(OLECHAR**)elementStorageAddress;
     
    393392        SafeArrayUnlock(psa);
    394393        return E_OUTOFMEMORY;
    395       } else 
    396         *((BSTR*)pv) = pbstrReturnedStr; 
     394      } else
     395        *((BSTR*)pv) = pbstrReturnedStr;
    397396    }
    398397    else if( psa->fFeatures == FADF_VARIANT) {
     
    406405    }
    407406    else if( isPointer(psa->fFeatures) )         /* simply copy the pointer */
    408       *(PVOID*)pv = *((PVOID*)elementStorageAddress); 
     407      *(PVOID*)pv = *((PVOID*)elementStorageAddress);
    409408    else                                         /* copy the bytes */
    410409      memcpy(pv, elementStorageAddress, psa->cbElements );
     
    415414  }
    416415
    417   return( SafeArrayUnlock(psa) ); 
     416  return( SafeArrayUnlock(psa) );
    418417}
    419418
     
    423422 */
    424423HRESULT WINAPI SafeArrayGetUBound(
    425   SAFEARRAY *psa, 
     424  SAFEARRAY *psa,
    426425  UINT    nDim,
    427426  LONG      *plUbound)
    428427{
    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)
    433432    return DISP_E_BADINDEX;
    434433
     
    436435    return DISP_E_BADINDEX;
    437436
    438   *plUbound = psa->rgsabound[nDim-1].lLbound + 
     437  *plUbound = psa->rgsabound[nDim-1].lLbound +
    439438              psa->rgsabound[nDim-1].cElements - 1;
    440439
     
    444443/*************************************************************************
    445444 *              SafeArrayGetLBound (OLEAUT32.20)
    446  * Return the LO bound for a given array dimension 
     445 * Return the LO bound for a given array dimension
    447446 */
    448447HRESULT WINAPI SafeArrayGetLBound(
    449448  SAFEARRAY *psa,
    450   UINT    nDim, 
     449  UINT    nDim,
    451450  LONG      *plLbound)
    452451{
    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)
    457456    return DISP_E_BADINDEX;
    458457
    459458  if(0 == nDim)
    460459    return DISP_E_BADINDEX;
    461  
     460
    462461  *plLbound = psa->rgsabound[nDim-1].lLbound;
    463462  return S_OK;
     
    470469UINT WINAPI SafeArrayGetDim(
    471470  SAFEARRAY * psa)
    472 { 
     471{
    473472  /*
    474473   * A quick test in Windows shows that the behavior here for an invalid
    475474   * pointer is to return 0.
    476475   */
    477   if(! validArg(psa)) 
     476  if(! validArg(psa))
    478477    return 0;
    479478
     
    487486UINT WINAPI SafeArrayGetElemsize(
    488487  SAFEARRAY * psa)
    489 { 
     488{
    490489  /*
    491490   * A quick test in Windows shows that the behavior here for an invalid
    492491   * pointer is to return 0.
    493492   */
    494   if(! validArg(psa)) 
     493  if(! validArg(psa))
    495494    return 0;
    496495
     
    500499/*************************************************************************
    501500 *              SafeArrayAccessData (OLEAUT32.23)
    502  * increment the access count and return the data 
     501 * increment the access count and return the data
    503502 */
    504503HRESULT WINAPI SafeArrayAccessData(
    505   SAFEARRAY *psa, 
     504  SAFEARRAY *psa,
    506505  void      **ppvData)
    507 { 
     506{
    508507  HRESULT hRes;
    509508
    510   if(! validArg(psa)) 
     509  if(! validArg(psa))
    511510    return E_INVALIDARG;
    512511
     
    514513
    515514  switch (hRes) {
    516     case S_OK: 
     515    case S_OK:
    517516      (*ppvData) = psa->pvData;
    518517      break;
     
    521520      return E_INVALIDARG;
    522521  }
    523  
     522
    524523  return S_OK;
    525524}
     
    532531HRESULT WINAPI SafeArrayUnaccessData(
    533532  SAFEARRAY * psa)
    534 { 
    535   if(! validArg(psa)) 
     533{
     534  if(! validArg(psa))
    536535    return E_INVALIDARG;
    537536
     
    539538}
    540539
    541 /************************************************************************ 
     540/************************************************************************
    542541 *              SafeArrayPtrOfIndex (OLEAUT32.148)
    543542 * Return a pointer to the element at rgIndices
    544543 */
    545544HRESULT WINAPI SafeArrayPtrOfIndex(
    546   SAFEARRAY *psa, 
    547   LONG      *rgIndices, 
     545  SAFEARRAY *psa,
     546  LONG      *rgIndices,
    548547  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
    551550                                         the desired one... */
    552551
    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))
    557556    return DISP_E_BADINDEX;
    558557
     
    563562  /* Figure out the number of items to skip */
    564563  stepCountInSAData = calcDisplacement(rgIndices, psa->rgsabound, psa->cDims);
    565  
     564
    566565  *ppvData = (char *) psa->pvData+(stepCountInSAData*psa->cbElements);
    567566
     
    569568}
    570569
    571 /************************************************************************ 
     570/************************************************************************
    572571 *              SafeArrayDestroyData (OLEAUT32.39)
    573572 * Frees the memory data bloc
     
    575574HRESULT WINAPI SafeArrayDestroyData(
    576575  SAFEARRAY *psa)
    577 { 
     576{
    578577  HRESULT  hRes;
    579578  ULONG    ulWholeArraySize; /* count spot in array  */
    580579  ULONG    ulDataIter;       /* to iterate the data space */
    581580
    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)
    586585    return DISP_E_ARRAYISLOCKED;
    587586
     
    592591
    593592    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)
    597596        IUnknown_Release(punk);
    598597    }
     
    605604      bstr = *(BSTR*)((char *) psa->pvData+(ulDataIter*(psa->cbElements)));
    606605
    607       if( bstr != NULL) 
     606      if( bstr != NULL)
    608607        SysFreeString( bstr );
    609608    }
     
    615614    }
    616615  }
    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
    619618     block since it has been allocated by AllocDescriptor and therefore
    620619     deserve to be freed by DestroyDescriptor */
     
    627626    psa->pvData = NULL;
    628627  }
    629  
     628
    630629  return S_OK;
    631630}
    632631
    633 /************************************************************************ 
     632/************************************************************************
    634633 *              SafeArrayCopyData (OLEAUT32.412)
    635634 * Copy the psaSource's data block into psaTarget if dimension and size
     
    639638  SAFEARRAY *psaSource,
    640639  SAFEARRAY **psaTarget)
    641 { 
     640{
    642641  USHORT   cDimCount;        /* looper */
    643642  LONG     lDelta;           /* looper */
    644   IUnknown *punk;   
     643  IUnknown *punk;
    645644  ULONG    ulWholeArraySize; /* Number of item in SA */
    646645  BSTR   bstr;
    647646
    648   if(! (validArg(psaSource) && validArg(*psaTarget)) ) 
     647  if(! (validArg(psaSource) && validArg(*psaTarget)) )
    649648    return E_INVALIDARG;
    650649
     
    652651    return E_INVALIDARG;
    653652
    654   ulWholeArraySize = getArraySize(psaSource); 
     653  ulWholeArraySize = getArraySize(psaSource);
    655654
    656655  /* The two arrays boundaries must be of same lenght */
    657656  for(cDimCount=0;cDimCount < psaSource->cDims; cDimCount++)
    658     if( psaSource->rgsabound[cDimCount].cElements != 
     657    if( psaSource->rgsabound[cDimCount].cElements !=
    659658      (*psaTarget)->rgsabound[cDimCount].cElements)
    660659      return E_INVALIDARG;
    661660
    662   if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr 
     661  if( isPointer((*psaTarget)->fFeatures) ) {         /* the target contains ptr
    663662                                                        that must be released */
    664663    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
     
    666665        ((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    667666
    668       if( punk != NULL) 
     667      if( punk != NULL)
    669668        IUnknown_Release(punk);
    670669    }
     
    672671  }
    673672  else if( (*psaTarget)->fFeatures & FADF_BSTR) {    /* the target contain BSTR
    674                                                         that must be freed */ 
     673                                                        that must be freed */
    675674    for(lDelta=0;lDelta < ulWholeArraySize; lDelta++) {
    676       bstr = 
     675      bstr =
    677676        *(BSTR*)((char *) (*psaTarget)->pvData + (lDelta * (*psaTarget)->cbElements));
    678677
    679       if( bstr != NULL) 
     678      if( bstr != NULL)
    680679        SysFreeString( bstr );
    681680    }
     
    691690}
    692691
    693 /************************************************************************ 
     692/************************************************************************
    694693 *              SafeArrayDestroy (OLEAUT32.16)
    695694 * Deallocates all memory reserved for the SafeArray
     
    697696HRESULT WINAPI SafeArrayDestroy(
    698697  SAFEARRAY * psa)
    699 { 
     698{
    700699  HRESULT hRes;
    701700
    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)
    706705    return DISP_E_ARRAYISLOCKED;
    707706
     
    713712}
    714713
    715 /************************************************************************ 
     714/************************************************************************
    716715 *              SafeArrayCopy (OLEAUT32.27)
    717716 * Make a dupplicate of a SafeArray
    718717 */
    719718HRESULT WINAPI SafeArrayCopy(
    720   SAFEARRAY *psa, 
     719  SAFEARRAY *psa,
    721720  SAFEARRAY **ppsaOut)
    722 { 
     721{
    723722  HRESULT hRes;
    724723  DWORD   dAllocSize;
    725724  ULONG   ulWholeArraySize; /* size of the thing */
    726725
    727   if(! validArg(psa)) 
     726  if(! validArg(psa))
    728727    return E_INVALIDARG;
    729728
     
    731730
    732731    /* Duplicate the SAFEARRAY struc */
    733     memcpy(*ppsaOut, psa, 
     732    memcpy(*ppsaOut, psa,
    734733            sizeof(*psa)+(sizeof(*(psa->rgsabound))*(psa->cDims-1)));
    735734
     
    738737    /* make sure the new safe array doesn't have the FADF_CREATEVECTOR flag,
    739738       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 */
    743742    ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    744743    dAllocSize = ulWholeArraySize*psa->cbElements;
    745744
    746     (*ppsaOut)->pvData = 
     745    (*ppsaOut)->pvData =
    747746      HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dAllocSize);
    748747    if( (*ppsaOut)->pvData != NULL) {   /* HeapAlloc succeed */
     
    754753        return hRes;
    755754      }
    756        
     755
    757756    } else { /* failed to allocate or dupplicate... */
    758757      SafeArrayDestroyDescriptor(*ppsaOut);
     
    766765}
    767766
    768 /************************************************************************ 
     767/************************************************************************
    769768 *              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
    771770 * SAFEARRAY structure.
    772771 */
    773772SAFEARRAY* WINAPI SafeArrayCreateVector(
    774   VARTYPE vt, 
    775   LONG    lLbound, 
    776   ULONG   cElements) 
    777 { 
     773  VARTYPE vt,
     774  LONG    lLbound,
     775  ULONG   cElements)
     776{
    778777  SAFEARRAY *psa;
    779778
     
    784783
    785784  /* 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,
    788787                      (sizeof(*psa) + (VARTYPE_SIZE[vt] * cElements))))) {
    789788    return NULL;
    790789  }
    791                                                                                
    792   /* setup data members... */ 
     790
     791  /* setup data members... */
    793792  psa->cDims      = 1; /* always and forever */
    794793  psa->fFeatures  = getFeatures(vt) | FADF_CREATEVECTOR;  /* undocumented flag used by Microsoft */
     
    800799  psa->rgsabound[0].lLbound   = lLbound;
    801800
    802   return(psa);                           
    803 } 
    804 
    805 /************************************************************************ 
     801  return(psa);
     802}
     803
     804/************************************************************************
    806805 *              SafeArrayRedim (OLEAUT32.40)
    807806 * Changes the caracteristics of the last dimension of the SafeArray
    808807 */
    809808HRESULT WINAPI SafeArrayRedim(
    810   SAFEARRAY      *psa, 
     809  SAFEARRAY      *psa,
    811810  SAFEARRAYBOUND *psaboundNew)
    812 { 
     811{
    813812  LONG   lDelta;  /* hold difference in size */
    814813  USHORT cDims=1; /* dims counter */
    815814
    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 )
    820819    return DISP_E_ARRAYISLOCKED;
    821820
    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 )
    826825    return E_UNEXPECTED;/* UNDOC error condition */
    827826
     
    837836
    838837  } else /* need to enlarge (lDelta +) reduce (lDelta -) */
    839     if(! resizeSafeArray(psa, lDelta)) 
     838    if(! resizeSafeArray(psa, lDelta))
    840839      return E_UNEXPECTED; /* UNDOC error condition */
    841840
    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
    843842     at array creation time... */
    844843  psa->rgsabound[0].cElements = psaboundNew->cElements;
     
    852851 ************************************************************************/
    853852
    854 /************************************************************************ 
     853/************************************************************************
    855854 * Used to validate the SAFEARRAY type of arg
    856855 */
    857856static BOOL validArg(
    858   SAFEARRAY *psa) 
     857  SAFEARRAY *psa)
    859858{
    860859  SAFEARRAYBOUND *sab;
     
    886885}
    887886
    888 /************************************************************************ 
     887/************************************************************************
    889888 * Used to reallocate memory
    890889 */
    891890static BOOL resizeSafeArray(
    892   SAFEARRAY *psa, 
     891  SAFEARRAY *psa,
    893892  LONG lDelta)
    894893{
    895894  ULONG    ulWholeArraySize;  /* use as multiplicator */
    896   PVOID    pvNewBlock = NULL; 
     895  PVOID    pvNewBlock = NULL;
    897896  IUnknown *punk;
    898897  BSTR   bstr;
     
    905904              punk = *(IUnknown**)
    906905          ((char *) psa->pvData+((ulWholeArraySize+lDelta)*psa->cbElements));
    907        
     906
    908907        if( punk != NULL )
    909908          IUnknown_Release(punk);
     
    926925  if (!(psa->fFeatures & FADF_CREATEVECTOR))
    927926  {
    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
    929928       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
    931930       releasing to the system the unused memory */
    932931
    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)
    935934        return FALSE; /* TODO If we get here it means:
    936935                         SHRINK situation :  we've deleted the undesired
     
    941940  else
    942941  {
    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
    944943       the descriptor in SafeArrayCreateVector function. */
    945944
    946945    if((pvNewBlock = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
    947        ulWholeArraySize * psa->cbElements)) == NULL) 
     946       ulWholeArraySize * psa->cbElements)) == NULL)
    948947        return FALSE;
    949948
     
    955954}
    956955
    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.
    959958 */
    960959static INT getFeatures(
    961   VARTYPE vt) 
     960  VARTYPE vt)
    962961{
    963962  switch(vt) {
     
    970969}
    971970
    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...
    975974 */
    976975static BOOL isPointer(
    977   USHORT feature) 
     976  USHORT feature)
    978977{
    979978  switch(feature) {
     
    984983}
    985984
    986 /************************************************************************ 
    987  * Used to calculate the displacement when accessing or modifying 
     985/************************************************************************
     986 * Used to calculate the displacement when accessing or modifying
    988987 * safearray data set.
    989988 *
     
    995994 */
    996995static ULONG calcDisplacement(
    997   LONG           *coor, 
    998   SAFEARRAYBOUND *mat, 
    999   LONG           dim) 
     996  LONG           *coor,
     997  SAFEARRAYBOUND *mat,
     998  LONG           dim)
    1000999{
    10011000  ULONG res = 0;
    10021001  LONG  iterDim;
    10031002
    1004   for(iterDim=0; iterDim<dim; iterDim++) 
     1003  for(iterDim=0; iterDim<dim; iterDim++)
    10051004    /* 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) *
    10071006            endOfDim(coor, mat, iterDim+1, dim));
    10081007
     
    10111010}
    10121011
    1013 /************************************************************************ 
    1014  * Recursivity agent for calcDisplacement method.  Used within Put and 
     1012/************************************************************************
     1013 * Recursivity agent for calcDisplacement method.  Used within Put and
    10151014 * Get methods.
    10161015 */
    10171016static 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)
    10241023    return 1;
    1025   else 
     1024  else
    10261025    return (endOfDim(coor, mat, dim+1, realDim) * mat[dim].cElements);
    10271026}
    10281027
    10291028
    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
    10321031 * methods.
    10331032 */
    10341033static BOOL validCoordinate(
    1035   LONG      *coor, 
    1036   SAFEARRAY *psa) 
     1034  LONG      *coor,
     1035  SAFEARRAY *psa)
    10371036{
    10381037  INT   iter=0;
     
    10481047    if((hRes = SafeArrayGetUBound(psa, (iter+1), &lUBound)) != S_OK)
    10491048      return FALSE;
    1050  
    1051     if(lLBound > lUBound) 
    1052       return FALSE; 
     1049
     1050    if(lLBound > lUBound)
     1051      return FALSE;
    10531052
    10541053    if((coor[iter] < lLBound) || (coor[iter] > lUBound))
     
    10561055  }
    10571056  return TRUE;
    1058 } 
    1059 
    1060 /************************************************************************ 
     1057}
     1058
     1059/************************************************************************
    10611060 * Method used to calculate the number of cells of the SA
    10621061 */
    10631062static ULONG getArraySize(
    1064   SAFEARRAY *psa) 
    1065 {
    1066   USHORT cCount; 
     1063  SAFEARRAY *psa)
     1064{
     1065  USHORT cCount;
    10671066  ULONG  ulWholeArraySize = 1;
    10681067
     
    10701069    ulWholeArraySize *= psa->rgsabound[cCount].cElements;
    10711070
    1072   return ulWholeArraySize; 
    1073 }
    1074 
    1075 
    1076 /************************************************************************ 
     1071  return ulWholeArraySize;
     1072}
     1073
     1074
     1075/************************************************************************
    10771076 * Method used to handle data space dupplication for Copy32 and CopyData32
    10781077 */
    10791078static HRESULT duplicateData(
    1080   SAFEARRAY *psa, 
    1081   SAFEARRAY **ppsaOut) 
     1079  SAFEARRAY *psa,
     1080  SAFEARRAY **ppsaOut)
    10821081{
    10831082  ULONG    ulWholeArraySize; /* size of the thing */
     
    10851084
    10861085  ulWholeArraySize = getArraySize(psa); /* Number of item in SA */
    1087  
     1086
    10881087  SafeArrayLock(*ppsaOut);
    10891088
    1090   if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment 
     1089  if( isPointer(psa->fFeatures) ) {  /* If datatype is object increment
    10911090                                        object's reference count */
    10921091    IUnknown *punk;
     
    11001099
    11011100    /* Copy the source array data into target array */
    1102     memcpy((*ppsaOut)->pvData, psa->pvData, 
     1101    memcpy((*ppsaOut)->pvData, psa->pvData,
    11031102      ulWholeArraySize*psa->cbElements);
    11041103
    11051104  }
    1106   else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate 
     1105  else if( psa->fFeatures & FADF_BSTR ) { /* if datatype is BSTR allocate
    11071106                                             the BSTR in the new array */
    11081107    BSTR   pbstrReAllocStr = NULL;
     
    11161115      }
    11171116
    1118       *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) = 
     1117      *((BSTR*)((char *) (*ppsaOut)->pvData+(lDelta * psa->cbElements))) =
    11191118        pbstrReAllocStr;
    11201119    }
     
    11311130  else { /* Simply copy the source array data into target array */
    11321131
    1133     memcpy((*ppsaOut)->pvData, psa->pvData, 
     1132    memcpy((*ppsaOut)->pvData, psa->pvData,
    11341133      ulWholeArraySize*psa->cbElements);
    11351134  }
     
    11411140
    11421141
    1143 /************************************************************************ 
    1144  *              SafeArrayGetVarType (OLEAUT32.77)
     1142/************************************************************************
     1143 *              SafeArrayGetVartype (OLEAUT32.77)
    11451144 * Returns the VARTYPE stored in the given safearray
    11461145 */
    1147 HRESULT WINAPI SafeArrayGetVarType(
     1146HRESULT WINAPI SafeArrayGetVartype(
    11481147  SAFEARRAY* psa,
    11491148  VARTYPE*   pvt)
  • trunk/src/oleaut32/stubs.cpp

    r8450 r9400  
    1 /* $Id: stubs.cpp,v 1.15 2002-05-17 10:17:00 sandervl Exp $ */
     1/* $Id: stubs.cpp,v 1.16 2002-11-12 17:07:47 sandervl Exp $ */
    22/*
    33 * Win32 COM/OLE stubs for OS/2
     
    9696}
    9797
    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 }
    10798
    10899//*****************************************************************************
  • trunk/src/oleaut32/tmarshal.c

    r8663 r9400  
    4141#include "typelib.h"
    4242#include "wine/debug.h"
    43 #include "ntddk.h"
     43#include "winternl.h"
    4444
    4545static const WCHAR riidW[5] = {'r','i','i','d',0};
     
    367367
    368368/* how much space do we use on stack in DWORD steps. */
    369 static int const
     369int const
    370370_argsize(DWORD vt) {
    371371    switch (vt) {
  • trunk/src/oleaut32/typelib.c

    r8640 r9400  
    2020 * License along with this library; if not, write to the Free Software
    2121 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22  *                   
     22 *
    2323 * --------------------------------------------------------------------------------------
    2424 * Known problems (2000, Francois Jacques)
    2525 *
    2626 * - 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
    3030 *   its typekind. Pointed structures aren't copied - only the address of the pointers.
    3131 *   So when you release the dispinterface, you delete the vtable-interface structures
    3232 *   as well... fortunately, clean up of structures is not implemented.
    33  * 
     33 *
    3434 * - locale stuff is partially implemented but hasn't been tested.
    3535 *
     
    5050 * -. some methods just return pointers to internal data structures, this is
    5151 *      partly laziness, partly I want to check how windows does it.
    52  * 
     52 *
    5353 */
    5454
    5555#include "config.h"
     56#include "wine/port.h"
    5657
    5758#include <stdlib.h>
     
    7172#include "typelib.h"
    7273#include "wine/debug.h"
    73 #include "ntddk.h"
     74#include "parsedt.h"
    7475
    7576WINE_DEFAULT_DEBUG_CHANNEL(ole);
    7677WINE_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
     86static WORD FromLEWord(WORD p_iVal)
     87{
     88  return (((p_iVal & 0x00FF) << 8) |
     89          ((p_iVal & 0xFF00) >> 8));
     90}
     91
     92
     93static 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
     112static 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
     126static 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
    77143
    78144/****************************************************************************
     
    84150 */
    85151HRESULT WINAPI
    86 QueryPathOfRegTypeLib16(       
     152QueryPathOfRegTypeLib16(
    87153        REFGUID guid,   /* [in] referenced guid */
    88154        WORD wMaj,      /* [in] major version */
     
    119185        return S_OK;
    120186}
    121  
     187
    122188/****************************************************************************
    123189 *              QueryPathOfRegTypeLib   [OLEAUT32.164]
     
    126192 */
    127193HRESULT WINAPI
    128 QueryPathOfRegTypeLib( 
     194QueryPathOfRegTypeLib(
    129195        REFGUID guid,   /* [in] referenced guid */
    130196        WORD wMaj,      /* [in] major version */
     
    160226            "SOFTWARE\\Classes\\Typelib\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\\%d.%d\\%lx\\win32",
    161227            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],
    163229            guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7],
    164230            wMaj,
     
    200266        }
    201267    }
    202        
     268
    203269    if (hr != S_OK)
    204270                TRACE_(typelib)("%s not found\n", szTypeLibKey);
    205        
     271
    206272    return hr;
    207273}
     
    281347    INT index = 1;
    282348    TRACE("(%s,%d,%p)\n",debugstr_w(szFile), regkind, pptLib);
    283    
     349
    284350    if(!SearchPathW(NULL,szFile,NULL,sizeof(szPath)/sizeof(WCHAR),szPath,
    285351                    NULL)) {
     
    288354        pIndexStr = strrchrW(szFile, '\\');
    289355        if(pIndexStr && pIndexStr != szFile && *++pIndexStr != '\0') {
    290             index = wcstol(pIndexStr, NULL, 10);
     356            index = atoiW(pIndexStr);
    291357            memcpy(szFileCopy, szFile,
    292358                   (pIndexStr - szFile - 1) * sizeof(WCHAR));
     
    333399 *              LoadRegTypeLib  [OLEAUT32.162]
    334400 */
    335 HRESULT WINAPI LoadRegTypeLib( 
     401HRESULT WINAPI LoadRegTypeLib(
    336402        REFGUID rguid,          /* [in] referenced guid */
    337403        WORD wVerMajor,         /* [in] major version */
     
    352418
    353419    return res;
    354 }       
     420}
    355421
    356422
    357423/******************************************************************************
    358424 *              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
    360426 * NOTES
    361427 *    Docs: ITypeLib FAR * ptlib
     
    556622/******************************************************************************
    557623 *      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
    559625 * NOTES
    560626 *
     
    569635        LCID lcid,      /* [in] locale id */
    570636        SYSKIND syskind)
    571 {   
     637{
    572638    TRACE("(IID: %s): stub\n",debugstr_guid(libid));
    573639    return S_OK;        /* FIXME: pretend everything is OK */
     
    594660     * to retrieve the "versionForced" info from misc/version.c :(
    595661     * (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");
    597663    switch(GetVersion() & 0x8000ffff)  /* mask off build number */
    598664    {
     
    616682/*======================= ITypeLib implementation =======================*/
    617683
    618 typedef struct tagTLBCustData 
     684typedef struct tagTLBCustData
    619685{
    620686    GUID guid;
     
    649715    UINT ref;
    650716    TLIBATTR LibAttr;            /* guid,lcid,syskind,version,flags */
    651    
     717
    652718    /* strings can be stored in tlb as multibyte strings BUT they are *always*
    653719     * exported to the application as a UNICODE string.
     
    690756                               TLB_REF_INTERNAL for internal refs
    691757                               TLB_REF_NOT_FOUND for broken refs */
    692  
     758
    693759    struct tagTLBRefType * next;
    694760} TLBRefType;
     
    719785    int ctCustData;
    720786    TLBCustData * pCustData;        /* linked list to cust data; */
    721     struct tagTLBFuncDesc * next; 
     787    struct tagTLBFuncDesc * next;
    722788} TLBFuncDesc;
    723789
     
    732798    int ctCustData;
    733799    TLBCustData * pCustData;/* linked list to cust data; */
    734     struct tagTLBVarDesc * next; 
     800    struct tagTLBVarDesc * next;
    735801} TLBVarDesc;
    736802
     
    753819    ITypeLibImpl * pTypeLib;        /* back pointer to typelib */
    754820    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
    756822     * so why should we do it in unicode?
    757823     */
     
    880946}
    881947
    882 static void dump_ELEMDESC(ELEMDESC *edesc) {
     948void dump_ELEMDESC(ELEMDESC *edesc) {
    883949  char buf[200];
    884950  dump_TypeDesc(&edesc->tdesc,buf);
     
    887953  MESSAGE("\t\tu.parmadesc.lpex %p\n",edesc->u.paramdesc.pparamdescex);
    888954}
    889 static void dump_FUNCDESC(FUNCDESC *funcdesc) {
     955void dump_FUNCDESC(FUNCDESC *funcdesc) {
    890956  int i;
    891957  MESSAGE("memid is %08lx\n",funcdesc->memid);
     
    922988  MESSAGE("\twFlags: %x\n", funcdesc->wFuncFlags);
    923989}
    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
     991void dump_IDLDESC(IDLDESC *idl) {
     992  MESSAGE("\t\twIdlflags: %d\n",idl->wIDLFlags);
    1078993}
    1079994
     
    10911006};
    10921007
     1008void 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
     1029static 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}
     1044static void dump_TLBFuncDesc(TLBFuncDesc * pfd)
     1045{
     1046        while (pfd)
     1047        {
     1048          dump_TLBFuncDescOne(pfd);
     1049          pfd = pfd->next;
     1050        };
     1051}
     1052static 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
     1061static 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
     1069static 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
     1088static 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
     1098void 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
     1192static 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
    10931205static void dump_TypeInfo(ITypeInfoImpl * pty)
    10941206{
     
    11031215    dump_TLBVarDesc(pty->varlist);
    11041216    dump_TLBImplType(pty->impltypelist);
     1217}
     1218
     1219void 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);
    11051227}
    11061228#else
     
    11241246#define  dump_TLBFuncDesc(a)
    11251247#define  dump_TypeDesc(a,b)
    1126 #define  dump_Variant(a)
     1248#define  dump_VARDESC(a)
    11271249#define  debugstr_an(a,b) NULL
    11281250#endif
     
    11881310}
    11891311
     1312static 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
     1323static 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
    11901334static void MSFT_ReadGuid( GUID *pGuid, int offset, TLBContext *pcx)
    11911335{
    1192     TRACE_(typelib)("%s\n", debugstr_guid(pGuid));
    1193 
    11941336    if(offset<0 || pcx->pTblDir->pGuidTab.offset <0){
    11951337        memset(pGuid,0, sizeof(GUID));
     
    11971339    }
    11981340    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));
    11991345}
    12001346
     
    12071353    BSTR bstrName = NULL;
    12081354
    1209     MSFT_Read(&niName, sizeof(niName), pcx,
    1210                                 pcx->pTblDir->pNametab.offset+offset);
     1355    MSFT_ReadLEDWords(&niName, sizeof(niName), pcx,
     1356                      pcx->pTblDir->pNametab.offset+offset);
    12111357    niName.namelen &= 0xFF; /* FIXME: correct ? */
    12121358    name=TLB_Alloc((niName.namelen & 0xff) +1);
     
    12421388
    12431389    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);
    12451391    if(length <= 0) return 0;
    12461392    string=TLB_Alloc(length +1);
     
    12681414}
    12691415/*
    1270  * read a value and fill a VARIANT structure 
     1416 * read a value and fill a VARIANT structure
    12711417 */
    12721418static void MSFT_ReadValue( VARIANT * pVar, int offset, TLBContext *pcx )
     
    12811427        return;
    12821428    }
    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 );
    12851431    TRACE_(typelib)("Vartype = %x\n", V_VT(pVar));
    12861432    switch (V_VT(pVar)){
     
    12901436        case VT_I4  :
    12911437        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    :
    13001446        case VT_VOID    : /* FIXME: is this right? */
    1301         case VT_HRESULT : 
     1447        case VT_HRESULT :
    13021448            size=4; break;
    13031449        case VT_R8  :
    13041450        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 :
    13081454        case VT_DECIMAL :  /* FIXME: is this right? */
    13091455        case VT_FILETIME :
     
    13121458        case VT_BSTR    :{
    13131459            char * ptr;
    1314             MSFT_Read(&size, sizeof(INT), pcx, DO_NOT_SEEK );
     1460            MSFT_ReadLEDWords(&size, sizeof(INT), pcx, DO_NOT_SEEK );
    13151461            if(size <= 0) {
    13161462                FIXME("BSTR length = %d?\n", size);
     
    13281474    /* FIXME: this will not work AT ALL when the variant contains a pointer */
    13291475        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 :
    13331479        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;
    13481494            FIXME("VARTYPE %d is not supported, setting pointer to NULL\n",
    13491495                V_VT(pVar));
     
    13681514        count++;
    13691515        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);
    13721517        MSFT_ReadGuid(&(pNew->guid), entry.GuidOffset , pcx);
    13731518        MSFT_ReadValue(&(pNew->data), entry.DataOffset, pcx);
     
    13941539}
    13951540
    1396 static void 
     1541static void
    13971542MSFT_DoFuncs(TLBContext*     pcx,
    13981543            ITypeInfoImpl*  pTI,
    1399             int             cFuncs, 
     1544            int             cFuncs,
    14001545            int             cVars,
    1401             int             offset, 
     1546            int             offset,
    14021547            TLBFuncDesc**   pptfd)
    14031548{
    1404     /* 
     1549    /*
    14051550     * member information is stored in a data structure at offset
    14061551     * indicated by the memoffset field of the typeinfo structure
    14071552     * 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
    14091554     * of this (first) part excluding this field. Then follow the records,
    14101555     * for each member there is one record.
    14111556     *
    14121557     * 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
    14151560     * a field indicating the member type (function variable intereface etc)
    14161561     * I have not found it yet. At this time we depend on the information
     
    14191564     * Second follows an array sized nrMEM*sizeof(INT) with a memeber id
    14201565     * 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
    14231568     * of each member.
    1424      * 
     1569     *
    14251570     * Forth and last (?) part is an array with offsets to the records in the
    14261571     * first part of this file segment.
     
    14351580    TRACE_(typelib)("\n");
    14361581
    1437     MSFT_Read(&infolen, sizeof(INT), pcx, offset);
     1582    MSFT_ReadLEDWords(&infolen, sizeof(INT), pcx, offset);
    14381583
    14391584    for ( i = 0; i < cFuncs ; i++ )
     
    14421587
    14431588        /* 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));
    14481591
    14491592        (*pptfd)->Name = MSFT_ReadName(pcx, nameoffset);
    14501593
    14511594        /* read the function information record */
    1452         MSFT_Read(&reclength, sizeof(INT), pcx, recoffset);
    1453        
     1595        MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset);
     1596
    14541597        reclength &= 0x1ff;
    14551598
    1456         MSFT_Read(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;
     1599        MSFT_ReadLEDWords(pFuncRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK);
    14571600
    14581601        /* do the attributes */
     
    14631606        {
    14641607            (*pptfd)->helpcontext = pFuncRec->OptAttr[0] ;
    1465            
     1608
    14661609            if ( nrattributes > 1 )
    14671610            {
     
    14861629                        if ( nrattributes > 6 && pFuncRec->FKCCIC & 0x80 )
    14871630                        {
    1488                             MSFT_CustData(pcx, 
     1631                            MSFT_CustData(pcx,
    14891632                                          pFuncRec->OptAttr[6],
    14901633                                          &(*pptfd)->pCustData);
     
    14961639
    14971640        /* 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));
    15011643
    15021644        (*pptfd)->funcdesc.funckind   =  (pFuncRec->FKCCIC)      & 0x7;
     
    15081650        (*pptfd)->funcdesc.wFuncFlags =   LOWORD(pFuncRec->Flags) ;
    15091651
    1510         MSFT_GetTdesc(pcx, 
    1511                       pFuncRec->DataType,   
     1652        MSFT_GetTdesc(pcx,
     1653                      pFuncRec->DataType,
    15121654                      &(*pptfd)->funcdesc.elemdescFunc.tdesc,
    15131655                      pTI);
     
    15191661            MSFT_ParameterInfo paraminfo;
    15201662
    1521             (*pptfd)->funcdesc.lprgelemdescParam = 
     1663            (*pptfd)->funcdesc.lprgelemdescParam =
    15221664                TLB_Alloc(pFuncRec->nrargs * sizeof(ELEMDESC));
    15231665
    1524             (*pptfd)->pParamDesc = 
     1666            (*pptfd)->pParamDesc =
    15251667                TLB_Alloc(pFuncRec->nrargs * sizeof(TLBParDesc));
    15261668
    1527             MSFT_Read(&paraminfo,
    1528                       sizeof(paraminfo),
    1529                       pcx,
    1530                       recoffset + reclength -
    1531                       pFuncRec->nrargs * sizeof(MSFT_ParameterInfo));
     1669            MSFT_ReadLEDWords(&paraminfo, sizeof(paraminfo), pcx,
     1670                              recoffset + reclength - pFuncRec->nrargs * sizeof(MSFT_ParameterInfo));
    15321671
    15331672            for ( j = 0 ; j < pFuncRec->nrargs ; j++ )
     
    15351674                TYPEDESC* lpArgTypeDesc = 0;
    15361675
    1537                 MSFT_GetTdesc(pcx, 
    1538                               paraminfo.DataType,   
     1676                MSFT_GetTdesc(pcx,
     1677                              paraminfo.DataType,
    15391678                              &(*pptfd)->funcdesc.lprgelemdescParam[j].tdesc,
    15401679                              pTI);
     
    15441683                (*pptfd)->pParamDesc[j].Name = (void *) paraminfo.oName;
    15451684
    1546                 /* SEEK value = jump to offset, 
     1685                /* SEEK value = jump to offset,
    15471686                 * from there jump to the end of record,
    15481687                 * go back by (j-1) arguments
    15491688                 */
    1550                 MSFT_Read( &paraminfo ,
     1689                MSFT_ReadLEDWords( &paraminfo ,
    15511690                           sizeof(MSFT_ParameterInfo), pcx,
    1552                            recoffset + reclength - ((pFuncRec->nrargs - j - 1) 
     1691                           recoffset + reclength - ((pFuncRec->nrargs - j - 1)
    15531692                                               * sizeof(MSFT_ParameterInfo)));
    1554                 lpArgTypeDesc = 
     1693                lpArgTypeDesc =
    15551694                    & ((*pptfd)->funcdesc.lprgelemdescParam[j].tdesc);
    15561695
     
    15681707
    15691708                    case VT_USERDEFINED:
    1570                         MSFT_DoRefType(pcx, pTI, 
     1709                        MSFT_DoRefType(pcx, pTI,
    15711710                                       lpArgTypeDesc->u.hreftype);
    15721711
     
    15861725                TYPEDESC* lpArgTypeDesc;
    15871726
    1588                 (*pptfd)->funcdesc.elemdescFunc = 
     1727                (*pptfd)->funcdesc.elemdescFunc =
    15891728                (*pptfd)->funcdesc.lprgelemdescParam[j];
    15901729
     
    15991738                        break;
    16001739                    case VT_CARRAY:
    1601                         lpArgTypeDesc = 
     1740                        lpArgTypeDesc =
    16021741                        & (lpArgTypeDesc->u.lpadesc->tdescElem);
    16031742
     
    16051744
    16061745                    case VT_USERDEFINED:
    1607                         MSFT_DoRefType(pcx, 
     1746                        MSFT_DoRefType(pcx,
    16081747                                       pTI,
    16091748                                       lpArgTypeDesc->u.hreftype);
     
    16261765
    16271766                /* default value */
    1628                 if ( (PARAMFLAG_FHASDEFAULT & 
     1767                if ( (PARAMFLAG_FHASDEFAULT &
    16291768                      (*pptfd)->funcdesc.lprgelemdescParam[j].u.paramdesc.wParamFlags) &&
    16301769                     ((pFuncRec->FKCCIC) & 0x1000) )
    16311770                {
    1632                     INT* pInt = (INT *)((char *)pFuncRec + 
    1633                                    reclength - 
     1771                    INT* pInt = (INT *)((char *)pFuncRec +
     1772                                   reclength -
    16341773                                   (pFuncRec->nrargs * 4 + 1) * sizeof(INT) );
    16351774
     
    16391778                    pParamDesc->pparamdescex->cBytes = sizeof(PARAMDESCEX);
    16401779
    1641                     MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue), 
     1780                    MSFT_ReadValue(&(pParamDesc->pparamdescex->varDefaultValue),
    16421781                        pInt[j], pcx);
    16431782                }
     
    16451784                if ( nrattributes > 7 + j && pFuncRec->FKCCIC & 0x80 )
    16461785                {
    1647                     MSFT_CustData(pcx, 
     1786                    MSFT_CustData(pcx,
    16481787                                  pFuncRec->OptAttr[7+j],
    16491788                                  &(*pptfd)->pParamDesc[j].pCustData);
     
    16711810    TRACE_(typelib)("\n");
    16721811
    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));
    16761815    recoffset += offset+sizeof(INT);
    16771816    for(i=0;i<cVars;i++){
    16781817        *pptvd=TLB_Alloc(sizeof(TLBVarDesc));
    16791818    /* 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));
    16821821        (*pptvd)->Name=MSFT_ReadName(pcx, nameoffset);
    16831822    /* read the variable information record */
    1684         MSFT_Read(&reclength, sizeof(INT), pcx, recoffset);
     1823        MSFT_ReadLEDWords(&reclength, sizeof(INT), pcx, recoffset);
    16851824        reclength &=0xff;
    1686         MSFT_Read(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK) ;
     1825        MSFT_ReadLEDWords(pVarRec, reclength - sizeof(INT), pcx, DO_NOT_SEEK);
    16871826    /* Optional data */
    16881827        if(reclength >(6*sizeof(INT)) )
     
    16941833            (*pptvd)->HelpStringContext=pVarRec->HelpStringContext;
    16951834    /* 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));
    16981837        (*pptvd)->vardesc.varkind = pVarRec->VarKind;
    16991838        (*pptvd)->vardesc.wVarFlags = pVarRec->Flags;
    1700         MSFT_GetTdesc(pcx, pVarRec->DataType,   
     1839        MSFT_GetTdesc(pcx, pVarRec->DataType,
    17011840            &(*pptvd)->vardesc.elemdescVar.tdesc, pTI);
    17021841/*   (*pptvd)->vardesc.lpstrSchema; is reserved (SDK) FIXME?? */
     
    17391878        TRACE_(typelib)("offset %x, masked offset %x\n", offset, offset + (offset & 0xfffffffc));
    17401879
    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));
    17431882        for(j=0;pImpLib;j++){   /* search the known offsets of all import libraries */
    17441883            if(pImpLib->offset==impinfo.oImpFile) break;
     
    17761915        if(offset<0) break; /* paranoia */
    17771916        *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);
    17801919        (*ppImpl)->hRef = refrec.reftype;
    17811920        (*ppImpl)->implflags=refrec.flags;
     
    18001939
    18011940    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));
    18041943/* this is where we are coming from */
    18051944    ptiRet->pTypeLib = pLibInfo;
     
    18251964    ptiRet->TypeAttr.cbSizeVft=tiBase.cbSizeVft; /* FIXME: this is only the non inherited part */
    18261965    if(ptiRet->TypeAttr.typekind == TKIND_ALIAS)
    1827         MSFT_GetTdesc(pcx, tiBase.datatype1, 
     1966        MSFT_GetTdesc(pcx, tiBase.datatype1,
    18281967            &ptiRet->TypeAttr.tdescAlias, ptiRet);
    18291968
     
    18441983    if(ptiRet->TypeAttr.cFuncs >0 )
    18451984        MSFT_DoFuncs(pcx, ptiRet, ptiRet->TypeAttr.cFuncs,
    1846                     ptiRet->TypeAttr.cVars, 
     1985                    ptiRet->TypeAttr.cVars,
    18471986                    tiBase.memoffset, & ptiRet->funclist);
    18481987    /* variables */
    18491988    if(ptiRet->TypeAttr.cVars >0 )
    18501989        MSFT_DoVars(pcx, ptiRet, ptiRet->TypeAttr.cFuncs,
    1851                    ptiRet->TypeAttr.cVars, 
     1990                   ptiRet->TypeAttr.cVars,
    18521991                   tiBase.memoffset, & ptiRet->varlist);
    18531992    if(ptiRet->TypeAttr.cImplTypes >0 ) {
     
    18551994        {
    18561995        case TKIND_COCLASS:
    1857             MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes , 
     1996            MSFT_DoImplTypes(pcx, ptiRet, ptiRet->TypeAttr.cImplTypes ,
    18581997                tiBase.datatype1);
    18591998            break;
    18601999        case TKIND_DISPATCH:
    18612000            ptiRet->impltypelist=TLB_Alloc(sizeof(TLBImplType));
    1862            
     2001
    18632002            if (tiBase.datatype1 != -1)
    18642003            {
     
    18832022                (*ppRef)->index            = TLB_REF_USE_GUID;
    18842023                (*ppRef)->pImpTLInfo       = TLB_Alloc(sizeof(TLBImpLib));
    1885                 (*ppRef)->pImpTLInfo->guid = IID_StdOle;             
     2024                (*ppRef)->pImpTLInfo->guid = IID_StdOle;
    18862025                (*ppRef)->pImpTLInfo->name = SysAllocStringLen(NULL,
    18872026                                                              nStdOleLen  + 1);
    1888              
     2027
    18892028                MultiByteToWideChar(CP_ACP,
    18902029                                    MB_PRECOMPOSED,
     
    18932032                                    (*ppRef)->pImpTLInfo->name,
    18942033                                    SysStringLen((*ppRef)->pImpTLInfo->name));
    1895                                  
     2034
    18962035                (*ppRef)->pImpTLInfo->lcid          = 0;
    18972036                (*ppRef)->pImpTLInfo->wVersionMajor = 2;
     
    19302069    int ret = TYPE_E_CANTLOADLIBRARY;
    19312070    DWORD dwSignature = 0;
    1932     HFILE hFile;
     2071    HANDLE hFile;
    19332072
    19342073    TRACE_(typelib)("%s:%d\n", debugstr_w(pszFileName), index);
     
    19502089
    19512090          /* first try to load as *.tlb */
    1952           dwSignature = *((DWORD*) pBase);
     2091          dwSignature = FromLEDWord(*((DWORD*) pBase));
    19532092          if ( dwSignature == MSFT_SIGNATURE)
    19542093          {
     
    19822121            LPVOID pBase = LockResource(hGlobal);
    19832122            DWORD  dwTLBLength = SizeofResource(hinstDLL, hrsrc);
    1984            
     2123
    19852124            if (pBase)
    19862125            {
    19872126              /* try to load as incore resource */
    1988               dwSignature = *((DWORD*) pBase);
     2127              dwSignature = FromLEDWord(*((DWORD*) pBase));
    19892128              if ( dwSignature == MSFT_SIGNATURE)
    19902129              {
     
    20452184    cx.pLibInfo = pTypeLibImpl;
    20462185    cx.length = dwTLBLength;
    2047    
     2186
    20482187    /* read header */
    2049     MSFT_Read((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);
     2188    MSFT_ReadLEDWords((void*)&tlbHeader, sizeof(tlbHeader), &cx, 0);
    20502189    TRACE("header:\n");
    20512190    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) {
    20532192        FIXME("Header type magic 0x%08x not supported.\n",tlbHeader.magic1);
    20542193        return NULL;
     
    20612200    /* now read the segment directory */
    20622201    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);
    20642203    cx.pTblDir = &tlbSegDir;
    20652204
     
    20982237    {
    20992238            int offset;
    2100             MSFT_Read(&offset, sizeof(offset), &cx, sizeof(tlbHeader));
     2239            MSFT_ReadLEDWords(&offset, sizeof(offset), &cx, sizeof(tlbHeader));
    21012240            pTypeLibImpl->HelpStringDll = MSFT_ReadString(&cx, offset);
    21022241    }
     
    21162255        INT16 td[4];
    21172256        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);
    21192258        for(i=0; i<cTD; )
    21202259        {
     
    21382277                pTypeLibImpl->pTypeDesc[i].u.hreftype = MAKELONG(td[2],td[3]);
    21392278            }
    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);
    21412280        }
    21422281
     
    21472286            if(tlbSegDir.pArrayDescriptions.offset>0)
    21482287            {
    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);
    21502289                pTypeLibImpl->pTypeDesc[i].u.lpadesc = TLB_Alloc(sizeof(ARRAYDESC)+sizeof(SAFEARRAYBOUND)*(td[3]-1));
    21512290
     
    21592298                for(j = 0; j<td[2]; j++)
    21602299                {
    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);
    21652304                }
    21662305            }
     
    21842323            *ppImpLib = TLB_Alloc(sizeof(TLBImpLib));
    21852324            (*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);
    21922331
    21932332            size >>= 2;
     
    26562795            }
    26572796        }
    2658        
     2797
    26592798        ppFuncDesc = &((*ppFuncDesc)->next);
    26602799        if(pFunc->next == 0xffff) break;
     
    28022941
    28032942    pHeader = pLib;
    2804    
     2943
    28052944    TRACE("header:\n");
    28062945    TRACE("\tmagic=0x%08lx, file blocks = %d\n", pHeader->SLTG_magic,
    28072946          pHeader->nrOfFileBlks );
    2808     if (memcmp(&pHeader->SLTG_magic, TLBMAGIC1, 4)) {
     2947    if (pHeader->SLTG_magic != SLTG_SIGNATURE) {
    28092948        FIXME("Header type magic 0x%08lx not supported.\n",
    28102949              pHeader->SLTG_magic);
    28112950        return NULL;
    28122951    }
    2813    
     2952
    28142953    /* There are pHeader->nrOfFileBlks - 2 TypeInfo records in this typelib */
    28152954    pTypeLibImpl->TypeInfoCount = pHeader->nrOfFileBlks - 2;
     
    28442983          pBlkEntry[order].next != 0;
    28452984          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;
    28512986    }
    28522987    pLibBlk = pBlk;
     
    28673002
    28683003    ptr = (char*)pLibBlk + len;
    2869    
     3004
    28703005    for(i = 0; i < pTypeLibImpl->TypeInfoCount; i++) {
    28713006        WORD w, extra;
     
    29173052       dust and we should be pointing at the beginning of the name
    29183053       table */
    2919  
     3054
    29203055    pNameTable = (char*)pLibBlk + len;
    29213056
     
    29303065       break;
    29313066   }
    2932    
     3067
    29333068    pNameTable += 0x216;
    29343069
     
    29803115      (*ppTypeInfoImpl)->TypeAttr.wTypeFlags =
    29813116        (pTIHeader->typeflags1 >> 3) | (pTIHeader->typeflags2 << 5);
    2982      
     3117
    29833118      if((pTIHeader->typeflags1 & 7) != 2)
    29843119        FIXME("typeflags1 = %02x\n", pTIHeader->typeflags1);
     
    29943129      switch(pTIHeader->typekind) {
    29953130      case TKIND_ENUM:
    2996         pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable); 
     3131        pTITail = SLTG_ProcessEnum(pBlk, *ppTypeInfoImpl, pNameTable);
    29973132        break;
    29983133
    29993134      case TKIND_RECORD:
    3000         pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable); 
     3135        pTITail = SLTG_ProcessRecord(pBlk, *ppTypeInfoImpl, pNameTable);
    30013136        break;
    30023137
     
    30233158      }
    30243159      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;
    30303161    }
    30313162
     
    30513182
    30523183    *ppvObject=NULL;
    3053     if(IsEqualIID(riid, &IID_IUnknown) || 
     3184    if(IsEqualIID(riid, &IID_IUnknown) ||
    30543185       IsEqualIID(riid,&IID_ITypeLib)||
    30553186       IsEqualIID(riid,&IID_ITypeLib2))
     
    30863217
    30873218    --(This->ref);
    3088    
     3219
    30893220    TRACE("(%p)->(%u)\n",This, This->ref);
    30903221
     
    31183249          This->HelpStringDll = NULL;
    31193250      }
    3120    
     3251
    31213252      ITypeInfo_Release((ITypeInfo*) This->pTypeInfo);
    31223253      HeapFree(GetProcessHeap(),0,This);
     
    31283259
    31293260/* ITypeLib::GetTypeInfoCount
    3130  * 
     3261 *
    31313262 * Returns the number of type descriptions in the type library
    31323263 */
     
    31443275static HRESULT WINAPI ITypeLib2_fnGetTypeInfo(
    31453276    ITypeLib2 *iface,
    3146     UINT index, 
     3277    UINT index,
    31473278    ITypeInfo **ppTInfo)
    31483279{
    31493280    int i;
    3150    
     3281
    31513282    ICOM_THIS( ITypeLibImpl, iface);
    31523283    ITypeInfoImpl *pTypeInfo = This->pTypeInfo;
     
    31553286
    31563287    if (!ppTInfo) return E_INVALIDARG;
    3157    
     3288
    31583289    /* search element n in list */
    31593290    for(i=0; i < index; i++)
     
    31653296        return TYPE_E_ELEMENTNOTFOUND;
    31663297      }
    3167     }   
     3298    }
    31683299
    31693300    *ppTInfo = (ITypeInfo *) pTypeInfo;
    3170    
     3301
    31713302    ITypeInfo_AddRef(*ppTInfo);
    31723303    TRACE("-- found (%p)\n",*ppTInfo);
     
    31913322
    31923323    if(!pTKind) return E_INVALIDARG;
    3193    
     3324
    31943325    /* search element n in list */
    31953326    for(i=0; i < index; i++)
     
    32383369    }
    32393370
    3240     TRACE("-- found (%p, %s)\n", 
    3241           pTypeInfo, 
     3371    TRACE("-- found (%p, %s)\n",
     3372          pTypeInfo,
    32423373          debugstr_w(pTypeInfo->Name));
    32433374
     
    32533384 */
    32543385static HRESULT WINAPI ITypeLib2_fnGetLibAttr(
    3255         ITypeLib2 *iface, 
     3386        ITypeLib2 *iface,
    32563387        LPTLIBATTR *ppTLibAttr)
    32573388{
     
    32923423    BSTR *pBstrName,
    32933424    BSTR *pBstrDocString,
    3294     DWORD *pdwHelpContext, 
     3425    DWORD *pdwHelpContext,
    32953426    BSTR *pBstrHelpFile)
    32963427{
    32973428    ICOM_THIS( ITypeLibImpl, iface);
    3298    
     3429
    32993430    HRESULT result = E_INVALIDARG;
    3300    
     3431
    33013432    ITypeInfo *pTInfo;
    33023433
    3303    
     3434
    33043435    TRACE("(%p) index %d Name(%p) DocString(%p) HelpContext(%p) HelpFile(%p)\n",
    33053436        This, index,
    3306         pBstrName, pBstrDocString, 
     3437        pBstrName, pBstrDocString,
    33073438        pdwHelpContext, pBstrHelpFile);
    3308    
     3439
    33093440    if(index<0)
    3310     { 
     3441    {
    33113442        /* documentation for the typelib */
    33123443        if(pBstrName)
     
    33403471        result = S_OK;
    33413472    }
    3342     else 
     3473    else
    33433474    {
    33443475        /* for a typeinfo */
     
    33473478        if(SUCCEEDED(result))
    33483479        {
    3349             result = ITypeInfo_GetDocumentation(pTInfo, 
    3350                                           MEMBERID_NIL, 
     3480            result = ITypeInfo_GetDocumentation(pTInfo,
     3481                                          MEMBERID_NIL,
    33513482                                          pBstrName,
    3352                                           pBstrDocString, 
     3483                                          pBstrDocString,
    33533484                                          pdwHelpContext, pBstrHelpFile);
    3354            
     3485
    33553486            ITypeInfo_Release(pTInfo);
    33563487        }
     
    33983529        for(pVInfo=pTInfo->varlist;pVInfo;pVInfo=pVInfo->next)
    33993530            if(!memcmp(szNameBuf,pVInfo->Name, nNameBufLen)) goto ITypeLib2_fnIsName_exit;
    3400        
     3531
    34013532    }
    34023533    *pfName=FALSE;
     
    34053536    TRACE("(%p)slow! search for %s: %s found!\n", This,
    34063537          debugstr_w(szNameBuf), *pfName?"NOT":"");
    3407    
     3538
    34083539    return S_OK;
    34093540}
     
    34283559    TLBVarDesc *pVInfo;
    34293560    int i,j = 0;
    3430    
     3561
    34313562    UINT nNameBufLen = SysStringLen(szNameBuf);
    34323563
     
    34513582
    34523583    *pcFound=j;
    3453    
     3584
    34543585    return S_OK;
    34553586}
     
    34763607static HRESULT WINAPI ITypeLib2_fnGetCustData(
    34773608        ITypeLib2 * iface,
    3478         REFGUID guid, 
     3609        REFGUID guid,
    34793610        VARIANT *pVarVal)
    34803611{
     
    34863617      if( IsEqualIID(guid, &pCData->guid)) break;
    34873618    }
    3488    
     3619
    34893620    TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT");
    34903621
     
    35053636 */
    35063637static HRESULT WINAPI ITypeLib2_fnGetLibStatistics(
    3507         ITypeLib2 * iface, 
     3638        ITypeLib2 * iface,
    35083639        ULONG *pcUniqueNames,
    35093640        ULONG *pcchUniqueNames)
     
    35263657 */
    35273658static HRESULT WINAPI ITypeLib2_fnGetDocumentation2(
    3528         ITypeLib2 * iface, 
     3659        ITypeLib2 * iface,
    35293660        INT index,
    35303661        LCID lcid,
     
    35593690      /* for a typeinfo */
    35603691      result=ITypeLib2_GetTypeInfo(iface, index, &pTInfo);
    3561      
     3692
    35623693      if(SUCCEEDED(result))
    3563       { 
     3694      {
    35643695        ITypeInfo2 * pTInfo2;
    3565         result = ITypeInfo_QueryInterface(pTInfo, 
    3566                                           &IID_ITypeInfo2, 
     3696        result = ITypeInfo_QueryInterface(pTInfo,
     3697                                          &IID_ITypeInfo2,
    35673698                                          (LPVOID*) &pTInfo2);
    35683699
    35693700        if(SUCCEEDED(result))
    35703701        {
    3571           result = ITypeInfo2_GetDocumentation2(pTInfo2, 
    3572                                            MEMBERID_NIL, 
     3702          result = ITypeInfo2_GetDocumentation2(pTInfo2,
     3703                                           MEMBERID_NIL,
    35733704                                           lcid,
    3574                                            pbstrHelpString, 
    3575                                            pdwHelpStringContext, 
     3705                                           pbstrHelpString,
     3706                                           pdwHelpStringContext,
    35763707                                           pbstrHelpStringDll);
    3577  
     3708
    35783709          ITypeInfo2_Release(pTInfo2);
    35793710        }
    3580            
     3711
    35813712        ITypeInfo_Release(pTInfo);
    35823713      }
     
    35873718/* ITypeLib2::GetAllCustData
    35883719 *
    3589  * Gets all custom data items for the library. 
     3720 * Gets all custom data items for the library.
    35903721 *
    35913722 */
     
    35973728    TLBCustData *pCData;
    35983729    int i;
    3599     TRACE("(%p) returning %d items\n", This, This->ctCustData); 
     3730    TRACE("(%p) returning %d items\n", This, This->ctCustData);
    36003731    pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM));
    36013732    if(pCustData->prgCustData ){
     
    36613792
    36623793    *ppvObject=NULL;
    3663     if(IsEqualIID(riid, &IID_IUnknown) || 
     3794    if(IsEqualIID(riid, &IID_IUnknown) ||
    36643795            IsEqualIID(riid,&IID_ITypeInfo)||
    36653796            IsEqualIID(riid,&IID_ITypeInfo2))
     
    36943825
    36953826    --(This->ref);
    3696    
     3827
    36973828    TRACE("(%p)->(%u)\n",This, This->ref);
    36983829
     
    37013832      FIXME("destroy child objects\n");
    37023833
    3703       TRACE("destroying ITypeInfo(%p)\n",This); 
     3834      TRACE("destroying ITypeInfo(%p)\n",This);
    37043835      if (This->Name)
    37053836      {
     
    37073838          This->Name = 0;
    37083839      }
    3709      
     3840
    37103841      if (This->DocString)
    37113842      {
     
    37663897    ICOM_THIS( ITypeInfoImpl, iface);
    37673898    int i;
    3768     TLBFuncDesc * pFDesc; 
     3899    TLBFuncDesc * pFDesc;
    37693900    TRACE("(%p) index %d\n", This, index);
    37703901    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++, pFDesc=pFDesc->next)
     
    37803911/* ITypeInfo::GetVarDesc
    37813912 *
    3782  * Retrieves a VARDESC structure that describes the specified variable. 
     3913 * Retrieves a VARDESC structure that describes the specified variable.
    37833914 *
    37843915 */
     
    37883919    ICOM_THIS( ITypeInfoImpl, iface);
    37893920    int i;
    3790     TLBVarDesc * pVDesc; 
     3921    TLBVarDesc * pVDesc;
    37913922    TRACE("(%p) index %d\n", This, index);
    37923923    for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++, pVDesc=pVDesc->next)
     
    38103941{
    38113942    ICOM_THIS( ITypeInfoImpl, iface);
    3812     TLBFuncDesc * pFDesc; 
    3813     TLBVarDesc * pVDesc; 
     3943    TLBFuncDesc * pFDesc;
     3944    TLBVarDesc * pVDesc;
    38143945    int i;
    38153946    TRACE("(%p) memid=0x%08lx Maxname=%d\n", This, memid, cMaxNames);
     
    38904021      */
    38914022      if( This->TypeAttr.typekind != TKIND_DISPATCH) return E_INVALIDARG;
    3892      
     4023
    38934024      if (This->TypeAttr.wTypeFlags & TYPEFLAG_FDISPATCHABLE &&
    38944025          This->TypeAttr.wTypeFlags & TYPEFLAG_FDUAL )
     
    39094040        pImpl = pImpl->next;
    39104041      }
    3911      
     4042
    39124043      if (!pImpl) return TYPE_E_ELEMENTNOTFOUND;
    3913      
     4044
    39144045      *pRefType = pImpl->hRef;
    3915      
     4046
    39164047      TRACE("-- 0x%08lx\n", pImpl->hRef );
    39174048    }
    3918    
     4049
    39194050    return S_OK;
    3920    
     4051
    39214052}
    39224053
    39234054/* ITypeInfo::GetImplTypeFlags
    3924  * 
    3925  * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface 
     4055 *
     4056 * Retrieves the IMPLTYPEFLAGS enumeration for one implemented interface
    39264057 * or base interface in a type description.
    39274058 */
     
    39534084{
    39544085    ICOM_THIS( ITypeInfoImpl, iface);
    3955     TLBFuncDesc * pFDesc; 
    3956     TLBVarDesc * pVDesc; 
     4086    TLBFuncDesc * pFDesc;
     4087    TLBVarDesc * pVDesc;
    39574088    HRESULT ret=S_OK;
    39584089
     
    39744105            return ret;
    39754106        }
    3976     }   
     4107    }
    39774108    for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next) {
    39784109        if(!lstrcmpiW(*rgszNames, pVDesc->Name)) {
     
    39814112        }
    39824113    }
    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 &&
    39854116            This->TypeAttr.cImplTypes ){
    39864117        /* recursive search */
    39874118        ITypeInfo *pTInfo;
    3988         ret=ITypeInfo_GetRefTypeInfo(iface, 
     4119        ret=ITypeInfo_GetRefTypeInfo(iface,
    39894120                This->impltypelist->hRef, &pTInfo);
    39904121        if(SUCCEEDED(ret)){
     
    40004131
    40014132/* ITypeInfo::Invoke
    4002  * 
     4133 *
    40034134 * Invokes a method, or accesses a property of an object, that implements the
    40044135 * interface described by the type description.
     
    40184149    case CC_STDCALL:
    40194150
     4151#ifdef __WIN32OS2__
    40204152        switch (nrargs) {
    4021 #ifdef __WIN32OS2__
    40224153        case 0: {
    40234154                DWORD (* WINAPI xfunc)() = func;
     
    40714202        }
    40724203#else
     4204        switch (nrargs) {
    40734205        case 0: {
    40744206                DWORD (WINAPI *xfunc)() = func;
     
    41104242                res = xfunc(args[0],args[1],args[2],args[3],args[4],args[5],args[6]);
    41114243                break;
    4112         }
     4244        }
    41134245        case 8: {
    41144246                DWORD (WINAPI *xfunc)(DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD) = func;
     
    41374269}
    41384270
     4271extern int const _argsize(DWORD vt);
     4272
     4273/***********************************************************************
     4274 *              DispCallFunc (OLEAUT32.@)
     4275 */
     4276HRESULT WINAPI
     4277DispCallFunc(
     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
    41394322static HRESULT WINAPI ITypeInfo_fnInvoke(
    41404323    ITypeInfo2 *iface,
     
    41484331{
    41494332    ICOM_THIS( ITypeInfoImpl, iface);
    4150     TLBFuncDesc * pFDesc; 
    4151     TLBVarDesc * pVDesc; 
     4333    TLBFuncDesc * pFDesc;
     4334    TLBVarDesc * pVDesc;
    41524335    int i;
    41534336
     
    41644347    if (pFDesc) {
    41654348        dump_TLBFuncDescOne(pFDesc);
     4349        /* dump_FUNCDESC(&pFDesc->funcdesc);*/
    41664350        switch (pFDesc->funcdesc.funckind) {
    41674351        case FUNC_PUREVIRTUAL:
    41684352        case FUNC_VIRTUAL: {
    41694353            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
    41724371            args[0] = (DWORD)pIUnk;
    4173 
     4372            argspos = 1; args2pos = 0;
    41744373            for (i=0;i<pFDesc->funcdesc.cParams;i++) {
     4374                int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
    41754375                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;
    41814391                } else {
    41824392                    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);
    41844395                    /*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. */
    41904399                    if ((tdesc->vt == VT_PTR) &&
    41914400                        (tdesc->u.lptdesc->vt == VT_VARIANT) &&
    41924401                        pVarResult
    41934402                    )
    4194                         args[i+1] = (DWORD)(pVarResult+(i-pDispParams->cArgs));
     4403                        args[argspos]= (DWORD)pVarResult;
     4404                    argspos     += 1;
     4405                    args2pos    += arglen;
    41954406                }
    41964407            }
     
    42024413            res = _invoke((*(DWORD***)pIUnk)[pFDesc->funcdesc.oVft/4],
    42034414                    pFDesc->funcdesc.callconv,
    4204                     pFDesc->funcdesc.cParams+1,
     4415                    numargs,
    42054416                    args
    42064417            );
    42074418            if (pVarResult && (dwFlags & (DISPATCH_PROPERTYGET))) {
     4419                args2pos = 0;
    42084420                for (i=0;i<pFDesc->funcdesc.cParams-pDispParams->cArgs;i++) {
     4421                    int arglen = _argsize(pFDesc->funcdesc.lprgelemdescParam[i].tdesc.vt);
    42094422                    TYPEDESC *tdesc = &(pFDesc->funcdesc.lprgelemdescParam[i+pDispParams->cArgs].tdesc);
    42104423                    /* If we are a pointer to a variant, we are done already */
     
    42124425                        continue;
    42134426
    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));
    42164429
    42174430                    if (tdesc->vt == VT_PTR)
    42184431                        tdesc = tdesc->u.lptdesc;
    4219                     V_VT(pVarResult+i) = tdesc->vt;
     4432                    V_VT(pVarResult) = tdesc->vt;
    42204433
    42214434                    /* HACK: VB5 likes this.
     
    42254438                     */
    42264439                    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;
    42304444                }
    42314445            }
     
    42844498
    42854499/* ITypeInfo::GetDocumentation
    4286  * 
     4500 *
    42874501 * Retrieves the documentation string, the complete Help file name and path,
    42884502 * 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.)
    42894505 */
    42904506static HRESULT WINAPI ITypeInfo_fnGetDocumentation( ITypeInfo2 *iface,
     
    42934509{
    42944510    ICOM_THIS( ITypeInfoImpl, iface);
    4295     TLBFuncDesc * pFDesc; 
    4296     TLBVarDesc * pVDesc; 
     4511    TLBFuncDesc * pFDesc;
     4512    TLBVarDesc * pVDesc;
    42974513    TRACE("(%p) memid %ld Name(%p) DocString(%p)"
    42984514          " HelpContext(%p) HelpFile(%p)\n",
     
    43214537    for(pVDesc=This->varlist; pVDesc; pVDesc=pVDesc->next)
    43224538        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;
    43254546        }
    43264547    }
     
    43294550
    43304551/*  ITypeInfo::GetDllEntry
    4331  * 
     4552 *
    43324553 * Retrieves a description or specification of an entry point for a function
    43334554 * in a DLL.
     
    43384559{
    43394560    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        }
    43414589    return E_FAIL;
    43424590}
    43434591
    43444592/* ITypeInfo::GetRefTypeInfo
    4345  * 
     4593 *
    43464594 * If a type description references other type descriptions, it retrieves
    43474595 * the referenced type descriptions.
     
    43564604
    43574605
    4358     if (hRefType == -1 && 
     4606    if (hRefType == -1 &&
    43594607        (((ITypeInfoImpl*) This)->TypeAttr.typekind   == TKIND_DISPATCH) &&
    43604608        (((ITypeInfoImpl*) This)->TypeAttr.wTypeFlags &  TYPEFLAG_FDUAL))
    43614609    {
    4362           /* when we meet a DUAL dispinterface, we must create the interface 
     4610          /* when we meet a DUAL dispinterface, we must create the interface
    43634611          * version of it.
    43644612          */
    43654613          ITypeInfoImpl* pTypeInfoImpl = (ITypeInfoImpl*) ITypeInfo_Constructor();
    43664614
    4367                
     4615
    43684616          /* the interface version contains the same information as the dispinterface
    43694617           * copy the contents of the structs.
     
    43714619          *pTypeInfoImpl = *This;
    43724620          pTypeInfoImpl->ref = 1;
    4373                
     4621
    43744622          /* change the type to interface */
    43754623          pTypeInfoImpl->TypeAttr.typekind = TKIND_INTERFACE;
    4376          
     4624
    43774625          *ppTInfo = (ITypeInfo*) pTypeInfoImpl;
    43784626
     
    44224670            if(SUCCEEDED(result)) {
    44234671                if(pRefType->index == TLB_REF_USE_GUID)
    4424                     result = ITypeLib2_GetTypeInfoOfGuid(pTLib, 
    4425                                                          &pRefType->guid, 
     4672                    result = ITypeLib2_GetTypeInfoOfGuid(pTLib,
     4673                                                         &pRefType->guid,
    44264674                                                         ppTInfo);
    44274675                else
     
    44404688
    44414689/* ITypeInfo::AddressOfMember
    4442  * 
     4690 *
    44434691 * Retrieves the addresses of static functions or variables, such as those
    44444692 * defined in a DLL.
     
    44534701
    44544702/* 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
    44574705 * (coclass).
    44584706 */
    4459 static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, 
    4460         IUnknown *pUnk, REFIID riid, VOID  **ppvObj) 
     4707static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface,
     4708        IUnknown *pUnk, REFIID riid, VOID  **ppvObj)
    44614709{
    44624710    ICOM_THIS( ITypeInfoImpl, iface);
     
    44784726
    44794727/* ITypeInfo::GetContainingTypeLib
    4480  * 
     4728 *
    44814729 * Retrieves the containing type library and the index of the type description
    44824730 * within that type library.
     
    45514799 * Returns the type flags without any allocations. This returns a DWORD type
    45524800 * flag, which expands the type flags without growing the TYPEATTR (type
    4553  * attribute). 
     4801 * attribute).
    45544802 *
    45554803 */
     
    45764824    HRESULT result;
    45774825    /* FIXME: should check for invKind??? */
    4578     for(i=0, pFuncInfo=This->funclist;pFuncInfo && 
     4826    for(i=0, pFuncInfo=This->funclist;pFuncInfo &&
    45794827            memid != pFuncInfo->funcdesc.memid; i++, pFuncInfo=pFuncInfo->next);
    45804828    if(pFuncInfo){
     
    45934841 *
    45944842 * 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).
    45964844 *
    45974845 */
     
    46034851    int i;
    46044852    HRESULT result;
    4605     for(i=0, pVarInfo=This->varlist; pVarInfo && 
     4853    for(i=0, pVarInfo=This->varlist; pVarInfo &&
    46064854            memid != pVarInfo->vardesc.memid; i++, pVarInfo=pVarInfo->next)
    46074855        ;
     
    46564904    ICOM_THIS( ITypeInfoImpl, iface);
    46574905    TLBCustData *pCData=NULL;
    4658     TLBFuncDesc * pFDesc; 
     4906    TLBFuncDesc * pFDesc;
    46594907    int i;
    46604908    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++,
     
    46854933        REFGUID guid,
    46864934        VARIANT *pVarVal)
    4687 {   
     4935{
    46884936    ICOM_THIS( ITypeInfoImpl, iface);
    46894937    TLBCustData *pCData=NULL;
    4690     TLBFuncDesc * pFDesc; 
     4938    TLBFuncDesc * pFDesc;
    46914939    int i;
    46924940
     
    46944942
    46954943    if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams)
    4696         for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData; 
     4944        for(pCData=pFDesc->pParamDesc[indexParam].pCustData; pCData;
    46974945                pCData = pCData->next)
    46984946            if( IsEqualIID(guid, &pCData->guid)) break;
     
    47184966        REFGUID guid,
    47194967        VARIANT *pVarVal)
    4720 {   
     4968{
    47214969    ICOM_THIS( ITypeInfoImpl, iface);
    47224970    TLBCustData *pCData=NULL;
    4723     TLBVarDesc * pVDesc; 
     4971    TLBVarDesc * pVDesc;
    47244972    int i;
    47254973
     
    47545002        REFGUID guid,
    47555003        VARIANT *pVarVal)
    4756 {   
     5004{
    47575005    ICOM_THIS( ITypeInfoImpl, iface);
    47585006    TLBCustData *pCData=NULL;
    4759     TLBImplType * pRDesc; 
     5007    TLBImplType * pRDesc;
    47605008    int i;
    47615009
     
    47695017      }
    47705018    }
    4771    
     5019
    47725020    TRACE("(%p) guid %s %s found!x)\n", This, debugstr_guid(guid), pCData? "" : "NOT");
    47735021
     
    47825030
    47835031/* ITypeInfo2::GetDocumentation2
    4784  * 
     5032 *
    47855033 * Retrieves the documentation string, the complete Help file name and path,
    47865034 * the localization context to use, and the context ID for the library Help
     
    47975045{
    47985046    ICOM_THIS( ITypeInfoImpl, iface);
    4799     TLBFuncDesc * pFDesc; 
    4800     TLBVarDesc * pVDesc; 
     5047    TLBFuncDesc * pFDesc;
     5048    TLBVarDesc * pVDesc;
    48015049    TRACE("(%p) memid %ld lcid(0x%lx)  HelpString(%p) "
    48025050          "HelpStringContext(%p) HelpStringDll(%p)\n",
     
    48455093/* ITypeInfo2::GetAllCustData
    48465094 *
    4847  * Gets all custom data items for the Type info. 
     5095 * Gets all custom data items for the Type info.
    48485096 *
    48495097 */
     
    48565104    int i;
    48575105
    4858     TRACE("(%p) returning %d items\n", This, This->ctCustData); 
     5106    TRACE("(%p) returning %d items\n", This, This->ctCustData);
    48595107
    48605108    pCustData->prgCustData = TLB_Alloc(This->ctCustData * sizeof(CUSTDATAITEM));
     
    48845132    ICOM_THIS( ITypeInfoImpl, iface);
    48855133    TLBCustData *pCData;
    4886     TLBFuncDesc * pFDesc; 
     5134    TLBFuncDesc * pFDesc;
    48875135    int i;
    4888     TRACE("(%p) index %d\n", This, index); 
     5136    TRACE("(%p) index %d\n", This, index);
    48895137    for(i=0, pFDesc=This->funclist; i!=index && pFDesc; i++,
    48905138            pFDesc=pFDesc->next)
     
    49205168    ICOM_THIS( ITypeInfoImpl, iface);
    49215169    TLBCustData *pCData=NULL;
    4922     TLBFuncDesc * pFDesc; 
     5170    TLBFuncDesc * pFDesc;
    49235171    int i;
    4924     TRACE("(%p) index %d\n", This, indexFunc); 
     5172    TRACE("(%p) index %d\n", This, indexFunc);
    49255173    for(i=0, pFDesc=This->funclist; i!=indexFunc && pFDesc; i++,
    49265174            pFDesc=pFDesc->next)
    49275175        ;
    49285176    if(pFDesc && indexParam >=0 && indexParam<pFDesc->funcdesc.cParams){
    4929         pCustData->prgCustData = 
     5177        pCustData->prgCustData =
    49305178            TLB_Alloc(pFDesc->pParamDesc[indexParam].ctCustData *
    49315179                    sizeof(CUSTDATAITEM));
     
    49575205    ICOM_THIS( ITypeInfoImpl, iface);
    49585206    TLBCustData *pCData;
    4959     TLBVarDesc * pVDesc; 
     5207    TLBVarDesc * pVDesc;
    49605208    int i;
    4961     TRACE("(%p) index %d\n", This, index); 
     5209    TRACE("(%p) index %d\n", This, index);
    49625210    for(i=0, pVDesc=This->varlist; i!=index && pVDesc; i++,
    49635211            pVDesc=pVDesc->next)
     
    49955243    ICOM_THIS( ITypeInfoImpl, iface);
    49965244    TLBCustData *pCData;
    4997     TLBImplType * pRDesc; 
     5245    TLBImplType * pRDesc;
    49985246    int i;
    4999     TRACE("(%p) index %d\n", This, index); 
     5247    TRACE("(%p) index %d\n", This, index);
    50005248    for(i=0, pRDesc=This->impltypelist; i!=index && pRDesc; i++,
    50015249            pRDesc=pRDesc->next)
     
    50215269}
    50225270
    5023 static ICOM_VTABLE(ITypeInfo2) tinfvt = 
     5271static ICOM_VTABLE(ITypeInfo2) tinfvt =
    50245272{
    50255273    ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
  • trunk/src/oleaut32/typelib.h

    r8640 r9400  
    2525#include "wine/windef16.h"
    2626
    27 #define TLBMAGIC2 "MSFT"
    28 #define TLBMAGIC1 "SLTG"
    2927#define HELPDLLFLAG (0x0100)
    3028#define DO_NOT_SEEK (-1)
     
    138136        INT     helpcontext;    /* */
    139137        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
    140142        INT16   cImplTypes;     /* nr of implemented interfaces */
    141143        INT16   cbSizeVft;      /* virtual table size, not including inherits */
     144#endif
    142145/*050*/ INT     size;           /* size in bytes, at least for structures */
    143146        /* FIXME: name of this field */
     
    165168    INT   DataType;     /* data type of the memeber, eg return of function */
    166169    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
    167174    INT16 VtableOffset; /* offset in vtable */
    168175    INT16 res3;         /* some offset into dunno what */
     176#endif
    169177    INT   FKCCIC;       /* bit string with the following  */
    170178                        /* meaning (bit 0 is the msb): */
     
    175183                        /* Invokation kind (bits 9-12 ) */
    176184                        /* 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
    177189    INT16 nrargs;       /* number of arguments (including optional ????) */
    178190    INT16 nroargs;      /* nr of optional arguments */
     191#endif
    179192    /* optional attribute fields, the number of them is variable */
    180193    INT   OptAttr[1];
     
    209222    INT   DataType;     /* data type of the variable */
    210223    INT   Flags;        /* VarFlags (LOWORD) */
     224#ifdef WORDS_BIGENDIAN
     225    INT16 res3;         /* some offset into dunno what */
     226    INT16 VarKind;      /* VarKind */
     227#else
    211228    INT16 VarKind;      /* VarKind */
    212229    INT16 res3;         /* some offset into dunno what */
     230#endif
    213231    INT   OffsValue;    /* value of the variable or the offset  */
    214232                        /* in the data structure */
     
    558576extern DWORD _invoke(LPVOID func,CALLCONV callconv, int nrargs, DWORD *args);
    559577
     578#ifdef __WIN32OS2__
     579#ifdef DEBUG
     580extern void dump_Variant(VARIANT * pvar);
     581#else
     582#define  dump_Variant(a)
     583#endif
     584#else
     585extern void dump_Variant(VARIANT * pvar);
     586#endif
     587
    560588#include "poppack.h"
    561589
    562590/*---------------------------END--------------------------------------------*/
    563591#endif
    564 
    565 
  • trunk/src/oleaut32/variant.c

    r8450 r9400  
    3636
    3737#include "config.h"
    38  
     38
    3939#include <string.h>
    4040#include <stdlib.h>
     
    5353#include "winerror.h"
    5454#include "parsedt.h"
     55#include "typelib.h"
    5556
    5657WINE_DEFAULT_DEBUG_CHANNEL(ole);
     
    100101 * 400 then it is a leap year.
    101102 */
    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 */
     108static 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
    111114 *
    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
     155typedef struct tagFORMATTOKEN {
     156    char  *str;
     157    BYTE   tokenSize;
     158    BYTE   tokenId;
     159    int    varTypeRequired;
     160} FORMATTOKEN;
     161
     162typedef struct tagFORMATHDR {
     163    BYTE   len;
     164    BYTE   hex3;
     165    BYTE   hex6;
     166    BYTE   reserved[8];
     167} FORMATHDR;
     168
     169FORMATTOKEN 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};
    117203
    118204/******************************************************************************
     
    248334    int leapYear = 0;
    249335
    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. */
    251338
    252339    /* Start at 1. This is the way DATE is defined.
     
    257344    *pDateOut = 1;
    258345
    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;
    319420    }
    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
    328422    *pDateOut += pTm->tm_hour / 24.0;
    329423    *pDateOut += pTm->tm_min / 1440.0;
     
    346440 * Returns TRUE if successful.
    347441 */
    348 static BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
     442BOOL DateToTm( DATE dateIn, DWORD dwFlags, struct tm* pTm )
    349443{
    350444    double decimalPart = 0.0;
    351445    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;
    357446
    358447    memset(pTm,0,sizeof(*pTm));
     
    365454     * This simplifies the processing of the DATE value.
    366455     */
     456    decimalPart = fmod( dateIn, 1.0 ); /* Do this before the -1, otherwise 0.xx goes negative */
    367457    dateIn -= 1.0;
    368 
    369458    wholePart = (double) floor( dateIn );
    370     decimalPart = fmod( dateIn, wholePart );
    371459
    372460    if( !(dwFlags & VAR_TIMEVALUEONLY) )
    373461    {
    374         int nDay = 0;
     462        unsigned int nDay = 0;
    375463        int leapYear = 0;
    376464        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            }
    462577        }
    463578    }
     
    466581        /* find the number of seconds in this day.
    467582         * 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
    468585         */
    469586        pTm->tm_hour = (int) ( decimalPart * 24 );
    470587        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);
    472591    }
    473592    return TRUE;
     
    521640        break;
    522641    case( VT_BSTR ):
     642    case( VT_DISPATCH ):
     643    case( VT_UNKNOWN ):
    523644        size = sizeof(void*);
    524645        break;
    525646    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 */
    529650    default:
    530651        FIXME("Add size information for type vt=%d\n", V_VT(parg) & VT_TYPEMASK );
     
    536657/******************************************************************************
    537658 *         StringDupAtoBstr             [INTERNAL]
    538  * 
     659 *
    539660 */
    540661static BSTR StringDupAtoBstr( char* strIn )
     
    563684   nSign = (d >= 0.0) ? 1 : -1;
    564685    d = fabs( d );
    565    
     686
    566687        /* Remove the decimals.
    567688         */
     
    630751                str[0] = '\0';
    631752                strToken = strtok( pNewString, strOfCharToRemove );
    632                 while( strToken != NULL ) { 
     753                while( strToken != NULL ) {
    633754                        strcat( str, strToken );
    634755                        strToken = strtok( NULL, strOfCharToRemove );
     
    671792        int nTokens = 0;
    672793        LPSTR pChar = NULL;
    673        
     794
    674795        /* Check if we have a valid argument
    675796         */
     
    684805                 */
    685806                strToken = strtok( strRealString, " " );
    686                 while( strToken != NULL ) { 
    687                         nTokens++;             
    688                         strToken = strtok( NULL, " " ); 
     807                while( strToken != NULL ) {
     808                        nTokens++;
     809                        strToken = strtok( NULL, " " );
    689810                }
    690811
     
    778899                case '7':
    779900                case '8':
    780                 case '9': 
     901                case '9':
    781902                        if( bFirstDigitsProcessed == FALSE )
    782903                        {
     
    824945                /* If DecimalPoint...
    825946                 */
    826                 case '.': 
     947                case '.':
    827948                        if( bDecimalPointProcessed ||
    828949                                bSecondDigitsProcessed ||
     
    8941015        vtFrom = V_VT(ps) & VT_TYPEMASK;
    8951016
    896        
     1017
    8971018        /* Note: Since "long" and "int" values both have 4 bytes and are
    8981019         * both signed integers "int" will be treated as "long" in the
     
    9011022         */
    9021023
    903         /* Trivial Case: If the coercion is from two types that are 
     1024        /* Trivial Case: If the coercion is from two types that are
    9041025         * identical then we can blindly copy from one argument to another.*/
    9051026        if ((vt==vtFrom))
     
    12471368                }
    12481369                break;
    1249                
     1370
    12501371        case( VT_R4 ):
    12511372                switch( vtFrom )
     
    16101731                break;
    16111732        }
    1612        
     1733
    16131734        return res;
    16141735}
     
    16561777                        res = DISP_E_BADVARTYPE;
    16571778                }
    1658                        
     1779
    16591780    }
    16601781    else
     
    16621783        res = ValidateVtRange( vt );
    16631784    }
    1664                
     1785
    16651786        return res;
    16661787}
     
    16891810                        res = DISP_E_BADVARTYPE;
    16901811                }
    1691                        
     1812
    16921813    }
    16931814    else
     
    16951816        res = ValidateVtRange( vt );
    16961817    }
    1697                
     1818
    16981819        return res;
    16991820}
     
    17701891      }
    17711892    }
    1772        
     1893
    17731894    /*
    17741895     * Empty all the fields and mark the type as empty.
     
    18001921  {
    18011922    res = VariantClear( pvargDest );
    1802                
     1923
    18031924    if( res == S_OK )
    18041925    {
     
    18541975          }
    18551976        }
    1856        
     1977
    18571978        V_VT(pvargDest) = V_VT(pvargSrc);
    1858       }     
     1979      }
    18591980    }
    18601981  }
     
    18802001  if( res != S_OK )
    18812002    return res;
    1882  
     2003
    18832004  if( V_VT(pvargSrc) & VT_BYREF )
    18842005  {
     
    19312052                 * If the inner Variant itself contains an
    19322053                 * other inner variant the E_INVALIDARG error is
    1933                  * returned. 
     2054                 * returned.
    19342055                 */
    19352056                if( pvargSrc->n1.n2.wReserved1 & PROCESSING_INNER_VARIANT )
     
    19482069                   */
    19492070                  (V_UNION(pvargSrc,pvarVal))->n1.n2.wReserved1 |= PROCESSING_INNER_VARIANT;
    1950                  
     2071
    19512072                  /* Dereference the inner variant.
    19522073                   */
     
    20112132        VARIANTARG varg;
    20122133        VariantInit( &varg );
    2013        
     2134
    20142135        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);
    20152138
    20162139        /* validate our source argument.
     
    20562179                                VariantClear( &Variant );
    20572180                        }
    2058        
     2181
    20592182                }
    20602183                else
     
    20682191         */
    20692192        VariantClear( &varg );
    2070        
     2193
    20712194        /* set the type of the destination
    20722195         */
     
    20742197                V_VT(pvargDest) = vt;
    20752198
     2199    TRACE("Dest Var:\n");
     2200    dump_Variant(pvargDest);
     2201
    20762202        return res;
    20772203}
     
    20952221
    20962222        *pbOut = (BYTE) sIn;
    2097        
     2223
    20982224        return S_OK;
    20992225}
     
    21142240
    21152241        *pbOut = (BYTE) lIn;
    2116        
     2242
    21172243        return S_OK;
    21182244}
     
    21352261
    21362262        *pbOut = (BYTE) fltIn;
    2137        
     2263
    21382264        return S_OK;
    21392265}
     
    22642390         */
    22652391        dValue = atof( pNewString );
    2266        
     2392
    22672393        /* We don't need the string anymore so free it.
    22682394         */
     
    22882414HRESULT WINAPI VarUI1FromCy(CY cyIn, BYTE* pbOut) {
    22892415   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2290    
     2416
    22912417   if (t > UI1_MAX || t < UI1_MIN) return DISP_E_OVERFLOW;
    2292    
     2418
    22932419   *pbOut = (BYTE)t;
    22942420   return S_OK;
     
    23032429
    23042430        *psOut = (short) bIn;
    2305        
     2431
    23062432        return S_OK;
    23072433}
     
    23222448
    23232449        *psOut = (short) lIn;
    2324        
     2450
    23252451        return S_OK;
    23262452}
     
    24702596         */
    24712597        dValue = atof( pNewString );
    2472        
     2598
    24732599        /* We don't need the string anymore so free it.
    24742600         */
     
    24942620HRESULT WINAPI VarI2FromCy(CY cyIn, short* psOut) {
    24952621   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2496    
     2622
    24972623   if (t > I2_MAX || t < I2_MIN) return DISP_E_OVERFLOW;
    2498    
     2624
    24992625   *psOut = (SHORT)t;
    25002626   return S_OK;
     
    26632789         */
    26642790        dValue = atof( pNewString );
    2665        
     2791
    26662792        /* We don't need the string anymore so free it.
    26672793         */
     
    26872813HRESULT WINAPI VarI4FromCy(CY cyIn, LONG* plOut) {
    26882814   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2689    
     2815
    26902816   if (t > I4_MAX || t < I4_MIN) return DISP_E_OVERFLOW;
    2691    
     2817
    26922818   *plOut = (LONG)t;
    26932819   return S_OK;
     
    28382964         */
    28392965        dValue = atof( pNewString );
    2840        
     2966
    28412967        /* We don't need the string anymore so free it.
    28422968         */
     
    28612987HRESULT WINAPI VarR4FromCy(CY cyIn, FLOAT* pfltOut) {
    28622988   *pfltOut = (FLOAT)((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    2863    
     2989
    28642990   return S_OK;
    28652991}
     
    29813107        LPSTR pNewString = NULL;
    29823108
    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 );
    29843111
    29853112        /* Check if we have a valid argument
    29863113         */
    2987         pNewString = HEAP_strdupWtoA( GetProcessHeap(), 0, strIn );
    29883114        RemoveCharacterFromString( pNewString, "," );
    29893115        if( IsValidRealString( pNewString ) == FALSE )
     
    29953121         */
    29963122        dValue = atof( pNewString );
    2997        
     3123
    29983124        /* We don't need the string anymore so free it.
    29993125         */
     
    30113137HRESULT WINAPI VarR8FromCy(CY cyIn, double* pdblOut) {
    30123138   *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);
    30143140   return S_OK;
    30153141}
     
    31003226 *
    31013227 * The formats for the date part are has follows:
    3102  * mm/[dd/][yy]yy 
     3228 * mm/[dd/][yy]yy
    31033229 * [dd/]mm/[yy]yy
    3104  * [yy]yy/mm/dd 
     3230 * [yy]yy/mm/dd
    31053231 * January dd[,] [yy]yy
    31063232 * dd January [yy]yy
     
    31093235 *
    31103236 * The formats for the date and time string are has follows.
    3111  * date[whitespace][time] 
     3237 * date[whitespace][time]
    31123238 * [time][whitespace]date
    31133239 *
     
    31353261        ret = DISP_E_TYPEMISMATCH;
    31363262    }
    3137 
    3138 
     3263    TRACE("Return value %f\n", *pdateOut);
    31393264        return ret;
    31403265}
     
    32183343
    32193344        *pbstrOut =  StringDupAtoBstr( pBuffer );
    3220        
     3345
    32213346        return S_OK;
    32223347}
     
    32773402 */
    32783403HRESULT 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
    32843419/******************************************************************************
    32853420 *              VarBstrFromDate         [OLEAUT32.114]
     
    33163451    memset( &TM, 0, sizeof(TM) );
    33173452
    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 );
    33193454
    33203455    if( DateToTm( dateIn, dwFlags, &TM ) == FALSE )
     
    33303465        strftime( pBuffer, BUFFER_MAX, "%x %X", &TM );
    33313466
     3467        TRACE("result: %s\n", pBuffer);
    33323468                *pbstrOut = StringDupAtoBstr( pBuffer );
    3333 
    33343469        return S_OK;
    33353470}
     
    35083643
    35093644        HeapFree( GetProcessHeap(), 0, pNewString );
    3510        
     3645
    35113646        return ret;
    35123647}
     
    35553690      if (cyIn.s.Hi || cyIn.s.Lo) *pboolOut = -1;
    35563691      else *pboolOut = 0;
    3557      
     3692
    35583693      return S_OK;
    35593694}
     
    36883823         */
    36893824        dValue = atof( pNewString );
    3690  
     3825
    36913826        /* We don't need the string anymore so free it.
    36923827         */
     
    37583893HRESULT WINAPI VarI1FromCy(CY cyIn, CHAR* pcOut) {
    37593894   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3760    
     3895
    37613896   if (t > CHAR_MAX || t < CHAR_MIN) return DISP_E_OVERFLOW;
    3762    
     3897
    37633898   *pcOut = (CHAR)t;
    37643899   return S_OK;
     
    38874022         */
    38884023        dValue = atof( pNewString );
    3889  
     4024
    38904025        /* We don't need the string anymore so free it.
    38914026         */
     
    39364071        TRACE("( %ld, %p ), stub\n", ulIn, puiOut );
    39374072
    3938         if( ulIn < UI2_MIN || ulIn > UI2_MAX )
     4073        if( ulIn > UI2_MAX )
    39394074        {
    39404075                return DISP_E_OVERFLOW;
     
    39684103         */
    39694104        dValue = atof( pNewString );
    3970  
     4105
    39714106        /* We don't need the string anymore so free it.
    39724107         */
     
    39924127HRESULT WINAPI VarUI2FromCy(CY cyIn, USHORT* pusOut) {
    39934128   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    3994    
     4129
    39954130   if (t > UI2_MAX || t < UI2_MIN) return DISP_E_OVERFLOW;
    3996      
     4131
    39974132   *pusOut = (USHORT)t;
    3998    
     4133
    39994134   return S_OK;
    40004135}
     
    40364171        TRACE("( %ld, %p ), stub\n", lIn, pulOut );
    40374172
    4038         if( lIn < UI4_MIN )
     4173        if( lIn < 0 )
    40394174        {
    40404175                return DISP_E_OVERFLOW;
     
    41404275HRESULT WINAPI VarUI4FromCy(CY cyIn, ULONG* pulOut) {
    41414276   double t = round((((double)cyIn.s.Hi * 4294967296.0) + (double)cyIn.s.Lo) / 10000);
    4142    
     4277
    41434278   if (t > UI4_MAX || t < UI4_MIN) return DISP_E_OVERFLOW;
    41444279
     
    41804315      pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    41814316      if (lIn < 0) pcyOut->s.Hi--;
    4182    
     4317
    41834318      return S_OK;
    41844319}
     
    41934328   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    41944329   if (fltIn < 0) pcyOut->s.Hi--;
    4195    
     4330
    41964331   return S_OK;
    41974332}
     
    42254360/**********************************************************************
    42264361 *              VarCyFromStr [OLEAUT32.104]
     4362 * FIXME: Never tested with decimal seperator other than '.'
    42274363 */
    42284364HRESULT 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
    42344415/**********************************************************************
    42354416 *              VarCyFromBool [OLEAUT32.106]
     
    42404421   else pcyOut->s.Hi = 0;
    42414422   pcyOut->s.Lo = (ULONG)boolIn * (ULONG)10000;
    4242    
     4423
    42434424   return S_OK;
    42444425}
     
    42524433   else pcyOut->s.Hi = 0;
    42534434   pcyOut->s.Lo = (ULONG)cIn * (ULONG)10000;
    4254    
     4435
    42554436   return S_OK;
    42564437}
     
    42634444   pcyOut->s.Hi = 0;
    42644445   pcyOut->s.Lo = (ULONG)usIn * (ULONG)10000;
    4265    
     4446
    42664447   return S_OK;
    42674448}
     
    42754456   pcyOut->s.Hi = (LONG)(t / (double)4294967296.0);
    42764457   pcyOut->s.Lo = (ULONG)fmod(t, (double)4294967296.0);
    4277      
     4458
    42784459   return S_OK;
    42794460}
     
    42914472
    42924473    TRACE("( 0x%x, 0x%x, %p ), stub\n", wDosDate, wDosTime, pvtime );
    4293    
     4474
    42944475    t.tm_sec = (wDosTime & 0x001f) * 2;
    42954476    t.tm_min = (wDosTime & 0x07e0) >> 5;
    42964477    t.tm_hour = (wDosTime & 0xf800) >> 11;
    4297    
     4478
    42984479    t.tm_mday = (wDosDate & 0x001f);
    42994480    t.tm_mon = (wDosDate & 0x01e0) >> 5;
     
    43124493    int i,lastent=0;
    43134494    int cDig;
     4495    BOOL foundNum=FALSE;
     4496
    43144497    FIXME("(%s,flags=%lx,....), partial stub!\n",debugstr_w(strIn),dwFlags);
    43154498    FIXME("numparse: cDig=%d, InFlags=%lx\n",pnumprs->cDig,pnumprs->dwInFlags);
    43164499
    43174500    /* The other struct components are to be set by us */
    4318 
    43194501    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;
    43204508
    43214509    cDig = 0;
    43224510    for (i=0; strIn[i] ;i++) {
    43234511        if ((strIn[i]>='0') && (strIn[i]<='9')) {
     4512            foundNum = TRUE;
    43244513            if (pnumprs->cDig > cDig) {
    43254514                *(rgbDig++)=strIn[i]-'0';
     
    43274516                lastent = i;
    43284517            }
    4329         }
     4518        } else if ((strIn[i]=='-') && (foundNum==FALSE)) {
     4519            pnumprs->dwOutFlags |= NUMPRS_NEG;
     4520        }
    43304521    }
    43314522    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);
    43384524    return S_OK;
    43394525}
     
    43484534    DWORD xint;
    43494535    int i;
    4350     FIXME("(,dwVtBits=%lx,....), partial stub!\n",dwVtBits);
     4536    FIXME("(..,dwVtBits=%lx,....), partial stub!\n",dwVtBits);
    43514537
    43524538    xint = 0;
    43534539    for (i=0;i<pnumprs->cDig;i++)
    43544540        xint = xint*10 + rgbDig[i];
     4541
     4542    if (pnumprs->dwOutFlags & NUMPRS_NEG) {
     4543        xint = xint * -1;
     4544    }
    43554545
    43564546    VariantInit(pvar);
     
    43644554        V_UNION(pvar,dblVal) = xint;
    43654555        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);
    43684577        return E_FAIL;
    4369     }
    4370 }
    4371 
     4578}
     4579
     4580
     4581/**********************************************************************
     4582 *              VarFormatDateTime [OLEAUT32.97]
     4583 */
     4584HRESULT 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 */
     4593HRESULT 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}
    43724598
    43734599/**********************************************************************
     
    44034629HRESULT WINAPI SystemTimeToVariantTime( LPSYSTEMTIME  lpSystemTime, double *pvtime )
    44044630{
    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 
    44084631    struct tm t;
    44094632
     
    44204643
    44214644        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 */
    44234646        t.tm_year = lpSystemTime->wYear;
    44244647
     
    44274650    else
    44284651    {
     4652        double tmpDate;
     4653        long firstDayOfNextYear;
     4654        long thisDay;
     4655        long leftInYear;
     4656        long result;
     4657
     4658        double decimalPart = 0.0;
     4659
    44294660        t.tm_sec = lpSystemTime->wSecond;
    44304661        t.tm_min = lpSystemTime->wMinute;
    44314662        t.tm_hour = lpSystemTime->wHour;
    44324663
    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 */
    44394665        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 */
    44414670        TmToDATE( &t, pvtime );
    44424671
    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);
    44444699
    44454700        return 1;
     
    44684723    struct tm r;
    44694724
    4470     TRACE(" Variant = %f SYSTEMTIME ptr %p", vtime, lpSystemTime);
     4725    TRACE(" Variant = %f SYSTEMTIME ptr %p\n", vtime, lpSystemTime);
    44714726
    44724727    if (vtime >= 0)
     
    46194874    *datein = t;
    46204875
    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;
    46254878}
    46264879
    46274880
    46284881/**********************************************************************
    4629  *              VarBstrCmp [OLEAUT32.440]
     4882 *              VarBstrCmp [OLEAUT32.314]
    46304883 *
    4631  * flags can be: 
     4884 * flags can be:
    46324885 *   NORM_IGNORECASE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS
    46334886 *   NORM_IGNORESTRINGWIDTH, NORM_IGNOREKANATYPE, NORM_IGNOREKASHIDA
     
    46364889HRESULT WINAPI VarBstrCmp(BSTR left, BSTR right, LCID lcid, DWORD flags)
    46374890{
    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    }
    46444902
    46454903    if(flags&NORM_IGNORECASE)
     
    46574915
    46584916/**********************************************************************
    4659  *              VarBstrCat [OLEAUT32.439]
     4917 *              VarBstrCat [OLEAUT32.313]
    46604918 */
    46614919HRESULT WINAPI VarBstrCat(BSTR left, BSTR right, BSTR *out)
    46624920{
    46634921    BSTR result;
     4922    int size = 0;
    46644923
    46654924    TRACE("( %s %s %p )\n", debugstr_w(left), debugstr_w(right), out);
    46664925
    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;
    46764938}
    46774939
    46784940/**********************************************************************
    4679  *              VarCat [OLEAUT32.441]
     4941 *              VarCat [OLEAUT32.318]
    46804942 */
    46814943HRESULT WINAPI VarCat(LPVARIANT left, LPVARIANT right, LPVARIANT out)
     
    46994961    return S_OK;
    47004962}
     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 */
     4972HRESULT 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 */
     5078HRESULT 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 */
     5112HRESULT 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 */
     5147HRESULT 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 */
     5288HRESULT 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 */
     5486HRESULT 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 */
     5563HRESULT 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.