by iPromise
As you guys well know I coded a memory scanner to simply find addresses that I can use for my hacks. However, whenever I do a next scan with my memory scanner it tends to give me a random access violation (mostly on games not other non-gaming applications). So I saw that maybe I needed to protect the memory to PAGE_READWRITE or any other memory readable constants. So I tested it and gave it a run and it kept giving me random access violations.
So heres my code for my next scan:
Code: |
void NextScan(HWND hWndDlg) { int Min = 0; int Max = SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_GETCOUNT, 0, 0); char TypeBuf[500] = {0}; GetWindowTextA(GetDlgItem(hWndDlg, IDC_COMBO1), (LPSTR) TypeBuf, 500); char ValueBuf[500] = {0}; GetWindowTextA(GetDlgItem(hWndDlg, IDC_EDIT1), (LPSTR) ValueBuf, 500); string ValueStr; ValueStr += (LPSTR) ValueBuf; stringstream ConvertValue; unsigned int Value; ConvertValue << (LPSTR) ValueBuf; ConvertValue >> Value; char Scan[500] = {0}; GetWindowTextA(GetDlgItem(hWndDlg, IDC_COMBO2), (LPSTR) Scan, 500); DWORD lpflOldProtect; if (!strcmp(Scan, "Exact Value")) { for (int i = Min; i <= Max; i ++) { char AddressBuf[500] = {0}; SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) AddressBuf); stringstream ConvertAddress(AddressBuf); LPVOID lpAddress; ConvertAddress >> lpAddress; DWORD dwAddress = (DWORD) lpAddress; VirtualProtect((LPVOID) dwAddress, 4, PAGE_READWRITE, &lpflOldProtect); if (((!strcmp(TypeBuf, "Byte")) && *(BYTE*) dwAddress != (BYTE) Value) || ((!strcmp(TypeBuf, "2 Bytes")) && *(WORD*) dwAddress != (WORD) Value) || ((!strcmp(TypeBuf, "4 Bytes")) && *(DWORD*) dwAddress != (DWORD) Value) || ((!strcmp(TypeBuf, "8 Bytes")) && *(UINT64*) dwAddress != (UINT64) Value)) { SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_DELETESTRING, (WPARAM) i, 0); } VirtualProtect((LPVOID) dwAddress, 4, lpflOldProtect, &lpflOldProtect); } GetResults(hWndDlg); } if (!strcmp(Scan, "Decreased..")) { for (int i = Min; i <= Max; i ++) { char AddressBuf[500] = {0}; SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) AddressBuf); stringstream ConvertAddress(AddressBuf); LPVOID lpAddress; ConvertAddress >> lpAddress; DWORD dwAddress = (DWORD) lpAddress; VirtualProtect((LPVOID) dwAddress, 4, PAGE_READWRITE, &lpflOldProtect); if (((!strcmp(TypeBuf, "Byte")) && ((*(BYTE*) dwAddress) >= ((BYTE) Value))) || ((!strcmp(TypeBuf, "2 Bytes")) && ((*(WORD*) dwAddress) >= ((WORD) Value))) || ((!strcmp(TypeBuf, "4 Bytes")) && ((*(DWORD*) dwAddress) >= ((DWORD) Value))) || ((!strcmp(TypeBuf, "8 Bytes")) && ((*(UINT64*) dwAddress) >= ((UINT64) Value)))) { SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_DELETESTRING, (WPARAM) i, 0); } VirtualProtect((LPVOID) dwAddress, 4, lpflOldProtect, &lpflOldProtect); } GetResults(hWndDlg); } if (!strcmp(Scan, "Increased..")) { for (int i = Min; i <= Max; i ++) { char AddressBuf[500] = {0}; SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_GETTEXT, (WPARAM) i, (LPARAM) (LPTSTR) AddressBuf); stringstream ConvertAddress(AddressBuf); LPVOID lpAddress; ConvertAddress >> lpAddress; DWORD dwAddress = (DWORD) lpAddress; VirtualProtect((LPVOID) dwAddress, 4, PAGE_READWRITE, &lpflOldProtect); if (((!strcmp(TypeBuf, "Byte")) && *(BYTE*) dwAddress <= (BYTE) Value) || ((!strcmp(TypeBuf, "2 Bytes")) && *(WORD*) dwAddress <= (WORD) Value) || ((!strcmp(TypeBuf, "4 Bytes")) && *(DWORD*) dwAddress <= (DWORD) Value) || ((!strcmp(TypeBuf, "8 Bytes")) && *(UINT64*) dwAddress <= (UINT64) Value)) { SendMessage(GetDlgItem(hWndDlg, IDC_LIST1), LB_DELETESTRING, (WPARAM) i, 0); } VirtualProtect((LPVOID) dwAddress, 4, lpflOldProtect, &lpflOldProtect); } GetResults(hWndDlg); } } |
Please, suggestions and comments can help me out.
0 comentarios:
Publicar un comentario