BOOL
CConfigCache::Read(__in LPCTSTR lpszName,
__out PVOID lpValue,
__in DWORD dwSize,
__out_opt PDWORD dwRetSize /*= NULL */)
{
try
{
if (CanIAccessCache())
{
CScopeGuard<CMutex> guard(m_FunctionLock);
//
// ....... ignore some useless code
//
PCACHE_ITEM CacheItem = m_SharedMemory.find<CACHE_ITEM>(lpszName).first;
if (CacheItem)
{
if (dwSize >= CacheItem->CacheLength)
{
if (dwRetSize)
*dwRetSize = CacheItem->CacheLength;
if (lpValue && CacheItem->CacheLength && CacheItem->CacheValue)
{
CopyMemory(lpValue, CacheItem->CacheValue.get(), CacheItem->CacheLength);
return DecryptBuffer((LPBYTE)lpValue, CacheItem->CacheLength);
}
else
{
return TRUE;
}
}
else if (dwRetSize)
{
*dwRetSize = CacheItem->CacheLength;
return TRUE;
}
else
{
return FALSE;
}
}
else
{
++m_ReadConfigCacheMissCount;
}
}
return FALSE;
}
catch (BOOSTIP::interprocess_exception &)
{
EXCEPTION_OUT("CConfigCache::Read interprocess_exception\n");
MakeCacheInvalid();
return FALSE;
}
catch (CConfigCacheBaseException &)
{
EXCEPTION_OUT("CConfigCache::Read CConfigCacheBaseException\n");
MakeCacheInvalid();
return FALSE;
}
}
Program random crash at :
PCACHE_ITEM CacheItem = m_SharedMemory.find<CACHE_ITEM>(lpszName).first;
I don't know why?