Ignore:
Timestamp:
Feb 15, 2002, 6:18:52 PM (24 years ago)
Author:
sandervl
Message:

Wine 20020215 resync

File:
1 edited

Legend:

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

    r7508 r7926  
    66 *      Copyright 1999  Francis Beaudet
    77 *  Copyright 1999  Sylvain St-Germain
     8 *  Copyright 2002  Marcus Meissner
    89 */
    910
     
    1415#include <string.h>
    1516#include <assert.h>
     17
    1618#include "windef.h"
     19#include "objbase.h"
     20#include "ole2.h"
     21#include "ole2ver.h"
     22#include "rpc.h"
     23#include "winerror.h"
     24#include "winreg.h"
     25#include "wownt32.h"
    1726#include "wtypes.h"
    18 #include "wingdi.h"
     27#include "wine/unicode.h"
     28#include "wine/obj_base.h"
     29#include "wine/obj_clientserver.h"
     30#include "wine/obj_misc.h"
     31#include "wine/obj_marshal.h"
     32#include "wine/obj_storage.h"
     33#include "wine/obj_channel.h"
    1934#include "wine/winbase16.h"
    20 #include "winerror.h"
    21 #include "wownt32.h"
    22 #include "ole2ver.h"
     35#include "compobj_private.h"
     36#include "ifs.h"
     37
    2338#include "debugtools.h"
    24 #include "heap.h"
    25 #include "winreg.h"
    26 #include "rpc.h"
    27 
    28 #include "wine/obj_base.h"
    29 #include "wine/obj_misc.h"
    30 #include "wine/obj_storage.h"
    31 #include "wine/obj_clientserver.h"
    32 
    33 #include "ole.h"
    34 #include "ifs.h"
    35 #include "compobj_private.h"
    36 
    37 #ifdef __WIN32OS2__
    38 #include <heapstring.h>
    39 #endif
    4039
    4140DEFAULT_DEBUG_CHANNEL(ole);
     
    4443 *  COM External Lock structures and methods declaration
    4544 *
    46  *  This api provides a linked list to managed external references to 
    47  *  COM objects. 
    48  *
    49  *  The public interface consists of three calls: 
     45 *  This api provides a linked list to managed external references to
     46 *  COM objects.
     47 *
     48 *  The public interface consists of three calls:
    5049 *      COM_ExternalLockAddRef
    5150 *      COM_ExternalLockRelease
     
    5756
    5857/*
    59  * Declaration of the static structure that manage the 
     58 * Declaration of the static structure that manage the
    6059 * external lock to COM  objects.
    6160 */
     
    8281
    8382/*
    84  * Public Interface to the external lock list   
     83 * Public Interface to the external lock list
    8584 */
    8685static void COM_ExternalLockFreeList();
     
    9089
    9190/*
    92  * Private methods used to managed the linked list   
     91 * Private methods used to managed the linked list
    9392 */
    9493static BOOL COM_ExternalLockInsert(
     
    125124 * libraries are freed
    126125 */
    127 static ULONG s_COMLockCount = 0;
     126static LONG s_COMLockCount = 0;
    128127
    129128/*
     
    142141  DWORD     connectFlags;
    143142  DWORD     dwCookie;
     143  HANDLE    hThread; /* only for localserver */
    144144  struct tagRegisteredClass* nextClass;
    145145} RegisteredClass;
    146146
     147static CRITICAL_SECTION csRegisteredClassList;
    147148static RegisteredClass* firstRegisteredClass = NULL;
    148149
     
    152153 */
    153154typedef struct tagOpenDll {
    154   HINSTANCE hLibrary;       
     155  HINSTANCE hLibrary;
    155156  struct tagOpenDll *next;
    156157} OpenDll;
    157158
     159static CRITICAL_SECTION csOpenDllList;
    158160static OpenDll *openDllList = NULL; /* linked list of open dlls */
    159161
     
    170172
    171173/******************************************************************************
     174 * Initialize/Uninitialize critical sections.
     175 */
     176void COMPOBJ_InitProcess( void )
     177{
     178    InitializeCriticalSection( &csRegisteredClassList );
     179    InitializeCriticalSection( &csOpenDllList );
     180}
     181
     182void COMPOBJ_UninitProcess( void )
     183{
     184    DeleteCriticalSection( &csRegisteredClassList );
     185    DeleteCriticalSection( &csOpenDllList );
     186}
     187
     188/******************************************************************************
    172189 *           CoBuildVersion [COMPOBJ.1]
     190 *           CoBuildVersion [OLE32.4]
    173191 *
    174192 * RETURNS
     
    181199}
    182200
    183 #ifndef __WIN32OS2__
    184 /******************************************************************************
    185  *              CoInitialize16  [COMPOBJ.2]
     201/******************************************************************************
     202 *              CoInitialize    [COMPOBJ.2]
    186203 * Set the win16 IMalloc used for memory management
    187204 */
     
    192209    return S_OK;
    193210}
    194 #endif
    195211
    196212/******************************************************************************
     
    204220        LPVOID lpReserved       /* [in] pointer to win32 malloc interface
    205221                                   (obsolete, should be NULL) */
    206 ) 
     222)
    207223{
    208224  /*
     
    225241 *
    226242 * BUGS
    227  * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE 
     243 * Only the single threaded model is supported. As a result RPC_E_CHANGED_MODE
    228244 * is never returned.
    229245 *
     
    234250                                   (obsolete, should be NULL) */
    235251        DWORD dwCoInit          /* [in] A value from COINIT specifies the threading model */
    236 ) 
     252)
    237253{
    238254  HRESULT hr;
     
    248264   * Check for unsupported features.
    249265   */
    250   if (dwCoInit!=COINIT_APARTMENTTHREADED) 
     266  if (dwCoInit!=COINIT_APARTMENTTHREADED)
    251267  {
    252268    FIXME(":(%p,%x): unsupported flag %x\n", lpReserved, (int)dwCoInit, (int)dwCoInit);
     
    257273   * Check the lock count. If this is the first time going through the initialize
    258274   * process, we have to initialize the libraries.
     275   *
     276   * And crank-up that lock count.
    259277   */
    260   if (s_COMLockCount==0)
     278  if (InterlockedExchangeAdd(&s_COMLockCount,1)==0)
    261279  {
    262280    /*
     
    265283    TRACE("() - Initializing the COM libraries\n");
    266284
     285
    267286    RunningObjectTableImpl_Initialize();
    268287
     
    272291    hr = S_FALSE;
    273292
    274   /*
    275    * Crank-up that lock count.
    276    */
    277   s_COMLockCount++;
    278 
    279293  return hr;
    280294}
    281295
    282 #ifndef __WIN32OS2__
    283 /***********************************************************************
    284  *           CoUninitialize16   [COMPOBJ.3]
    285  * Don't know what it does.
     296/***********************************************************************
     297 *           CoUninitialize   [COMPOBJ.3]
     298 * Don't know what it does.
    286299 * 3-Nov-98 -- this was originally misspelled, I changed it to what I
    287300 *   believe is the correct spelling
     
    292305  CoFreeAllLibraries();
    293306}
    294 #endif
    295307
    296308/***********************************************************************
     
    303315void WINAPI CoUninitialize(void)
    304316{
     317  LONG lCOMRefCnt;
    305318  TRACE("()\n");
    306  
     319
    307320  /*
    308321   * Decrease the reference count.
    309    */
    310   s_COMLockCount--;
    311  
    312   /*
    313322   * If we are back to 0 locks on the COM library, make sure we free
    314323   * all the associated data structures.
    315324   */
    316   if (s_COMLockCount==0)
     325  lCOMRefCnt = InterlockedExchangeAdd(&s_COMLockCount,-1);
     326  if (lCOMRefCnt==1)
    317327  {
    318328    /*
     
    336346     */
    337347    COM_ExternalLockFreeList();
    338 }
     348
     349  }
     350  else if (lCOMRefCnt<1) {
     351    ERR( "CoUninitialize() - not CoInitialized.\n" );
     352    InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */
     353  }
    339354}
    340355
    341356#ifndef __WIN32OS2__
    342357/***********************************************************************
    343  *           CoGetMalloc16    [COMPOBJ.4]
     358 *           CoGetMalloc    [COMPOBJ.4]
    344359 * RETURNS
    345360 *      The current win16 IMalloc
     
    355370}
    356371#endif
    357 
    358372/******************************************************************************
    359373 *              CoGetMalloc     [OLE32.20]
     
    374388#ifndef __WIN32OS2__
    375389/***********************************************************************
    376  *           CoCreateStandardMalloc16 [COMPOBJ.71]
     390 *           CoCreateStandardMalloc [COMPOBJ.71]
    377391 */
    378392HRESULT WINAPI CoCreateStandardMalloc16(DWORD dwMemContext,
     
    384398    return S_OK;
    385399}
     400#endif
    386401
    387402/******************************************************************************
    388403 *              CoDisconnectObject      [COMPOBJ.15]
     404 *              CoDisconnectObject      [OLE32.8]
    389405 */
    390406HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
     
    395411
    396412/***********************************************************************
    397  *           IsEqualGUID16 [COMPOBJ.18]
     413 *           IsEqualGUID [COMPOBJ.18]
    398414 *
    399415 * Compares two Unique Identifiers.
     
    408424    return !memcmp( g1, g2, sizeof(GUID) );
    409425}
    410 #endif
    411 
    412 /******************************************************************************
    413  *              CLSIDFromString16       [COMPOBJ.20]
    414  * Converts a unique identifier from its string representation into
     426
     427/******************************************************************************
     428 *              CLSIDFromString [COMPOBJ.20]
     429 * Converts a unique identifier from its string representation into
    415430 * the GUID struct.
    416431 *
    417  * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6] 
     432 * Class id: DWORD-WORD-WORD-BYTES[2]-BYTES[6]
    418433 *
    419434 * RETURNS
     
    516531/******************************************************************************
    517532 *              CLSIDFromString [OLE32.3]
    518  * Converts a unique identifier from its string representation into
     533 *              IIDFromString   [OLE32.74]
     534 * Converts a unique identifier from its string representation into
    519535 * the GUID struct.
    520536 *
     
    527543HRESULT WINAPI CLSIDFromString(
    528544        LPCOLESTR idstr,        /* [in] string representation of GUID */
    529         CLSID *id               /* [out] GUID represented by above string */
    530 ) {
    531     LPOLESTR16      xid = HEAP_strdupWtoA(GetProcessHeap(),0,idstr);
    532     HRESULT       ret = CLSIDFromString16(xid,id);
    533 
    534     HeapFree(GetProcessHeap(),0,xid);
     545        CLSID *id )             /* [out] GUID represented by above string */
     546{
     547    char xid[40];
     548    HRESULT ret;
     549
     550    if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL ))
     551        return CO_E_CLASSSTRING;
     552    ret = CLSIDFromString16(xid,id);
    535553    if(ret != S_OK) { /* It appears a ProgID is also valid */
    536554        ret = CLSIDFromProgID(idstr, id);
     
    548566 *      the string representation and HRESULT
    549567 */
    550 #ifdef __WIN32OS2__
    551 HRESULT WINAPI WINE_StringFromCLSID(
     568HRESULT WINE_StringFromCLSID(
    552569        const CLSID *id,        /* [in] GUID to be converted */
    553570        LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    554 #else
    555 static HRESULT WINE_StringFromCLSID(
    556         const CLSID *id,        /* [in] GUID to be converted */
    557         LPSTR idstr             /* [out] pointer to buffer to contain converted guid */
    558 #endif
    559571) {
    560572  static const char *hex = "0123456789ABCDEF";
     
    567579          return E_FAIL;
    568580        }
    569        
     581
    570582  sprintf(idstr, "{%08lX-%04X-%04X-%02X%02X-",
    571583          id->Data1, id->Data2, id->Data3,
     
    586598  return S_OK;
    587599}
     600
    588601#ifndef __WIN32OS2__
    589602/******************************************************************************
    590  *              StringFromCLSID16       [COMPOBJ.19]
     603 *              StringFromCLSID [COMPOBJ.19]
    591604 * Converts a GUID into the respective string representation.
    592605 * The target string is allocated using the OLE IMalloc.
     
    629642}
    630643#endif
     644
    631645/******************************************************************************
    632646 *              StringFromCLSID [OLE32.151]
     647 *              StringFromIID   [OLE32.153]
    633648 * Converts a GUID into the respective string representation.
    634649 * The target string is allocated using the OLE IMalloc.
     
    657672
    658673/******************************************************************************
    659  *              StringFromGUID2 [COMPOBJ.76] [OLE32.152]
     674 *              StringFromGUID2 [COMPOBJ.76]
     675 *              StringFromGUID2 [OLE32.152]
    660676 *
    661677 * Converts a global unique identifier into a string of an API-
     
    729745
    730746/******************************************************************************
    731  *              CLSIDFromProgID16       [COMPOBJ.61]
     747 *              CLSIDFromProgID [COMPOBJ.61]
    732748 * Converts a program id into the respective GUID. (By using a registry lookup)
    733749 * RETURNS
     
    767783HRESULT WINAPI CLSIDFromProgID(
    768784        LPCOLESTR progid,       /* [in] program id as found in registry */
    769         LPCLSID riid            /* [out] associated CLSID */
    770 ) {
    771         LPOLESTR16 pid = HEAP_strdupWtoA(GetProcessHeap(),0,progid);
    772         HRESULT       ret = CLSIDFromProgID16(pid,riid);
    773 
    774         HeapFree(GetProcessHeap(),0,pid);
    775         return ret;
     785        LPCLSID riid )          /* [out] associated CLSID */
     786{
     787    static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
     788    char buf2[80];
     789    DWORD buf2len = sizeof(buf2);
     790    HKEY xhkey;
     791
     792    WCHAR *buf = HeapAlloc( GetProcessHeap(),0,(strlenW(progid)+8) * sizeof(WCHAR) );
     793    strcpyW( buf, progid );
     794    strcatW( buf, clsidW );
     795    if (RegOpenKeyW(HKEY_CLASSES_ROOT,buf,&xhkey))
     796    {
     797        HeapFree(GetProcessHeap(),0,buf);
     798        return CO_E_CLASSSTRING;
     799    }
     800    HeapFree(GetProcessHeap(),0,buf);
     801
     802    if (RegQueryValueA(xhkey,NULL,buf2,&buf2len))
     803    {
     804        RegCloseKey(xhkey);
     805        return CO_E_CLASSSTRING;
     806    }
     807    RegCloseKey(xhkey);
     808    return CLSIDFromString16(buf2,riid);
    776809}
    777810
     
    782815 *
    783816 * This function returns the CLSID of the DLL that implements the proxy and stub
    784  * for the specified interface. 
    785  *
    786  * It determines this by searching the 
     817 * for the specified interface.
     818 *
     819 * It determines this by searching the
    787820 * HKEY_CLASSES_ROOT\Interface\{string form of riid}\ProxyStubClsid32 in the registry
    788821 * and any interface id registered by CoRegisterPSClsid within the current process.
    789  * 
     822 *
    790823 * FIXME: We only search the registry, not ids registered with CoRegisterPSClsid.
    791824 */
     
    822855
    823856    /* ... Once we have the key, query the registry to get the
    824        value of CLSID as a string, and convert it into a 
     857       value of CLSID as a string, and convert it into a
    825858       proper CLSID structure to be passed back to the app */
    826859    buf2len = sizeof(buf2);
     
    846879
    847880/***********************************************************************
    848  *              WriteClassStm
     881 *              WriteClassStm (OLE32.159)
    849882 *
    850883 * This function write a CLSID on stream
     
    861894
    862895/***********************************************************************
    863  *              ReadClassStm
     896 *              ReadClassStm (OLE32.135)
    864897 *
    865898 * This function read a CLSID from a stream
    866899 */
    867 HRESULT WINAPI ReadClassStm(IStream *pStm,REFCLSID rclsid)
     900HRESULT WINAPI ReadClassStm(IStream *pStm,CLSID *pclsid)
    868901{
    869902    ULONG nbByte;
    870903    HRESULT res;
    871    
    872     TRACE("(%p,%p)\n",pStm,rclsid);
    873 
    874     if (rclsid==NULL)
     904
     905    TRACE("(%p,%p)\n",pStm,pclsid);
     906
     907    if (pclsid==NULL)
    875908        return E_INVALIDARG;
    876    
    877     res = IStream_Read(pStm,(void*)rclsid,sizeof(CLSID),&nbByte);
     909
     910    res = IStream_Read(pStm,(void*)pclsid,sizeof(CLSID),&nbByte);
    878911
    879912    if (FAILED(res))
    880913        return res;
    881    
     914
    882915    if (nbByte != sizeof(CLSID))
    883916        return S_FALSE;
     
    908941        return 0;
    909942}
    910 
     943#endif
    911944/* FIXME: this function is not declared in the WINELIB headers. But where should it go ? */
    912945/***********************************************************************
    913  *           CallObjectInWOW (COMPOBJ.201)
     946 *           CALLOBJECTINWOW (COMPOBJ.201)
    914947 */
    915948HRESULT WINAPI CallObjectInWOW(LPVOID p1,LPVOID p2) {
     
    919952
    920953/******************************************************************************
    921  *              CoRegisterClassObject16 [COMPOBJ.5]
     954 *              CoRegisterClassObject   [COMPOBJ.5]
    922955 *
    923956 * Don't know where it registers it ...
     
    942975
    943976/******************************************************************************
    944  *      CoRevokeClassObject16 [COMPOBJ.6]
     977 *      CoRevokeClassObject [COMPOBJ.6]
    945978 *
    946979 */
     
    950983    return 0;
    951984}
    952 #endif
    953 
     985
     986/******************************************************************************
     987 *      CoFileTimeToDosDateTime [COMPOBJ.30]
     988 */
     989BOOL16 WINAPI CoFileTimeToDosDateTime16(const FILETIME *ft, LPWORD lpDosDate, LPWORD lpDosTime)
     990{
     991    return FileTimeToDosDateTime(ft, lpDosDate, lpDosTime);
     992}
     993
     994/******************************************************************************
     995 *      CoDosDateTimeToFileTime [COMPOBJ.31]
     996 */
     997BOOL16 WINAPI CoDosDateTimeToFileTime16(WORD wDosDate, WORD wDosTime, FILETIME *ft)
     998{
     999    return DosDateTimeToFileTime(wDosDate, wDosTime, ft);
     1000}
    9541001
    9551002/***
    9561003 * COM_GetRegisteredClassObject
    9571004 *
    958  * This internal method is used to scan the registered class list to 
     1005 * This internal method is used to scan the registered class list to
    9591006 * find a class object.
    9601007 *
    961  * Params: 
     1008 * Params:
    9621009 *   rclsid        Class ID of the class to find.
    9631010 *   dwClsContext  Class context to match.
     
    9711018        LPUNKNOWN*  ppUnk)
    9721019{
     1020  HRESULT hr = S_FALSE;
    9731021  RegisteredClass* curClass;
     1022
     1023  EnterCriticalSection( &csRegisteredClassList );
    9741024
    9751025  /*
     
    10021052      IUnknown_AddRef(curClass->classObject);
    10031053
    1004       return S_OK;
     1054      hr = S_OK;
     1055      goto end;
    10051056    }
    10061057
     
    10111062  }
    10121063
     1064end:
     1065  LeaveCriticalSection( &csRegisteredClassList );
    10131066  /*
    10141067   * If we get to here, we haven't found our class.
    10151068   */
    1016   return S_FALSE;
     1069  return hr;
     1070}
     1071
     1072static DWORD WINAPI
     1073_LocalServerThread(LPVOID param) {
     1074    HANDLE              hPipe;
     1075    char                pipefn[200];
     1076    RegisteredClass *newClass = (RegisteredClass*)param;
     1077    HRESULT             hres;
     1078    IStream             *pStm;
     1079    STATSTG             ststg;
     1080    unsigned char       *buffer;
     1081    int                 buflen;
     1082    IClassFactory       *classfac;
     1083    LARGE_INTEGER       seekto;
     1084    ULARGE_INTEGER      newpos;
     1085    ULONG               res;
     1086
     1087    TRACE("Starting threader for %s.\n",debugstr_guid(&newClass->classIdentifier));
     1088    strcpy(pipefn,PIPEPREF);
     1089    WINE_StringFromCLSID(&newClass->classIdentifier,pipefn+strlen(PIPEPREF));
     1090
     1091    hres = IUnknown_QueryInterface(newClass->classObject,&IID_IClassFactory,(LPVOID*)&classfac);
     1092    if (hres) return hres;
     1093
     1094    hres = CreateStreamOnHGlobal(0,TRUE,&pStm);
     1095    if (hres) {
     1096        FIXME("Failed to create stream on hglobal.\n");
     1097        return hres;
     1098    }
     1099    hres = CoMarshalInterface(pStm,&IID_IClassFactory,(LPVOID)classfac,0,NULL,0);
     1100    if (hres) {
     1101        FIXME("CoMarshalInterface failed, %lx!\n",hres);
     1102        return hres;
     1103    }
     1104    hres = IStream_Stat(pStm,&ststg,0);
     1105    if (hres) return hres;
     1106
     1107    buflen = ststg.cbSize.s.LowPart;
     1108    buffer = HeapAlloc(GetProcessHeap(),0,buflen);
     1109    seekto.s.LowPart = 0;
     1110    seekto.s.HighPart = 0;
     1111    hres = IStream_Seek(pStm,seekto,SEEK_SET,&newpos);
     1112    if (hres) {
     1113        FIXME("IStream_Seek failed, %lx\n",hres);
     1114        return hres;
     1115    }
     1116    hres = IStream_Read(pStm,buffer,buflen,&res);
     1117    if (hres) {
     1118        FIXME("Stream Read failed, %lx\n",hres);
     1119        return hres;
     1120    }
     1121    IStream_Release(pStm);
     1122
     1123    while (1) {
     1124        hPipe = CreateNamedPipeA(
     1125            pipefn,
     1126            PIPE_ACCESS_DUPLEX,
     1127            PIPE_TYPE_BYTE|PIPE_WAIT,
     1128            PIPE_UNLIMITED_INSTANCES,
     1129            4096,
     1130            4096,
     1131            NMPWAIT_USE_DEFAULT_WAIT,
     1132            NULL
     1133        );
     1134        if (hPipe == INVALID_HANDLE_VALUE) {
     1135            FIXME("pipe creation failed for %s, le is %lx\n",pipefn,GetLastError());
     1136            return 1;
     1137        }
     1138        if (!ConnectNamedPipe(hPipe,NULL)) {
     1139            ERR("Failure during ConnectNamedPipe %lx, ABORT!\n",GetLastError());
     1140            CloseHandle(hPipe);
     1141            continue;
     1142        }
     1143        WriteFile(hPipe,buffer,buflen,&res,NULL);
     1144        CloseHandle(hPipe);
     1145    }
     1146    return 0;
    10171147}
    10181148
     
    10301160        DWORD flags,        /* [in] REGCLS flags indicating how connections are made */
    10311161        LPDWORD lpdwRegister
    1032 ) 
     1162)
    10331163{
    10341164  RegisteredClass* newClass;
    10351165  LPUNKNOWN        foundObject;
    10361166  HRESULT          hr;
    1037     char buf[80];
    1038 
    1039     WINE_StringFromCLSID(rclsid,buf);
    10401167
    10411168  TRACE("(%s,%p,0x%08lx,0x%08lx,%p)\n",
    1042         buf,pUnk,dwClsContext,flags,lpdwRegister);
    1043 
    1044   /*
    1045    * Perform a sanity check on the parameters
    1046    */
     1169        debugstr_guid(rclsid),pUnk,dwClsContext,flags,lpdwRegister);
     1170
    10471171  if ( (lpdwRegister==0) || (pUnk==0) )
    1048   {
    10491172    return E_INVALIDARG;
    1050 }
    1051 
    1052   /*
    1053    * Initialize the cookie (out parameter)
    1054    */
     1173
    10551174  *lpdwRegister = 0;
    10561175
     
    10601179   */
    10611180  hr = COM_GetRegisteredClassObject(rclsid, dwClsContext, &foundObject);
    1062 
    1063   if (hr == S_OK)
    1064   {
    1065     /*
    1066      * The COM_GetRegisteredClassObject increased the reference count on the
    1067      * object so it has to be released.
    1068      */
     1181  if (hr == S_OK) {
    10691182    IUnknown_Release(foundObject);
    1070 
    10711183    return CO_E_OBJISREG;
    10721184  }
    1073    
    1074   /*
    1075    * If it is not registered, we must create a new entry for this class and
    1076    * append it to the registered class list.
    1077    * We use the address of the chain node as the cookie since we are sure it's
    1078    * unique.
    1079    */
     1185
    10801186  newClass = HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass));
    1081 
    1082   /*
    1083    * Initialize the node.
    1084    */
     1187  if ( newClass == NULL )
     1188    return E_OUTOFMEMORY;
     1189
     1190  EnterCriticalSection( &csRegisteredClassList );
     1191
    10851192  newClass->classIdentifier = *rclsid;
    10861193  newClass->runContext      = dwClsContext;
    10871194  newClass->connectFlags    = flags;
     1195  /*
     1196   * Use the address of the chain node as the cookie since we are sure it's
     1197   * unique.
     1198   */
    10881199  newClass->dwCookie        = (DWORD)newClass;
    10891200  newClass->nextClass       = firstRegisteredClass;
     
    10971208
    10981209  firstRegisteredClass = newClass;
    1099 
    1100   /*
    1101    * Assign the out parameter (cookie)
    1102    */
     1210  LeaveCriticalSection( &csRegisteredClassList );
     1211
    11031212  *lpdwRegister = newClass->dwCookie;
    1104    
    1105   /*
    1106    * We're successful Yippee!
    1107    */
     1213
     1214  if (dwClsContext & CLSCTX_LOCAL_SERVER) {
     1215      DWORD tid;
     1216
     1217      STUBMGR_Start();
     1218      newClass->hThread=CreateThread(NULL,0,_LocalServerThread,newClass,0,&tid);
     1219  }
    11081220  return S_OK;
    11091221}
     
    11171229 */
    11181230HRESULT WINAPI CoRevokeClassObject(
    1119         DWORD dwRegister)
    1120 {
     1231        DWORD dwRegister)
     1232{
     1233  HRESULT hr = E_INVALIDARG;
    11211234  RegisteredClass** prevClassLink;
    11221235  RegisteredClass*  curClass;
    11231236
    11241237  TRACE("(%08lx)\n",dwRegister);
     1238
     1239  EnterCriticalSection( &csRegisteredClassList );
    11251240
    11261241  /*
     
    11491264      /*
    11501265       * Free the memory used by the chain node.
    1151  */
     1266       */
    11521267      HeapFree(GetProcessHeap(), 0, curClass);
    11531268
    1154     return S_OK;
    1155 }
     1269      hr = S_OK;
     1270      goto end;
     1271    }
    11561272
    11571273    /*
     
    11621278  }
    11631279
     1280end:
     1281  LeaveCriticalSection( &csRegisteredClassList );
    11641282  /*
    11651283   * If we get to here, we haven't found our class.
    11661284   */
    1167   return E_INVALIDARG;
     1285  return hr;
     1286}
     1287
     1288static HRESULT WINAPI Remote_CoGetClassObject(
     1289    REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
     1290    REFIID iid, LPVOID *ppv
     1291) {
     1292  HKEY          key;
     1293  char          buf[200];
     1294  HRESULT       hres = E_UNEXPECTED;
     1295  char          xclsid[80];
     1296  WCHAR         dllName[MAX_PATH+1];
     1297  DWORD         dllNameLen = sizeof(dllName);
     1298  STARTUPINFOW  sinfo;
     1299  PROCESS_INFORMATION   pinfo;
     1300
     1301  WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
     1302
     1303  sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid);
     1304  hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
     1305
     1306  if (hres != ERROR_SUCCESS)
     1307      return REGDB_E_CLASSNOTREG;
     1308
     1309  memset(dllName,0,sizeof(dllName));
     1310  hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
     1311  if (hres)
     1312          return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
     1313  RegCloseKey(key);
     1314
     1315  TRACE("found LocalServer32 exe %s\n", debugstr_w(dllName));
     1316
     1317  memset(&sinfo,0,sizeof(sinfo));
     1318  sinfo.cb = sizeof(sinfo);
     1319  if (!CreateProcessW(NULL,dllName,NULL,NULL,FALSE,0,NULL,NULL,&sinfo,&pinfo))
     1320      return E_FAIL;
     1321  return create_marshalled_proxy(rclsid,iid,ppv);
    11681322}
    11691323
    11701324/***********************************************************************
    11711325 *           CoGetClassObject [COMPOBJ.7]
     1326 *           CoGetClassObject [OLE32.16]
     1327 *
     1328 * FIXME.  If request allows of several options and there is a failure
     1329 *         with one (other than not being registered) do we try the
     1330 *         others or return failure?  (E.g. inprocess is registered but
     1331 *         the DLL is not found but the server version works)
    11721332 */
    11731333HRESULT WINAPI CoGetClassObject(
     
    11781338    HRESULT     hres = E_UNEXPECTED;
    11791339    char        xclsid[80];
    1180     WCHAR dllName[MAX_PATH+1];
    1181     DWORD dllNameLen = sizeof(dllName);
     1340    WCHAR ProviderName[MAX_PATH+1];
     1341    DWORD ProviderNameLen = sizeof(ProviderName);
    11821342    HINSTANCE hLibrary;
    11831343#ifdef __WIN32OS2__
    1184     typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid, 
     1344    typedef HRESULT (* CALLBACK DllGetClassObjectFunc)(REFCLSID clsid,
    11851345                             REFIID iid, LPVOID *ppv);
    11861346#else
    1187     typedef HRESULT CALLBACK (*DllGetClassObjectFunc)(REFCLSID clsid,
     1347    typedef HRESULT (CALLBACK *DllGetClassObjectFunc)(REFCLSID clsid,
    11881348                             REFIID iid, LPVOID *ppv);
    11891349#endif
    11901350    DllGetClassObjectFunc DllGetClassObject;
     1351    HKEY key;
     1352    char buf[200];
    11911353
    11921354    WINE_StringFromCLSID((LPCLSID)rclsid,xclsid);
     
    12031365
    12041366    /*
    1205      * First, try and see if we can't match the class ID with one of the 
     1367     * First, try and see if we can't match the class ID with one of the
    12061368     * registered classes.
    12071369     */
     
    12231385    }
    12241386
    1225     /* out of process and remote servers not supported yet */
    1226     if (     ((CLSCTX_LOCAL_SERVER|CLSCTX_REMOTE_SERVER) & dwClsContext)
     1387    if (((CLSCTX_LOCAL_SERVER) & dwClsContext)
     1388        && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext))
     1389        return Remote_CoGetClassObject(rclsid,dwClsContext,pServerInfo,iid,ppv);
     1390
     1391    /* remote servers not supported yet */
     1392    if (     ((CLSCTX_REMOTE_SERVER) & dwClsContext)
    12271393        && !((CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER) & dwClsContext)
    12281394    ){
    1229         FIXME("%s %s not supported!\n",
    1230                 (dwClsContext&CLSCTX_LOCAL_SERVER)?"CLSCTX_LOCAL_SERVER":"",
    1231                 (dwClsContext&CLSCTX_REMOTE_SERVER)?"CLSCTX_REMOTE_SERVER":""
    1232         );
    1233         return E_ACCESSDENIED;
     1395        FIXME("CLSCTX_REMOTE_SERVER not supported!\n");
     1396        return E_NOINTERFACE;
    12341397    }
    12351398
     
    12381401        char buf[200];
    12391402
     1403        memset(ProviderName,0,sizeof(ProviderName));
    12401404        sprintf(buf,"CLSID\\%s\\InprocServer32",xclsid);
    1241         hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key);
    1242 
    1243         if (hres != ERROR_SUCCESS) {
    1244             return REGDB_E_CLASSNOTREG;
     1405        if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) ||
     1406            ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)),
     1407             RegCloseKey (key),
     1408             hres != ERROR_SUCCESS))
     1409        {
     1410            hres = REGDB_E_CLASSNOTREG;
     1411        }
     1412        /* Don't ask me.  MSDN says that CoGetClassObject does NOT call CoLoadLibrary */
     1413        else if ((hLibrary = CoLoadLibrary(ProviderName, TRUE)) == 0)
     1414        {
     1415            FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(ProviderName));
     1416            hres = E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
    12451417        }
    1246 
    1247         memset(dllName,0,sizeof(dllName));
    1248         hres= RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)dllName,&dllNameLen);
    1249         if (hres)
    1250                 return REGDB_E_CLASSNOTREG; /* FIXME: check retval */
    1251         RegCloseKey(key);
    1252         TRACE("found InprocServer32 dll %s\n", debugstr_w(dllName));
    1253 
    1254         /* open dll, call DllGetClassObject */
    1255         hLibrary = CoLoadLibrary(dllName, TRUE);
    1256         if (hLibrary == 0) {
    1257             FIXME("couldn't load InprocServer32 dll %s\n", debugstr_w(dllName));
    1258             return E_ACCESSDENIED; /* or should this be CO_E_DLLNOTFOUND? */
     1418        else if (!(DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject")))
     1419        {
     1420            /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
     1421            FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(ProviderName));
     1422            hres = E_ACCESSDENIED;
    12591423        }
    1260         DllGetClassObject = (DllGetClassObjectFunc)GetProcAddress(hLibrary, "DllGetClassObject");
    1261         if (!DllGetClassObject) {
    1262             /* not sure if this should be called here CoFreeLibrary(hLibrary);*/
    1263             FIXME("couldn't find function DllGetClassObject in %s\n", debugstr_w(dllName));
    1264             return E_ACCESSDENIED;
     1424        else
     1425        {
     1426            /* Ask the DLL for its class object. (there was a note here about
     1427             * class factories but this is good.
     1428             */
     1429            return DllGetClassObject(rclsid, iid, ppv);
     1430        }
     1431    }
     1432   
     1433
     1434    /* Finally try out of process */
     1435    /* out of process and remote servers not supported yet */
     1436    if (CLSCTX_LOCAL_SERVER & dwClsContext)
     1437    {
     1438        memset(ProviderName,0,sizeof(ProviderName));
     1439        sprintf(buf,"CLSID\\%s\\LocalServer32",xclsid);
     1440        if (((hres = RegOpenKeyExA(HKEY_CLASSES_ROOT, buf, 0, KEY_READ, &key)) != ERROR_SUCCESS) ||
     1441            ((hres = RegQueryValueExW(key,NULL,NULL,NULL,(LPBYTE)ProviderName,&ProviderNameLen)),
     1442             RegCloseKey (key),
     1443             hres != ERROR_SUCCESS))
     1444        {
     1445            hres = REGDB_E_CLASSNOTREG;
     1446        }
     1447        else
     1448        {
     1449            /* CO_E_APPNOTFOUND if no exe */
     1450            FIXME("CLSCTX_LOCAL_SERVER %s registered but not yet supported!\n",debugstr_w(ProviderName));
     1451            hres = E_ACCESSDENIED;
    12651452        }
    1266 
    1267         /*
    1268          * Ask the DLL for its class object. (there was a note here about class
    1269          * factories but this is good.
    1270          */
    1271         return DllGetClassObject(rclsid, iid, ppv);
    1272     }
     1453    }
     1454
     1455    if (CLSCTX_REMOTE_SERVER & dwClsContext)
     1456    {
     1457        FIXME ("CLSCTX_REMOTE_SERVER not supported\n");
     1458        hres = E_ACCESSDENIED;
     1459    }
     1460
    12731461    return hres;
    12741462}
    1275 
    1276 /***********************************************************************
    1277  *        CoResumeClassObjects
     1463/***********************************************************************
     1464 *        CoResumeClassObjects (OLE32.173)
    12781465 *
    12791466 * Resumes classobjects registered with REGCLS suspended
     
    12861473
    12871474/***********************************************************************
    1288  *        GetClassFile
     1475 *        GetClassFile (OLE32.67)
    12891476 *
    12901477 * This function supplies the CLSID associated with the given filename.
    12911478 */
    1292 HRESULT WINAPI GetClassFile(LPOLESTR filePathName,CLSID *pclsid)
     1479HRESULT WINAPI GetClassFile(LPCOLESTR filePathName,CLSID *pclsid)
    12931480{
    12941481    IStorage *pstg=0;
     
    13161503       pattern in the registry. this case is not frequently used ! so I present only the psodocode for
    13171504       this case
    1318        
     1505
    13191506     for(i=0;i<nFileTypes;i++)
    13201507
     
    13491536    length=lstrlenW(absFile);
    13501537    for(i=length-1; ( (i>=0) && (extention[i]=absFile[i]) );i--);
    1351        
     1538
    13521539    /* get the progId associated to the extension */
    13531540    progId=CoTaskMemAlloc(sizeProgId);
     
    13771564#ifndef __WIN32OS2__
    13781565/******************************************************************************
    1379  *              CoRegisterMessageFilter16       [COMPOBJ.27]
     1566 *              CoRegisterMessageFilter [COMPOBJ.27]
    13801567 */
    13811568HRESULT WINAPI CoRegisterMessageFilter16(
     
    13871574}
    13881575#endif
    1389 
    1390 /***********************************************************************
    1391  *           CoCreateInstance [COMPOBJ.13, OLE32.7]
     1576/***********************************************************************
     1577 *           CoCreateInstance [COMPOBJ.13]
     1578 *           CoCreateInstance [OLE32.7]
    13921579 */
    13931580HRESULT WINAPI CoCreateInstance(
     
    13961583        DWORD dwClsContext,
    13971584        REFIID iid,
    1398         LPVOID *ppv) 
     1585        LPVOID *ppv)
    13991586{
    14001587        HRESULT hres;
     
    14111598   */
    14121599  *ppv = 0;
    1413  
     1600
    14141601  /*
    14151602   * Get a class factory to construct the object we want.
     
    14221609
    14231610  if (FAILED(hres)) {
    1424     FIXME("no instance created for %s, hres is 0x%08lx\n",debugstr_guid(iid),hres);
     1611    FIXME("no classfactory created for CLSID %s, hres is 0x%08lx\n",
     1612          debugstr_guid(rclsid),hres);
    14251613    return hres;
    14261614  }
     
    14311619        hres = IClassFactory_CreateInstance(lpclf, pUnkOuter, iid, ppv);
    14321620        IClassFactory_Release(lpclf);
     1621        if(FAILED(hres))
     1622          FIXME("no instance created for interface %s of class %s, hres is 0x%08lx\n",
     1623                debugstr_guid(iid), debugstr_guid(rclsid),hres);
    14331624
    14341625        return hres;
     
    14391630 */
    14401631HRESULT WINAPI CoCreateInstanceEx(
    1441   REFCLSID      rclsid, 
     1632  REFCLSID      rclsid,
    14421633  LPUNKNOWN     pUnkOuter,
    1443   DWORD         dwClsContext, 
     1634  DWORD         dwClsContext,
    14441635  COSERVERINFO* pServerInfo,
    14451636  ULONG         cmq,
     
    14721663   * Get the object and get its IUnknown pointer.
    14731664   */
    1474   hr = CoCreateInstance(rclsid, 
     1665  hr = CoCreateInstance(rclsid,
    14751666                        pUnkOuter,
    14761667                        dwClsContext,
     
    15091700
    15101701/***********************************************************************
    1511  *           CoFreeLibrary [COMPOBJ.13]
     1702 *           CoFreeLibrary [OLE32.13]
    15121703 */
    15131704void WINAPI CoFreeLibrary(HINSTANCE hLibrary)
     
    15151706    OpenDll *ptr, *prev;
    15161707    OpenDll *tmp;
     1708
     1709    EnterCriticalSection( &csOpenDllList );
    15171710
    15181711    /* lookup library in linked list */
     
    15271720    if (ptr == NULL) {
    15281721        /* shouldn't happen if user passed in a valid hLibrary */
    1529         return;
     1722        goto end;
    15301723    }
    15311724    /* assert: ptr points to the library entry to free */
     
    15421735        prev->next = tmp;
    15431736    }
    1544 
    1545 }
    1546 
    1547 
    1548 /***********************************************************************
    1549  *           CoFreeAllLibraries [COMPOBJ.12]
     1737end:
     1738    LeaveCriticalSection( &csOpenDllList );
     1739}
     1740
     1741
     1742/***********************************************************************
     1743 *           CoFreeAllLibraries [OLE32.12]
    15501744 */
    15511745void WINAPI CoFreeAllLibraries(void)
    15521746{
    15531747    OpenDll *ptr, *tmp;
     1748
     1749    EnterCriticalSection( &csOpenDllList );
    15541750
    15551751    for (ptr = openDllList; ptr != NULL; ) {
     
    15581754        ptr = tmp;
    15591755    }
     1756
     1757    LeaveCriticalSection( &csOpenDllList );
    15601758}
    15611759
     
    15641762/***********************************************************************
    15651763 *           CoFreeUnusedLibraries [COMPOBJ.17]
     1764 *           CoFreeUnusedLibraries [OLE32.14]
    15661765 */
    15671766void WINAPI CoFreeUnusedLibraries(void)
     
    15711770    DllCanUnloadNowFunc DllCanUnloadNow;
    15721771
     1772    EnterCriticalSection( &csOpenDllList );
     1773
    15731774    for (ptr = openDllList; ptr != NULL; ) {
    15741775        DllCanUnloadNow = (DllCanUnloadNowFunc)
    15751776            GetProcAddress(ptr->hLibrary, "DllCanUnloadNow");
    1576        
     1777
    15771778        if ( (DllCanUnloadNow != NULL) &&
    15781779             (DllCanUnloadNow() == S_OK) ) {
     
    15841785        }
    15851786    }
    1586 }
    1587 
    1588 /***********************************************************************
    1589  *           CoFileTimeNow [COMPOBJ.82, OLE32.10]
     1787
     1788    LeaveCriticalSection( &csOpenDllList );
     1789}
     1790
     1791/***********************************************************************
     1792 *           CoFileTimeNow [COMPOBJ.82]
     1793 *           CoFileTimeNow [OLE32.10]
     1794 *
    15901795 * RETURNS
    15911796 *      the current system time in lpFileTime
     
    16081813    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
    16091814
    1610     if (FAILED(ret)) 
     1815    if (FAILED(ret))
    16111816        return NULL;
    16121817
     
    16221827    HRESULT     ret = CoGetMalloc(0,&lpmalloc);
    16231828
    1624     if (FAILED(ret)) 
     1829    if (FAILED(ret))
    16251830      return;
    16261831
     
    16391844  LPMALLOC lpmalloc;
    16401845  HRESULT  ret = CoGetMalloc(0,&lpmalloc);
    1641  
    1642   if (FAILED(ret)) 
     1846
     1847  if (FAILED(ret))
    16431848    return NULL;
    16441849
     
    16541859    OpenDll *ptr;
    16551860    OpenDll *tmp;
    1656  
     1861
    16571862    TRACE("(%s, %d)\n", debugstr_w(lpszLibName), bAutoFree);
    16581863
     
    16611866    if (!bAutoFree)
    16621867        return hLibrary;
     1868
     1869    EnterCriticalSection( &csOpenDllList );
    16631870
    16641871    if (openDllList == NULL) {
     
    16841891        }
    16851892    }
    1686      
     1893
     1894    LeaveCriticalSection( &csOpenDllList );
     1895
    16871896    return hLibrary;
    16881897}
     
    16961905}
    16971906
    1698 #ifndef __WIN32OS2__
    1699 /******************************************************************************
    1700  *              CoLockObjectExternal16  [COMPOBJ.63]
     1907/******************************************************************************
     1908 *              CoLockObjectExternal    [COMPOBJ.63]
    17011909 */
    17021910HRESULT WINAPI CoLockObjectExternal16(
     
    17081916    return S_OK;
    17091917}
    1710 #endif
    17111918
    17121919/******************************************************************************
     
    17191926{
    17201927
    1721   if (fLock) 
     1928  if (fLock)
    17221929  {
    1723     /* 
     1930    /*
    17241931     * Increment the external lock coutner, COM_ExternalLockAddRef also
    17251932     * increment the object's internal lock counter.
    17261933     */
    1727     COM_ExternalLockAddRef( pUnk); 
     1934    COM_ExternalLockAddRef( pUnk);
    17281935  }
    17291936  else
    17301937  {
    1731     /* 
     1938    /*
    17321939     * Decrement the external lock coutner, COM_ExternalLockRelease also
    17331940     * decrement the object's internal lock counter.
     
    17391946}
    17401947
    1741 #ifndef __WIN32OS2__
    1742 /***********************************************************************
    1743  *           CoGetState16 [COMPOBJ.115]
     1948/***********************************************************************
     1949 *           CoGetState [COMPOBJ.115]
    17441950 */
    17451951HRESULT WINAPI CoGetState16(LPDWORD state)
     
    17501956}
    17511957/***********************************************************************
    1752  *           CoSetState [COM32.42]
     1958 *           CoSetState [OLE32.42]
    17531959 */
    17541960HRESULT WINAPI CoSetState(LPDWORD state)
     
    17581964    return S_OK;
    17591965}
    1760 #endif
    17611966/***********************************************************************
    17621967 *          CoCreateFreeThreadedMarshaler [OLE32.5]
     
    17651970{
    17661971   FIXME ("(%p %p): stub\n", punkOuter, ppunkMarshal);
    1767    
     1972
    17681973   return S_OK;
    17691974}
    1770 
    1771 
    1772 /***********************************************************************
    1773  *           DllGetClassObject [OLE32.63]
    1774  */
    1775 HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
    1776 {       
    1777         FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n",debugstr_guid(rclsid),debugstr_guid(iid));
    1778         *ppv = NULL;
    1779         return CLASS_E_CLASSNOTAVAILABLE;
    1780 }
    1781 
    17821975
    17831976/***
    17841977 * COM_RevokeAllClasses
    17851978 *
    1786  * This method is called when the COM libraries are uninitialized to 
     1979 * This method is called when the COM libraries are uninitialized to
    17871980 * release all the references to the class objects registered with
    17881981 * the library
     
    17901983static void COM_RevokeAllClasses()
    17911984{
     1985  EnterCriticalSection( &csRegisteredClassList );
     1986
    17921987  while (firstRegisteredClass!=0)
    17931988  {
    17941989    CoRevokeClassObject(firstRegisteredClass->dwCookie);
    17951990  }
     1991
     1992  LeaveCriticalSection( &csRegisteredClassList );
    17961993}
    17971994
     
    18011998
    18021999/****************************************************************************
    1803  * Public - Method that increments the count for a IUnknown* in the linked 
     2000 * Public - Method that increments the count for a IUnknown* in the linked
    18042001 * list.  The item is inserted if not already in the list.
    18052002 */
     
    18222019   * Add an internal lock to the object
    18232020   */
    1824   IUnknown_AddRef(pUnk); 
     2021  IUnknown_AddRef(pUnk);
    18252022}
    18262023
    18272024/****************************************************************************
    1828  * Public - Method that decrements the count for a IUnknown* in the linked 
     2025 * Public - Method that decrements the count for a IUnknown* in the linked
    18292026 * list.  The item is removed from the list if its count end up at zero or if
    18302027 * bRelAll is TRUE.
     
    18432040      IUnknown_Release(pUnk);     /* release local locks as well */
    18442041
    1845       if ( bRelAll == FALSE ) 
     2042      if ( bRelAll == FALSE )
    18462043        break;  /* perform single release */
    18472044
    1848     } while ( externalLock->uRefCount > 0 ); 
     2045    } while ( externalLock->uRefCount > 0 );
    18492046
    18502047    if ( externalLock->uRefCount == 0 )  /* get rid of the list entry */
     
    18642061    COM_ExternalLockDelete(head);     /* get rid of the head stuff       */
    18652062
    1866     head = elList.head;               /* get the new head...             */ 
     2063    head = elList.head;               /* get the new head...             */
    18672064  }
    18682065}
     
    18802077  {
    18812078      DPRINTF( "\t%p with %lu references count.\n", current->pUnk, current->uRefCount);
    1882  
    1883     /* Skip to the next item */ 
     2079
     2080    /* Skip to the next item */
    18842081    current = current->next;
    1885   } 
     2082  }
    18862083
    18872084}
     
    19032100  IUnknown         *pUnk)
    19042101{
    1905   if ( element == EL_END_OF_LIST ) 
     2102  if ( element == EL_END_OF_LIST )
    19062103    return EL_NOT_FOUND;
    19072104
     
    19092106    return element;
    19102107
    1911   else                                 /* Not the right guy, keep on looking */ 
     2108  else                                 /* Not the right guy, keep on looking */
    19122109    return COM_ExternalLockLocate( element->next, pUnk);
    19132110}
     
    19292126  if (newLock!=NULL)
    19302127  {
    1931     if ( elList.head == EL_END_OF_LIST ) 
     2128    if ( elList.head == EL_END_OF_LIST )
    19322129    {
    19332130      elList.head = newLock;    /* The list is empty */
    19342131    }
    1935     else 
     2132    else
    19362133    {
    1937       /* 
     2134      /*
    19382135       * insert does it at the head
    19392136       */
     
    19432140
    19442141    /*
    1945      * Set new list item data member 
     2142     * Set new list item data member
    19462143     */
    19472144    newLock->pUnk      = pUnk;
    19482145    newLock->uRefCount = 1;
    19492146    newLock->next      = previousHead;
    1950    
     2147
    19512148    return TRUE;
    19522149  }
     
    19652162  if ( current == itemList )
    19662163  {
    1967     /* 
    1968      * this section handles the deletion of the first node 
     2164    /*
     2165     * this section handles the deletion of the first node
    19692166     */
    19702167    elList.head = itemList->next;
    1971     HeapFree( GetProcessHeap(), 0, itemList); 
     2168    HeapFree( GetProcessHeap(), 0, itemList);
    19722169  }
    19732170  else
    19742171  {
    1975     do 
     2172    do
    19762173    {
    19772174      if ( current->next == itemList )   /* We found the item to free  */
    19782175      {
    19792176        current->next = itemList->next;  /* readjust the list pointers */
    1980  
    1981         HeapFree( GetProcessHeap(), 0, itemList); 
    1982         break; 
     2177
     2178        HeapFree( GetProcessHeap(), 0, itemList);
     2179        break;
    19832180      }
    1984  
    1985       /* Skip to the next item */ 
     2181
     2182      /* Skip to the next item */
    19862183      current = current->next;
    1987  
     2184
    19882185    } while ( current != EL_END_OF_LIST );
    19892186  }
    19902187}
    19912188
    1992 #ifndef __WIN32OS2__
    1993 /***********************************************************************
    1994  *      COMPOBJ_DllEntryPoint                   [COMPOBJ.entry]
     2189/***********************************************************************
     2190 *      DllEntryPoint                   [COMPOBJ.116]
    19952191 *
    19962192 *    Initialization code for the COMPOBJ DLL
     
    20152211        return TRUE;
    20162212}
    2017 #endif
     2213
    20182214/******************************************************************************
    20192215 *              OleGetAutoConvert        [OLE32.104]
     
    20542250HRESULT WINAPI OleSetAutoConvert(REFCLSID clsidOld, REFCLSID clsidNew)
    20552251{
    2056     HKEY hkey = 0, hkeyConvert = 0;
     2252    HKEY hkey = 0;
    20572253    char buf[200], szClsidNew[200];
    20582254    HRESULT res = S_OK;
    20592255
    2060     TRACE("(%p,%p);\n", clsidOld, clsidNew);
     2256    TRACE("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
    20612257    sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
    20622258    WINE_StringFromCLSID(clsidNew, szClsidNew);
     
    20662262        goto done;
    20672263    }
    2068     if (RegCreateKeyA(hkey, "AutoConvertTo", &hkeyConvert))
     2264    if (RegSetValueA(hkey, "AutoConvertTo", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
    20692265    {
    20702266        res = REGDB_E_WRITEREGDB;
    20712267        goto done;
    20722268    }
    2073     if (RegSetValueExA(hkeyConvert, NULL, 0,
    2074                             REG_SZ, (LPBYTE)szClsidNew, strlen(szClsidNew)+1))
     2269
     2270done:
     2271    if (hkey) RegCloseKey(hkey);
     2272    return res;
     2273}
     2274
     2275/******************************************************************************
     2276 *              CoTreatAsClass        [OLE32.46]
     2277 */
     2278HRESULT WINAPI CoTreatAsClass(REFCLSID clsidOld, REFCLSID clsidNew)
     2279{
     2280    HKEY hkey = 0;
     2281    char buf[200], szClsidNew[200];
     2282    HRESULT res = S_OK;
     2283
     2284    FIXME("(%s,%s)\n", debugstr_guid(clsidOld), debugstr_guid(clsidNew));
     2285    sprintf(buf,"CLSID\\");WINE_StringFromCLSID(clsidOld,&buf[6]);
     2286    WINE_StringFromCLSID(clsidNew, szClsidNew);
     2287    if (RegOpenKeyA(HKEY_CLASSES_ROOT,buf,&hkey))
     2288    {
     2289        res = REGDB_E_CLASSNOTREG;
     2290        goto done;
     2291    }
     2292    if (RegSetValueA(hkey, "AutoTreatAs", REG_SZ, szClsidNew, strlen(szClsidNew)+1))
    20752293    {
    20762294        res = REGDB_E_WRITEREGDB;
     
    20792297
    20802298done:
    2081     if (hkeyConvert) RegCloseKey(hkeyConvert);
    20822299    if (hkey) RegCloseKey(hkey);
    2083 
    20842300    return res;
    20852301}
     2302
    20862303
    20872304/***********************************************************************
     
    21012318    return !memcmp(rguid1,rguid2,sizeof(GUID));
    21022319}
    2103 
    2104 #ifdef __WIN32OS2__
    2105 // ----------------------------------------------------------------------
    2106 // CLSIDFromStringA()
    2107 // @@@PH: this is not a WINE API, but a replacement for CLSIDFromString16
    2108 //        which used to accept ASCII strings instead of OLE strings
    2109 // ----------------------------------------------------------------------
    2110 
    2111 HRESULT WIN32API CLSIDFromStringA(
    2112     LPCSTR              lpsz,           // [in] - ASCII string CLSID
    2113     LPCLSID             pclsid)         // [out] - Binary CLSID
    2114 {
    2115     return CLSIDFromString16(lpsz, pclsid);
    2116 }
    2117 #endif
Note: See TracChangeset for help on using the changeset viewer.