I tryed to clear my code, Waiting for help .. =(
Well, I Made a simple console, with a int that you can see the value and change it anytime, Then i made a console application to write another value to that int..
But idk what is wrong, it says Memory Written but does not happen nothing, I found the adress with C.E 5.6 and 6 ( I didn reopen the console, so the adress didn changed...) ..Here is my code:
Possible problems:Code:#include <iostream> #include <Windows.h> using namespace std; int newvalue = 666; int main() { while(true) { HWND hWnd = FindWindow(0,L"mhtest"); if(!hWnd) { cout << "Window not found!" << endl; system("cls"); } else { cout << "Windows found! Starting the memory hacking process.." << endl; Sleep(2000); system("cls"); DWORD pID; GetWindowThreadProcessId(hWnd, &pID); HANDLE pA = OpenProcess(PROCESS_ALL_ACCESS,false, pID); if(!pA) { cout << "Cant acess the program.." << endl; Sleep(2000); system("cls"); } else { int ss = WriteProcessMemory(hWnd,(LPVOID)0x00E79138, &newvalue,(DWORD)sizeof(newvalue),NULL); if(!ss) { cout << "Failed to write the memory.." << ss << endl; Sleep(2000); system("cls"); } else { cout << "Memory written!.." << ss << endl; Sleep(2000); system("cls"); } } } } }
Converting the adress to hex (i just 0xADRESS it)..
Please help me..
If my code is wrong, please give me a example..And PS: Idk why but the WriteProcessMemory is returning 0 =( now i see that..
Last edited by Lyoto Machida; 05-18-2011 at 03:54 PM.
I tryed to clear my code, Waiting for help .. =(
Help yourself, best way to learn.
Well if im here, its because i cant help myself -.-
But i think i got the problem..
Is the adress..
The adress must be ME Test.exe(my program) + 19138 ..
But how do i get the ME Test.exe ?
Please help me..
@Virtual Void
Lyoto Machida (05-18-2011)
Process Security and Access Rights (Windows)
Don't use PROCESS_ALL_ACCESS when you only need PROCESS_VM_WRITE.Windows Server 2003 and Windows XP/2000: The size of the PROCESS_ALL_ACCESS flag increased on Windows Server 2008 and Windows Vista. If an application compiled for Windows Server 2008 and Windows Vista is run on Windows Server 2003 or Windows XP/2000, the PROCESS_ALL_ACCESS flag is too large and the function specifying this flag fails with ERROR_ACCESS_DENIED. To avoid this problem, specify the minimum set of access rights required for the operation. If PROCESS_ALL_ACCESS must be used, set _WIN32_WINNT to the minimum operating system targeted by your application (for example, #define _WIN32_WINNT _WIN32_WINNT_WINXP). For more information, see Using the Windows Headers.
Lyoto Machida (05-18-2011),Void (05-20-2011)
Lyoto Machida (05-18-2011)
Shut up Cookie.
@-Away
Pointers are your friend ; But Calculating size from moduleList / PEB / w.e as Fovea posted is pretty much the most efficient way to do it externally as you are trying to do (:
Love You All~
I believe it was said already but...
Get the module base address.
I'm pretty sure there is simpler solution or more effective, but I did this when I was playing around with solitaire at the very beggining.
<pId> is the process id.Code:MODULEENTRY32 mEntry32; HANDLE hSnapMods = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pId); if(Module32First(hSnapMods, &mEntry32) == TRUE) { do { if(strcmp(mEntry32.szModule, "solitaire.exe") == 0) { mAddress = (DWORD)mEntry32.modBaseAddr + appOffSet; break; } } while(Module32Next(hSnapMods, &mEntry32) == TRUE); }
<mEntry32.modBaseAddr> will be the module base address.
Now instead of copying it and see that works (or not), try to understand first what is in there.
Last edited by 'Bruno; 05-19-2011 at 03:53 AM.
Light travels faster than sound. That's why most people seem bright until you hear them speak.
[MPGH]master131 (05-19-2011),Void (05-20-2011)
Why the if(strcmp(mEntry32.szModule
Keep giving error? mEntry blabla not compatible with char * blablaa