forked from fengjixuchui/A-Protect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tcpip.c
409 lines (382 loc) · 21.5 KB
/
Tcpip.c
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
//**************************************************************************
//*
//* A盾电脑防护 website:https://www.3600safe.com/
//*
//*文件说明:
//* 枚举tcpip各个例程
//**************************************************************************
#include "Tcpip.h"
//填充各个结构发送至ring3
VOID FixFixTcp(PTCPDISPATCHBAKUP TcpDispatchBakUp,PDRIVER_OBJECT PTcpDriverObject,int i,ULONG ulReal_Dispatch,WCHAR *lpwzDispatchName,ULONG Dispatch)
{
ULONG ulCurrentTcpDispatch;
ULONG ulHookModuleBase;
ULONG ulHookModuleSize;
BOOL bIsHooked = FALSE;
ULONG ulReloadTcpDispatch;
TcpDispatchBakUp->TcpDispatch[i].ulTcpDispatch = ulReal_Dispatch;
TcpDispatchBakUp->TcpDispatch[i].ulNumber = Dispatch;
memset(TcpDispatchBakUp->TcpDispatch[i].lpwzTcpDispatchName,0,sizeof(TcpDispatchBakUp->TcpDispatch[0].lpwzTcpDispatchName));
wcsncpy(TcpDispatchBakUp->TcpDispatch[i].lpwzTcpDispatchName,lpwzDispatchName,wcslen(lpwzDispatchName));
ulCurrentTcpDispatch = PTcpDriverObject->MajorFunction[Dispatch];
if (DebugOn)
KdPrint(("ulCurrentTcpDispatch:%08x-%08x",ulCurrentTcpDispatch,PTcpDriverObject));
if (ulCurrentTcpDispatch == ulReal_Dispatch)
{
bIsHooked = TRUE;
WinVer = GetWindowsVersion();
if (WinVer == WINDOWS_VERSION_2K3_SP1_SP2)
{
goto _FunRet;
}
ulReloadTcpDispatch = ulReal_Dispatch - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
//检查是否inline hook
if (GetFunctionCodeSize(ulReal_Dispatch) == GetFunctionCodeSize(ulReloadTcpDispatch) &&
memcmp(ulReal_Dispatch,ulReloadTcpDispatch,GetFunctionCodeSize(ulReal_Dispatch)) != NULL)
{
TcpDispatchBakUp->TcpDispatch[i].Hooked = 2; //fsd inline hook
//简单的处理一下头5字节的hook的检查
ulCurrentTcpDispatch = *(PULONG)(ulReal_Dispatch+1)+(ULONG)(ulReal_Dispatch+5);
//如果不是开头jmp hook,就写回原始地址
if (!RMmIsAddressValid(ulCurrentTcpDispatch))
{
ulCurrentTcpDispatch = ulReal_Dispatch;
}
}
}
_FunRet:
if (!bIsHooked)
{
TcpDispatchBakUp->TcpDispatch[i].Hooked = 1; //fsd hook
}
memset(TcpDispatchBakUp->TcpDispatch[i].lpszBaseModule,0,sizeof(TcpDispatchBakUp->TcpDispatch[0].lpszBaseModule));
if (!IsAddressInSystem(
ulCurrentTcpDispatch,
&ulHookModuleBase,
&ulHookModuleSize,
TcpDispatchBakUp->TcpDispatch[i].lpszBaseModule))
{
strcat(TcpDispatchBakUp->TcpDispatch[i].lpszBaseModule,"Unknown3");
}
TcpDispatchBakUp->TcpDispatch[i].ulCurrentTcpDispatch = ulCurrentTcpDispatch;
TcpDispatchBakUp->TcpDispatch[i].ulModuleSize = ulHookModuleSize;
TcpDispatchBakUp->TcpDispatch[i].ulModuleBase = ulHookModuleBase;
}
VOID SetTcpHook(ULONG ulNumber,ULONG ulRealDispatch)
{
PDRIVER_OBJECT PTcpDriverObject = NULL;
ULONG ulReloadDispatch;
if (RMmIsAddressValid(PTcpDriverObjectBakup))
{
PTcpDriverObject = PTcpDriverObjectBakup;
PTcpDriverObject->MajorFunction[ulNumber] = ulRealDispatch; //恢复 fsd hook
if (GetWindowsVersion() == WINDOWS_VERSION_XP)
{
ulReloadDispatch = ulRealDispatch - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
//恢复 fsd inline hook
if (GetFunctionCodeSize(ulRealDispatch) != GetFunctionCodeSize(ulReloadDispatch))
{
return;
}
if (memcmp(ulRealDispatch,ulReloadDispatch,GetFunctionCodeSize(ulRealDispatch)) == NULL)
{
return;
}
__asm
{
cli
push eax
mov eax,cr0
and eax,not 0x10000
mov cr0,eax
pop eax
}
memcpy(ulRealDispatch,ulReloadDispatch,GetFunctionCodeSize(ulRealDispatch));
__asm
{
push eax
mov eax,cr0
or eax,0x10000
mov cr0,eax
pop eax
sti
}
}
}
}
NTSTATUS ReLoadTcpip(PDRIVER_OBJECT DriverObject,PTCPDISPATCHBAKUP TcpDispatchBakUp,int Type)
{
ULONG ulOldTcpipDispatch;
ULONG ulNewTcpipDispatch;
PDRIVER_OBJECT PTcpipDriverObject = NULL;
int i=0,count=0;
WIN_VER_DETAIL WinVer;
BOOL bIsReLoadSuccess = FALSE;
UNICODE_STRING UnicodeModule;
HANDLE hSection;
DWORD TcpDriverEntry = 0;
ULONG ulDriverEntryToDispatchCodeOffset;
ULONG ulOffset;
ULONG ulAddress;
ULONG ulModuleBase;
WinVer = GetWindowsVersion();
if (WinVer == WINDOWS_VERSION_7)
return STATUS_UNSUCCESSFUL;
//获取driverobject
if (GetDriverObject(L"\\Driver\\Tcpip",&PTcpipDriverObject) == STATUS_SUCCESS)
{
PTcpDriverObjectBakup = PTcpipDriverObject;
ulTcpipModuleBase = PTcpipDriverObject->DriverStart;
ulTcpipModuleSize = PTcpipDriverObject->DriverSize;
WinVer = GetWindowsVersion();
if (WinVer == WINDOWS_VERSION_2K3_SP1_SP2)
{
if (DebugOn)
KdPrint(("WINDOWS_VERSION_2K3_SP1_SP2:%08X\n",ulTcpipModuleBase));
goto _FunRet;
}
//reload
if (PeLoad(
L"\\SystemRoot\\system32\\drivers\\Tcpip.sys",
&ulReLoadTcpipModuleBase,
DriverObject,
ulTcpipModuleBase
))
{
bIsReLoadSuccess = TRUE;
}
_FunRet:
if (!bIsReLoadSuccess)
{
//KdPrint(("MapFileAsSection\n"));
RtlInitUnicodeString(&UnicodeModule,L"\\SystemRoot\\system32\\drivers\\tcpip.sys");
hSection = MapFileAsSection(&UnicodeModule,&ulModuleBase);
if (hSection)
{
ulReLoadTcpipModuleBase = ulModuleBase;
//KdPrint(("ulModuleBase:%08X\n",ulModuleBase));
ZwClose(hSection);
}else
KdPrint(("MapFileAsSection false\n"));
}
if (GetDriverEntryPoint(ulReLoadTcpipModuleBase,&TcpDriverEntry))
{
WinVer = GetWindowsVersion();
switch (WinVer)
{
case WINDOWS_VERSION_XP:
ulDriverEntryToDispatchCodeOffset = 0x155; //硬编码了,xp
ulOffset = 0;
break;
// case WINDOWS_VERSION_7:
// ulDriverEntryToDispatchCodeOffset = 0x205; //硬编码了,win7
// ulOffset = 0;
// break;
case WINDOWS_VERSION_2K3_SP1_SP2:
ulDriverEntryToDispatchCodeOffset = 0x174; //硬编码了,2003
ulOffset = (ULONG)PTcpipDriverObject->DriverStart - 0x10000;
break;
}
ulAddress = TcpDriverEntry + ulDriverEntryToDispatchCodeOffset;
ulReal_TCP_IRP_MJ_CREATE = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_CLOSE = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_READ = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_WRITE = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_QUERY_INFORMATION = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SET_INFORMATION = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_QUERY_EA = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SET_EA = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_FLUSH_BUFFERS = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_DEVICE_CONTROL = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SHUTDOWN = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_LOCK_CONTROL = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_CLEANUP = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_CREATE_MAILSLOT = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_QUERY_SECURITY = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SET_SECURITY = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_POWER = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SYSTEM_CONTROL = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_DEVICE_CHANGE = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_QUERY_QUOTA = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_SET_QUOTA = *(PULONG)(ulAddress+1) + ulOffset;
ulReal_TCP_IRP_MJ_PNP_POWER = *(PULONG)(ulAddress+1) + ulOffset;
//KdPrint(("dispatch:%08x\n",*(PULONG)(ulAddress+1) + ulOffset));
if (Type == 1)
{
//填充结构
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,0,ulReal_TCP_IRP_MJ_CREATE,L"IRP_MJ_CREATE",IRP_MJ_CREATE);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,1,ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE,L"IRP_MJ_CREATE_NAMED_PIPE",IRP_MJ_CREATE_NAMED_PIPE);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,2,ulReal_TCP_IRP_MJ_CLOSE,L"IRP_MJ_CLOSE",IRP_MJ_CLOSE);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,3,ulReal_TCP_IRP_MJ_READ,L"IRP_MJ_READ",IRP_MJ_READ);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,4,ulReal_TCP_IRP_MJ_WRITE,L"IRP_MJ_WRITE",IRP_MJ_WRITE);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,5,ulReal_TCP_IRP_MJ_QUERY_INFORMATION,L"IRP_MJ_QUERY_INFORMATION",IRP_MJ_QUERY_INFORMATION);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,6,ulReal_TCP_IRP_MJ_SET_INFORMATION,L"IRP_MJ_SET_INFORMATION",IRP_MJ_SET_INFORMATION);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,7,ulReal_TCP_IRP_MJ_QUERY_EA,L"IRP_MJ_QUERY_EA",IRP_MJ_QUERY_EA);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,8,ulReal_TCP_IRP_MJ_SET_EA,L"IRP_MJ_SET_EA",IRP_MJ_SET_EA);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,9,ulReal_TCP_IRP_MJ_FLUSH_BUFFERS,L"IRP_MJ_FLUSH_BUFFERS",IRP_MJ_FLUSH_BUFFERS);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,10,ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION,L"IRP_MJ_QUERY_VOLUME_INFORMATION",IRP_MJ_QUERY_VOLUME_INFORMATION);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,11,ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION,L"IRP_MJ_SET_VOLUME_INFORMATION",IRP_MJ_SET_VOLUME_INFORMATION);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,12,ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL,L"IRP_MJ_DIRECTORY_CONTROL",IRP_MJ_DIRECTORY_CONTROL);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,13,ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL,L"IRP_MJ_FILE_SYSTEM_CONTROL",IRP_MJ_FILE_SYSTEM_CONTROL);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,14,ulReal_TCP_IRP_MJ_DEVICE_CONTROL,L"IRP_MJ_DEVICE_CONTROL",IRP_MJ_DEVICE_CONTROL);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,15,ulReal_TCP_IRP_MJ_SHUTDOWN,L"IRP_MJ_SHUTDOWN",IRP_MJ_SHUTDOWN);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,16,ulReal_TCP_IRP_MJ_LOCK_CONTROL,L"IRP_MJ_LOCK_CONTROL",IRP_MJ_LOCK_CONTROL);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,17,ulReal_TCP_IRP_MJ_CLEANUP,L"IRP_MJ_CLEANUP",IRP_MJ_CLEANUP);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,18,ulReal_TCP_IRP_MJ_CREATE_MAILSLOT,L"IRP_MJ_CREATE_MAILSLOT",IRP_MJ_CREATE_MAILSLOT);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,19,ulReal_TCP_IRP_MJ_QUERY_SECURITY,L"IRP_MJ_QUERY_SECURITY",IRP_MJ_QUERY_SECURITY);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,20,ulReal_TCP_IRP_MJ_SET_SECURITY,L"IRP_MJ_SET_SECURITY",IRP_MJ_SET_SECURITY);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,21,ulReal_TCP_IRP_MJ_POWER,L"IRP_MJ_POWER",IRP_MJ_POWER);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,22,ulReal_TCP_IRP_MJ_SYSTEM_CONTROL,L"IRP_MJ_SYSTEM_CONTROL",IRP_MJ_SYSTEM_CONTROL);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,23,ulReal_TCP_IRP_MJ_DEVICE_CHANGE,L"IRP_MJ_DEVICE_CHANGE",IRP_MJ_DEVICE_CHANGE);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,24,ulReal_TCP_IRP_MJ_QUERY_QUOTA,L"IRP_MJ_QUERY_QUOTA",IRP_MJ_QUERY_QUOTA);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,25,ulReal_TCP_IRP_MJ_SET_QUOTA,L"IRP_MJ_SET_QUOTA",IRP_MJ_SET_QUOTA);
FixFixTcp(TcpDispatchBakUp,PTcpDriverObjectBakup,26,ulReal_TCP_IRP_MJ_PNP_POWER,L"IRP_MJ_PNP_POWER",IRP_MJ_PNP_POWER);
TcpDispatchBakUp->ulCount = 27;
return STATUS_SUCCESS;
}
switch (WinVer)
{
case WINDOWS_VERSION_XP:
//让所有的调用都走reload Tcp
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE] = ulReal_TCP_IRP_MJ_CREATE - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLOSE] = ulReal_TCP_IRP_MJ_CLOSE - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_READ] = ulReal_TCP_IRP_MJ_READ - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_WRITE] = ulReal_TCP_IRP_MJ_WRITE - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_INFORMATION - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_INFORMATION] = ulReal_TCP_IRP_MJ_SET_INFORMATION - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_EA] = ulReal_TCP_IRP_MJ_QUERY_EA - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_EA] = ulReal_TCP_IRP_MJ_SET_EA - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = ulReal_TCP_IRP_MJ_FLUSH_BUFFERS - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ulReal_TCP_IRP_MJ_DEVICE_CONTROL - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SHUTDOWN] = ulReal_TCP_IRP_MJ_SHUTDOWN - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_LOCK_CONTROL] = ulReal_TCP_IRP_MJ_LOCK_CONTROL - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLEANUP] = ulReal_TCP_IRP_MJ_CLEANUP - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = ulReal_TCP_IRP_MJ_CREATE_MAILSLOT - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_SECURITY] = ulReal_TCP_IRP_MJ_QUERY_SECURITY - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_SECURITY] = ulReal_TCP_IRP_MJ_SET_SECURITY - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_POWER] = ulReal_TCP_IRP_MJ_POWER - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_SYSTEM_CONTROL - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CHANGE] = ulReal_TCP_IRP_MJ_DEVICE_CHANGE - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_QUOTA] = ulReal_TCP_IRP_MJ_QUERY_QUOTA - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_QUOTA] = ulReal_TCP_IRP_MJ_SET_QUOTA - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_PNP_POWER] = ulReal_TCP_IRP_MJ_PNP_POWER - ulTcpipModuleBase + ulReLoadTcpipModuleBase;
break;
case WINDOWS_VERSION_2K3_SP1_SP2:
//2003的话,先恢复吧
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE] = ulReal_TCP_IRP_MJ_CREATE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLOSE] = ulReal_TCP_IRP_MJ_CLOSE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_READ] = ulReal_TCP_IRP_MJ_READ;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_WRITE] = ulReal_TCP_IRP_MJ_WRITE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_INFORMATION] = ulReal_TCP_IRP_MJ_SET_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_EA] = ulReal_TCP_IRP_MJ_QUERY_EA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_EA] = ulReal_TCP_IRP_MJ_SET_EA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = ulReal_TCP_IRP_MJ_FLUSH_BUFFERS;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ulReal_TCP_IRP_MJ_DEVICE_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SHUTDOWN] = ulReal_TCP_IRP_MJ_SHUTDOWN;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_LOCK_CONTROL] = ulReal_TCP_IRP_MJ_LOCK_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLEANUP] = ulReal_TCP_IRP_MJ_CLEANUP;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = ulReal_TCP_IRP_MJ_CREATE_MAILSLOT;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_SECURITY] = ulReal_TCP_IRP_MJ_QUERY_SECURITY;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_SECURITY] = ulReal_TCP_IRP_MJ_SET_SECURITY;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_POWER] = ulReal_TCP_IRP_MJ_POWER;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_SYSTEM_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CHANGE] = ulReal_TCP_IRP_MJ_DEVICE_CHANGE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_QUOTA] = ulReal_TCP_IRP_MJ_QUERY_QUOTA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_QUOTA] = ulReal_TCP_IRP_MJ_SET_QUOTA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_PNP_POWER] = ulReal_TCP_IRP_MJ_PNP_POWER;
break;
}
}
}
return STATUS_SUCCESS;
}
NTSTATUS ReLoadTcpipFree()
{
int i=0;
BOOL bIsWinVer = FALSE;
WIN_VER_DETAIL WinVer;
PDRIVER_OBJECT PTcpDriverObject = NULL;
WinVer = GetWindowsVersion();
if (WinVer == WINDOWS_VERSION_7)
return STATUS_UNSUCCESSFUL;
if (RMmIsAddressValid(PTcpDriverObjectBakup))
{
PTcpDriverObject = PTcpDriverObjectBakup;
if (DebugOn)
KdPrint(("ReLoadTcpFree success"));
if (ulReal_TCP_IRP_MJ_CREATE &&
ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE &&
ulReal_TCP_IRP_MJ_CLOSE &&
ulReal_TCP_IRP_MJ_READ &&
ulReal_TCP_IRP_MJ_WRITE &&
ulReal_TCP_IRP_MJ_QUERY_INFORMATION &&
ulReal_TCP_IRP_MJ_SET_INFORMATION &&
ulReal_TCP_IRP_MJ_QUERY_EA &&
ulReal_TCP_IRP_MJ_SET_EA &&
ulReal_TCP_IRP_MJ_FLUSH_BUFFERS &&
ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION &&
ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION &&
ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL &&
ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL &&
ulReal_TCP_IRP_MJ_DEVICE_CONTROL &&
ulReal_TCP_IRP_MJ_SHUTDOWN &&
ulReal_TCP_IRP_MJ_LOCK_CONTROL &&
ulReal_TCP_IRP_MJ_CLEANUP &&
ulReal_TCP_IRP_MJ_CREATE_MAILSLOT &&
ulReal_TCP_IRP_MJ_QUERY_SECURITY &&
ulReal_TCP_IRP_MJ_SET_SECURITY &&
ulReal_TCP_IRP_MJ_POWER &&
ulReal_TCP_IRP_MJ_SYSTEM_CONTROL &&
ulReal_TCP_IRP_MJ_DEVICE_CHANGE &&
ulReal_TCP_IRP_MJ_QUERY_QUOTA &&
ulReal_TCP_IRP_MJ_SET_QUOTA &&
ulReal_TCP_IRP_MJ_PNP_POWER)
{
//恢复
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE] = ulReal_TCP_IRP_MJ_CREATE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] = ulReal_TCP_IRP_MJ_CREATE_NAMED_PIPE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLOSE] = ulReal_TCP_IRP_MJ_CLOSE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_READ] = ulReal_TCP_IRP_MJ_READ;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_WRITE] = ulReal_TCP_IRP_MJ_WRITE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_INFORMATION] = ulReal_TCP_IRP_MJ_SET_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_EA] = ulReal_TCP_IRP_MJ_QUERY_EA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_EA] = ulReal_TCP_IRP_MJ_SET_EA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = ulReal_TCP_IRP_MJ_FLUSH_BUFFERS;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_QUERY_VOLUME_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_VOLUME_INFORMATION] = ulReal_TCP_IRP_MJ_SET_VOLUME_INFORMATION;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] = ulReal_TCP_IRP_MJ_DIRECTORY_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_FILE_SYSTEM_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CONTROL] = ulReal_TCP_IRP_MJ_DEVICE_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SHUTDOWN] = ulReal_TCP_IRP_MJ_SHUTDOWN;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_LOCK_CONTROL] = ulReal_TCP_IRP_MJ_LOCK_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CLEANUP] = ulReal_TCP_IRP_MJ_CLEANUP;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_CREATE_MAILSLOT] = ulReal_TCP_IRP_MJ_CREATE_MAILSLOT;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_SECURITY] = ulReal_TCP_IRP_MJ_QUERY_SECURITY;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_SECURITY] = ulReal_TCP_IRP_MJ_SET_SECURITY;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_POWER] = ulReal_TCP_IRP_MJ_POWER;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = ulReal_TCP_IRP_MJ_SYSTEM_CONTROL;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_DEVICE_CHANGE] = ulReal_TCP_IRP_MJ_DEVICE_CHANGE;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_QUERY_QUOTA] = ulReal_TCP_IRP_MJ_QUERY_QUOTA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_SET_QUOTA] = ulReal_TCP_IRP_MJ_SET_QUOTA;
PTcpDriverObjectBakup->MajorFunction[IRP_MJ_PNP_POWER] = ulReal_TCP_IRP_MJ_PNP_POWER;
}
}
return STATUS_SUCCESS;
}