|
|
1.1 root 1: /* 1.1.1.6 ! root 2: Copyright (c) 2008-2009 TrueCrypt Foundation. All rights reserved. 1.1 root 3: 1.1.1.5 root 4: Governed by the TrueCrypt License 2.6 the full text of which is contained 1.1 root 5: in the file License.txt included in TrueCrypt binary and source code 6: distribution packages. 7: */ 8: 9: #ifndef TC_HEADER_DRIVER_ENCRYPTED_IO_QUEUE 10: #define TC_HEADER_DRIVER_ENCRYPTED_IO_QUEUE 11: 12: #include "TCdefs.h" 13: #include "Apidrvr.h" 14: 1.1.1.6 ! root 15: #if 0 ! 16: # define TC_TRACE_IO_QUEUE ! 17: #endif ! 18: 1.1.1.5 root 19: #define TC_ENC_IO_QUEUE_MAX_FRAGMENT_SIZE (256 * 1024) 1.1.1.6 ! root 20: ! 21: #define TC_ENC_IO_QUEUE_PREALLOCATED_ITEM_COUNT 16 ! 22: #define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT 256 ! 23: ! 24: #define TC_ENC_IO_QUEUE_MEM_ALLOC_RETRY_DELAY 1 ! 25: #define TC_ENC_IO_QUEUE_MEM_ALLOC_TIMEOUT (20 * 1000) ! 26: ! 27: ! 28: typedef struct EncryptedIoQueueBufferStruct ! 29: { ! 30: struct EncryptedIoQueueBufferStruct *NextBuffer; ! 31: ! 32: void *Address; ! 33: ULONG Size; ! 34: BOOL InUse; ! 35: ! 36: } EncryptedIoQueueBuffer; ! 37: 1.1 root 38: 39: typedef struct 40: { 41: PDEVICE_OBJECT DeviceObject; 42: 1.1.1.6 ! root 43: KMUTEX BufferPoolMutex; ! 44: EncryptedIoQueueBuffer *FirstPoolBuffer; ! 45: 1.1 root 46: CRYPTO_INFO *CryptoInfo; 47: 48: // File-handle-based IO 49: HANDLE HostFileHandle; 50: int64 VirtualDeviceLength; 1.1.1.5 root 51: SECURITY_CLIENT_CONTEXT *SecurityClientContext; 1.1 root 52: 53: // Filter device 54: BOOL IsFilterDevice; 55: PDEVICE_OBJECT LowerDeviceObject; 56: int64 EncryptedAreaStart; 57: int64 EncryptedAreaEnd; 1.1.1.4 root 58: BOOL RemapEncryptedArea; 59: int64 RemappedAreaOffset; 60: int64 RemappedAreaDataUnitOffset; 1.1 root 61: IO_REMOVE_LOCK RemoveLock; 62: 63: // Main tread 64: PKTHREAD MainThread; 65: LIST_ENTRY MainThreadQueue; 66: KSPIN_LOCK MainThreadQueueLock; 67: KEVENT MainThreadQueueNotEmptyEvent; 68: 69: // IO thread 70: PKTHREAD IoThread; 71: LIST_ENTRY IoThreadQueue; 72: KSPIN_LOCK IoThreadQueueLock; 73: KEVENT IoThreadQueueNotEmptyEvent; 74: 75: // Completion thread 76: PKTHREAD CompletionThread; 77: LIST_ENTRY CompletionThreadQueue; 78: KSPIN_LOCK CompletionThreadQueueLock; 79: KEVENT CompletionThreadQueueNotEmptyEvent; 80: 1.1.1.6 ! root 81: // Fragment buffers 1.1 root 82: byte *FragmentBufferA; 83: byte *FragmentBufferB; 84: KEVENT FragmentBufferAFreeEvent; 85: KEVENT FragmentBufferBFreeEvent; 86: 1.1.1.6 ! root 87: // Read-ahead buffer ! 88: BOOL ReadAheadBufferValid; ! 89: LARGE_INTEGER LastReadOffset; ! 90: ULONG LastReadLength; ! 91: LARGE_INTEGER ReadAheadOffset; ! 92: ULONG ReadAheadLength; ! 93: byte *ReadAheadBuffer; ! 94: LARGE_INTEGER MaxReadAheadOffset; ! 95: 1.1 root 96: LONG OutstandingIoCount; 97: KEVENT NoOutstandingIoEvent; 1.1.1.6 ! root 98: LONG IoThreadPendingRequestCount; ! 99: 1.1.1.3 root 100: KEVENT RequestCompletedEvent; 101: 1.1 root 102: __int64 TotalBytesRead; 103: __int64 TotalBytesWritten; 104: 1.1.1.6 ! root 105: volatile BOOL StartPending; 1.1 root 106: volatile BOOL ThreadExitRequested; 107: 108: volatile BOOL Suspended; 109: volatile BOOL SuspendPending; 110: volatile BOOL StopPending; 111: 112: KEVENT QueueResumedEvent; 113: 1.1.1.6 ! root 114: #ifdef TC_TRACE_IO_QUEUE ! 115: LARGE_INTEGER LastPerformanceCounter; ! 116: #endif ! 117: 1.1 root 118: } EncryptedIoQueue; 119: 120: 121: typedef struct 122: { 123: EncryptedIoQueue *Queue; 124: PIRP OriginalIrp; 125: BOOL Write; 126: ULONG OriginalLength; 127: LARGE_INTEGER OriginalOffset; 1.1.1.3 root 128: LONG OutstandingRequestCount; 1.1 root 129: NTSTATUS Status; 1.1.1.6 ! root 130: ! 131: #ifdef TC_TRACE_IO_QUEUE ! 132: LARGE_INTEGER OriginalIrpOffset; ! 133: #endif ! 134: 1.1 root 135: } EncryptedIoQueueItem; 136: 137: 138: typedef struct 139: { 140: EncryptedIoQueueItem *Item; 141: 142: BOOL CompleteOriginalIrp; 143: LARGE_INTEGER Offset; 144: ULONG Length; 145: int64 EncryptedOffset; 146: ULONG EncryptedLength; 147: byte *Data; 148: byte *OrigDataBufferFragment; 149: 150: LIST_ENTRY ListEntry; 151: LIST_ENTRY CompletionListEntry; 152: } EncryptedIoRequest; 153: 154: 155: NTSTATUS EncryptedIoQueueAddIrp (EncryptedIoQueue *queue, PIRP irp); 156: BOOL EncryptedIoQueueIsRunning (EncryptedIoQueue *queue); 157: BOOL EncryptedIoQueueIsSuspended (EncryptedIoQueue *queue); 158: NTSTATUS EncryptedIoQueueResumeFromHold (EncryptedIoQueue *queue); 1.1.1.5 root 159: NTSTATUS EncryptedIoQueueStart (EncryptedIoQueue *queue); 1.1 root 160: NTSTATUS EncryptedIoQueueStop (EncryptedIoQueue *queue); 161: NTSTATUS EncryptedIoQueueHoldWhenIdle (EncryptedIoQueue *queue, int64 timeout); 162: 163: 164: #endif // TC_HEADER_DRIVER_ENCRYPTED_IO_QUEUE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.