#include #include #include #include #include #include #include #include #include #ifndef POLARITY #define POLARITY #endif #ifndef RELEASE_ME #define RELEASE_ME #endif #ifndef DELETE_ME #define DELETE_ME #endif #ifndef INTERNAL #define INTERNAL #endif #include #include #include #include #include #include void DumpMemManager(ULONG_PTR pByte) { DEFINE_CPP_VAR( CTempMemoryManager, varCTempMemoryManager); CTempMemoryManager * pTmpAll = GET_CPP_VAR_PTR( CTempMemoryManager , varCTempMemoryManager ); ReadMemory(pByte,pTmpAll,sizeof(CTempMemoryManager),0); dprintf(" m_dwTotalUsed %08x\n",pTmpAll->m_dwTotalUsed); dprintf(" m_dwTotalAllocated %08x\n",pTmpAll->m_dwTotalAllocated); dprintf(" m_dwNumAllocations %08x\n",pTmpAll->m_dwNumAllocations); dprintf(" m_dwNumMisses %08x\n",pTmpAll->m_dwNumMisses); DEFINE_CPP_VAR( CFlexArray, varArr); CFlexArray * pArr = GET_CPP_VAR_PTR(CFlexArray,varArr); DWORD i; ReadMemory((ULONG_PTR)pTmpAll->m_pAllocations,pArr,sizeof(CFlexArray),0); CTempMemoryManager::CAllocation ** pAllocs = (CTempMemoryManager::CAllocation **)_alloca(pArr->m_nSize*sizeof(void*)); ReadMemory((ULONG_PTR)pArr->m_pArray,pAllocs,pArr->m_nSize*sizeof(void*),0); dprintf(" m_pArray %p %d\n",pArr->m_pArray,pArr->m_nSize); DWORD dwTotal = 0; for (i=0;im_nSize;i++) { dprintf(" CAllocation %d - %p\n",i,pAllocs[i]); DEFINE_CPP_VAR( CTempMemoryManager::CAllocation, varCAllocation ); CTempMemoryManager::CAllocation * pCAll = GET_CPP_VAR_PTR( CTempMemoryManager::CAllocation, varCAllocation ); ReadMemory((ULONG_PTR)pAllocs[i],pCAll,sizeof(CTempMemoryManager::CAllocation),0); dprintf(" m_dwAllocationSize %p\n",pCAll->m_dwAllocationSize); dprintf(" m_dwUsed %p\n",pCAll->m_dwUsed); dprintf(" m_dwFirstFree %p\n",pCAll->m_dwFirstFree); dwTotal += pCAll->m_dwAllocationSize; } dprintf(" TOT %p\n",dwTotal); } // // // dumps the CTempMemoryManagers in repdrvfs // ////////////////////////////////////////////////////// DECLARE_API(tmpall) { INIT_API(); ULONG_PTR pByte = GetExpression(args); if (pByte) { DumpMemManager(pByte); return; } pByte = GetExpression("repdrvfs!g_Manager"); dprintf("repdrvfs!g_Manager @ %p\n",pByte); if (pByte) { DumpMemManager(pByte); } } // // // this enum is copyed from btr.h // // enum { const_DefaultPageSize = 0x2000, const_CurrentVersion = 0x101 }; enum { PAGE_TYPE_IMPOSSIBLE = 0x0, // Not supposed to happen PAGE_TYPE_ACTIVE = 0xACCC, // Page is active with data PAGE_TYPE_DELETED = 0xBADD, // A deleted page on free list PAGE_TYPE_ADMIN = 0xADDD, // Page zero only // All pages OFFSET_PAGE_TYPE = 0, // True for all pages OFFSET_PAGE_ID = 1, // True for all pages OFFSET_NEXT_PAGE = 2, // True for all pages (Page continuator) // Admin Page (page zero) only OFFSET_LOGICAL_ROOT = 3, // Root of database }; #define PS_PAGE_SIZE (8192) #define MIN_ARRAY_KEYS (256) /* void DumpFile(HANDLE hFile,DWORD * pPage) { // read the AdminPage BOOL bRet; DWORD nRead; bRet = ReadFile(hFile,pPage,PS_PAGE_SIZE,&nRead,0); if (bRet && (PS_PAGE_SIZE == nRead)) { dprintf(" A %08x %08x %08x R %08x F %08x T %08x %08x %08x\n", pPage[OFFSET_PAGE_TYPE], pPage[OFFSET_PAGE_ID], pPage[OFFSET_NEXT_PAGE], pPage[OFFSET_LOGICAL_ROOT], pPage[OFFSET_FREE_LIST_ROOT], pPage[OFFSET_TOTAL_PAGES], pPage[OFFSET_PAGE_SIZE], pPage[OFFSET_IMPL_VERSION ]); } else { dprintf(" ReadFile %d\n",GetLastError()); } // read the other pages DWORD i; DWORD dwTotPages = pPage[OFFSET_TOTAL_PAGES]; for (i=1;idwNextAdminPage; dprintf(" ver %08x Next %08x Ent %08x\n",pAdmin->dwVersion,pAdmin->dwNextAdminPage,pAdmin->dwNumberEntriesOnPage); VarObjHeapFreeList * pFreeEntry = (VarObjHeapFreeList *)(pAdmin+1); dprintf(" dwPageId dwFreeSp dwCRC32\n"); if (pAdmin->dwNumberEntriesOnPage > (PS_PAGE_SIZE/sizeof(VarObjHeapFreeList))) { dprintf("Suspicious dwNumberEntriesOnPage %08x on page %x\n",pAdmin->dwNumberEntriesOnPage,AdminIndex); break; } for (i=0;idwNumberEntriesOnPage;i++) { dprintf(" %08x - %08x %08x %08X\n",i,pFreeEntry->dwPageId,pFreeEntry->dwFreeSpace,pFreeEntry->dwCRC32); pFreeEntry++; } } while(AdminIndex); } }; void Dump_Index(BYTE * pMap,BYTE * pBtr) { if (pMap && pBtr) { debugCPageFile a0(pMap); debugCPageFile a(a0.getEnd()); BYTE * pStart = pBtr + (a.pPagesA[0]*PS_PAGE_SIZE); debugBtrPage b(pStart); dprintf(" %08x %08x %08x %08x - %08X\n",b.dwPageType,b.dwPageId,b.dwNextPage,b.dwLogicalRoot,a.pPagesA[0]); //other pages DWORD i; for (i=0;im_lStageOffset,pWriteInst->m_bCommitted); dprintf(" m_dwLen %08x m_Location.m_nFileId %02x m_Location.m_lStartOffset %I64x\n",pWriteInst->m_dwLen,pWriteInst->m_Location.m_nFileId,pWriteInst->m_Location.m_lStartOffset); dprintf(" m_lZOrder %x m_bReuse %02x\n",pWriteInst->m_lZOrder,pWriteInst->m_bReuse); } return 0; } void DumpLongStage(ULONG_PTR Addr, // FileCache OOP pointer CFileCache * pFileCache, // inproc pointer ULONG_PTR Verbose) { // // CAbstractSource // dprintf(" + CLongFileStagingFile %p\n",Addr+FIELD_OFFSET(CFileCache,m_AbstractSource)); CAbstractFileSource * pAbsS = &pFileCache->m_AbstractSource; CLongFileStagingFile * pLongStage = &pAbsS->m_Stage; CLongFileStagingFile * pLongStag_OOP = (CLongFileStagingFile *)(Addr + FIELD_OFFSET(CFileCache,m_AbstractSource) + FIELD_OFFSET(CAbstractFileSource,m_Stage)); // CStageMgr members dprintf(" m_hFile %x m_hFlushFile %x\n",pLongStage->m_hFile,pLongStage->m_hFlushFile); //long m_lFirstFreeOffset; //CCritSec m_cs; dprintf(" m_qToWrite\n"); _List * pList_OOP = (_List *)((BYTE *)pLongStag_OOP + FIELD_OFFSET(CLongFileStagingFile,m_qToWrite)); PrintListCB(pList_OOP,CallBackWriteInst); dprintf(" m_stReplacedInstructions\n"); pList_OOP = (_List *)((BYTE *)pLongStag_OOP + FIELD_OFFSET(CLongFileStagingFile,m_stReplacedInstructions)); PrintListCB(pList_OOP,NULL); dprintf(" m_qTransaction\n"); pList_OOP = (_List *)((BYTE *)pLongStag_OOP + FIELD_OFFSET(CLongFileStagingFile,m_qTransaction)); PrintListCB(pList_OOP,CallBackWriteInst); dprintf(" TransIdx %I64d m_lTransactionStartOffset %x\n",pLongStage->m_nTransactionIndex,pLongStage->m_lTransactionStartOffset); //BYTE m_TransactionHash[16]; dprintf(" bInTransaction %d bFailedBefore %d lStatus %d\n",pLongStage->m_bInTransaction,pLongStage->m_bFailedBefore,pLongStage->m_lStatus); //pStage->m_lMaxFileSize; //pStage->m_lAbortTransactionFileSize; // bool m_bMustFail; // bool m_bNonEmptyTransaction; if (Verbose) { // the multimap has the compare function _Map * pMapStarts = (_Map *)((BYTE*)pLongStag_OOP + sizeof(void *) + FIELD_OFFSET(CLongFileStagingFile,m_mapStarts)); dprintf(" m_mapStarts\n"); dprintf(" std::multimap< { CFileLocation::m_nFileId, CFileLocation::m_lStartOffset }, CWriteFileInstruction* >\n"); PrintMapCB(pMapStarts,TRUE,NULL); _Map * pMapEnds = (_Map *)((BYTE*)pLongStag_OOP + sizeof(void *) + FIELD_OFFSET(CLongFileStagingFile,m_mapEnds)); dprintf(" m_mapEnds\n"); dprintf(" std::multimap< { CFileLocation::m_nFileId, CFileLocation::m_lStartOffset }, CWriteFileInstruction* >\n"); PrintMapCB(pMapEnds,TRUE,NULL); } } DECLARE_API( stage ) { INIT_API(); ULONG_PTR Addr = 0; ULONG_PTR Verbose = GetExpression(args); Addr = GetExpression("repdrvfs!g_Glob"); if (Addr) { Addr += FIELD_OFFSET(CGlobals,m_FileCache); } if (Addr) { DEFINE_CPP_VAR(CFileCache,varCFileCache); CFileCache * pFileCache = GET_CPP_VAR_PTR(CFileCache,varCFileCache); dprintf("CFileCache @ %p\n",Addr); if (ReadMemory((ULONG_PTR)Addr,pFileCache,sizeof(CFileCache),0)) { DumpLongStage(Addr,pFileCache,Verbose); } else { dprintf("RM %p\n",Addr); } } else { dprintf("unable to resolve repdrvfs!g_Glob\n"); } } */ /* DECLARE_API( filec_old ) { INIT_API(); ULONG_PTR Addr = 0; if (0 != strlen(args)) { Addr = GetExpression(args); } else { Addr = GetExpression("repdrvfs!g_Glob"); if (Addr) { Addr += FIELD_OFFSET(CGlobals,m_FileCache); } } if (Addr) { DEFINE_CPP_VAR(CFileCache,varCFileCache); CFileCache * pFileCache = GET_CPP_VAR_PTR(CFileCache,varCFileCache); dprintf("CFileCache @ %p\n",Addr); if (ReadMemory((ULONG_PTR)Addr,pFileCache,sizeof(CFileCache),0)) { dprintf(" m_lRef %d\n",pFileCache->m_lRef); DumpLongStage(Addr,pFileCache,TRUE); // // CObjectHeap // dprintf(" + CObjectHeap %p\n",Addr+FIELD_OFFSET(CFileCache,m_ObjectHeap)); CObjectHeap * pObjectHeap_OOP = (CObjectHeap *)(Addr+FIELD_OFFSET(CFileCache,m_ObjectHeap)); DEFINE_CPP_VAR(CFileHeap,varCFileHeap); CFileHeap * pFileHeap = GET_CPP_VAR_PTR(CFileHeap,varCFileHeap); CFileHeap * pFileHeap_OOP = (CFileHeap *)((ULONG_PTR)pObjectHeap_OOP+FIELD_OFFSET(CObjectHeap,m_Heap)); dprintf(" +++ CFileHeap %p\n",pFileHeap_OOP); if (ReadMemory((ULONG_PTR)pFileHeap_OOP,pFileHeap,sizeof(CFileHeap),NULL)) { DEFINE_CPP_VAR(CAbstractFile,varCAbstractFile); CAbstractFile * pAbstract = GET_CPP_VAR_PTR(CAbstractFile,varCAbstractFile); dprintf(" m_pMainFile %p\n",pFileHeap->m_pMainFile); ReadMemory((ULONG_PTR)pFileHeap->m_pMainFile,pAbstract,sizeof(CAbstractFile),NULL); dprintf(" m_pStage %p m_nId %d\n",pAbstract->m_pStage,pAbstract->m_nId); dprintf(" m_pFreeFile %p\n",pFileHeap->m_pFreeFile); ReadMemory((ULONG_PTR)pFileHeap->m_pFreeFile,pAbstract,sizeof(CAbstractFile),NULL); dprintf(" m_pStage %p m_nId %d\n",pAbstract->m_pStage,pAbstract->m_nId); dprintf(" m_mapFree\n"); dprintf(" std::map< DWORD , { CRecordInfo::m_dwIndex, CRecordInfo::m_nOffset } >\n"); _Map * pMapFree = (_Map *)((BYTE *)pFileCache->m_ObjectHeap.m_pHeap+FIELD_OFFSET(CFileHeap,m_mapFree)); PrintMapCB(pMapFree,TRUE,NULL); dprintf(" m_mapFreeOffset\n"); dprintf(" std::map< TOffset , DWORD >\n"); _Map * pMapOffset = (_Map *)((BYTE *)pFileCache->m_ObjectHeap.m_pHeap+FIELD_OFFSET(CFileHeap,m_mapFreeOffset)); PrintMapCB(pMapOffset,TRUE,NULL); } else { dprintf("RM %p %d\n",Addr,GetLastError()); } CBtrIndex * pBtrIndex_OOP = (CBtrIndex *)((ULONG_PTR)pObjectHeap_OOP+FIELD_OFFSET(CObjectHeap,m_Index)); dprintf(" +++ CBtrIndex %p\n",pBtrIndex_OOP); } else { dprintf("RM %p %d\n",Addr,GetLastError()); } } else { dprintf("cannot resolve repdrvfs!g_Glob\n"); } } */ /* long m_lRef; BOOL m_bInit; CPageSource m_TransactionManager; CObjectHeap m_ObjectHeap; */ void Print_CPageCache(ULONG_PTR pPageCache_OOP) { DEFINE_CPP_VAR(CPageCache,varCPageCache); CPageCache * pPageCache = GET_CPP_VAR_PTR(CPageCache,varCPageCache); dprintf(" + CPageCache @ %p\n",pPageCache_OOP); if (ReadMemory(pPageCache_OOP,pPageCache,sizeof(CPageCache),NULL)) { /* DWORD m_dwStatus; DWORD m_dwPageSize; DWORD m_dwCacheSize; DWORD m_dwCachePromoteThreshold; DWORD m_dwCacheSpillRatio; DWORD m_dwLastFlushTime; DWORD m_dwWritesSinceFlush; DWORD m_dwLastCacheAccess; DWORD m_dwReadHits; DWORD m_dwReadMisses; DWORD m_dwWriteHits; DWORD m_dwWriteMisses; HANDLE m_hFile; std::vector > m_aCache; */ // dprintf(" m_dwStatus %08x\n",pPageCache->m_dwStatus); dprintf(" m_dwPageSize %08x\n",pPageCache->m_dwPageSize); dprintf(" m_dwCacheSize %08x\n",pPageCache->m_dwCacheSize); dprintf(" m_hFile %p\n",pPageCache->m_hFile); _Vector * pVector; ULONG_PTR Size; SCachePage ** ppSCachePage; pVector = (_Vector *)&pPageCache->m_aCache; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(SCachePage *); dprintf(" m_aCache - S %x - P %p\n",Size,pVector->_First); ppSCachePage = new SCachePage *[Size]; if(ppSCachePage) { if (ReadMemory((ULONG_PTR)pVector->_First,ppSCachePage,sizeof(SCachePage *)*Size,NULL)) { for (ULONG_PTR i=0;im_bDirty,pSCachePage->m_dwPhysId,pSCachePage->m_pPage); } }; } delete [] ppSCachePage; }; } else { dprintf("RM %p\n",pPageCache_OOP); } }; void Print_CPageFile(ULONG_PTR pPageFile_OOP, BOOL bVerbose) { DEFINE_CPP_VAR(CPageFile,varCPageFile); CPageFile * pPageFile = GET_CPP_VAR_PTR(CPageFile,varCPageFile); dprintf(" + CPageFile @ %p\n",pPageFile_OOP); if (ReadMemory(pPageFile_OOP,pPageFile,sizeof(CPageFile),NULL)) { /* LONG m_lRef; DWORD m_dwStatus; DWORD m_dwPageSize; CRITICAL_SECTION m_cs; WString m_sDirectory; WString m_sMapFile; WString m_sMainFile; CPageCache *m_pCache; BOOL m_bInTransaction; DWORD m_dwLastCheckpoint; DWORD m_dwTransVersion; // Generation A Mapping std::vector > m_aPageMapA; std::vector > m_aPhysFreeListA; std::vector > m_aLogicalFreeListA; std::vector > m_aReplacedPagesA; DWORD m_dwPhysPagesA; // Generation B Mapping std::vector > m_aPageMapB; std::vector > m_aPhysFreeListB; std::vector > m_aLogicalFreeListB; std::vector > m_aReplacedPagesB; DWORD m_dwPhysPagesB; */ dprintf(" m_lRef %08x\n",pPageFile->m_lRef); // dprintf(" m_dwStatus %08x\n",pPageFile->m_dwStatus); dprintf(" m_dwPageSize %08x\n",pPageFile->m_dwPageSize); // dprintf(" m_pCache %p\n",pPageFile->m_pCache); // Print_CPageCache((ULONG_PTR)pPageFile->m_pCache); dprintf(" m_bInTransaction %08x\n",pPageFile->m_bInTransaction); dprintf(" m_dwLastCheckpoint %08x\n",pPageFile->m_dwLastCheckpoint); dprintf(" m_dwTransVersion %08x\n",pPageFile->m_dwTransVersion); _Vector * pVector; ULONG_PTR Size; DWORD * pDW; pVector = (_Vector *)&pPageFile->m_aPageMapA; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aPageMapA - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } pVector = (_Vector *)&pPageFile->m_aPhysFreeListA; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aPhysFreeListA - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; }; pVector = (_Vector *)&pPageFile->m_aLogicalFreeListA; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aLogicalFreeListA - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } pVector = (_Vector *)&pPageFile->m_aReplacedPagesA; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aReplacedPagesA - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } dprintf(" m_dwPhysPagesA %08x\n",pPageFile->m_dwPhysPagesA); pVector = (_Vector *)&pPageFile->m_aPageMapB; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aPageMapB - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } pVector = (_Vector *)&pPageFile->m_aPhysFreeListB; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aPhysFreeListB - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } pVector = (_Vector *)&pPageFile->m_aLogicalFreeListB; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aLogicalFreeListB - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } pVector = (_Vector *)&pPageFile->m_aReplacedPagesB; Size = ((ULONG_PTR)pVector->_Last - (ULONG_PTR)pVector->_First)/sizeof(DWORD); dprintf(" m_aReplacedPagesB - S %x - P %p\n",Size,pVector->_First); if (bVerbose) { pDW = new DWORD[Size]; if(pDW) { if (ReadMemory((ULONG_PTR)pVector->_First,pDW,sizeof(DWORD)*Size,NULL)) { PrintDWORDS(pDW,Size); } delete [] pDW; }; } dprintf(" m_dwPhysPagesB %08x\n",pPageFile->m_dwPhysPagesB); } else { dprintf("RM %p\n",pPageFile_OOP); } } DECLARE_API( filec ) { INIT_API(); ULONG_PTR Addr = 0; if (0 != strlen(args)) { Addr = GetExpression(args); } else { Addr = GetExpression("repdrvfs!g_Glob"); if (Addr) { Addr += FIELD_OFFSET(CGlobals,m_FileCache); } } if (Addr) { DEFINE_CPP_VAR(CFileCache,varCFileCache); CFileCache * pFileCache = GET_CPP_VAR_PTR(CFileCache,varCFileCache); dprintf("CFileCache @ %p\n",Addr); if (ReadMemory((ULONG_PTR)Addr,pFileCache,sizeof(CFileCache),0)) { dprintf(" m_lRef %d m_bInit %d\n",pFileCache->m_lRef,pFileCache->m_bInit); // // CPageSource // dprintf(" + CPageSource %p\n",Addr+FIELD_OFFSET(CFileCache,m_TransactionManager)); CPageSource * pPageSource_OOP = (CPageSource *)(Addr+FIELD_OFFSET(CFileCache,m_TransactionManager)); CPageSource * pPageSource = (CPageSource *)((BYTE *)pFileCache+FIELD_OFFSET(CFileCache,m_TransactionManager)); //dprintf(); dprintf(" m_dwStatus %08x\n",pPageSource->m_dwStatus); dprintf(" m_dwPageSize %08x\n",pPageSource->m_dwPageSize); dprintf(" m_dwCacheSize %08x\n",pPageSource->m_dwCacheSize); dprintf(" m_dwCacheSpillRatio %08x\n",pPageSource->m_dwCacheSpillRatio); dprintf(" m_dwLastCheckpoint %08x\n",pPageSource->m_dwLastCheckpoint); // dprintf(" m_dwCheckpointInterval %08x\n",pPageSource->m_dwCheckpointInterval); // WString m_sDirectory; // WString m_sBTreeMap; // WString m_sObjMap; // CPageFile * dprintf(" m_BTreePF\n"); Print_CPageFile((ULONG_PTR)pPageSource_OOP+FIELD_OFFSET(CPageSource,m_BTreePF),FALSE); dprintf(" m_ObjPF\n"); Print_CPageFile((ULONG_PTR)pPageSource_OOP+FIELD_OFFSET(CPageSource,m_ObjPF),FALSE); dprintf(" m_hFileMap1 %x\n",pPageSource->m_hFileMap1); dprintf(" m_hFileMap2 %x\n",pPageSource->m_hFileMap2); dprintf(" m_hFileMapVer %x\n",pPageSource->m_hFileMapVer); dprintf(" m_dwFileMapVer %08x\n",pPageSource->m_dwFileMapVer); // // CObjectHeap // dprintf(" + CObjectHeap %p\n",Addr+FIELD_OFFSET(CFileCache,m_ObjectHeap)); CObjectHeap * pObjectHeap_OOP = (CObjectHeap *)(Addr+FIELD_OFFSET(CFileCache,m_ObjectHeap)); DEFINE_CPP_VAR(CVarObjHeap,varCVarObjHeap); CVarObjHeap * pVarObjHeap = GET_CPP_VAR_PTR(CVarObjHeap,varCVarObjHeap); CVarObjHeap * pVarObjHeap_OOP = (CVarObjHeap *)((ULONG_PTR)pObjectHeap_OOP+FIELD_OFFSET(CObjectHeap,m_Heap)); dprintf(" +++ CVarObjHeap %p\n",pVarObjHeap_OOP); if (ReadMemory((ULONG_PTR)pVarObjHeap_OOP,pVarObjHeap,sizeof(CVarObjHeap),NULL)) { // this pagefile is the same as CPageSource::m_pObjPF VarObjAdminPageEntry ** ppEntries = (VarObjAdminPageEntry **)_alloca(sizeof(VarObjAdminPageEntry *)*pVarObjHeap->m_aAdminPages.m_nSize); if (ReadMemory((ULONG_PTR)pVarObjHeap->m_aAdminPages.m_pArray,ppEntries,sizeof(VarObjAdminPageEntry *)*pVarObjHeap->m_aAdminPages.m_nSize,NULL)) { dprintf(" admin pages\n"); for(DWORD i=0;im_aAdminPages.m_nSize;i++) { //VarObjAdminPageEntry //dprintf(" - %x P %p\n",i,ppEntries[i]); VarObjAdminPageEntry Entry; if (ReadMemory((ULONG_PTR)ppEntries[i],&Entry,sizeof(Entry),NULL)) { dprintf(" %08x %p %d\n",Entry.dwPageId,Entry.pbPage,Entry.bDirty); } else { dprintf("RM %p\n",ppEntries[i]); } } } else { dprintf("RM %p\n",pVarObjHeap->m_aAdminPages.m_pArray); } } else { dprintf("RM %p %d\n",pVarObjHeap_OOP,GetLastError()); } DEFINE_CPP_VAR(CBtrIndex,varCBtrIndex); CBtrIndex * pBtrIndex = GET_CPP_VAR_PTR(CBtrIndex,varCBtrIndex); CBtrIndex * pBtrIndex_OOP = (CBtrIndex *)((ULONG_PTR)pObjectHeap_OOP+FIELD_OFFSET(CObjectHeap,m_Index)); dprintf(" +++ CBtrIndex %p\n",pBtrIndex_OOP); if (ReadMemory((ULONG_PTR)pBtrIndex_OOP,pBtrIndex,sizeof(CBtrIndex),NULL)) { } else { dprintf("RM %p %d\n",pBtrIndex_OOP,GetLastError()); } } else { dprintf("RM %p %d\n",Addr,GetLastError()); } } else { dprintf("cannot resolve repdrvfs!g_Glob\n"); } } DWORD Dump_CClassRecord(void * pKey,void * pData) { //dprintf("Dump_CClassRecord\n"); DEFINE_CPP_VAR(CClassRecord,MyClassRecord); CClassRecord * pClassRecord = GET_CPP_VAR_PTR(CClassRecord,MyClassRecord); if (pData) { ReadMemory((ULONG_PTR)pData,pClassRecord,sizeof(CClassRecord),NULL); WCHAR pName[MAX_PATH]; ReadMemory((ULONG_PTR)pClassRecord->m_wszClassName,pName,MAX_PATH,NULL); pName[MAX_PATH-1]=0; dprintf(" %p - %S\n",pClassRecord->m_pClassDef,pName); } return 0; } DWORD Dump_CHierarchyCacheMap(void * pKey,void * pData) { //dprintf("Dump_CHierarchyCacheMap\n"); DEFINE_CPP_VAR(CHierarchyCache,MyHierarchyCache); CHierarchyCache * pHieCache = GET_CPP_VAR_PTR(CHierarchyCache,MyHierarchyCache); if (pKey) { WCHAR pString[MAX_PATH+1]; pString[MAX_PATH]=0; if (ReadMemory((MEMORY_ADDRESS)pKey,pString,MAX_PATH*sizeof(WCHAR),NULL)) { dprintf(" - %S\n",pString); } } if (pData) { DWORD Num; PrintMapCB((_Map *)((ULONG_PTR)pData+FIELD_OFFSET(CHierarchyCache,m_map)),TRUE,Dump_CClassRecord); } return 0; }; // // // dumps the Forest Cache // // DECLARE_API( forestc ) { INIT_API(); ULONG_PTR Addr = 0; if (0 != strlen(args)) { Addr = GetExpression(args); } else { Addr = GetExpression("repdrvfs!g_Glob"); if (Addr) { Addr += FIELD_OFFSET(CGlobals,m_ForestCache); } } if (Addr) { CForestCache * pForestCache_OOP = (CForestCache *)Addr; if (pForestCache_OOP) { dprintf("CForestCache @ %p\n",pForestCache_OOP); DEFINE_CPP_VAR(CForestCache,varCForestCache); CForestCache * pForestCache = GET_CPP_VAR_PTR(CForestCache,varCForestCache); ReadMemory((ULONG_PTR)pForestCache_OOP,pForestCache,sizeof(CForestCache),0); DWORD Num; PrintMapCB((_Map *)((ULONG_PTR)pForestCache_OOP+FIELD_OFFSET(CForestCache,m_map)),TRUE,Dump_CHierarchyCacheMap); dprintf(" CClassRecord list\n"); CClassRecord * pCRec = pForestCache->m_pMostRecentlyUsed; Num = 0; while(pCRec) { DEFINE_CPP_VAR(CClassRecord,CRec); ReadMemory((ULONG_PTR)pCRec,&CRec,sizeof(CClassRecord),0); pCRec = ((CClassRecord *)&CRec)->m_pLessRecentlyUsed; dprintf(" %d - %p\n",Num,pCRec); Num++; if (CheckControlC()) break; }; dprintf(" T %d CClassRecord\n",Num); } } else { dprintf(" unable to resolve repdrvfs!g_Glob\n"); } }