Changeset 3243 for trunk/src/shell32/regstream.cpp
- Timestamp:
- Mar 26, 2000, 6:34:57 PM (25 years ago)
- 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 sandervlExp $ */1 /* $Id: regstream.cpp,v 1.2 2000-03-26 16:34:43 cbratschi Exp $ */ 2 2 3 3 /* … … 8 8 * Project Odin Software License can be found in LICENSE.TXT 9 9 * 10 * Corel WINE 20000324 level 10 11 */ 11 12 12 13 /* 13 * 14 * SHRegOpenStream 14 15 */ 15 16 … … 47 48 48 49 typedef struct 49 { 50 DWORDref;51 HKEYhKey;52 LPSTRpszSubKey;53 LPSTRpszValue;54 LPBYTEpbBuffer;55 DWORDdwLength;56 DWORDdwPos;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; 57 58 } ISHRegStream; 58 59 … … 65 66 static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj) 66 67 { 67 68 69 70 68 ICOM_THIS(ISHRegStream, iface); 69 70 char xriid[50]; 71 WINE_StringFromCLSID((LPCLSID)riid,xriid); 71 72 72 73 dprintf(("SHELL32:regstream IStream_fnQueryInterface (%p)->(\n\tIID:\t%s,%p)\n", … … 75 76 ppvObj)); 76 77 77 78 79 if(IsEqualIID(riid, &IID_IUnknown))/*IUnknown*/80 81 82 else if(IsEqualIID(riid, &IID_IStream))/*IStream*/83 84 85 86 87 88 89 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", 90 91 ppvObj, 91 92 *ppvObj)); 92 93 94 95 93 return S_OK; 94 } 95 dprintf(("SHELL32:regstream IStream_fnQueryInterface-- Interface: E_NOINTERFACE\n")); 96 return E_NOINTERFACE; 96 97 } 97 98 … … 101 102 static ULONG WINAPI IStream_fnAddRef(IStream *iface) 102 103 { 103 104 105 104 ICOM_THIS(ISHRegStream, iface); 105 106 dprintf(("SHELL32:regstream IStream_fnAddRef (%p)->(count=%lu)\n", 106 107 This, 107 108 This->ref)); 108 109 109 110 110 shell32_ObjCount++; 111 return ++(This->ref); 111 112 } 112 113 … … 116 117 static ULONG WINAPI IStream_fnRelease(IStream *iface) 117 118 { 118 119 120 121 This)); 122 123 124 125 126 127 This)); 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 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; 145 146 } 146 147 147 148 HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead) 148 149 { 149 150 151 152 153 150 ICOM_THIS(ISHRegStream, iface); 151 152 DWORD dwBytesToRead, dwBytesLeft; 153 154 dprintf(("SHELL32:regstream IStream_fnRead(%p)->(%p,0x%08lx,%p)\n", 154 155 This, 155 156 pv, 156 157 cb, 157 158 pcbRead)); 158 159 160 161 162 163 164 if ( 0 >= dwBytesLeft )/* end of buffer */165 166 167 168 169 170 171 This->dwPos += dwBytesToRead;/* adjust pointer */172 173 174 175 176 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; 177 178 } 178 179 HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten) 179 180 { 180 181 182 183 This)); 184 185 181 ICOM_THIS(ISHRegStream, iface); 182 183 dprintf(("SHELL32:regstream IStream_fnWrite(%p)\n", 184 This)); 185 186 return E_NOTIMPL; 186 187 } 187 188 HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) 188 189 { 189 190 191 192 This)); 193 194 190 ICOM_THIS(ISHRegStream, iface); 191 192 dprintf(("SHELL32:regstream IStream_fnSeek(%p)\n", 193 This)); 194 195 return E_NOTIMPL; 195 196 } 196 197 HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize) 197 198 { 198 199 200 201 This)); 202 203 199 ICOM_THIS(ISHRegStream, iface); 200 201 dprintf(("SHELL32:regstream IStream_fnSetSize(%p)\n", 202 This)); 203 204 return E_NOTIMPL; 204 205 } 205 206 HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) 206 207 { 207 208 209 210 This)); 211 212 208 ICOM_THIS(ISHRegStream, iface); 209 210 dprintf(("SHELL32:regstream IStream_fnCopyTo(%p)\n", 211 This)); 212 213 return E_NOTIMPL; 213 214 } 214 215 HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags) 215 216 { 216 217 218 219 This)); 220 221 217 ICOM_THIS(ISHRegStream, iface); 218 219 dprintf(("SHELL32:regstream IStream_fnCommit(%p)\n", 220 This)); 221 222 return E_NOTIMPL; 222 223 } 223 224 HRESULT WINAPI IStream_fnRevert (IStream * iface) 224 225 { 225 226 227 228 This)); 229 230 226 ICOM_THIS(ISHRegStream, iface); 227 228 dprintf(("SHELL32:regstream IStream_fnRevert(%p)\n", 229 This)); 230 231 return E_NOTIMPL; 231 232 } 232 233 HRESULT WINAPI IStream_fnLockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 233 234 { 234 235 236 237 This)); 238 239 235 ICOM_THIS(ISHRegStream, iface); 236 237 dprintf(("SHELL32:regstream IStream_fnLockRegion(%p)\n", 238 This)); 239 240 return E_NOTIMPL; 240 241 } 241 242 HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 242 243 { 243 244 245 246 This)); 247 248 244 ICOM_THIS(ISHRegStream, iface); 245 246 dprintf(("SHELL32:regstream IStream_fnUnlockRegion(%p)\n", 247 This)); 248 249 return E_NOTIMPL; 249 250 } 250 251 HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG* pstatstg, DWORD grfStatFlag) 251 252 { 252 253 254 255 This)); 256 257 253 ICOM_THIS(ISHRegStream, iface); 254 255 dprintf(("SHELL32:regstream IStream_fnStat(%p)\n", 256 This)); 257 258 return E_NOTIMPL; 258 259 } 259 260 HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm) 260 261 { 261 262 263 264 This)); 265 266 262 ICOM_THIS(ISHRegStream, iface); 263 264 dprintf(("SHELL32:regstream IStream_fnClone(%p)\n", 265 This)); 266 267 return E_NOTIMPL; 267 268 } 268 269 269 270 static struct ICOM_VTABLE(IStream) rstvt = 270 { 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 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 287 288 }; 288 289 … … 291 292 */ 292 293 IStream *IStream_Constructor(HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD grfMode) 293 { ISHRegStream*rstr;294 DWORDdwType;295 296 297 298 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; 299 300 300 301 dprintf(("SHELL32:regstream IStream_Constructor(%08xh,%ls,%ls,%08xh)\n", … … 304 305 grfMode)); 305 306 306 307 308 309 310 311 312 313 314 315 rstr->pszValue = HEAP_strdupA (GetProcessHeap(),0, pszValue); 316 317 318 319 320 321 322 323 324 325 326 327 328 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; 329 330 } 330 331 331 332 332 333 /************************************************************************* 333 * OpenRegStream 334 * OpenRegStream [SHELL32.85] 334 335 * 335 336 * NOTES … … 343 344 pszValue, 344 345 grfMode)); 345 346 } 346 return IStream_Constructor(hkey, pszSubkey, pszValue, grfMode); 347 }
Note:
See TracChangeset
for help on using the changeset viewer.