Hi,
I’m facing a surprising problem: my NDIS driver failed to load when built in the free build environment but there is no problem when built in the checked build environment.
The error is the following:
#I163 Device not started: Device has problem: 0x27: CM_PROB_DRIVER_FAILED_LOAD.
After many tries, I’ve found 2 lines of code:
IndicateWorkItemContext *iwic = MEMALLOC_S(context->handles.adapter, IndicateWorkItemContext);
if (iwic != NULL)
{
iwic->item = IoAllocateWorkItem (pdo); // FAILED
if (iwic->item != NULL)
{
/* setup the context and queue allocated work item */
iwic->adapter = context->handles.adapter;
iwic->lock = &context->indicate.lock;
iwic->packet = packet;
DBGPRINT(DL_LOG8, " queueing work item %p, context %p", iwic->item, iwic);
IoQueueWorkItem (iwic->item, indicateWorkItemRoutine, DelayedWorkQueue, iwic); // FAILED
DBGFRETP(NDIS_STATUS, NDIS_STATUS_PENDING);
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate work item");
MEMFREE_S(iwic);
}
}
else
{
/* error */
DBGPRINT(DL_ERROR, " could not allocate memory for work item context");
DBGFRETP(NDIS_STATUS, NDIS_STATUS_RESOURCES);
}
If these 2 lines (marked with FAILED) are present in the free build, the driver can’t load. If they are not compiled in the free build, the driver loads without problem.
In the checked build, the driver loads with these two lines compiled.
Note that these lines are part of a function that is *NOT* called (I’ve suppressed as much code as possible, including the function calling this function with those lines).
It’s just their presence, not their execution, that is causing the problem.
I’ve tried to disable compiler optimisation in the free build (by setting MSC_OPTIMIZATION value to /Od /Oi in the sources file) without success.
Any idea ?
Thank you,
Arnaud