Changeset 78474 in vbox for trunk/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp
- Timestamp:
- May 13, 2019 7:44:15 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/SharedClipboard/ClipboardStreamImpl-win.cpp
r78440 r78474 25 25 #include <iprt/asm.h> 26 26 #include <iprt/ldr.h> 27 #include <iprt/thread.h> 27 28 28 29 #include <VBox/GuestHost/SharedClipboard.h> … … 43 44 *********************************************************************************************************************************/ 44 45 46 47 48 VBoxClipboardWinStreamImpl::VBoxClipboardWinStreamImpl(void) 49 : m_lRefCount(1) 50 { 51 52 } 53 54 VBoxClipboardWinStreamImpl::~VBoxClipboardWinStreamImpl(void) 55 { 56 } 57 58 /* 59 * IUnknown methods. 60 */ 61 62 STDMETHODIMP VBoxClipboardWinStreamImpl::QueryInterface(REFIID iid, void ** ppvObject) 63 { 64 AssertPtrReturn(ppvObject, E_INVALIDARG); 65 66 if ( iid == IID_IStream 67 || iid == IID_IUnknown) 68 { 69 AddRef(); 70 *ppvObject = this; 71 return S_OK; 72 } 73 74 *ppvObject = 0; 75 return E_NOINTERFACE; 76 } 77 78 STDMETHODIMP_(ULONG) VBoxClipboardWinStreamImpl::AddRef(void) 79 { 80 LONG lCount = InterlockedIncrement(&m_lRefCount); 81 LogFlowFunc(("lCount=%RI32\n", lCount)); 82 return lCount; 83 } 84 85 STDMETHODIMP_(ULONG) VBoxClipboardWinStreamImpl::Release(void) 86 { 87 LONG lCount = InterlockedDecrement(&m_lRefCount); 88 LogFlowFunc(("lCount=%RI32\n", m_lRefCount)); 89 if (lCount == 0) 90 { 91 delete this; 92 return 0; 93 } 94 95 return lCount; 96 } 97 98 /* 99 * IStream methods. 100 */ 101 102 STDMETHODIMP VBoxClipboardWinStreamImpl::Clone(IStream** ppStream) 103 { 104 RT_NOREF(ppStream); 105 106 LogFlowFuncEnter(); 107 return E_NOTIMPL; 108 } 109 110 STDMETHODIMP VBoxClipboardWinStreamImpl::Commit(DWORD dwFrags) 111 { 112 RT_NOREF(dwFrags); 113 114 LogFlowFuncEnter(); 115 return E_NOTIMPL; 116 } 117 118 STDMETHODIMP VBoxClipboardWinStreamImpl::CopyTo(IStream* pDestStream, ULARGE_INTEGER nBytesToCopy, ULARGE_INTEGER* nBytesRead, 119 ULARGE_INTEGER* nBytesWritten) 120 { 121 RT_NOREF(pDestStream, nBytesToCopy, nBytesRead, nBytesWritten); 122 123 LogFlowFuncEnter(); 124 return E_NOTIMPL; 125 } 126 127 STDMETHODIMP VBoxClipboardWinStreamImpl::LockRegion(ULARGE_INTEGER nStart, ULARGE_INTEGER nBytes,DWORD dwFlags) 128 { 129 RT_NOREF(nStart, nBytes, dwFlags); 130 131 LogFlowFuncEnter(); 132 return E_NOTIMPL; 133 } 134 135 static ULONG cbFileSize = _1M; 136 static ULONG cbSizeRead = 0; 137 138 STDMETHODIMP VBoxClipboardWinStreamImpl::Read(void* pvBuffer, ULONG nBytesToRead, ULONG* nBytesRead) 139 { 140 /* If the file size is 0, already return at least 1 byte, else the whole operation will fail. */ 141 142 ULONG cbToRead = RT_MIN(cbFileSize - cbSizeRead, _4K /* nBytesToRead */); 143 144 if (cbToRead > nBytesToRead) 145 cbToRead = nBytesToRead; 146 147 LogFlowFunc(("pvBuffer=%p, nBytesToRead=%u -> cbSizeRead=%u, cbToRead=%u\n", pvBuffer, nBytesToRead, cbSizeRead, cbToRead)); 148 149 if (cbToRead) 150 { 151 memset(pvBuffer, cbToRead, 0x65); 152 cbSizeRead += cbToRead; 153 } 154 155 if (nBytesRead) 156 *nBytesRead = cbToRead; 157 158 if (cbSizeRead == cbFileSize) 159 cbSizeRead = 0; 160 161 return S_OK; 162 } 163 164 STDMETHODIMP VBoxClipboardWinStreamImpl::Revert(void) 165 { 166 LogFlowFuncEnter(); 167 return E_NOTIMPL; 168 } 169 170 STDMETHODIMP VBoxClipboardWinStreamImpl::Seek(LARGE_INTEGER nMove, DWORD dwOrigin, ULARGE_INTEGER* nNewPos) 171 { 172 RT_NOREF(nMove, dwOrigin, nNewPos); 173 174 LogFlowFuncEnter(); 175 return E_NOTIMPL; 176 } 177 178 STDMETHODIMP VBoxClipboardWinStreamImpl::SetSize(ULARGE_INTEGER nNewSize) 179 { 180 RT_NOREF(nNewSize); 181 182 LogFlowFuncEnter(); 183 return E_NOTIMPL; 184 } 185 186 STDMETHODIMP VBoxClipboardWinStreamImpl::Stat(STATSTG* statstg, DWORD dwFlags) 187 { 188 RT_NOREF(statstg, dwFlags); 189 190 LogFlowFuncEnter(); 191 return E_NOTIMPL; 192 } 193 194 STDMETHODIMP VBoxClipboardWinStreamImpl::UnlockRegion(ULARGE_INTEGER nStart, ULARGE_INTEGER nBytes, DWORD dwFlags) 195 { 196 RT_NOREF(nStart, nBytes, dwFlags); 197 198 LogFlowFuncEnter(); 199 return E_NOTIMPL; 200 } 201 202 STDMETHODIMP VBoxClipboardWinStreamImpl::Write(const void* pvBuffer, ULONG nBytesToRead, ULONG* nBytesRead) 203 { 204 RT_NOREF(pvBuffer, nBytesToRead, nBytesRead); 205 206 LogFlowFuncEnter(); 207 return E_NOTIMPL; 208 } 209 210 /* 211 * Own stuff. 212 */ 213 214 /* static */ 215 HRESULT VBoxClipboardWinStreamImpl::Create(IStream **ppStream) 216 { 217 VBoxClipboardWinStreamImpl *pStream = new VBoxClipboardWinStreamImpl(); 218 if (pStream) 219 { 220 pStream->AddRef(); 221 222 *ppStream = pStream; 223 return S_OK; 224 } 225 226 return E_FAIL; 227 } 228
Note:
See TracChangeset
for help on using the changeset viewer.