Hello guys! :D I've been trying to mess with injection and I'm building a general DLL that will injects anything I want into an existing process. The objective is currently to achieve a custom screen size for the Conquer Online Client. I currently have this piece of code: DWORD idProcess = GetCurrentProcessId();
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, idProcess);
if (hProcess)
{
const LPVOID BASE_W_ADDR = (LPVOID) (0x00469DEF + 6);
const LPVOID BASE_H_ADDR = (LPVOID) (0x00469DFC + 6);
int width = GetPrivateProfileIntA("GameResolution", "Width", 1024, CONFIG_FILE);
int height = GetPrivateProfileIntA("GameResolution", "Height", 768, CONFIG_FILE);
int read = 0;
SIZE_T bytes_read = 0, bytes_written = 0;
DWORD error = 0;
if (ReadProcessMemory(hProcess, BASE_W_ADDR, &read, 4, &bytes_read) || GetLastError() == ERROR_PARTIAL_COPY) {
if (bytes_read == 0)
MessageBoxA(NULL, "Could not get width memory offset.", "ReadProcessMemory error", MB_OK);
if (!WriteProcessMemory(hProcess, BASE_W_ADDR, (LPCVOID)width, 4, &bytes_written))
MessageBoxA(NULL, "Could not write to width memory offset.", "WriteProcessMemory error", MB_OK);
error = GetLastError();
if (error != 0)
{
sprintf_s(msg, "Error writing to memory! %d" , error);
MessageBoxA(NULL, msg, "WriteProcessMemory error", MB_OK);
}
else
{
sprintf_s(msg, "Width edited with success! :D Old X: %d", read);
MessageBoxA(NULL, msg, "Success?", MB_OK);
}
error = 0;
}
if (ReadProcessMemory(hProcess, BASE_H_ADDR, &read, 4, &bytes_read) || GetLastError() == ERROR_PARTIAL_COPY) {
if (bytes_read == 0)
MessageBoxA(NULL, "Could not get height memory offset.", "ReadProcessMemory error", MB_OK);
if (!WriteProcessMemory(hProcess, BASE_H_ADDR, (LPCVOID)height, 4, &bytes_written))
MessageBoxA(NULL, "Could not write to height memory offset.", "WriteProcessMemory error", MB_OK);
error = GetLastError();
if (error != 0)
{
sprintf_s(msg, "Error writing to memory! %d", error);
MessageBoxA(NULL, msg, "WriteProcessMemory error", MB_OK);
}
else
{
sprintf_s(msg, "Height edited with success! :D Old X: %d", read);
MessageBoxA(NULL, msg, "Success?", MB_OK);
}
}
} It will give me an error related to ERROR_FILE_NOT_FOUND on width change and will give no error on height change, but neither work. I have tried a lot of solutions from Stack Overflow and etc but idk what's wrong there. The process can currently ReadProcessMemory with success, it will return the current screen resolution at that memory pointer but I can't set the one in my ini file. Any lights on this?