From: Mohit Gupta Mohit on
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;
}

From: Prakash Manannavar on
Hi Mohit,


As I know, whatever you have coded is not a MicroSoft's standard
DriverEntry(),


Please check the code for DriverEntry and AddDevice functions and if
possible give somemore details.
--
~~~~~
Prakash A Manannavar,
Bangalore/Bengaluru.

From: Mohit Gupta on
Respected Prakash

Given code example doesn't comply to WDF standards, though can say this is a
legacy driver which doesn't support PnP as of now. Since I am a beginner in
Window Driver Development, I am trying out few things before even trying WDF.

I am trying is to hook interrupt using this driver and unhook it when driver
is stopped.

I am starting driver using

1) net start MyDriver
2) net stop MyDriver

Can you or somebody please help as IoConnectInterrupt is returning
STATUS_FAILED_PARAMETER? What I am doing wrong

"Prakash Manannavar" wrote:

> Hi Mohit,
>
>
> As I know, whatever you have coded is not a MicroSoft's standard
> DriverEntry(),
>
>
> Please check the code for DriverEntry and AddDevice functions and if
> possible give somemore details.
> --
> ~~~~~
> Prakash A Manannavar,
> Bangalore/Bengaluru.
>
From: Scott Noone on
> Can you or somebody please help as IoConnectInterrupt is returning
> STATUS_FAILED_PARAMETER? What I am doing wrong

IoConnectInterrupt is meant to be called with parameters given to your
driver via the PnP Manager, HAL, and bus driver. It's not meant to be called
with parameters poofed up from thin air, so it's not surprising that it's
failing in this way.

In order to make this work properly you need to have a device with an
interrupt and a fully PnP compliant driver. For the driver, KMDF will save
you lots of pain and suffering.

-scott

--
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com

"Mohit Gupta" <MohitGupta(a)discussions.microsoft.com> wrote in message
news:1BFEA3A5-98FD-4B8A-87C0-EE08D78749BD(a)microsoft.com...
> Respected Prakash
>
> Given code example doesn't comply to WDF standards, though can say this is
> a
> legacy driver which doesn't support PnP as of now. Since I am a beginner
> in
> Window Driver Development, I am trying out few things before even trying
> WDF.
>
> I am trying is to hook interrupt using this driver and unhook it when
> driver
> is stopped.
>
> I am starting driver using
>
> 1) net start MyDriver
> 2) net stop MyDriver
>
> Can you or somebody please help as IoConnectInterrupt is returning
> STATUS_FAILED_PARAMETER? What I am doing wrong
>
> "Prakash Manannavar" wrote:
>
>> Hi Mohit,
>>
>>
>> As I know, whatever you have coded is not a MicroSoft's standard
>> DriverEntry(),
>>
>>
>> Please check the code for DriverEntry and AddDevice functions and if
>> possible give somemore details.
>> --
>> ~~~~~
>> Prakash A Manannavar,
>> Bangalore/Bengaluru.
>>
From: Mohit Gupta on
Then how do I hook software interrupts? What you are saying seems as if
IoConnectInterrupt can only be used for handling interrupts for PnP supported
hardware devices.

Is there any other way to hook function for software interrupt, for example,
at vector 0x97? One approach is to change IDT table directly, however, WIN-OS
doesn't support that and is strongly discouraged. Surely there must be
another way around. Please advise



"Scott Noone" wrote:

> > Can you or somebody please help as IoConnectInterrupt is returning
> > STATUS_FAILED_PARAMETER? What I am doing wrong
>
> IoConnectInterrupt is meant to be called with parameters given to your
> driver via the PnP Manager, HAL, and bus driver. It's not meant to be called
> with parameters poofed up from thin air, so it's not surprising that it's
> failing in this way.
>
> In order to make this work properly you need to have a device with an
> interrupt and a fully PnP compliant driver. For the driver, KMDF will save
> you lots of pain and suffering.
>
> -scott
>
> --
> Scott Noone
> Consulting Associate
> OSR Open Systems Resources, Inc.
> http://www.osronline.com
>
> "Mohit Gupta" <MohitGupta(a)discussions.microsoft.com> wrote in message
> news:1BFEA3A5-98FD-4B8A-87C0-EE08D78749BD(a)microsoft.com...
> > Respected Prakash
> >
> > Given code example doesn't comply to WDF standards, though can say this is
> > a
> > legacy driver which doesn't support PnP as of now. Since I am a beginner
> > in
> > Window Driver Development, I am trying out few things before even trying
> > WDF.
> >
> > I am trying is to hook interrupt using this driver and unhook it when
> > driver
> > is stopped.
> >
> > I am starting driver using
> >
> > 1) net start MyDriver
> > 2) net stop MyDriver
> >
> > Can you or somebody please help as IoConnectInterrupt is returning
> > STATUS_FAILED_PARAMETER? What I am doing wrong
> >
> > "Prakash Manannavar" wrote:
> >
> >> Hi Mohit,
> >>
> >>
> >> As I know, whatever you have coded is not a MicroSoft's standard
> >> DriverEntry(),
> >>
> >>
> >> Please check the code for DriverEntry and AddDevice functions and if
> >> possible give somemore details.
> >> --
> >> ~~~~~
> >> Prakash A Manannavar,
> >> Bangalore/Bengaluru.
> >>