首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

编写内核程序出错error求帮助,该如何处理

2012-06-08 
编写内核程序出错error求帮助C/C++ code#include ntddk.hNTSTATUS IN_Dispatch(IN PDRIVER_OBJECT mydri

编写内核程序出错error求帮助

C/C++ code
#include <ntddk.h>NTSTATUS IN_Dispatch(IN PDRIVER_OBJECT mydriver,IN PIRP irp);void UnloadIN(IN PDRIVER_OBJECT mydriver);#define FILE_DEVICE_IN 0x00008010#define CONTROL_MOUSE 0x815#define CONTROL_KEYBOARD 0x820#define IOCTL_IN_MOUSE        CTL_CODE(FILE_DEVICE_IN,\                                CONTROL_MOUSE,\                                METHOD_BUFFERED,\                                FILE_ANY_ACCESS)#define IOCTL_IN_KEYBOARD    CTL_CODE(FILE_DEVICE_IN,\                                CONTROL_KEYBOARD,\                                METHOD_BUFFERED,\                                FILE_ANY_ACCESS)void SetDate(char scancode){    __asm    {        s:        in al, 0x64        and al, 10        jnz s        mov al, 0xD2        out 0x64, al        x:        in al, 0x64        and al, 10        jnz x        mov al, scancode        out 0x60, al    }}NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath){    UNICODE_STRING  DeviceNameUnicodeString;    UNICODE_STRING  DeviceLinkUnicodeString;    NTSTATUS state = 0;    PDEVICE_OBJECT  DeviceObject = 0;    RtlInitUnicodeString (&DeviceNameUnicodeString, L"\\Device\\IN_Mouse_Keyboard");    state= IoCreateDevice(DriverObject,0,&DeviceNameUnicodeString,FILE_DEVICE_IN,0,TRUE,&DeviceObject);    if(STATUS_SUCCESS == state)    {        size_t i;        for(i = 0;i<IRP_MJ_MAXIMUM_FUNCTION;++i)        {        DriverObject->MajorFunction[i] = IN_Dispatch;//在该行出错        }        DriverObject->DriverUnload= UnloadIN;        state = IoCreateSymbolicLink (&DeviceLinkUnicodeString,&DeviceNameUnicodeString);        if(!(STATUS_SUCCESS == state))        {            IoDeleteDevice(DeviceObject);        }        RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\IN_Mouse_Keyboard");    }    else        return state;}NTSTATUS IN_Dispatch(IN PDRIVER_OBJECT mydriver,IN PIRP irp){  PIO_STACK_LOCATION IrpStack;  ULONG              dwInputBufferLength;  ULONG              dwOutputBufferLength;  ULONG              dwIoControlCode;  PVOID              pvIOBuffer;  NTSTATUS           ntStatus;  UCHAR* InputBuffer;  // Init to default settings  irp->IoStatus.Status      = STATUS_SUCCESS;  irp->IoStatus.Information = 0;    IrpStack = IoGetCurrentIrpStackLocation(irp);  pvIOBuffer           = irp->AssociatedIrp.SystemBuffer;  dwInputBufferLength  = IrpStack->Parameters.DeviceIoControl.InputBufferLength;  dwOutputBufferLength = IrpStack->Parameters.DeviceIoControl.OutputBufferLength;  switch (IrpStack->MajorFunction)  {    case IRP_MJ_DEVICE_CONTROL:      dwIoControlCode = IrpStack->Parameters.DeviceIoControl.IoControlCode;      switch (dwIoControlCode)      {      case IOCTL_IN_MOUSE:          break;      case IOCTL_IN_KEYBOARD:         InputBuffer = (UCHAR*)irp->AssociatedIrp.SystemBuffer;         SetDate(InputBuffer[0]);         SetDate(InputBuffer[1]);          break;      default:          irp->IoStatus.Status = STATUS_INVALID_PARAMETER;        break;      }    break;  }  ntStatus = irp->IoStatus.Status;  IoCompleteRequest (irp, IO_NO_INCREMENT);  return ntStatus;}void UnloadIN(IN PDRIVER_OBJECT mydriver){    UNICODE_STRING DeviceLinkUnicodeString;    NTSTATUS ntStatus;    RtlInitUnicodeString (&DeviceLinkUnicodeString, L"\\DosDevices\\IN_Mouse_Keyboard");    ntStatus = IoDeleteSymbolicLink (&DeviceLinkUnicodeString);    if (NT_SUCCESS(ntStatus))    {        IoDeleteDevice (mydriver->DeviceObject);    }}



错误信息:
error C4028: formal parameter 1 different from declaration

[解决办法]
NTSTATUS IN_Dispatch(IN PDRIVER_OBJECT mydriver,IN PIRP irp);


改成
NTSTATUS IN_Dispatch(IN PDEVICE_OBJECT mydriver,IN PIRP irp);

热点排行