--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainerBase.cpp Tue Aug 31 16:45:49 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainerBase.cpp Wed Sep 01 12:37:10 2010 +0100
@@ -49,44 +49,58 @@
-DObject* DMemSpyDriverLogChanContainerBase::CheckedOpen(TMemSpyDriverContainerType aContainerType, DObject* aObject, TBool aQuick)
- {
- __ASSERT_CRITICAL;
- __ASSERT_DEBUG(aObject != NULL, MemSpyDriverUtils::Fault( __LINE__ ));
- const TObjectType expectedType = ObjectTypeFromMemSpyContainerType(aContainerType);
+
+
+
+DObject* DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer( TMemSpyDriverContainerType aContainerType, DObject* aSearchFor, TBool aQuick )
+ {
+ __ASSERT_DEBUG( aSearchFor != NULL, MemSpyDriverUtils::Fault( __LINE__ ) );
+ const TObjectType expectedType = ObjectTypeFromMemSpyContainerType( aContainerType );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - START - aSearchFor: 0x%08x, expectedType: %d", aSearchFor, expectedType ));
- // Quick mode means we just check container ids and we trust that the object will exist.
- // [TomS: not entirely convinced we can ever be certain of that]
- TInt err = KErrNotFound;
- if (aQuick)
+ DObject* ret = NULL;
+
+ // Quick mode means we just check container ids and we trust that the object
+ // will exist.
+ if ( aQuick )
{
- LOG("quick CheckedOpen of %08x", aObject);
- const TObjectType objectType = OSAdaption().DThread().GetObjectType(*aObject);
- if (objectType == expectedType)
+ const TObjectType objectType = OSAdaption().DThread().GetObjectType( *aSearchFor );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - aSearchFor.iContainerID: %d", objectType ) );
+ if ( objectType == expectedType )
{
- err = aObject->Open();
+ ret = aSearchFor;
}
}
- else
- {
- DObjectCon* container = Kern::Containers()[expectedType];
+ else
+ {
+ // Full check to see if the specified object is part of the container
+ DObjectCon* container = Kern::Containers()[ expectedType ];
container->Wait();
+ NKern::LockSystem();
+
const TInt count = container->Count();
- for (TInt i = 0; i < count; i++)
+ for(TInt i=0; i<count; i++)
{
- DObject* object = (*container)[i];
- if (object == aObject)
+ DObject* object = (*container)[ i ];
+
+ // Do the two match?
+ if ( object == aSearchFor )
{
- err = aObject->Open();
- break;
- }
- }
- container->Signal();
- }
+ TRACE( Kern::Printf(" found match: %O", object));
+
+ ret = object;
+ break;
+ }
+ }
- LOG("CheckedOpen(%d, 0x%08x, quick=%d) returned error %d", aContainerType, aObject, aQuick, err);
- return (err == KErrNone) ? aObject : NULL;
- }
+ NKern::UnlockSystem();
+ container->Signal();
+ }
+
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - END - ret: 0x%08x", ret ));
+ TRACE( Kern::Printf(" ") );
+ return ret;
+ }