📄 disp_ev.c
字号:
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
//
// $Id: disp_ev.c,v 1.1.1.1 2002/09/24 11:12:16 dev Exp $
/*
* This file contains TDI_SET_EVENT_HANDLER handler
*/
#include <ntddk.h>
#include <tdikrnl.h>
#include "sock.h"
#include "dispatch.h"
#include "events.h"
#include "memtrack.h"
#include "obj_tbl.h"
#include "tdi_fw.h"
int
tdi_set_event_handler(PIRP irp, PIO_STACK_LOCATION irps, struct completion *completion)
{
PTDI_REQUEST_KERNEL_SET_EVENT r = (PTDI_REQUEST_KERNEL_SET_EVENT)&irps->Parameters;
NTSTATUS status;
struct ot_entry *ote = NULL;
KIRQL irql;
int result = FILTER_DENY;
TDI_EVENT_CONTEXT *ctx;
KdPrint(("[tdi_fw] tdi_set_event_handler: [%s] devobj 0x%x; fileobj 0x%x; EventType: %d\n",
r->EventHandler ? "(+)ADD" : "(-)REMOVE",
irps->DeviceObject,
irps->FileObject,
r->EventType));
ote = ot_find_fileobj(irps->FileObject, &irql);
if (ote == NULL) {
KdPrint(("[tdi_fw] tdi_set_event_handler: ot_find_fileobj(0x%x)\n", irps->FileObject));
if (r->EventHandler == NULL) {
// for fileobjects loaded earlier than our driver allow removing
result = FILTER_ALLOW;
}
goto done;
}
if (r->EventType < 0 || r->EventType >= MAX_EVENT) {
KdPrint(("[tdi_fw] tdi_set_event_handler: unknown EventType %d!\n", r->EventType));
result = FILTER_ALLOW;
goto done;
}
ctx = &ote->ctx[r->EventType];
if (r->EventHandler) {
/* add EventHandler */
int i;
for (i = 0; g_tdi_event_handlers[i].event != (ULONG)-1; i++)
if (g_tdi_event_handlers[i].event == r->EventType)
break;
if (g_tdi_event_handlers[i].event == (ULONG)-1) {
KdPrint(("[tdi_fw] tdi_set_event_handler: unknown EventType %d!\n", r->EventType));
result = FILTER_ALLOW;
goto done;
}
ctx->old_handler = r->EventHandler;
ctx->old_context = r->EventContext;
if (g_tdi_event_handlers[i].handler != NULL) {
r->EventHandler = g_tdi_event_handlers[i].handler;
r->EventContext = ctx;
} else {
r->EventHandler = NULL;
r->EventContext = NULL;
}
KdPrint(("[tdi_fw] tdi_set_event_handler: old_handler 0x%x; old_context 0x%x\n",
r->EventHandler, r->EventContext));
} else {
/* remove EventHandler */
ctx->old_handler = NULL;
ctx->old_context = NULL;
}
result = FILTER_ALLOW;
done:
// cleanup
if (ote != NULL)
KeReleaseSpinLock(&g_ot_hash_guard, irql);
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -