Discussion:
IoConnectInterrupt - STATUS_INVALID_PARAMETER
(too old to reply)
Mohit Gupta
2010-06-15 10:53:38 UTC
Permalink
Hi All,

I am trying to install an interrupt handler for 0x97 (hard coded for testing
purposes), but when I try to run IoConnectInterrupt it always return
STATUS_INVALID_PARAMETER.

Note: 0x97 is a software interrupt which I want my driver to process for
learning purposes. Every resources I have got so far talks about hardware
interrupts. Does that mean drivers can't be used for software interrupt
handling? (just a question - could be a stupid one)

I don't know what I am doing wrong. Please HELP HELP HELP!!!

Below is the source code

NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING
RegistryPath)
{
NTSTATUS ntstatus;
CHAR buffer[BUFFER_SIZE];
UNICODE_STRING driverNameString, linkStringForUserPrograms;
PDEVICE_OBJECT pDeviceObject;
NTSTATUS status;
PKDVR_DEVICE_EXTENSION pDriverExtension = NULL;
int nSizeOfDriverExt = sizeof(KDVR_DEVICE_EXTENSION);

//Interrupt specific
ULONG vector = 0x97; //Hooking software interrupt which will be fired by
User mode application. Testing how interrupt works
KIRQL irql = 3; // DIRQL 3..26 (interrupt level)
KINTERRUPT_MODE mode = Latched; // latching mode
KAFFINITY affinity = 0x0001; // 1st processor affinity
BOOLEAN irqshare = FALSE; // shared interrupt - none

//Driver unload Routine
pDriverObject->DriverUnload = DriverUnload;

RtlStringCbPrintfA(buffer, sizeof(buffer), "Beginning to create device\r\n");
DoTraceEx(buffer);
//name of the device
RtlInitUnicodeString(&driverNameString, L"\\Device\\MGDeviceDriver0");

//creating new device
status = IoCreateDevice ( pDriverObject, nSizeOfDriverExt,
&driverNameString, FILE_DEVICE_UNKNOWN, 0,
TRUE, &pDeviceObject );
if (!NT_SUCCESS( status ))
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to create device\r\n");
DoTraceEx(buffer);
return status;
}

pDriverExtension = pDeviceObject->DeviceExtension;

//creating new device
pDriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchRoutine;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchRoutine;

status = IoConnectInterrupt(&pDriverExtension->InterruptObject,
(PKSERVICE_ROUTINE) OnInterrupt, (PVOID) pDriverExtension, NULL,
vector, irql, irql, mode, irqshare, affinity, FALSE);
if (!NT_SUCCESS( status ))
{
if(status == STATUS_INVALID_PARAMETER)
{
//This is getting failed (Don't know why?) NEED YOUR HELP HERE
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect interrupt
due to invalid parameter %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
else
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect
interrupt...what's wrong don't know %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
}
return STATUS_SUCCESS;
}
Doron Holan [MSFT]
2010-06-15 20:01:31 UTC
Permalink
you can't do this. the interrupt value has to be a translated value that the
OS understands, not a random value you pass in

d

"Mohit Gupta" wrote in message news:76AA77EB-E9F6-4CA8-9CDE-***@microsoft.com...

Hi All,

I am trying to install an interrupt handler for 0x97 (hard coded for testing
purposes), but when I try to run IoConnectInterrupt it always return
STATUS_INVALID_PARAMETER.

Note: 0x97 is a software interrupt which I want my driver to process for
learning purposes. Every resources I have got so far talks about hardware
interrupts. Does that mean drivers can't be used for software interrupt
handling? (just a question - could be a stupid one)

I don't know what I am doing wrong. Please HELP HELP HELP!!!

Below is the source code

NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING
RegistryPath)
{
NTSTATUS ntstatus;
CHAR buffer[BUFFER_SIZE];
UNICODE_STRING driverNameString, linkStringForUserPrograms;
PDEVICE_OBJECT pDeviceObject;
NTSTATUS status;
PKDVR_DEVICE_EXTENSION pDriverExtension = NULL;
int nSizeOfDriverExt = sizeof(KDVR_DEVICE_EXTENSION);

//Interrupt specific
ULONG vector = 0x97; //Hooking software interrupt which will be fired by
User mode application. Testing how interrupt works
KIRQL irql = 3; // DIRQL 3..26 (interrupt level)
KINTERRUPT_MODE mode = Latched; // latching mode
KAFFINITY affinity = 0x0001; // 1st processor affinity
BOOLEAN irqshare = FALSE; // shared interrupt - none

//Driver unload Routine
pDriverObject->DriverUnload = DriverUnload;

RtlStringCbPrintfA(buffer, sizeof(buffer), "Beginning to create
device\r\n");
DoTraceEx(buffer);
//name of the device
RtlInitUnicodeString(&driverNameString, L"\\Device\\MGDeviceDriver0");

//creating new device
status = IoCreateDevice ( pDriverObject, nSizeOfDriverExt,
&driverNameString, FILE_DEVICE_UNKNOWN, 0,
TRUE, &pDeviceObject );
if (!NT_SUCCESS( status ))
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to create device\r\n");
DoTraceEx(buffer);
return status;
}

pDriverExtension = pDeviceObject->DeviceExtension;

//creating new device
pDriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchRoutine;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchRoutine;

status = IoConnectInterrupt(&pDriverExtension->InterruptObject,
(PKSERVICE_ROUTINE) OnInterrupt, (PVOID) pDriverExtension, NULL,
vector, irql, irql, mode, irqshare, affinity, FALSE);
if (!NT_SUCCESS( status ))
{
if(status == STATUS_INVALID_PARAMETER)
{
//This is getting failed (Don't know why?) NEED YOUR HELP HERE
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect interrupt
due to invalid parameter %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
else
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect
interrupt...what's wrong don't know %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
}
return STATUS_SUCCESS;
}
Mohit Gupta
2010-06-16 00:46:37 UTC
Permalink
Then how do I connect interrupt at vector 0x97 which happens to be software
interrupt? Is there any other way to hook interrupts with our own provided
interrupt function?
Post by Doron Holan [MSFT]
you can't do this. the interrupt value has to be a translated value that the
OS understands, not a random value you pass in
d
Hi All,
I am trying to install an interrupt handler for 0x97 (hard coded for testing
purposes), but when I try to run IoConnectInterrupt it always return
STATUS_INVALID_PARAMETER.
Note: 0x97 is a software interrupt which I want my driver to process for
learning purposes. Every resources I have got so far talks about hardware
interrupts. Does that mean drivers can't be used for software interrupt
handling? (just a question - could be a stupid one)
I don't know what I am doing wrong. Please HELP HELP HELP!!!
Below is the source code
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING
RegistryPath)
{
NTSTATUS ntstatus;
CHAR buffer[BUFFER_SIZE];
UNICODE_STRING driverNameString, linkStringForUserPrograms;
PDEVICE_OBJECT pDeviceObject;
NTSTATUS status;
PKDVR_DEVICE_EXTENSION pDriverExtension = NULL;
int nSizeOfDriverExt = sizeof(KDVR_DEVICE_EXTENSION);
//Interrupt specific
ULONG vector = 0x97; //Hooking software interrupt which will be fired by
User mode application. Testing how interrupt works
KIRQL irql = 3; // DIRQL 3..26 (interrupt level)
KINTERRUPT_MODE mode = Latched; // latching mode
KAFFINITY affinity = 0x0001; // 1st processor affinity
BOOLEAN irqshare = FALSE; // shared interrupt - none
//Driver unload Routine
pDriverObject->DriverUnload = DriverUnload;
RtlStringCbPrintfA(buffer, sizeof(buffer), "Beginning to create device\r\n");
DoTraceEx(buffer);
//name of the device
RtlInitUnicodeString(&driverNameString, L"\\Device\\MGDeviceDriver0");
//creating new device
status = IoCreateDevice ( pDriverObject, nSizeOfDriverExt,
&driverNameString, FILE_DEVICE_UNKNOWN, 0,
TRUE, &pDeviceObject );
if (!NT_SUCCESS( status ))
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to create device\r\n");
DoTraceEx(buffer);
return status;
}
pDriverExtension = pDeviceObject->DeviceExtension;
//creating new device
pDriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchRoutine;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchRoutine;
status = IoConnectInterrupt(&pDriverExtension->InterruptObject,
(PKSERVICE_ROUTINE) OnInterrupt, (PVOID) pDriverExtension, NULL,
vector, irql, irql, mode, irqshare, affinity, FALSE);
if (!NT_SUCCESS( status ))
{
if(status == STATUS_INVALID_PARAMETER)
{
//This is getting failed (Don't know why?) NEED YOUR HELP HERE
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect interrupt
due to invalid parameter %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
else
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect
interrupt...what's wrong don't know %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
}
return STATUS_SUCCESS;
}
.
Pavel A.
2010-06-18 01:43:53 UTC
Permalink
You need to tweak IDT entries manually, which is harder than you expect.
Windows is not Linux, new system calls cannot be added in this way. At
least, not easily.
--pa
Post by Mohit Gupta
Then how do I connect interrupt at vector 0x97 which happens to be software
interrupt? Is there any other way to hook interrupts with our own provided
interrupt function?
Post by Doron Holan [MSFT]
you can't do this. the interrupt value has to be a translated value that the
OS understands, not a random value you pass in
d
Hi All,
I am trying to install an interrupt handler for 0x97 (hard coded for testing
purposes), but when I try to run IoConnectInterrupt it always return
STATUS_INVALID_PARAMETER.
Note: 0x97 is a software interrupt which I want my driver to process for
learning purposes. Every resources I have got so far talks about hardware
interrupts. Does that mean drivers can't be used for software interrupt
handling? (just a question - could be a stupid one)
I don't know what I am doing wrong. Please HELP HELP HELP!!!
Below is the source code
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING
RegistryPath)
{
NTSTATUS ntstatus;
CHAR buffer[BUFFER_SIZE];
UNICODE_STRING driverNameString, linkStringForUserPrograms;
PDEVICE_OBJECT pDeviceObject;
NTSTATUS status;
PKDVR_DEVICE_EXTENSION pDriverExtension = NULL;
int nSizeOfDriverExt = sizeof(KDVR_DEVICE_EXTENSION);
//Interrupt specific
ULONG vector = 0x97; //Hooking software interrupt which will be fired by
User mode application. Testing how interrupt works
KIRQL irql = 3; // DIRQL 3..26 (interrupt level)
KINTERRUPT_MODE mode = Latched; // latching mode
KAFFINITY affinity = 0x0001; // 1st processor affinity
BOOLEAN irqshare = FALSE; // shared interrupt - none
//Driver unload Routine
pDriverObject->DriverUnload = DriverUnload;
RtlStringCbPrintfA(buffer, sizeof(buffer), "Beginning to create device\r\n");
DoTraceEx(buffer);
//name of the device
RtlInitUnicodeString(&driverNameString, L"\\Device\\MGDeviceDriver0");
//creating new device
status = IoCreateDevice ( pDriverObject, nSizeOfDriverExt,
&driverNameString, FILE_DEVICE_UNKNOWN, 0,
TRUE, &pDeviceObject );
if (!NT_SUCCESS( status ))
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to create
device\r\n");
DoTraceEx(buffer);
return status;
}
pDriverExtension = pDeviceObject->DeviceExtension;
//creating new device
pDriverObject->MajorFunction[IRP_MJ_CREATE] = DispatchRoutine;
pDriverObject->MajorFunction[IRP_MJ_CLOSE] = DispatchRoutine;
status = IoConnectInterrupt(&pDriverExtension->InterruptObject,
(PKSERVICE_ROUTINE) OnInterrupt, (PVOID) pDriverExtension, NULL,
vector, irql, irql, mode, irqshare, affinity, FALSE);
if (!NT_SUCCESS( status ))
{
if(status == STATUS_INVALID_PARAMETER)
{
//This is getting failed (Don't know why?) NEED YOUR HELP HERE
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect interrupt
due to invalid parameter %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
else
{
RtlStringCbPrintfA(buffer, sizeof(buffer), "Failed to connect
interrupt...what's wrong don't know %d %#X\r\n", status, status);
DoTraceEx(buffer);
}
}
return STATUS_SUCCESS;
}
.
Loading...