示例#1
0
DWORD WINAPI __stdcall SearchThread(void *b)
{    
   result_struct *results;
   u32 startaddr;
   u32 endaddr;
   searcharg_struct *searcharg=(searcharg_struct *)b;

   startaddr=searcharg->startaddr;
   endaddr=searcharg->endaddr;

   PostMessage(GetDlgItem(searcharg->hDlg, IDC_SEARCHPB), PBM_SETRANGE, 0, MAKELPARAM (0, (endaddr-startaddr) / SEARCHSIZE));
   PostMessage(GetDlgItem(searcharg->hDlg, IDC_SEARCHPB), PBM_SETSTEP, 1, 0);

   while (KillSearchThread != 1)
   {
      u32 numresults=1;

      if ((searcharg->endaddr - startaddr) > SEARCHSIZE)
         endaddr = startaddr+SEARCHSIZE;
      else
         endaddr = searcharg->endaddr;

      results = MappedMemorySearch(startaddr, endaddr,
                                   searcharg->searchtype | SEARCHEXACT,
                                   searcharg->searchstr,
                                   NULL, &numresults);
      if (results && numresults)
      {
         // We're done
         searcharg->results = results;          
         EndDialog(searcharg->hDlg, TRUE);
         return 0;
      }

      if (results)
         free(results);

      startaddr += (endaddr - startaddr);
      if (startaddr >= searcharg->endaddr)
      {
         EndDialog(searcharg->hDlg, TRUE);
         searcharg->results = NULL;
         return 0;
      }

      PostMessage(GetDlgItem(searcharg->hDlg, IDC_SEARCHPB), PBM_STEPIT, 0, 0);
   }
   return 0;
}
示例#2
0
void MemorySearch::process() 
{
   result_struct *results;
   u32 numResults=1;
   int searchEnd;

   if ((endAddress - curAddress) > searchSize)
      searchEnd = curAddress+searchSize;
   else
      searchEnd = endAddress;

   results = MappedMemorySearch(curAddress, searchEnd,
      searchType | SEARCHEXACT,
      searchString.toLatin1().constData(),
      NULL, &numResults);
   if (results && numResults)
   {
      timer->stop();

      // We're done
      emit searchResult(true, false, results[0].addr);
      free(results);
      return;
   }

   if (results)
      free(results);

   curAddress += (searchEnd - curAddress);
   if (curAddress >= endAddress)
   {
      timer->stop();
      emit searchResult(false, false, 0);
      return;
   }

   steps++;
   emit setBarValue(steps);
}