|
|
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.7 ! root 4: Governed by the TrueCrypt License 2.7 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: 1.1.1.7 ! root 21: #define TC_ENC_IO_QUEUE_PREALLOCATED_ITEM_COUNT 8 ! 22: #define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT 16 1.1.1.6 root 23: 24: #define TC_ENC_IO_QUEUE_MEM_ALLOC_RETRY_DELAY 1 1.1.1.7 ! root 25: #define TC_ENC_IO_QUEUE_MEM_ALLOC_TIMEOUT 1000 1.1.1.6 root 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; 1.1.1.7 ! root 101: KEVENT PoolBufferFreeEvent; 1.1.1.3 root 102: 1.1 root 103: __int64 TotalBytesRead; 104: __int64 TotalBytesWritten; 105: 1.1.1.6 root 106: volatile BOOL StartPending; 1.1 root 107: volatile BOOL ThreadExitRequested; 108: 109: volatile BOOL Suspended; 110: volatile BOOL SuspendPending; 111: volatile BOOL StopPending; 112: 113: KEVENT QueueResumedEvent; 114: 1.1.1.6 root 115: #ifdef TC_TRACE_IO_QUEUE 116: LARGE_INTEGER LastPerformanceCounter; 117: #endif 118: 1.1 root 119: } EncryptedIoQueue; 120: 121: 122: typedef struct 123: { 124: EncryptedIoQueue *Queue; 125: PIRP OriginalIrp; 126: BOOL Write; 127: ULONG OriginalLength; 128: LARGE_INTEGER OriginalOffset; 1.1.1.3 root 129: LONG OutstandingRequestCount; 1.1 root 130: NTSTATUS Status; 1.1.1.6 root 131: 132: #ifdef TC_TRACE_IO_QUEUE 133: LARGE_INTEGER OriginalIrpOffset; 134: #endif 135: 1.1 root 136: } EncryptedIoQueueItem; 137: 138: 139: typedef struct 140: { 141: EncryptedIoQueueItem *Item; 142: 143: BOOL CompleteOriginalIrp; 144: LARGE_INTEGER Offset; 145: ULONG Length; 146: int64 EncryptedOffset; 147: ULONG EncryptedLength; 148: byte *Data; 149: byte *OrigDataBufferFragment; 150: 151: LIST_ENTRY ListEntry; 152: LIST_ENTRY CompletionListEntry; 153: } EncryptedIoRequest; 154: 155: 156: NTSTATUS EncryptedIoQueueAddIrp (EncryptedIoQueue *queue, PIRP irp); 157: BOOL EncryptedIoQueueIsRunning (EncryptedIoQueue *queue); 158: BOOL EncryptedIoQueueIsSuspended (EncryptedIoQueue *queue); 159: NTSTATUS EncryptedIoQueueResumeFromHold (EncryptedIoQueue *queue); 1.1.1.5 root 160: NTSTATUS EncryptedIoQueueStart (EncryptedIoQueue *queue); 1.1 root 161: NTSTATUS EncryptedIoQueueStop (EncryptedIoQueue *queue); 162: NTSTATUS EncryptedIoQueueHoldWhenIdle (EncryptedIoQueue *queue, int64 timeout); 163: 164: 165: #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.