MCPcopy Create free account
hub / github.com/DFIR-ORC/dfir-orc / SetFilePointer

Method SetFilePointer

src/OrcLib/MemoryStream.cpp:366–407  ·  view source on GitHub ↗

MemoryStream::SetFilePointer Sets the stream's current pointer. If the resultant pointer is greater than the number of valid bytes in the buffer, the resultant is clipped to the latter value Parameters: See SetFilePointer() doc for the descriptions of all parameters */

Source from the content-addressed store, hash-verified

364See SetFilePointer() doc for the descriptions of all parameters
365*/
366HRESULT
367MemoryStream::SetFilePointer(__in LONGLONG DistanceToMove, __in DWORD dwMoveMethod, __out_opt PULONG64 pCurrPointer)
368{
369 HRESULT hr = E_FAIL;
370 DWORD dwNewFilePointer = 0;
371
372 if (DistanceToMove > MAXDWORD)
373 return E_INVALIDARG;
374 LARGE_INTEGER liDistanceToMove;
375 liDistanceToMove.QuadPart = DistanceToMove;
376
377 switch (dwMoveMethod)
378 {
379 case SEEK_CUR:
380 dwNewFilePointer = LONG(m_dwCurrFilePointer) + liDistanceToMove.LowPart;
381 break;
382 case SEEK_END:
383 dwNewFilePointer = (LONG)m_cbBuffer + liDistanceToMove.LowPart;
384 break;
385
386 case SEEK_SET:
387 dwNewFilePointer = liDistanceToMove.LowPart;
388 break;
389
390 default:
391 return E_INVALIDARG;
392 }
393
394 // Clip the pointer to [0, cbBuffer]
395 if (dwNewFilePointer > m_cbBuffer)
396 {
397 if (FAILED(hr = SetBufferSize(dwNewFilePointer, m_cbReservedBytes)))
398 return hr;
399 }
400 m_dwCurrFilePointer = dwNewFilePointer;
401
402 if (pCurrPointer)
403 {
404 *pCurrPointer = m_dwCurrFilePointer;
405 }
406 return S_OK;
407}
408
409/*
410MemoryStream::GetSize

Callers 2

CloneMethod · 0.45
DuplicateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected