I get an KERN-EXEC 0 i.e. "Kernel cannot find an object in the object index for the current process or current thread" when I try to access a handle (in this case a logical channel) created in a DLL Open() function, in another DLL function Map() . The application thread exits with -13 (KErrDied) due to this.

When I print the handle of the driver (using Handle() inherited from RHandleBase), I get different values in RDevice::Open() and RDevice::Map(). It is obvious that the handle is lost/ invalid in the second case.

Is this an issue with the scope of the handle or is it a limitation of the DLL?


I've given a section of my code below. It is the call driver.Convert() in RDevice::Map() that throws the error.

Code snippet...

RDevice.cpp:

EXPORT_C
TInt
RDevice::Open (TInt aID, TAny * aArg)
{
...

if (status == KErrNone)
{
status = driver.Open (0) ;
if (status != KErrNone)
{
RDebug::Printf ("Open driver: %d", status) ;
}
}

...

}


EXPORT_C
TInt
RDevice::Map (TAny* Start, TUint32 Size,
TUint32 aFlag)
{
...

if (status == KErrNone)
{
status = driver.Convert(Start, Size) ;
if (status != KErrNone)
{
RDebug::Printf ("driver.Convert: %d", status) ;
}
}

...

}


RDevice.h:

class RDevice : public RBusLogicalChannel
{

...

private:
RDriver driver ;
....

} ;