阅读:2067回复:3
获取SSDT中NT系列函数出错
驱动中的一些函数:
//SSDT 结构体 typedef struct _tagSSDT { PVOID pvSSDTBase; PVOID pvServiceCounterTable; ULONG ulNumberOfServices; PVOID pvParamTableBase; } MYSSDT, *PMYSSDT; #include <ntddk.h> #include <ntstatus.h> #include "IOCTL.h" PMYSSDT KeServiceDescriptorTable; #define IOCTL_GETSSDT (ULONG)CTL_CODE( FILE_DRIVER_SSDT, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS) NTSTATUS SSDTDeviceIoCtl( PDEVICE_OBJECT pDeviceObject, PIRP Irp ) { NTSTATUS s; PIO_STACK_LOCATION IrpStack; PVOID InputBuffer; PVOID OutputBuffer; ULONG InputBufferLength; ULONG OutputBufferLength; ULONG IoControlCode; s = Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; IrpStack = IoGetCurrentIrpStackLocation( Irp ); InputBuffer = Irp->AssociatedIrp.SystemBuffer; OutputBuffer = Irp->AssociatedIrp.SystemBuffer; InputBufferLength = IrpStack->Parameters.DeviceIoControl.InputBufferLength; OutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength; IoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode; /////////////////////////////////////////////// //这里处理分发例程 switch( IoControlCode ) { //************************************************* case IOCTL_GETSSDT: //得到SSDT RtlCopyMemory( OutputBuffer, KeServiceDescriptorTable, sizeof( MYSSDT ) ); DbgPrint( "SSDT: GetSSDT Completeled!" ); break; 用户层的一些函数: BOOL GetSSDT( IN HANDLE hDriver, OUT PMYSSDT ssdt ) { if( ssdt == NULL ) { return FALSE; } DWORD dwRet; BOOL bRet = DeviceIoControl( hDriver, IOCTL_GETSSDT, NULL, 0, ssdt, sizeof( MYSSDT ), \ &dwRet, NULL ); if( bRet ) { TotalSSDTCount = ssdt->ulNumberOfServices; //获取服务个数 return TRUE; } return FALSE; } 调试时发现ssdt->pvSSDTBase=0xcccccccc; ssdt->pvServiceCounterTable=0xcccccccc; ssdt->ulNumberOfServices=3435973836; ssdt->pvParamTableBase=0xcccccccc; 经过一个晚上的思考不清楚哪里出错了?哪位高手指点下!!! |
|
沙发#
发布于:2010-05-22 01:55
extern PMYSSDT KeServiceDescriptorTable;
|
|
板凳#
发布于:2010-05-22 09:21
有什么问题吗????
|
|
地板#
发布于:2010-05-24 21:42
#define IOCTL_GETSSDT (ULONG)CTL_CODE( FILE_DRIVER_SSDT, 0x01, METHOD_BUFFERED, FILE_ANY_ACCESS)
这里有问题吧。自定义控制码的CTL_CODE的第2个值,要使用0X800以后的,前面的都是被MS使用了。 你应该换个,like this: #define IOCTL_GETSSDT (ULONG)CTL_CODE( FILE_DRIVER_SSDT, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS) |
|