-
C++ Wow 2.4.3 Mem Reading/Writing
So I've spent the past weekend looking into this and I am still drawing blanks:
Code:
#include<iostream>
#include<Windows.h>
using namespace std;
int main()
{
int newValue = 0;
HWND hwnd = FindWindowA(NULL, "World of Warcraft");
if (hwnd == NULL)
{
cout << "Woops homie can't find Wow." << endl;
Sleep(3000);
exit(-1);
}
else
{
DWORD procID;
GetWindowThreadProcessId(hwnd, &procID);
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
if (procID == NULL)
{
cout << "Cannot Find window procces." << endl;
Sleep(3000);
exit(-1);
}
else
{
WriteProcessMemory(handle, (LPVOID)0x008C8398, &newValue, sizeof(newValue), 0);
}
}
return 0;
}
There are no errors and the WriteProccesMem differently is triggered however it does not do any writing, Any help would be amazing thanks!
PS:
The address is taken from a 2.4..5 dump thread and works checked with Cheat Engine.
We are trying to change the vaule of 0x008C8398 to 0 (Allowing Wall Climb)
Last edited by Dupheadss; 06-04-2017 at 10:59 AM.
-
Post Thanks / Like - 1 Thanks
Jansi (1 members gave Thanks to Dupheadss for this useful post)
-
What's the page type? Try VirtualProtect I guess.
VirtualProtect function (Windows)
I would also check if you have a valid handle. Or output GetLastEror() and see if you get anything.
Last edited by DarkLinux; 06-04-2017 at 05:35 PM.
-
Post Thanks / Like - 2 Thanks
Dupheadss,
Jansi (2 members gave Thanks to DarkLinux for this useful post)
-
Hint: do not ignore the result of WriteProcessMemory()
-
Post Thanks / Like - 1 Thanks
Dupheadss (1 members gave Thanks to namreeb for this useful post)
-
Thanks for the reply I'll look into VirtualProtect in a bit, However.
GetLastError() returned 6 after some googling it says that error points to an invalid Handler?
So I printed the handle to console and got
00000000000204E0
PID: 3612
CheatEng Handle : 00000E1C-Wow.exe
Any tips?
EDIT --------
Did some more digging and found that the OpenProcess is throwing the error 5 (Access Denied )
if you could show me a tut on your VirtualProtect Function I'd be grateful.
Last edited by Dupheadss; 06-05-2017 at 10:13 AM.
-
Nothing about a good old google search:
LMGTFY
Also about OpenProcess:
OpenProcess returns access denied
Check my blog: https://zzuks.blogspot.com
-
Post Thanks / Like - 1 Thanks
Dupheadss (1 members gave Thanks to Corthezz for this useful post)
-
Member
I had a similar problem and found that i had forgotten to run the compiled exe with admin priviledges
-
Post Thanks / Like - 1 Thanks
Dupheadss (1 members gave Thanks to tperkz for this useful post)
-
So i have used VirtualProtectEx However it is throwing the error of invalid Handle ?
using the Handle i get from FindWindowA()
-
-
My handle is returning 262900 ? that doesn't seem right.
-
Contributor
I don't know if this is your issue, but from my experience i had to change AdjustTokenPrivileges for my TBC and Vanilla c++.
-
Member
I am trying to learn C++ -> WoW injection and your post was a great start. DarkLinux was right - after setting VirtualProtectEx your code works (with admin privileges).
One thing I noticed is that you are setting an int value, but the variable is of type float. I am not sure if it makes any difference since we are changing it to zero.
Here is the complete working sample (Visual Studio, Windows 10):
Code:
#include <iostream>
#include <Windows.h>
int main() {
HWND hWnd = FindWindow(0, TEXT("World of Warcraft"));
if (hWnd == 0) {
std::cerr << "Error cannot find window." << std::endl;
} else {
DWORD proccessID;
GetWindowThreadProcessId(hWnd, &proccessID);
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccessID);
if (!hProcess) {
std::cerr << "Could not open the process!" << std::endl;
} else {
float newData = 0.0;
float oldData = 0.0;
DWORD oldProtect = 0;
LPVOID address = (LPVOID)0x008C8398;
if (ReadProcessMemory(hProcess, address, &oldData, sizeof(oldData), NULL)) {
std::cout << "Old Climb value: " << oldData << std::endl;
}
// Enable writing to the page
VirtualProtectEx(hProcess, address, sizeof(newData), PAGE_EXECUTE_READWRITE, &oldProtect);
if (!WriteProcessMemory(hProcess, address, &newData, sizeof(newData), NULL)) {
std::cerr << "Error in WriteProcessMemory: " << GetLastError() << std::endl;
}
// Restore the original rights
VirtualProtectEx(hProcess, address, sizeof(newData), oldProtect, NULL);
if (ReadProcessMemory(hProcess, address, &oldData, sizeof(oldData), NULL)) {
std::cout << "New Climb value: " << oldData << std::endl;
}
CloseHandle(hProcess);
}
}
std::getchar();
return 0;
}
-
Post Thanks / Like - 1 Thanks
Dupheadss (1 members gave Thanks to Jansi for this useful post)