]> git.sesse.net Git - freerainbowtables/blobdiff - Client Applications/rcracki_mt/CrackEngine.cpp
merged paths
[freerainbowtables] / Client Applications / rcracki_mt / CrackEngine.cpp
index 7640a6310211340cdd4aef3b69aa75ccd34bbbae..0a4b1818bb9eb889771e94017cc28fb0ee9302c2 100644 (file)
@@ -1044,7 +1044,12 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                                }
 
                                static CMemoryPool mp(bytesForChainWalkSet, debug, maxMem);
-                               RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);
+                               RainbowChainO* pChain = NULL;
+                               if(doRti2Format) {
+                                       pChain = (RainbowChainO*)mp.Allocate(pReader->GetChainsLeft() * 16, nAllocatedSize);
+                               } else {
+                                       pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);
+                               }
                                #ifdef _WIN32
                                        if (debug) printf("Allocated %I64u bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen);
                                #else
@@ -1064,13 +1069,15 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
 
                                                // Load table chunk
                                                if (debug) printf("reading...\n");
-                                               unsigned int nDataRead = 0, nDataToRead = 0;
+                                               unsigned int nDataRead = 0;
                                                gettimeofday( &tv, NULL );
                                                if ( doRti2Format )
                                                {
-                                                       nDataToRead = nAllocatedSize / 16;
-                                                       nDataRead = nDataToRead;
-                                                       pReader->ReadChains(nDataRead, pChain);
+                                                       nDataRead = nAllocatedSize / 16;
+                                                       if(pReader->GetChainsLeft() <= 0) // No more data
+                                                               break; 
+                                                       pReader->ReadChains(nDataRead, (RainbowChain*)pChain);
+
                                                        nDataRead *= 8; // Convert from chains read to bytes
                                                }
                                                else
@@ -1086,6 +1093,10 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
 
                                                int nRainbowChainCountRead = nDataRead / 16;
 
+                                               if(doRti2Format) {
+                                                       nRainbowChainCountRead = nDataRead / 8;
+                                               }
+
                                                // Verify table chunk
                                                if (!fVerified)
                                                {
@@ -1136,13 +1147,6 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                                                // Already finished?
                                                if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen()))
                                                        break;
-
-                                               // finished the current table
-                                               if( doRti2Format && nDataToRead > (nDataRead / 8) )
-                                               {
-                                                       delete pReader;
-                                                       break;
-                                               }
                                        }
                                }
                                else