Hello,

I coded a simple work item callback, but it crashes my computer, I
can't guess why. here's the code :

void WorkItemCallback( WorkItemStruct *work )
{
KdPrint(( "Hello !" ));

IoFreeWorkItem( work->item );
ExFreePool( work );

}

work = (WorkItemStruct *) ExAllocatePool( PagedPool,
sizeof(WorkItemStruct) );

if( work != NULL )
{
work->item = IoAllocateWorkItem( DeviceObject );
IoQueueWorkItem( work->item, (PIO_WORKITEM_ROUTINE)
WorkItemCallback,
DelayedWorkQueue, work );

}

And here's the bugcheck :

*** Fatal System Error: 0x0000007e
(0xC0000005,0x80550211,0xF7A5BC50,0xF7A5B94C)

What could cause this bug ?

Re: WorkItem causes a blue screen ? by Vinzenz

Vinzenz
Fri Jul 28 10:44:43 CDT 2006

eric.minso@gmail.com schrieb:
> Hello,
>
> I coded a simple work item callback, but it crashes my computer, I
> can't guess why. here's the code :
>
> void WorkItemCallback( WorkItemStruct *work )
> {
> KdPrint(( "Hello !" ));
>
> IoFreeWorkItem( work->item );
> ExFreePool( work );
>
> }
>
> work = (WorkItemStruct *) ExAllocatePool( PagedPool,
> sizeof(WorkItemStruct) );
>
> if( work != NULL )
> {
> work->item = IoAllocateWorkItem( DeviceObject );
> IoQueueWorkItem( work->item, (PIO_WORKITEM_ROUTINE)
> WorkItemCallback,
> DelayedWorkQueue, work );
>
> }
>
> And here's the bugcheck :
>
> *** Fatal System Error: 0x0000007e
> (0xC0000005,0x80550211,0xF7A5BC50,0xF7A5B94C)
>
> What could cause this bug ?
>

VOID
(*PIO_WORKITEM_ROUTINE) (
IN PDEVICE_OBJECT DeviceObject,
IN PVOID Context
);

This is the definition of the the PIO_WORKITEM_ROUTINE.
But your WorkItemCallback is absolutely different, so this causes a
crash wenn the Function is called.
--
Regards,
Vinzenz Feenstra

And now visit my WeBlog < http://blog.evilissimo.net > ;)

Re: WorkItem causes a blue screen ? by eric

eric
Fri Jul 28 11:19:52 CDT 2006



> VOID
> (*PIO_WORKITEM_ROUTINE) (
> IN PDEVICE_OBJECT DeviceObject,
> IN PVOID Context
> );
>
> This is the definition of the the PIO_WORKITEM_ROUTINE.
> But your WorkItemCallback is absolutely different, so this causes a
> crash wenn the Function is called.


You were right !

I'm stupid :)


Re: WorkItem causes a blue screen ? by Alexander

Alexander
Fri Jul 28 23:23:01 CDT 2006

Here is a rule:
NEVER EVER cast function pointers (nor use any other gratitious casts). If
the compiler complains, fix your code!

<eric.minso@gmail.com> wrote in message
news:1154103592.760897.281330@m73g2000cwd.googlegroups.com...
>
>
>> VOID
>> (*PIO_WORKITEM_ROUTINE) (
>> IN PDEVICE_OBJECT DeviceObject,
>> IN PVOID Context
>> );
>>
>> This is the definition of the the PIO_WORKITEM_ROUTINE.
>> But your WorkItemCallback is absolutely different, so this causes a
>> crash wenn the Function is called.
>
>
> You were right !
>
> I'm stupid :)
>