moel@347
|
1 |
//-----------------------------------------------------------------------------
|
moel@347
|
2 |
// Author : hiyohiyo
|
moel@347
|
3 |
// Mail : hiyohiyo@crystalmark.info
|
moel@347
|
4 |
// Web : http://openlibsys.org/
|
moel@347
|
5 |
// License : The modified BSD license
|
moel@347
|
6 |
//
|
moel@347
|
7 |
// Copyright 2007-2008 OpenLibSys.org. All rights reserved.
|
moel@347
|
8 |
//-----------------------------------------------------------------------------
|
moel@347
|
9 |
|
moel@347
|
10 |
#include <ntddk.h>
|
moel@347
|
11 |
#include <devioctl.h>
|
moel@347
|
12 |
#include "OlsIoctl.h"
|
moel@347
|
13 |
|
moel@347
|
14 |
//-----------------------------------------------------------------------------
|
moel@347
|
15 |
//
|
moel@347
|
16 |
// Device Name
|
moel@347
|
17 |
//
|
moel@347
|
18 |
//-----------------------------------------------------------------------------
|
moel@347
|
19 |
|
moel@347
|
20 |
#define NT_DEVICE_NAME L"\\Device\\WinRing0_1_2_0"
|
moel@347
|
21 |
#define DOS_DEVICE_NAME L"\\DosDevices\\WinRing0_1_2_0"
|
moel@347
|
22 |
|
moel@347
|
23 |
//-----------------------------------------------------------------------------
|
moel@347
|
24 |
//
|
moel@347
|
25 |
// Function Prototypes
|
moel@347
|
26 |
//
|
moel@347
|
27 |
//-----------------------------------------------------------------------------
|
moel@347
|
28 |
|
moel@347
|
29 |
NTSTATUS DriverEntry(
|
moel@347
|
30 |
IN PDRIVER_OBJECT DriverObject,
|
moel@347
|
31 |
IN PUNICODE_STRING RegistryPath
|
moel@347
|
32 |
);
|
moel@347
|
33 |
|
moel@347
|
34 |
NTSTATUS OlsDispatch(
|
moel@347
|
35 |
IN PDEVICE_OBJECT pDO,
|
moel@347
|
36 |
IN PIRP pIrp
|
moel@347
|
37 |
);
|
moel@347
|
38 |
|
moel@347
|
39 |
VOID Unload(
|
moel@347
|
40 |
IN PDRIVER_OBJECT DriverObject
|
moel@347
|
41 |
);
|
moel@347
|
42 |
|
moel@347
|
43 |
//-----------------------------------------------------------------------------
|
moel@347
|
44 |
//
|
moel@347
|
45 |
// Function Prototypes for Control Code
|
moel@347
|
46 |
//
|
moel@347
|
47 |
//-----------------------------------------------------------------------------
|
moel@347
|
48 |
|
moel@347
|
49 |
NTSTATUS ReadMsr(
|
moel@347
|
50 |
void *lpInBuffer,
|
moel@347
|
51 |
ULONG nInBufferSize,
|
moel@347
|
52 |
void *lpOutBuffer,
|
moel@347
|
53 |
ULONG nOutBufferSize,
|
moel@347
|
54 |
ULONG *lpBytesReturned
|
moel@347
|
55 |
);
|
moel@347
|
56 |
|
moel@347
|
57 |
NTSTATUS WriteMsr(
|
moel@347
|
58 |
void *lpInBuffer,
|
moel@347
|
59 |
ULONG nInBufferSize,
|
moel@347
|
60 |
void *lpOutBuffer,
|
moel@347
|
61 |
ULONG nOutBufferSize,
|
moel@347
|
62 |
ULONG *lpBytesReturned
|
moel@347
|
63 |
);
|
moel@347
|
64 |
|
moel@347
|
65 |
NTSTATUS ReadPmc(
|
moel@347
|
66 |
void *lpInBuffer,
|
moel@347
|
67 |
ULONG nInBufferSize,
|
moel@347
|
68 |
void *lpOutBuffer,
|
moel@347
|
69 |
ULONG nOutBufferSize,
|
moel@347
|
70 |
ULONG *lpBytesReturned
|
moel@347
|
71 |
);
|
moel@347
|
72 |
|
moel@347
|
73 |
NTSTATUS ReadIoPort(
|
moel@347
|
74 |
ULONG ioControlCode,
|
moel@347
|
75 |
void *lpInBuffer,
|
moel@347
|
76 |
ULONG nInBufferSize,
|
moel@347
|
77 |
void *lpOutBuffer,
|
moel@347
|
78 |
ULONG nOutBufferSize,
|
moel@347
|
79 |
ULONG *lpBytesReturned
|
moel@347
|
80 |
);
|
moel@347
|
81 |
|
moel@347
|
82 |
NTSTATUS WriteIoPort(
|
moel@347
|
83 |
ULONG ioControlCode,
|
moel@347
|
84 |
void *lpInBuffer,
|
moel@347
|
85 |
ULONG nInBufferSize,
|
moel@347
|
86 |
void *lpOutBuffer,
|
moel@347
|
87 |
ULONG nOutBufferSize,
|
moel@347
|
88 |
ULONG *lpBytesReturned
|
moel@347
|
89 |
);
|
moel@347
|
90 |
|
moel@347
|
91 |
NTSTATUS ReadPciConfig(
|
moel@347
|
92 |
void *lpInBuffer,
|
moel@347
|
93 |
ULONG nInBufferSize,
|
moel@347
|
94 |
void *lpOutBuffer,
|
moel@347
|
95 |
ULONG nOutBufferSize,
|
moel@347
|
96 |
ULONG *lpBytesReturned
|
moel@347
|
97 |
);
|
moel@347
|
98 |
|
moel@347
|
99 |
NTSTATUS WritePciConfig(
|
moel@347
|
100 |
void *lpInBuffer,
|
moel@347
|
101 |
ULONG nInBufferSize,
|
moel@347
|
102 |
void *lpOutBuffer,
|
moel@347
|
103 |
ULONG nOutBufferSize,
|
moel@347
|
104 |
ULONG *lpBytesReturned
|
moel@347
|
105 |
);
|
moel@347
|
106 |
|
moel@347
|
107 |
NTSTATUS ReadMemory(
|
moel@347
|
108 |
void *lpInBuffer,
|
moel@347
|
109 |
ULONG nInBufferSize,
|
moel@347
|
110 |
void *lpOutBuffer,
|
moel@347
|
111 |
ULONG nOutBufferSize,
|
moel@347
|
112 |
ULONG *lpBytesReturned
|
moel@347
|
113 |
);
|
moel@347
|
114 |
|
moel@347
|
115 |
NTSTATUS WriteMemory(
|
moel@347
|
116 |
void *lpInBuffer,
|
moel@347
|
117 |
ULONG nInBufferSize,
|
moel@347
|
118 |
void *lpOutBuffer,
|
moel@347
|
119 |
ULONG nOutBufferSize,
|
moel@347
|
120 |
ULONG *lpBytesReturned
|
moel@347
|
121 |
);
|
moel@347
|
122 |
|
moel@347
|
123 |
|
moel@347
|
124 |
//-----------------------------------------------------------------------------
|
moel@347
|
125 |
//
|
moel@347
|
126 |
// Support Function Prototypes
|
moel@347
|
127 |
//
|
moel@347
|
128 |
//-----------------------------------------------------------------------------
|
moel@347
|
129 |
|
moel@347
|
130 |
NTSTATUS pciConfigRead(ULONG pciAddress, ULONG offset, void *data, int length);
|
moel@347
|
131 |
NTSTATUS pciConfigWrite(ULONG pciAddress, ULONG offset, void *data, int length);
|