* Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
* Copyright 2010 uroskn\r
*\r
- * This file is part of racrcki_mt.\r
+ * This file is part of rcracki_mt.\r
*\r
* rcracki_mt is free software: you can redistribute it and/or modify\r
* it under the terms of the GNU General Public License as published by\r
* along with rcracki_mt. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
\r
-#ifdef _WIN32\r
+#if defined(_WIN32) && !defined(__GNUC__)\r
#pragma warning(disable : 4786 4267 4018)\r
#endif\r
\r
#include "CrackEngine.h"\r
#include "RTI2Reader.h"\r
\r
+#ifndef _WIN32\r
+ #include <sys/resource.h>\r
+#endif\r
+\r
CCrackEngine::CCrackEngine()\r
{\r
ResetStatistics();\r
vector<rcrackiThread*> threadPool;\r
vector<pthread_t> pThreads;\r
\r
+ #ifndef _WIN32\r
+ /*\r
+ * On linux you cannot set the priority of a thread in the non real time\r
+ * scheduling groups. You can set the priority of the process. In\r
+ * windows BELOW_NORMAL represents a 1/8th drop in priority and this would\r
+ * be 20 * 1/8 on linux or about 2.5\r
+ */\r
+ setpriority( PRIO_PROCESS, 0, 2 );\r
+ #endif\r
+\r
pthread_attr_t attr;\r
pthread_attr_init(&attr);\r
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);\r
#ifdef _WIN32\r
sched_param param;\r
+ /*\r
+ * windows scheduling is 0 to 32 (low to high) with 8 as normal and 7 as\r
+ * BELOW_NORMAL\r
+ */\r
param.sched_priority = THREAD_PRIORITY_BELOW_NORMAL;\r
pthread_attr_setschedparam (&attr, ¶m);\r
#endif\r
- // XXX else set it to 5 or something (for linux)?\r
\r
bool pausing = false;\r
\r
\r
vector<rcrackiThread*> threadPool;\r
vector<pthread_t> pThreads;\r
+ \r
+ #ifndef _WIN32\r
+ /*\r
+ * On linux you cannot set the priority of a thread in the non real time\r
+ * scheduling groups. You can set the priority of the process. In\r
+ * windows BELOW_NORMAL represents a 1/8th drop in priority and this would\r
+ * be 20 * 1/8 on linux or about 2.5\r
+ */\r
+ setpriority( PRIO_PROCESS, 0, 2 );\r
+ #endif\r
\r
pthread_attr_t attr;\r
pthread_attr_init(&attr);\r
\r
// FileName\r
#ifdef _WIN32\r
- int nIndex = sPathName.find_last_of('\\');\r
+ string::size_type nIndex = sPathName.find_last_of('\\');\r
#else\r
- int nIndex = (int) sPathName.find_last_of('/');\r
+ string::size_type nIndex = sPathName.find_last_of('/');\r
#endif\r
string sFileName;\r
- if (nIndex != -1)\r
+ if (nIndex != string::npos)\r
sFileName = sPathName.substr(nIndex + 1);\r
else\r
sFileName = sPathName;\r
\r
static CMemoryPool mp(bytesForChainWalkSet, debug, maxMem);\r
RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize);\r
- if (debug) printf("Allocated %llu bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen);\r
+ #ifdef _WIN32\r
+ if (debug) printf("Allocated %I64u bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen);\r
+ #else\r
+ if (debug) printf("Allocated %llu bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen);\r
+ #endif\r
+\r
if (pChain != NULL)\r
{\r
nAllocatedSize = nAllocatedSize / sizeOfChain * sizeOfChain; // Round to sizeOfChain boundary\r
//printf("index nSize: %d\n", nSize);\r
//pIndex = (IndexChain*)new unsigned char[nSize];\r
IndexChain *pIndex = (IndexChain*)mpIndex.Allocate(nFileLenIndex, nAllocatedSizeIndex);\r
- if (debug) printf("Debug: Allocated %llu bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex);\r
+ #ifdef _WIN32\r
+ if (debug) printf("Debug: Allocated %I64u bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex);\r
+ #else\r
+ if (debug) printf("Debug: Allocated %llu bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex);\r
+ #endif\r
\r
static CMemoryPool mp(bytesForChainWalkSet + nAllocatedSizeIndex, debug, maxMem);\r
\r
while ( (unsigned long)ftell(fIndex) != nFileLenIndex ) // Index chunk read loop\r
{\r
// Load index chunk\r
+#ifdef _WIN32\r
+ if (debug) printf("Debug: Setting index to 0x00 in memory, %I64u bytes\n", nAllocatedSizeIndex);\r
+#else\r
if (debug) printf("Debug: Setting index to 0x00 in memory, %llu bytes\n", nAllocatedSizeIndex);\r
+#endif\r
memset(pIndex, 0x00, nAllocatedSizeIndex);\r
printf("reading index... ");\r
gettimeofday( &tv, NULL );\r
\r
//RainbowChain* pChain = (RainbowChain*)mp.Allocate(nFileLen, nAllocatedSize);\r
RainbowChain* pChain = (RainbowChain*)mp.Allocate(nCoveredRainbowTableChains * sizeOfChain, nAllocatedSize);\r
- if (debug) printf("Debug: Allocated %llu bytes for %u chains, filelen %lu\n", nAllocatedSize, nCoveredRainbowTableChains, (unsigned long)nFileLen);\r
+ #ifdef _WIN32\r
+ if (debug) printf("Debug: Allocated %I64u bytes for %u chains, filelen %lu\n", nAllocatedSize, nCoveredRainbowTableChains, (unsigned long)nFileLen);\r
+ #else\r
+ if (debug) printf("Debug: Allocated %llu bytes for %u chains, filelen %lu\n", nAllocatedSize, nCoveredRainbowTableChains, (unsigned long)nFileLen);\r
+ #endif\r
\r
if (pChain != NULL && nAllocatedSize > 0)\r
{\r