Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- tPermutationRequest request = { 0 };
- struct tUserData {
- unsigned __int32 hashToFind;
- std::vector<std::string> matches;
- } userData;
- request.firstPermutationInt = 0;
- request.lastPermutationInt = PermutationCalculator.GetLastPermutationOrdinalNumForSpecifiedLength(6);
- request.func = [](const char* permutatedStr, void* pUserData) -> bool
- {
- tUserData* pData = (tUserData*)pUserData;
- if (GTASA_CRC32_fromString(permutatedStr) == pData->hashToFind) // MYHASH
- {
- pData->matches.push_back(permutatedStr);
- return true;
- }
- return false;
- };
- request.pUserData = &userData;
- request.bAsynchronous = true;
- request.hEventWhenComplete = CreateEventA(NULL, false, false, "PermutationFinder");
- request.amplitudeToLastFoundMatch = 10000;
- unsigned __int32 hashesToFindArray[] = {
- 0x219976ed
- /*
- 0x61398fc7,
- 0x6b6c7562,
- 0x650952f8,
- 0xf39b8ca1,
- 0xbd985ec9
- */
- };
- for (int i = 0; i < _countof(hashesToFindArray); i++)
- {
- userData.hashToFind = hashesToFindArray[i];
- userData.matches.clear();
- PermutationCalculator.PermutateStringAndExecuteFunction(&request);
- while (true)
- {
- if (request.permutationState != PERMUTATION_STATE_IN_PROGRESS)
- break;
- unsigned __int64 totalNumberOfPermutationsToDo = 0;
- unsigned __int64 numberOfPermutationsProcessed = 0;
- for (int i = 0; i < request.numberOfThreadsActive; i++)
- {
- tPermutationRequestThreadInfo* pThreadInfo = request.threadInfo + i;
- totalNumberOfPermutationsToDo += (pThreadInfo->lastPermutationInt - pThreadInfo->firstPermutationInt);
- numberOfPermutationsProcessed += (pThreadInfo->curPermutationInt - pThreadInfo->firstPermutationInt);
- }
- DWORD tickCount = GetTickCount() - request.startTimeInMiliseconds;
- unsigned __int64 speed = numberOfPermutationsProcessed * 1000 / (tickCount != 0 ? tickCount : 1);
- printf("\rWork in progress: %s processed: %lld total: %lld Speed: %lld per second",
- request.threadInfo[0].curPermutation,
- numberOfPermutationsProcessed,
- totalNumberOfPermutationsToDo,
- speed
- );
- WaitForSingleObject(request.hEventWhenComplete, 200);
- }
- if (userData.matches.size())
- {
- for (auto it = userData.matches.begin(); it != userData.matches.end(); it++)
- printf("\n%s\n", it->c_str());
- }
- else
- printf("\nString was not found!\n");
- }
- // WaitForSingleObject(request.hEventWhenComplete, INFINITE);
- CloseHandle(request.hEventWhenComplete);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement