Re: Is it windows bug ? Callback routine get wrong argument ?!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Apparently you use an explicit cast to shut up the compiler that warned you
about the type mismatch.

(PIO_WORKITEM_ROUTINE) USBCAMD_ProcessStillReadWorkItem

It must be
VOID
USBCAMD_ProcessStillReadWorkItem (
IN PDEVICE_OBJECT DeviceObject,
IN PVOID Context
);
--
http://www.cristalink.com


"SL Chang" <slchang@xxxxxxxxx> wrote in message
news:OXr$cuYkFHA.3568@xxxxxxxxxxxxxxxxxxxxxxx
> Driver is base on USBCAMD code inside DDK sample.
> Before I replace ExXxxxWorkItem with IoXxxxWorkItem, the address is match
> and data is correct too.
> I don't know why.
>
> ////////////////////////////////////////////////////////////////////////////
> /////////////////////
> typedef struct _USBCAMD_WORK_ITEM {
> PIO_WORKITEM WorkItem;
> PUSBCAMD_READ_EXTENSION Request;
> PUSBCAMD_CHANNEL_EXTENSION ChannelExtension;
> ULONG StreamNumber;
> BOOLEAN CopyFrameToStillPin;
> NTSTATUS status;
> PHW_STREAM_REQUEST_BLOCK Srb;
> } USBCAMD_WORK_ITEM, *PUSBCAMD_WORK_ITEM;
> ////////////////////////////////////////////////////////////////////////////
> /////////////////////
> ROUTINE_A(...) {
> PUSBCAMD_WORK_ITEM usbWorkItem;
> usbWorkItem = (PUSBCAMD_WORK_ITEM) USBCAMD_ExAllocatePool(NonPagedPool,
> sizeof(USBCAMD_WORK_ITEM));
> if (usbWorkItem) {
> usbWorkItem->WorkItem = IoAllocateWorkItem(
> ChannelExtension->DeviceExtension->SCDeviceObject);
> usbWorkItem->Request = NULL;
> usbWorkItem->ChannelExtension = ChannelExtension;
> usbWorkItem->status = ntStatus;
> DbgPrint("Address before callback routine = %x\n", usbWorkItem);
> if (usbWorkItem->WorkItem && !IsStop) {
> IoQueueWorkItem(usbWorkItem->WorkItem,
> (PIO_WORKITEM_ROUTINE)
> USBCAMD_ProcessStillReadWorkItem,
> DelayedWorkQueue,
> usbWorkItem);
> }
> else
> ExFreePool(usbWorkItem);
> }
> }
> }
> ////////////////////////////////////////////////////////////////////////////
> /////////////////////////////////////
> VOID USBCAMD_ProcessStillReadWorkITem(PVOID Context) {
> PUSBCAMD_WORK_ITEM usbWorkItem = (PUSBCAMD_WORK_ITEM) Context;
>
> //--------------------------------------------------------------------------
> ----
> // here get wrong structure context and address isn't match also.
> //--------------------------------------------------------------------------
> ----
> DbgPrint("Address inside callback routine = %x\n", Context);
>
> // do something ...
>
> IoFreeWorkItem(usbWorkItem->WorkItem);
> }
>
>


.



Relevant Pages

  • Re: WaitForSingleObject and Thread
    ... Putting the cast in such context is *ALWAYS* a coding error. ... why did you manually expand LPVOID to void*? ... MainProc will block until the ReadThread is finished. ... reasonably certain that if all you do is launch a single thread and wait for it ...
    (microsoft.public.vc.mfc)
  • [PATH -mm -v2] Fix a race condtion of oops_in_progress
    ... extern int cause_of_death; ... void machine_restart ... context or a bust_spinlocks cleared the way for us. ...
    (Linux-Kernel)
  • Re: Warning to newbies
    ... alone "bogus" science. ... In that context, I believe the minotaurs should abandon C ... I particularly like "assign a pointer to void", ... NaN or either infinity is a trap representation. ...
    (comp.lang.c)
  • Generic Repository
    ... I am trying to create a generic repository over EF4. ... void Attach; ... Int64 Count(Func<T, Boolean> predicate); ... private ObjectContext _context; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [PATCH 6/6] AIO wait page and AIO lock page
    ... return status (which may be non-zero when the wait queue ... queue parameter is the running task's default io wait context. ... * Get a lock on the page, assuming we need to sleep to get it. ... -extern void FASTCALL); ...
    (Linux-Kernel)