X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=Client%20Applications%2Fconverti2%2Fconverti2.cpp;h=c447f0c79e75e96feebc0bb5f87498f0b4d3b707;hb=47c71901e7a97c226c8f1df749e3606d43656f32;hp=d534d81c8dc9433e05453c7b3de38c05a97935d2;hpb=be9db72731412fad58246851d4f345c01392351c;p=freerainbowtables diff --git a/Client Applications/converti2/converti2.cpp b/Client Applications/converti2/converti2.cpp index d534d81..c447f0c 100644 --- a/Client Applications/converti2/converti2.cpp +++ b/Client Applications/converti2/converti2.cpp @@ -1,7 +1,8 @@ #include #include #ifdef _WIN32 -#include + #include + #include #else #include #include @@ -13,7 +14,6 @@ #include #include #include -#include #include #include "Public.h" #include "MemoryPool.h" @@ -100,7 +100,7 @@ int GetMaxBits(uint64 highvalue) return 30; if(highvalue < 0x80000000) return 31; -#ifdef WIN32 +#if defined(_WIN32) && !defined(__GNUC__) if(highvalue < 0x0000000100000000I64) return 32; if(highvalue < 0x0000000200000000I64) @@ -297,7 +297,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int } unsigned int distribution[64] = {0}; unsigned int numProcessedChains = 0; - FILE* fileR; + FILE* fileR = NULL; BaseRTReader *reader = NULL; if(sPathName.substr(sPathName.length() - 2, sPathName.length()) == "rt") reader = (BaseRTReader*)new RTReader(sPathName); @@ -317,9 +317,9 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int int size = reader->GetChainsLeft() * sizeof(RainbowChain); static CMemoryPool mp; - unsigned int nAllocatedSize; + uint64 nAllocatedSize; RainbowChain* pChain = (RainbowChain*)mp.Allocate(size, nAllocatedSize); - unsigned int chainrowsize = ceil((float)(rti_startptlength + rti_endptlength + rti_cplength) / 8) * 8 ; // The size in bits (in whole bytes) + uint32 chainrowsize = (uint32)ceil((float)(rti_startptlength + rti_endptlength + rti_cplength) / 8) * 8 ; // The size in bits (in whole bytes) unsigned int chainrowsizebytes = chainrowsize / 8; if (pChain != NULL) { @@ -333,7 +333,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int /* if (ftell(file) == nFileLen) break;*/ printf("%u chains left to read\n", chainsLeft); - int nReadThisRound; + //int nReadThisRound; clock_t t1 = clock(); printf("reading...\n"); #ifdef _MEMORYDEBUG @@ -348,7 +348,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int printf("reading time: %.2f s\n", fTime); printf("converting %i chains...\n", nChains); t1 = clock(); - for(int i = 0; i < nChains; i++) { + for(unsigned int i = 0; i < nChains; i++) { if(showDistribution == 1) { distribution[GetMaxBits(pChain[i].nIndexS)-1]++; } @@ -403,7 +403,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int indexes.push_back(index); IndexRow high = {0}; // Used to find the highest numbers. This tells us how much we can pack the index bits - for(UINT4 i = 0; i < indexes.size(); i++) + for(uint32 i = 0; i < indexes.size(); i++) { if(indexes[i].numchains > high.numchains) high.numchains = indexes[i].numchains; @@ -417,7 +417,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int // unsigned int m_rti_index_prefixlength = GetMaxBits(high.prefix); unsigned int m_rti_index_numchainslength = GetMaxBits(high.numchains); // unsigned int m_rti_index_indexlength = GetMaxBits(high.prefixstart); - unsigned int m_indexrowsize = ceil((float)(/*m_rti_index_indexlength + */m_rti_index_numchainslength) / 8) * 8; // The size in bits (in whole bytes) + uint32 m_indexrowsize = (uint32)ceil((float)(/*m_rti_index_indexlength + */m_rti_index_numchainslength) / 8) * 8; // The size in bits (in whole bytes) unsigned int m_indexrowsizebytes = m_indexrowsize / 8; FILE *pFileIndex = fopen(sResultFileName.append(".index").c_str(), "wb"); fwrite("RTI2", 1, 4, pFileIndex); @@ -427,18 +427,18 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int // fwrite(&m_rti_index_indexlength , 1, 1, pFileIndex); fwrite(&m_rti_index_numchainslength, 1, 1, pFileIndex); - for(UINT4 i = 0; i < rti_cppos.size(); i++) { + for(uint32 i = 0; i < rti_cppos.size(); i++) { fwrite(&rti_cppos[i], 1, 4, pFileIndex); // The position of the checkpoints } // fwrite(&m_rti_index_prefixlength, 1, 1, pFileIndex); int zero = 0; fwrite(&indexes[0].prefix, 1, 8, pFileIndex); // Write the first prefix unsigned int lastPrefix = 0; - for(UINT4 i = 0; i < indexes.size(); i++) { + for(uint32 i = 0; i < indexes.size(); i++) { if(i == 0) { lastPrefix = indexes[0].prefix; } - unsigned int indexrow = 0; + //unsigned int indexrow = 0; // Checks how big a distance there is between the current and the next prefix. eg cur is 3 and next is 10 = 7. unsigned int diffSize = indexes[i].prefix - lastPrefix; if(i > 0 && diffSize > 1) { @@ -447,7 +447,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int // then write the distance amount of 00's if(diffSize > 1000) { - printf("WARNING! The distance to the next prefix is %i. Do you want to continue writing %i bytes of 0x00? Press y to continue", diffSize, diffSize); + printf("WARNING! The distance to the next prefix is %i. Do you want to continue writing %i bytes of 0x00? Press y to continue", diffSize, (diffSize*m_indexrowsizebytes)); #ifdef _WIN32 if ( _getch() != 'y' ) { #else @@ -457,7 +457,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, unsigned int exit(1); } } - for(UINT4 j = 1; j < diffSize; j++) + for(uint32 j = 1; j < diffSize; j++) { fwrite(&zero, 1, m_indexrowsizebytes, pFileIndex); } @@ -579,7 +579,7 @@ int main(int argc, char* argv[]) } } vector vPathName; -#ifdef WIN32 +#ifdef _WIN32 string sWildCharPathName = argv[1]; GetTableList(sWildCharPathName, vPathName); #else @@ -589,7 +589,7 @@ int main(int argc, char* argv[]) printf("no rainbow table found\n"); return 0; } - for (UINT4 i = 0; i < vPathName.size(); i++) { + for (uint32 i = 0; i < vPathName.size(); i++) { string sResultFile; int n = vPathName[i].find_last_of('\\'); if (n != -1) { @@ -617,4 +617,4 @@ int main(int argc, char* argv[]) printf("\n"); } return 0; -} \ No newline at end of file +}