Ignore:
Timestamp:
Mar 26, 2000, 6:34:57 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000324

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/regstream.cpp

    r1214 r3243  
    1 /* $Id: regstream.cpp,v 1.1 1999-10-09 11:13:20 sandervl Exp $ */
     1/* $Id: regstream.cpp,v 1.2 2000-03-26 16:34:43 cbratschi Exp $ */
    22
    33/*
     
    88 * Project Odin Software License can be found in LICENSE.TXT
    99 *
     10 * Corel WINE 20000324 level
    1011 */
    1112
    1213/*
    13  *      SHRegOpenStream
     14 *      SHRegOpenStream
    1415 */
    1516
     
    4748
    4849typedef struct
    49 {       ICOM_VTABLE(IStream)* lpvtbl;
    50         DWORD           ref;
    51         HKEY            hKey;
    52         LPSTR           pszSubKey;
    53         LPSTR           pszValue;
    54         LPBYTE          pbBuffer;
    55         DWORD           dwLength;
    56         DWORD           dwPos;
     50{       ICOM_VTABLE(IStream)* lpvtbl;
     51        DWORD           ref;
     52        HKEY            hKey;
     53        LPSTR           pszSubKey;
     54        LPSTR           pszValue;
     55        LPBYTE          pbBuffer;
     56        DWORD           dwLength;
     57        DWORD           dwPos;
    5758} ISHRegStream;
    5859
     
    6566static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj)
    6667{
    67         ICOM_THIS(ISHRegStream, iface);
    68 
    69         char    xriid[50];
    70         WINE_StringFromCLSID((LPCLSID)riid,xriid);
     68        ICOM_THIS(ISHRegStream, iface);
     69
     70        char    xriid[50];
     71        WINE_StringFromCLSID((LPCLSID)riid,xriid);
    7172
    7273  dprintf(("SHELL32:regstream IStream_fnQueryInterface (%p)->(\n\tIID:\t%s,%p)\n",
     
    7576           ppvObj));
    7677
    77         *ppvObj = NULL;
    78 
    79         if(IsEqualIID(riid, &IID_IUnknown))     /*IUnknown*/
    80         { *ppvObj = This;
    81         }
    82         else if(IsEqualIID(riid, &IID_IStream)) /*IStream*/
    83         { *ppvObj = This;
    84         }
    85 
    86         if(*ppvObj)
    87         {
    88           IStream_AddRef((IStream*)*ppvObj);
    89           dprintf(("SHELL32:regstream IStream_fnQueryInterface -- Interface: (%p)->(%p)\n",
     78        *ppvObj = NULL;
     79
     80        if(IsEqualIID(riid, &IID_IUnknown))     /*IUnknown*/
     81        { *ppvObj = This;
     82        }
     83        else if(IsEqualIID(riid, &IID_IStream)) /*IStream*/
     84        { *ppvObj = This;
     85        }
     86
     87        if(*ppvObj)
     88        {
     89          IStream_AddRef((IStream*)*ppvObj);
     90          dprintf(("SHELL32:regstream IStream_fnQueryInterface -- Interface: (%p)->(%p)\n",
    9091            ppvObj,
    9192            *ppvObj));
    92           return S_OK;
    93         }
    94         dprintf(("SHELL32:regstream IStream_fnQueryInterface-- Interface: E_NOINTERFACE\n"));
    95         return E_NOINTERFACE;
     93          return S_OK;
     94        }
     95        dprintf(("SHELL32:regstream IStream_fnQueryInterface-- Interface: E_NOINTERFACE\n"));
     96        return E_NOINTERFACE;
    9697}
    9798
     
    101102static ULONG WINAPI IStream_fnAddRef(IStream *iface)
    102103{
    103         ICOM_THIS(ISHRegStream, iface);
    104 
    105           dprintf(("SHELL32:regstream IStream_fnAddRef (%p)->(count=%lu)\n",
     104        ICOM_THIS(ISHRegStream, iface);
     105
     106          dprintf(("SHELL32:regstream IStream_fnAddRef (%p)->(count=%lu)\n",
    106107            This,
    107108            This->ref));
    108109
    109         shell32_ObjCount++;
    110         return ++(This->ref);
     110        shell32_ObjCount++;
     111        return ++(This->ref);
    111112}
    112113
     
    116117static ULONG WINAPI IStream_fnRelease(IStream *iface)
    117118{
    118         ICOM_THIS(ISHRegStream, iface);
    119 
    120           dprintf(("SHELL32:regstream IStream_fnRelease(%p)->()\n",
    121             This));
    122 
    123         shell32_ObjCount--;
    124 
    125         if (!--(This->ref))
    126         { dprintf(("SHELL32:regstream IStream_fnRelease destroying SHReg IStream (%p)\n",
    127             This));
    128 
    129           if (This->pszSubKey)
    130             HeapFree(GetProcessHeap(),0,This->pszSubKey);
    131 
    132           if (This->pszValue)
    133             HeapFree(GetProcessHeap(),0,This->pszValue);
    134 
    135           if (This->pbBuffer)
    136             HeapFree(GetProcessHeap(),0,This->pbBuffer);
    137 
    138           if (This->hKey)
    139             RegCloseKey(This->hKey);
    140 
    141           HeapFree(GetProcessHeap(),0,This);
    142           return 0;
    143         }
    144         return This->ref;
     119        ICOM_THIS(ISHRegStream, iface);
     120
     121          dprintf(("SHELL32:regstream IStream_fnRelease(%p)->()\n",
     122            This));
     123
     124        shell32_ObjCount--;
     125
     126        if (!--(This->ref))
     127        { dprintf(("SHELL32:regstream IStream_fnRelease destroying SHReg IStream (%p)\n",
     128            This));
     129
     130          if (This->pszSubKey)
     131            HeapFree(GetProcessHeap(),0,This->pszSubKey);
     132
     133          if (This->pszValue)
     134            HeapFree(GetProcessHeap(),0,This->pszValue);
     135
     136          if (This->pbBuffer)
     137            HeapFree(GetProcessHeap(),0,This->pbBuffer);
     138
     139          if (This->hKey)
     140            RegCloseKey(This->hKey);
     141
     142          HeapFree(GetProcessHeap(),0,This);
     143          return 0;
     144        }
     145        return This->ref;
    145146}
    146147
    147148HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead)
    148149{
    149         ICOM_THIS(ISHRegStream, iface);
    150 
    151         DWORD dwBytesToRead, dwBytesLeft;
    152        
    153         dprintf(("SHELL32:regstream IStream_fnRead(%p)->(%p,0x%08lx,%p)\n",
     150        ICOM_THIS(ISHRegStream, iface);
     151
     152        DWORD dwBytesToRead, dwBytesLeft;
     153
     154        dprintf(("SHELL32:regstream IStream_fnRead(%p)->(%p,0x%08lx,%p)\n",
    154155          This,
    155156          pv,
    156157          cb,
    157158          pcbRead));
    158        
    159         if ( !pv )
    160           return STG_E_INVALIDPOINTER;
    161        
    162         dwBytesLeft = This->dwLength - This->dwPos;
    163 
    164         if ( 0 >= dwBytesLeft )                                         /* end of buffer */
    165           return S_FALSE;
    166        
    167         dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
    168 
    169         memmove ( pv, (This->pbBuffer) + (This->dwPos), dwBytesToRead);
    170        
    171         This->dwPos += dwBytesToRead;                                   /* adjust pointer */
    172 
    173         if (pcbRead)
    174           *pcbRead = dwBytesToRead;
    175 
    176         return S_OK;
     159
     160        if ( !pv )
     161          return STG_E_INVALIDPOINTER;
     162
     163        dwBytesLeft = This->dwLength - This->dwPos;
     164
     165        if ( 0 >= dwBytesLeft )                                         /* end of buffer */
     166          return S_FALSE;
     167
     168        dwBytesToRead = ( cb > dwBytesLeft) ? dwBytesLeft : cb;
     169
     170        memmove ( pv, (This->pbBuffer) + (This->dwPos), dwBytesToRead);
     171
     172        This->dwPos += dwBytesToRead;                                   /* adjust pointer */
     173
     174        if (pcbRead)
     175          *pcbRead = dwBytesToRead;
     176
     177        return S_OK;
    177178}
    178179HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten)
    179180{
    180         ICOM_THIS(ISHRegStream, iface);
    181 
    182         dprintf(("SHELL32:regstream IStream_fnWrite(%p)\n",
    183           This));
    184 
    185         return E_NOTIMPL;
     181        ICOM_THIS(ISHRegStream, iface);
     182
     183        dprintf(("SHELL32:regstream IStream_fnWrite(%p)\n",
     184          This));
     185
     186        return E_NOTIMPL;
    186187}
    187188HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
    188189{
    189         ICOM_THIS(ISHRegStream, iface);
    190 
    191         dprintf(("SHELL32:regstream IStream_fnSeek(%p)\n",
    192           This));
    193 
    194         return E_NOTIMPL;
     190        ICOM_THIS(ISHRegStream, iface);
     191
     192        dprintf(("SHELL32:regstream IStream_fnSeek(%p)\n",
     193          This));
     194
     195        return E_NOTIMPL;
    195196}
    196197HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize)
    197198{
    198         ICOM_THIS(ISHRegStream, iface);
    199 
    200         dprintf(("SHELL32:regstream IStream_fnSetSize(%p)\n",
    201           This));
    202 
    203         return E_NOTIMPL;
     199        ICOM_THIS(ISHRegStream, iface);
     200
     201        dprintf(("SHELL32:regstream IStream_fnSetSize(%p)\n",
     202          This));
     203
     204        return E_NOTIMPL;
    204205}
    205206HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
    206207{
    207         ICOM_THIS(ISHRegStream, iface);
    208 
    209           dprintf(("SHELL32:regstream IStream_fnCopyTo(%p)\n",
    210             This));
    211 
    212         return E_NOTIMPL;
     208        ICOM_THIS(ISHRegStream, iface);
     209
     210          dprintf(("SHELL32:regstream IStream_fnCopyTo(%p)\n",
     211            This));
     212
     213        return E_NOTIMPL;
    213214}
    214215HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags)
    215216{
    216         ICOM_THIS(ISHRegStream, iface);
    217 
    218           dprintf(("SHELL32:regstream IStream_fnCommit(%p)\n",
    219             This));
    220 
    221         return E_NOTIMPL;
     217        ICOM_THIS(ISHRegStream, iface);
     218
     219          dprintf(("SHELL32:regstream IStream_fnCommit(%p)\n",
     220            This));
     221
     222        return E_NOTIMPL;
    222223}
    223224HRESULT WINAPI IStream_fnRevert (IStream * iface)
    224225{
    225         ICOM_THIS(ISHRegStream, iface);
    226 
    227         dprintf(("SHELL32:regstream IStream_fnRevert(%p)\n",
    228           This));
    229 
    230         return E_NOTIMPL;
     226        ICOM_THIS(ISHRegStream, iface);
     227
     228        dprintf(("SHELL32:regstream IStream_fnRevert(%p)\n",
     229          This));
     230
     231        return E_NOTIMPL;
    231232}
    232233HRESULT WINAPI IStream_fnLockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
    233234{
    234         ICOM_THIS(ISHRegStream, iface);
    235 
    236         dprintf(("SHELL32:regstream IStream_fnLockRegion(%p)\n",
    237           This));
    238 
    239         return E_NOTIMPL;
     235        ICOM_THIS(ISHRegStream, iface);
     236
     237        dprintf(("SHELL32:regstream IStream_fnLockRegion(%p)\n",
     238          This));
     239
     240        return E_NOTIMPL;
    240241}
    241242HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
    242243{
    243         ICOM_THIS(ISHRegStream, iface);
    244 
    245           dprintf(("SHELL32:regstream IStream_fnUnlockRegion(%p)\n",
    246             This));
    247 
    248         return E_NOTIMPL;
     244        ICOM_THIS(ISHRegStream, iface);
     245
     246          dprintf(("SHELL32:regstream IStream_fnUnlockRegion(%p)\n",
     247            This));
     248
     249        return E_NOTIMPL;
    249250}
    250251HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG*   pstatstg, DWORD grfStatFlag)
    251252{
    252         ICOM_THIS(ISHRegStream, iface);
    253 
    254           dprintf(("SHELL32:regstream IStream_fnStat(%p)\n",
    255             This));
    256 
    257         return E_NOTIMPL;
     253        ICOM_THIS(ISHRegStream, iface);
     254
     255          dprintf(("SHELL32:regstream IStream_fnStat(%p)\n",
     256            This));
     257
     258        return E_NOTIMPL;
    258259}
    259260HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm)
    260261{
    261         ICOM_THIS(ISHRegStream, iface);
    262 
    263           dprintf(("SHELL32:regstream IStream_fnClone(%p)\n",
    264             This));
    265 
    266         return E_NOTIMPL;
     262        ICOM_THIS(ISHRegStream, iface);
     263
     264          dprintf(("SHELL32:regstream IStream_fnClone(%p)\n",
     265            This));
     266
     267        return E_NOTIMPL;
    267268}
    268269
    269270static struct ICOM_VTABLE(IStream) rstvt =
    270 {       
    271         ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
    272         IStream_fnQueryInterface,
    273         IStream_fnAddRef,
    274         IStream_fnRelease,
    275         IStream_fnRead,
    276         IStream_fnWrite,
    277         IStream_fnSeek,
    278         IStream_fnSetSize,
    279         IStream_fnCopyTo,
    280         IStream_fnCommit,
    281         IStream_fnRevert,
    282         IStream_fnLockRegion,
    283         IStream_fnUnlockRegion,
    284         IStream_fnStat,
    285         IStream_fnClone
    286        
     271{
     272        ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
     273        IStream_fnQueryInterface,
     274        IStream_fnAddRef,
     275        IStream_fnRelease,
     276        IStream_fnRead,
     277        IStream_fnWrite,
     278        IStream_fnSeek,
     279        IStream_fnSetSize,
     280        IStream_fnCopyTo,
     281        IStream_fnCommit,
     282        IStream_fnRevert,
     283        IStream_fnLockRegion,
     284        IStream_fnUnlockRegion,
     285        IStream_fnStat,
     286        IStream_fnClone
     287
    287288};
    288289
     
    291292*/
    292293IStream *IStream_Constructor(HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD grfMode)
    293 {       ISHRegStream*   rstr;
    294         DWORD           dwType;
    295        
    296         rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
    297         rstr->lpvtbl=&rstvt;
    298         rstr->ref = 1;
     294{       ISHRegStream*   rstr;
     295        DWORD           dwType;
     296
     297        rstr = (ISHRegStream*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ISHRegStream));
     298        rstr->lpvtbl=&rstvt;
     299        rstr->ref = 1;
    299300
    300301 dprintf(("SHELL32:regstream IStream_Constructor(%08xh,%ls,%ls,%08xh)\n",
     
    304305          grfMode));
    305306
    306         if ( ERROR_SUCCESS == RegOpenKeyExA (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey)))
    307         { if ( ERROR_SUCCESS == RegQueryValueExA(rstr->hKey, (LPSTR)pszValue,0,0,0,&(rstr->dwLength)))
    308           {
    309             /* read the binary data into the buffer */
    310             rstr->pbBuffer = (BYTE*)HeapAlloc(GetProcessHeap(),0,rstr->dwLength);
    311             if (rstr->pbBuffer)
    312             { if ( ERROR_SUCCESS == RegQueryValueExA(rstr->hKey, (LPSTR)pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength)))
    313               { if (dwType == REG_BINARY )
    314                 { rstr->pszSubKey = HEAP_strdupA (GetProcessHeap(),0, pszSubKey);
    315                   rstr->pszValue = HEAP_strdupA (GetProcessHeap(),0, pszValue);         
    316                     dprintf(("SHELL32:regstream IStream_Constructor(%p)->0x%08x,%s,%s,0x%08lx\n", rstr, hKey, pszSubKey, pszValue, grfMode));
    317                   shell32_ObjCount++;
    318                   return (IStream*)rstr;
    319                 }
    320               }
    321               HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
    322             }
    323           }
    324           RegCloseKey(rstr->hKey);
    325 
    326         }
    327         HeapFree (GetProcessHeap(),0,rstr);
    328         return NULL;
     307        if ( ERROR_SUCCESS == RegOpenKeyExA (hKey, pszSubKey, 0, KEY_READ, &(rstr->hKey)))
     308        { if ( ERROR_SUCCESS == RegQueryValueExA(rstr->hKey, (LPSTR)pszValue,0,0,0,&(rstr->dwLength)))
     309          {
     310            /* read the binary data into the buffer */
     311            rstr->pbBuffer = (BYTE*)HeapAlloc(GetProcessHeap(),0,rstr->dwLength);
     312            if (rstr->pbBuffer)
     313            { if ( ERROR_SUCCESS == RegQueryValueExA(rstr->hKey, (LPSTR)pszValue,0,&dwType,rstr->pbBuffer,&(rstr->dwLength)))
     314              { if (dwType == REG_BINARY )
     315                { rstr->pszSubKey = HEAP_strdupA (GetProcessHeap(),0, pszSubKey);
     316                  rstr->pszValue = HEAP_strdupA (GetProcessHeap(),0, pszValue);
     317                    dprintf(("SHELL32:regstream IStream_Constructor(%p)->0x%08x,%s,%s,0x%08lx\n", rstr, hKey, pszSubKey, pszValue, grfMode));
     318                  shell32_ObjCount++;
     319                  return (IStream*)rstr;
     320                }
     321              }
     322              HeapFree (GetProcessHeap(),0,rstr->pbBuffer);
     323            }
     324          }
     325          RegCloseKey(rstr->hKey);
     326
     327        }
     328        HeapFree (GetProcessHeap(),0,rstr);
     329        return NULL;
    329330}
    330331
    331332
    332333/*************************************************************************
    333  * OpenRegStream                                [SHELL32.85]
     334 * OpenRegStream                                [SHELL32.85]
    334335 *
    335336 * NOTES
     
    343344           pszValue,
    344345           grfMode));
    345         return IStream_Constructor(hkey, pszSubkey, pszValue, grfMode);
    346 }
     346        return IStream_Constructor(hkey, pszSubkey, pszValue, grfMode);
     347}
Note: See TracChangeset for help on using the changeset viewer.