by iPromise
I'm writing all my information into a buffer, and when the scan is finished I add the items into the listbox. Everything works but, when scanning a process that is very big, and not knowing where the address your looking for's region is, i'm going to have a big problem. I tried creating a thread for each region that I find which is readable but I can't pass on the T class, the structure or the value in CreateThread().
For instance:
Code: |
template { T Value; DWORD dwBaseAddr; DWORD dwEndAddr; }; template CreateThread (NULL, NULL, (LPTHREAD_START_ROUTINE) RunScan |
Here is my current code:
Code: | ||||||||||||||||
template { SendMessageA (GetDlgItem (hWnd, IDC_LIST1), LB_RESETCONTENT, NULL, NULL); ofstream File ("C:\\File.txt"); File.clear (); bool Fast = ( SendMessageA (GetDlgItem(hWnd, IDC_CHECKBOX1), BM_GETCHECK, 0, 0) == BST_CHECKED ) ? true : false; bool Slow = ( SendMessageA (GetDlgItem(hWnd, IDC_CHECKBOX2), BM_GETCHECK, 0, 0) == BST_CHECKED ) ? true : false; DWORD dwStartAddr = GetCurSel_2 (IDC_EDIT2); DWORD dwStopAddr = GetCurSel_2 (IDC_EDIT3); for ( DWORD i = dwStartAddr; i < dwStopAddr; i ++ ) { MEMORY_BASIC_INFORMATION MBI = {0}; VirtualQuery ((LPCVOID) i, &MBI, sizeof (MEMORY_BASIC_INFORMATION)); if ( Fast ) { if ( ( MBI.State == MEM_COMMIT ) && ( MBI.Type == MEM_PRIVATE ) && ( MBI.RegionSize > 0 ) ) { DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - sizeof (T); for ( DWORD addr = (DWORD) MBI.BaseAddress; addr < (DWORD) dwEndAddr; addr ++ ) { int read = read_for_except if ( read == 0 ) { File << (LPVOID) addr << endl; } else if ( read == 2 ) { addr = dwEndAddr; } } i += (DWORD) MBI.RegionSize; } else { i += (DWORD) MBI.RegionSize; } } if ( Slow ) { if ( ( MBI.Protect == PAGE_READWRITE ) && ( MBI.RegionSize > 0 ) ) { DWORD dwEndAddr = ( (DWORD) MBI.BaseAddress + (DWORD) MBI.RegionSize ) - 1 - sizeof (T); for ( DWORD addr = (DWORD) MBI.BaseAddress; addr < (DWORD) dwEndAddr; addr ++ ) { int read = read_for_except if ( read == 0 ) { File << (LPVOID) addr << endl; } else if ( read == 2 ) { addr = dwEndAddr; } } i += (DWORD) MBI.RegionSize; } else { i += (DWORD) MBI.RegionSize; } } } File.close (); ifstream Read ("C:\\File.txt"); while ( !Read.eof() ) { LPVOID lpAddress; Read >> lpAddress; add_to_list ((DWORD) lpAddress, hWnd); } Read.close (); ObtainResults (); } |
0 comentarios:
Publicar un comentario