--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainers.cpp Tue Aug 31 16:45:49 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainers.cpp Wed Sep 01 12:37:10 2010 +0100
@@ -146,6 +146,7 @@
DObjectCon* container = Kern::Containers()[type];
container->Wait();
+ NKern::LockSystem();
const TInt count = container->Count();
for(TInt i=0; i<count; i++)
@@ -157,7 +158,9 @@
}
}
+ NKern::UnlockSystem();
container->Signal();
+
NKern::ThreadLeaveCS();
}
else
@@ -211,30 +214,34 @@
// Iterate through each handle in the thread/process and add it to the temp handles container if
// the handle is of the correct type.
+ MemSpyObjectIx_Wait( handles );
- MemSpyObjectIx_HandleLookupLock();
- const TInt handleCount = handles->Count();
- MemSpyObjectIx_HandleLookupUnlock();
+ TInt handleCount = handles->Count();
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - %d handles in index...", handleCount ));
for( TInt handleIndex=0; handleIndex<handleCount; handleIndex++ )
{
// Get a handle from the container...
- MemSpyObjectIx_HandleLookupLock();
- if (handleIndex >= handles->Count()) break; // Count may have changed in the meantime
- DObject* objectToSearchFor = (*handles)[ handleIndex ];
- if (objectToSearchFor && objectToSearchFor->Open() != KErrNone) objectToSearchFor = NULL;
- MemSpyObjectIx_HandleLookupUnlock();
+ NKern::LockSystem();
+ DObject* objectToSearchFor = (*handles)[ handleIndex ];
+ NKern::UnlockSystem();
- if (objectToSearchFor && OSAdaption().DThread().GetObjectType(*objectToSearchFor) == ObjectTypeFromMemSpyContainerType(params.iContainer))
+ if ( objectToSearchFor != NULL )
{
- // Found a match in the specified container. Write the object's handle (aka the object address)
- // back to the client address space
- AddTempHandle( objectToSearchFor );
+ // Check to see if this object is of the specified type. We can use quick mode
+ // because we know the object is valid since it's registered as a handle of the
+ // thread/process.
+ DObject* matchResult = CheckIfObjectIsInContainer( params.iContainer, objectToSearchFor, ETrue );
+ if ( matchResult )
+ {
+ // Found a match in the specified container. Write the object's handle (aka the object address)
+ // back to the client address space
+ AddTempHandle( matchResult );
+ }
}
- if (objectToSearchFor) objectToSearchFor->Close(NULL);
}
+ MemSpyObjectIx_Signal( handles );
NKern::ThreadLeaveCS();
}
@@ -300,21 +307,30 @@
// First, locate the specific DObject in question. Cast the handle, but don't use the object...
DObject* handleAsObject = (DObject*) params.iHandle;
- handleAsObject = CheckedOpen(params.iType, handleAsObject);
+ handleAsObject = CheckIfObjectIsInContainer( params.iType, handleAsObject );
if ( handleAsObject != NULL )
{
// We found the right object. First get generic info.
handleAsObject->FullName( params.iName );
handleAsObject->Name( params.iNameDetail );
- // Using threadAddaption to fetch generic info.
- // Implementations of following get functions are actually in DMemSpyDriverOSAdaptionDObject
- // so it does not matter what adaption to use for generic info.
- DMemSpyDriverOSAdaptionDThread& threadAddaption = OSAdaption().DThread();
- params.iAccessCount = threadAddaption.GetAccessCount( *handleAsObject );
- params.iUniqueID = threadAddaption.GetUniqueID( *handleAsObject );
- params.iProtection = threadAddaption.GetProtection( *handleAsObject );
- params.iAddressOfKernelOwner = threadAddaption.GetAddressOfKernelOwner( *handleAsObject );
+ NKern::LockSystem();
+ r = handleAsObject->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ // Using threadAddaption to fetch generic info.
+ // Implementations of following get functions are actually in DMemSpyDriverOSAdaptionDObject
+ // so it does not matter what adaption to use for generic info.
+ DMemSpyDriverOSAdaptionDThread& threadAddaption = OSAdaption().DThread();
+ params.iAccessCount = threadAddaption.GetAccessCount( *handleAsObject );
+ params.iUniqueID = threadAddaption.GetUniqueID( *handleAsObject );
+ params.iProtection = threadAddaption.GetProtection( *handleAsObject );
+ params.iAddressOfKernelOwner = threadAddaption.GetAddressOfKernelOwner( *handleAsObject );
+ //
+ handleAsObject->Close( NULL );
+ }
// Get type-specific info.
if ( params.iType == EMemSpyDriverContainerTypeThread )
@@ -322,49 +338,76 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeThread" ));
DThread* object = (DThread*) handleAsObject;
- DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iId = threadAdaption.GetId( *object );
- params.iPriority = threadAdaption.GetPriority( *object );
- params.iAddressOfOwningProcess = threadAdaption.GetAddressOfOwningProcess( *object );
- threadAdaption.GetNameOfOwningProcess( *object, params.iNameOfOwner );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread();
+ //
+ params.iId = threadAdaption.GetId( *object );
+ params.iPriority = threadAdaption.GetPriority( *object );
+ params.iAddressOfOwningProcess = threadAdaption.GetAddressOfOwningProcess( *object );
+ threadAdaption.GetNameOfOwningProcess( *object, params.iNameOfOwner );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeProcess )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeProcess" ));
DProcess* object = (DProcess*) handleAsObject;
- DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess();
- //
- params.iId = processAdaption.GetId( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iPriority = processAdaption.GetPriority( *object );
- params.iAddressOfOwningProcess = processAdaption.GetAddressOfOwningProcess( *object );
- params.iCreatorId = processAdaption.GetCreatorId( *object );
- params.iSecurityZone = processAdaption.GetSecurityZone( *object );
- params.iAttributes = processAdaption.GetAttributes( *object );
- params.iAddressOfDataBssStackChunk = processAdaption.GetAddressOfDataBssStackChunk( *object );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess();
+ //
+ params.iId = processAdaption.GetId( *object );
+ //
+ params.iPriority = processAdaption.GetPriority( *object );
+ params.iAddressOfOwningProcess = processAdaption.GetAddressOfOwningProcess( *object );
+ params.iCreatorId = processAdaption.GetCreatorId( *object );
+ params.iSecurityZone = processAdaption.GetSecurityZone( *object );
+ params.iAttributes = processAdaption.GetAttributes( *object );
+ params.iAddressOfDataBssStackChunk = processAdaption.GetAddressOfDataBssStackChunk( *object );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeChunk )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChunk" ));
DChunk* object = (DChunk*) handleAsObject;
- DMemSpyDriverOSAdaptionDChunk& ca = OSAdaption().DChunk();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iSize = ca.GetSize( *object );
- params.iId = ca.GetOwningProcessId( *object );
- params.iAddressOfOwningProcess = ca.GetAddressOfOwningProcess( *object );
- params.iMaxSize = ca.GetMaxSize( *object );
- params.iBottom = ca.GetBottom( *object );
- params.iTop = ca.GetTop( *object );
- params.iAttributes = ca.GetAttributes( *object );
- params.iStartPos = ca.GetStartPos( *object );
- params.iControllingOwner = ca.GetControllingOwnerId( *object );
- params.iRestrictions = ca.GetRestrictions( *object );
- params.iMapAttr = ca.GetMapAttr( *object );
- params.iChunkType = ca.GetType( *object );
- ca.GetNameOfOwningProcess( *object, params.iNameOfOwner );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDChunk& ca = OSAdaption().DChunk();
+ //
+ params.iSize = ca.GetSize( *object );
+ params.iId = ca.GetOwningProcessId( *object );
+ params.iAddressOfOwningProcess = ca.GetAddressOfOwningProcess( *object );
+ params.iMaxSize = ca.GetMaxSize( *object );
+ params.iBottom = ca.GetBottom( *object );
+ params.iTop = ca.GetTop( *object );
+ params.iAttributes = ca.GetAttributes( *object );
+ params.iStartPos = ca.GetStartPos( *object );
+ params.iControllingOwner = ca.GetControllingOwnerId( *object );
+ params.iRestrictions = ca.GetRestrictions( *object );
+ params.iMapAttr = ca.GetMapAttr( *object );
+ params.iChunkType = ca.GetType( *object );
+ ca.GetNameOfOwningProcess( *object, params.iNameOfOwner );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeLibrary )
{
@@ -373,19 +416,28 @@
Kern::AccessCode();
//
DLibrary* object = (DLibrary*) handleAsObject;
- DMemSpyDriverOSAdaptionDCodeSeg& csa = OSAdaption().DCodeSeg();
- DCodeSeg* codeSeg = csa.GetCodeSeg( *object );
- params.iAddressOfCodeSeg = (TUint8*)codeSeg;
- params.iMapCount = csa.GetMapCount( *object );
- params.iState = csa.GetState( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- if ( codeSeg )
+ if ( r == KErrNone )
{
- params.iSize = csa.GetSize( *codeSeg );
- }
- else
- {
- r = KErrNotFound;
+ DMemSpyDriverOSAdaptionDCodeSeg& csa = OSAdaption().DCodeSeg();
+ DCodeSeg* codeSeg = csa.GetCodeSeg( *object );
+ params.iAddressOfCodeSeg = (TUint8*)codeSeg;
+ params.iMapCount = csa.GetMapCount( *object );
+ params.iState = csa.GetState( *object );
+ //
+ if ( codeSeg )
+ {
+ params.iSize = csa.GetSize( *codeSeg );
+ }
+ else
+ {
+ r = KErrNotFound;
+ }
+ //
+ object->Close( NULL );
}
//
Kern::EndAccessCode();
@@ -395,21 +447,39 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSemaphore" ));
DSemaphore* object = (DSemaphore*) handleAsObject;
- DMemSpyDriverOSAdaptionDSemaphore& sa = OSAdaption().DSemaphore();
- params.iCount = sa.GetCount( *object );
- params.iResetting = sa.GetResetting( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDSemaphore& sa = OSAdaption().DSemaphore();
+ params.iCount = sa.GetCount( *object );
+ params.iResetting = sa.GetResetting( *object );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeMutex )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeMutex" ));
DMutex* object = (DMutex*) handleAsObject;
- DMemSpyDriverOSAdaptionDMutex& ma = OSAdaption().DMutex();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iCount = ma.GetHoldCount( *object );
- params.iWaitCount = ma.GetWaitCount( *object );
- params.iResetting = ma.GetResetting( *object );
- params.iOrder = ma.GetOrder( *object );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDMutex& ma = OSAdaption().DMutex();
+ //
+ params.iCount = ma.GetHoldCount( *object );
+ params.iWaitCount = ma.GetWaitCount( *object );
+ params.iResetting = ma.GetResetting( *object );
+ params.iOrder = ma.GetOrder( *object );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeTimer )
{
@@ -417,62 +487,98 @@
// Get timer properties
DTimer* object = (DTimer*) handleAsObject;
- DMemSpyDriverOSAdaptionDTimer& ta = OSAdaption().DTimer();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iTimerType = MapToMemSpyTimerType( ta.GetType( *object ) );
- params.iTimerState = MapToMemSpyTimerState( ta.GetState( *object ) );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDTimer& ta = OSAdaption().DTimer();
+ //
+ params.iTimerType = MapToMemSpyTimerType( ta.GetType( *object ) );
+ params.iTimerState = MapToMemSpyTimerState( ta.GetState( *object ) );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeServer )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeServer" ));
DServer* object = (DServer*) handleAsObject;
- DMemSpyDriverOSAdaptionDServer& sa = OSAdaption().DServer();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
//
- params.iCount = sa.GetSessionCount( *object );
- params.iId = sa.GetOwningThreadId( *object );
- params.iSessionType = sa.GetSessionType( *object );
- params.iAddressOfOwningThread = sa.GetAddressOfOwningThread( *object );
- sa.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDServer& sa = OSAdaption().DServer();
+ //
+ params.iCount = sa.GetSessionCount( *object );
+ params.iId = sa.GetOwningThreadId( *object );
+ params.iSessionType = sa.GetSessionType( *object );
+ params.iAddressOfOwningThread = sa.GetAddressOfOwningThread( *object );
+ sa.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeSession )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSession" ));
DSession* object = (DSession*) handleAsObject;
- DMemSpyDriverOSAdaptionDServer& serverAdaption = OSAdaption().DServer();
- DMemSpyDriverOSAdaptionDSession& sessionAdaption = OSAdaption().DSession();
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - open error: %d", r ));
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDServer& serverAdaption = OSAdaption().DServer();
+ DMemSpyDriverOSAdaptionDSession& sessionAdaption = OSAdaption().DSession();
- params.iName.Zero();
+ params.iName.Zero();
- TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting session type..." ));
- params.iSessionType = sessionAdaption.GetSessionType( *object );
- params.iAddressOfServer = sessionAdaption.GetAddressOfServer( *object );
- params.iTotalAccessCount = sessionAdaption.GetTotalAccessCount( *object );
- params.iSvrSessionType = sessionAdaption.GetSessionType( *object );
- params.iMsgCount = sessionAdaption.GetMsgCount( *object );
- params.iMsgLimit = sessionAdaption.GetMsgLimit( *object );
-
- // Its more useful in this instance, if the name object
- // points to the server which the session is connected to
- // (rather than displaying a process-local name).
- DServer* server = (DServer*)CheckedOpen(EMemSpyDriverContainerTypeServer, sessionAdaption.GetServer( *object ));
- TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting full name, server: 0x%08x", server ));
- //
- if ( server )
- {
- server->FullName( params.iName );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting session type..." ));
+ params.iSessionType = sessionAdaption.GetSessionType( *object );
+ params.iAddressOfServer = sessionAdaption.GetAddressOfServer( *object );
+ params.iTotalAccessCount = sessionAdaption.GetTotalAccessCount( *object );
+ params.iSvrSessionType = sessionAdaption.GetSessionType( *object );
+ params.iMsgCount = sessionAdaption.GetMsgCount( *object );
+ params.iMsgLimit = sessionAdaption.GetMsgLimit( *object );
+
+ // Its more useful in this instance, if the name object
+ // points to the server which the session is connected to
+ // (rather than displaying a process-local name).
+ DServer* server = sessionAdaption.GetServer( *object );
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting full name, server: 0x%08x", server ));
+ //
+ if ( server )
+ {
+ NKern::LockSystem();
+ r = server->Open();
+ NKern::UnlockSystem();
- // Continue as normal for other items
- TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - server: 0x%08x, server->iOwningThread: 0x%08x", server, server->iOwningThread ));
- DThread* owningThread = serverAdaption.GetOwningThread( *server );
- if ( owningThread )
- {
- TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting server thread id..." ));
- params.iId = serverAdaption.GetOwningThreadId( *server );
+ if ( r == KErrNone )
+ {
+ server->FullName( params.iName );
+
+ // Continue as normal for other items
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - server: 0x%08x, server->iOwningThread: 0x%08x", server, server->iOwningThread ));
+ DThread* owningThread = serverAdaption.GetOwningThread( *server );
+ if ( owningThread )
+ {
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting server thread id..." ));
+ params.iId = serverAdaption.GetOwningThreadId( *server );
+ }
+
+ server->Close( NULL );
+ }
}
- server->Close(NULL);
+ TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - closing session object..." ));
+ object->Close( NULL );
}
}
else if ( params.iType == EMemSpyDriverContainerTypeLogicalDevice )
@@ -480,21 +586,39 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeLogicalDevice" ));
DLogicalDevice* object = (DLogicalDevice*) handleAsObject;
- DMemSpyDriverOSAdaptionDLogicalDevice& lda = OSAdaption().DLogicalDevice();
- params.iOpenChannels = lda.GetOpenChannels( *object );
- params.iVersion = lda.GetVersion( *object );
- params.iParseMask = lda.GetParseMask( *object );
- params.iUnitsMask = lda.GetUnitsMask( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDLogicalDevice& lda = OSAdaption().DLogicalDevice();
+ params.iOpenChannels = lda.GetOpenChannels( *object );
+ params.iVersion = lda.GetVersion( *object );
+ params.iParseMask = lda.GetParseMask( *object );
+ params.iUnitsMask = lda.GetUnitsMask( *object );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypePhysicalDevice )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypePhysicalDevice" ));
DPhysicalDevice* object = (DPhysicalDevice*) handleAsObject;
- DMemSpyDriverOSAdaptionDPhysicalDevice& pda = OSAdaption().DPhysicalDevice();
- params.iVersion = pda.GetVersion( *object );
- params.iUnitsMask = pda.GetUnitsMask( *object );
- params.iAddressOfCodeSeg = pda.GetAddressOfCodeSeg( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDPhysicalDevice& pda = OSAdaption().DPhysicalDevice();
+ params.iVersion = pda.GetVersion( *object );
+ params.iUnitsMask = pda.GetUnitsMask( *object );
+ params.iAddressOfCodeSeg = pda.GetAddressOfCodeSeg( *object );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeLogicalChannel )
{
@@ -505,19 +629,37 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChangeNotifier" ));
DChangeNotifier* object = (DChangeNotifier*) handleAsObject;
- DMemSpyDriverOSAdaptionDChangeNotifier& cna = OSAdaption().DChangeNotifier();
- params.iChanges = cna.GetChanges( *object );
- params.iAddressOfOwningThread = cna.GetAddressOfOwningThread( *object );
- cna.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDChangeNotifier& cna = OSAdaption().DChangeNotifier();
+ params.iChanges = cna.GetChanges( *object );
+ params.iAddressOfOwningThread = cna.GetAddressOfOwningThread( *object );
+ cna.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeUndertaker )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeUndertaker" ));
DUndertaker* object = (DUndertaker*) handleAsObject;
- DMemSpyDriverOSAdaptionDUndertaker& uta = OSAdaption().DUndertaker();
- params.iAddressOfOwningThread = uta.GetAddressOfOwningThread( *object );
- uta.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDUndertaker& uta = OSAdaption().DUndertaker();
+ params.iAddressOfOwningThread = uta.GetAddressOfOwningThread( *object );
+ uta.GetNameOfOwningThread( *object, params.iNameOfOwner );
+ //
+ object->Close( NULL );
+ }
}
else if ( params.iType == EMemSpyDriverContainerTypeMsgQueue )
{
@@ -532,18 +674,26 @@
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeCondVar" ));
DCondVar* object = (DCondVar*) handleAsObject;
- DMemSpyDriverOSAdaptionDCondVar& cva = OSAdaption().DCondVar();
- params.iResetting = cva.GetResetting( *object );
- params.iAddressOfOwningThread = cva.GetAddressOfMutex( *object );
- cva.GetNameOfMutex( *object, params.iNameOfOwner );
- params.iWaitCount = cva.GetWaitCount( *object );
+ NKern::LockSystem();
+ r = object->Open();
+ NKern::UnlockSystem();
+ //
+ if ( r == KErrNone )
+ {
+ DMemSpyDriverOSAdaptionDCondVar& cva = OSAdaption().DCondVar();
+ params.iResetting = cva.GetResetting( *object );
+ params.iAddressOfOwningThread = cva.GetAddressOfMutex( *object );
+ cva.GetNameOfMutex( *object, params.iNameOfOwner );
+ params.iWaitCount = cva.GetWaitCount( *object );
+ //
+ object->Close( NULL );
+ }
}
else
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - KErrNotSupported" ));
r = KErrNotSupported;
}
- handleAsObject->Close(NULL);
}
else
{
@@ -731,12 +881,13 @@
NKern::ThreadEnterCS();
// First, locate the specific DObject in question. Cast the handle, but don't use the object...
- DObject* object = CheckedOpen(EMemSpyDriverContainerTypePropertyRef, aHandle);
+ // NB: This claims the system lock
+ DObject* object = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypePropertyRef, aHandle );
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - handle search returned: 0x%08x", object ));
if ( object != NULL )
{
- NKern::LockSystem(); // Keep this, the DPropertyRef APIs use it -TomS
+ NKern::LockSystem();
DMemSpyDriverOSAdaptionDPropertyRef& pra = OSAdaption().DPropertyRef();
const TBool isReady = pra.GetIsReady( *object );
@@ -762,7 +913,6 @@
}
NKern::UnlockSystem();
- object->Close(NULL);
}
NKern::ThreadLeaveCS();
@@ -789,7 +939,7 @@
NKern::ThreadEnterCS();
DObject* condVarHandle = (DObject*) params.iCondVarHandle;
- condVarHandle = CheckedOpen(EMemSpyDriverContainerTypeCondVar, condVarHandle);
+ condVarHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeCondVar, condVarHandle );
if ( condVarHandle == NULL )
{
Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - condVar not found");
@@ -799,9 +949,9 @@
ResetTempHandles();
- DCondVar* condVar = (DCondVar*) condVarHandle;
+ DCondVar* condVar = (DCondVar*) params.iCondVarHandle;;
- NKern::LockSystem(); // Keep this, needed for iterating suspended queue -TomS
+ NKern::LockSystem();
// Iterate through suspended threads, writing back thread pointer (handle)
// to client
@@ -853,7 +1003,6 @@
}
}
- condVarHandle->Close(NULL);
NKern::ThreadLeaveCS();
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - r: %d", r));
@@ -877,7 +1026,7 @@
NKern::ThreadEnterCS();
DObject* threadHandle = (DObject*) aThreadHandle;
- threadHandle = CheckedOpen(EMemSpyDriverContainerTypeThread, threadHandle);
+ threadHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeThread, threadHandle );
if ( threadHandle == NULL )
{
Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - thread not found");
@@ -894,7 +1043,6 @@
r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) );
}
- threadHandle->Close(NULL);
NKern::ThreadLeaveCS();
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - r: %d", r));
@@ -958,13 +1106,17 @@
if ( handles != NULL )
{
- TBool found = handles->Find( aHandleToLookFor );
- if (found)
+ MemSpyObjectIx_Wait( handles );
+ //
+ TInt searchResult = handles->At( aHandleToLookFor );
+ if ( searchResult != KErrNotFound )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - found handle match in [%O]", thread ));
aStream.WriteUint32( (TUint32) thread );
++matches;
}
+ //
+ MemSpyObjectIx_Signal( handles );
}
}
@@ -999,13 +1151,17 @@
if ( handles != NULL )
{
- TBool found = handles->Find( aHandleToLookFor );
- if ( found )
+ MemSpyObjectIx_Wait( handles );
+ //
+ TInt searchResult = handles->At( aHandleToLookFor );
+ if ( searchResult != KErrNotFound )
{
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - found handle match in [%O]", process ));
aStream.WriteUint32( (TUint32) process );
++matches;
}
+ //
+ MemSpyObjectIx_Signal( handles );
}
}