public unsafe void PointerOffset_Negative() { void *v = (void *)1000; v = Pointers.Offset(v, -42); ((int)v).Should().Be(958); }
public unsafe void PointerOffset() { void *v = (void *)1000; v = Pointers.Offset(v, 42); ((int)v).Should().Be(1042); }
public unsafe BackupStreamInformation?GetNextInfo() { void *buffer = _buffer.VoidPointer; Error.ThrowLastErrorIfFalse( Imports.BackupRead( hFile: _fileHandle, lpBuffer: buffer, nNumberOfBytesToRead: s_headerSize, lpNumberOfBytesRead: out uint bytesRead, bAbort: false, bProcessSecurity: true, context: ref _context)); // Exit if at the end if (bytesRead == 0) { return(null); } WIN32_STREAM_ID *streamId = (WIN32_STREAM_ID *)buffer; if (streamId->dwStreamNameSize > 0) { _buffer.EnsureByteCapacity(s_headerSize + streamId->dwStreamNameSize); Error.ThrowLastErrorIfFalse( Imports.BackupRead( hFile: _fileHandle, lpBuffer: Pointers.Offset(buffer, s_headerSize), nNumberOfBytesToRead: streamId->dwStreamNameSize, lpNumberOfBytesRead: out bytesRead, bAbort: false, bProcessSecurity: true, context: ref _context)); } if (streamId->Size > 0) { // Move to the next header, if any if (!Imports.BackupSeek( hFile: _fileHandle, dwLowBytesToSeek: uint.MaxValue, dwHighBytesToSeek: int.MaxValue, lpdwLowByteSeeked: out _, lpdwHighByteSeeked: out _, context: ref _context)) { Error.ThrowIfLastErrorNot(WindowsError.ERROR_SEEK); } } return(new BackupStreamInformation { Name = streamId->cStreamName.CreateString(), StreamType = streamId->dwStreamId, Size = streamId->Size }); }