|
|
1.1 root 1: /*
2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved.
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.5 ! root 15: #define TC_ENC_IO_QUEUE_MAX_FRAGMENT_SIZE (256 * 1024)
! 16: #define TC_ENC_IO_QUEUE_MEM_ALLOC_RETRY_DELAY 5
1.1.1.4 root 17: #define TC_ENC_IO_QUEUE_MEM_ALLOC_TIMEOUT (60 * 1000)
1.1 root 18:
19: typedef struct
20: {
21: PDEVICE_OBJECT DeviceObject;
22:
23: CRYPTO_INFO *CryptoInfo;
24:
25: // File-handle-based IO
26: HANDLE HostFileHandle;
27: int64 VirtualDeviceLength;
1.1.1.5 ! root 28: SECURITY_CLIENT_CONTEXT *SecurityClientContext;
1.1 root 29:
30: // Filter device
31: BOOL IsFilterDevice;
32: PDEVICE_OBJECT LowerDeviceObject;
33: int64 EncryptedAreaStart;
34: int64 EncryptedAreaEnd;
1.1.1.4 root 35: BOOL RemapEncryptedArea;
36: int64 RemappedAreaOffset;
37: int64 RemappedAreaDataUnitOffset;
1.1 root 38: IO_REMOVE_LOCK RemoveLock;
39:
40: // Main tread
41: PKTHREAD MainThread;
42: LIST_ENTRY MainThreadQueue;
43: KSPIN_LOCK MainThreadQueueLock;
44: KEVENT MainThreadQueueNotEmptyEvent;
45:
46: // IO thread
47: PKTHREAD IoThread;
48: LIST_ENTRY IoThreadQueue;
49: KSPIN_LOCK IoThreadQueueLock;
50: KEVENT IoThreadQueueNotEmptyEvent;
51:
52: // Completion thread
53: PKTHREAD CompletionThread;
54: LIST_ENTRY CompletionThreadQueue;
55: KSPIN_LOCK CompletionThreadQueueLock;
56: KEVENT CompletionThreadQueueNotEmptyEvent;
57:
58: byte *FragmentBufferA;
59: byte *FragmentBufferB;
60: KEVENT FragmentBufferAFreeEvent;
61: KEVENT FragmentBufferBFreeEvent;
62:
63: LONG OutstandingIoCount;
64: KEVENT NoOutstandingIoEvent;
65:
1.1.1.3 root 66: KEVENT RequestCompletedEvent;
67:
1.1 root 68: __int64 TotalBytesRead;
69: __int64 TotalBytesWritten;
70:
71: volatile BOOL ThreadExitRequested;
72:
73: volatile BOOL Suspended;
74: volatile BOOL SuspendPending;
75: volatile BOOL StopPending;
76:
77: KEVENT QueueResumedEvent;
78:
79: } EncryptedIoQueue;
80:
81:
82: typedef struct
83: {
84: EncryptedIoQueue *Queue;
85: PIRP OriginalIrp;
86: BOOL Write;
87: ULONG OriginalLength;
88: LARGE_INTEGER OriginalOffset;
1.1.1.3 root 89: LONG OutstandingRequestCount;
1.1 root 90: NTSTATUS Status;
91: } EncryptedIoQueueItem;
92:
93:
94: typedef struct
95: {
96: EncryptedIoQueueItem *Item;
97:
98: BOOL CompleteOriginalIrp;
99: LARGE_INTEGER Offset;
100: ULONG Length;
101: int64 EncryptedOffset;
102: ULONG EncryptedLength;
103: byte *Data;
104: byte *OrigDataBufferFragment;
105:
106: LIST_ENTRY ListEntry;
107: LIST_ENTRY CompletionListEntry;
108: } EncryptedIoRequest;
109:
110:
111: NTSTATUS EncryptedIoQueueAddIrp (EncryptedIoQueue *queue, PIRP irp);
112: BOOL EncryptedIoQueueIsRunning (EncryptedIoQueue *queue);
113: BOOL EncryptedIoQueueIsSuspended (EncryptedIoQueue *queue);
114: NTSTATUS EncryptedIoQueueResumeFromHold (EncryptedIoQueue *queue);
1.1.1.5 ! root 115: NTSTATUS EncryptedIoQueueStart (EncryptedIoQueue *queue);
1.1 root 116: NTSTATUS EncryptedIoQueueStop (EncryptedIoQueue *queue);
117: NTSTATUS EncryptedIoQueueHoldWhenIdle (EncryptedIoQueue *queue, int64 timeout);
118:
119:
120: #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.