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