#include <string>
#include <vector>
#ifdef _WIN32
-#include <io.h>
+ #include <io.h>
+ #include <conio.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <math.h>
#include <vector>
-#include <conio.h>
#include <sstream>
#include "Public.h"
#include "MemoryPool.h"
return 30;
if(highvalue < 0x80000000)
return 31;
-#ifdef WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
if(highvalue < 0x0000000100000000I64)
return 32;
if(highvalue < 0x0000000200000000I64)
}
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);
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) {
unsigned int nChains = nAllocatedSize / sizeof(RainbowChain);
uint64 curPrefix = 0, prefixStart = 0;
vector<IndexRow> indexes;
- while(reader->GetChainsLeft() > 0) {
+ unsigned int chainsLeft;
+ while((chainsLeft = reader->GetChainsLeft()) > 0) {
/* if (ftell(file) == nFileLen)
break;*/
- int nReadThisRound;
+ printf("%u chains left to read\n", chainsLeft);
+ //int nReadThisRound;
clock_t t1 = clock();
printf("reading...\n");
#ifdef _MEMORYDEBUG
printf("Grabbing %i chains from file\n", nChains);
#endif
- reader->ReadChains(nChains, pChain);
+ reader->ReadChains(nChains, pChain);
#ifdef _MEMORYDEBUG
printf("Recieved %i chains from file\n", nChains);
#endif
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]++;
}
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;
// 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);
// 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) {
// 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
exit(1);
}
}
- for(UINT4 j = 1; j < diffSize; j++)
+ for(uint32 j = 1; j < diffSize; j++)
{
fwrite(&zero, 1, m_indexrowsizebytes, pFileIndex);
}
}
}
vector<string> vPathName;
-#ifdef WIN32
+#ifdef _WIN32
string sWildCharPathName = argv[1];
GetTableList(sWildCharPathName, vPathName);
#else
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) {
printf("\n");
}
return 0;
-}
\ No newline at end of file
+}