Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > IoConnectInterrupt - STATUS_INVALID_PARAMETER

Reply
Thread Tools Display Modes

IoConnectInterrupt - STATUS_INVALID_PARAMETER

 
 
Mohit Gupta
Guest
Posts: n/a

 
      06-15-2010
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;
}

 
Reply With Quote
 
 
 
 
Prakash Manannavar
Guest
Posts: n/a

 
      06-15-2010
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.

 
Reply With Quote
 
Mohit Gupta
Guest
Posts: n/a

 
      06-15-2010
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.
>

 
Reply With Quote
 
Scott Noone
Guest
Posts: n/a

 
      06-15-2010
> 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" <> wrote in message
news:1BFEA3A5-98FD-4B8A-87C0-...
> 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.
>>

 
Reply With Quote
 
Mohit Gupta
Guest
Posts: n/a

 
      06-16-2010
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" <> wrote in message
> news:1BFEA3A5-98FD-4B8A-87C0-...
> > 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.
> >>

 
Reply With Quote
 
Tim Roberts
Guest
Posts: n/a

 
      06-16-2010
Mohit Gupta <> wrote:
>
>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.


That's correct. Windows does not support software interrupts. Just that
simple. There are supported methods for communicating between user-mode
and kernel-mode. Use them.
--
Tim Roberts,
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
Mohit Gupta
Guest
Posts: n/a

 
      06-16-2010
"Tim Roberts" wrote:

>
> That's correct. Windows does not support software interrupts. Just that
> simple. There are supported methods for communicating between user-mode
> and kernel-mode. Use them.


It's clearly documented that IDT consists of some OS specific interrupt
handlers, others for hardware interrupts (in total 15) and rest for software
interrupts.

"Windows does not support software interrupts." - Did you mean software
interrupt IDT entries are hooked to some dummy interrupts handlers which are
not used by windows at all?


> --
> Tim Roberts,
> Providenza & Boekelheide, Inc.
> .
>

 
Reply With Quote
 
Scott Noone
Guest
Posts: n/a

 
      06-16-2010
> It's clearly documented that IDT consists of some OS specific interrupt
> handlers, others for hardware interrupts (in total 15) and rest for
> software
> interrupts.


You're misunderstanding something. Even if you weren't, just because the
architecture supports something doesn't mean that Windows exposes it as a
general mechanism.

-scott

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


"Mohit Gupta" <> wrote in message
news:FF92A4C2-AF44-40CE-BBCF-...
> "Tim Roberts" wrote:
>
>>
>> That's correct. Windows does not support software interrupts. Just that
>> simple. There are supported methods for communicating between user-mode
>> and kernel-mode. Use them.

>
> It's clearly documented that IDT consists of some OS specific interrupt
> handlers, others for hardware interrupts (in total 15) and rest for
> software
> interrupts.
>
> "Windows does not support software interrupts." - Did you mean software
> interrupt IDT entries are hooked to some dummy interrupts handlers which
> are
> not used by windows at all?
>
>
>> --
>> Tim Roberts,
>> Providenza & Boekelheide, Inc.
>> .
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59