DLL Hook -> Edit GameIP Problem

12/02/2019 23:11 xKeRnx#1
Hello everyone,

i have the following problem, i have a game exe in this is e.g. this IP 127.0.0.1 <- String[9] i want to replace with 11.111.11.11 <- string[12]. With my code below it only replaces the first number of the old IP but not the complete IP... I found a way to replace the ip in the format string[9] so the last three characters are missing (.11)... i think of my code as something completely wrong... because i've been working with c++ for only about 2 weeks i hope someone from here can help me... Thanks :)

Code:
#include "pch.h"
#include <string>
using namespace std;

#define Offset 0x00B310CC

void RewriteValues() {
	char* ip;
	ip = (char*)Offset;
	*ip = (const char) *"11.111.11.11";
}


BOOL APIENTRY DllMain(HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		RewriteValues();
		break;
	}
	return TRUE;
}
12/03/2019 04:23 elmarcia#2
EDIT:

Try changing the value with cheat engine, make sure the string ends with null character in memory,
if that doesn't work, read below

Of course some characters are missing, your string is writting where it shouldn't. The correct way to do this is to replace the value of the pointers to that string not the value itself.

This is a c++ code to show what i mean.
Code:
	//original value at address X
	char ip[] = "127.0.0.1";
	//some pointer to the value (should find the pointer or pointers with CE)
	char *pip = ip;
	
    printf("pointer points to address: %X \n", &ip);
	//replace string
	 char replace[] = "123.4.5.6.7.8.9";
	 printf("Replace address is at %X\n", &replace);
	 printf("Current value: %s\n", pip);
	 system("pause");
	 //replace target pointer with replace string address
	 pip = replace;
	 printf("Current value: %s\n", pip);
	 system("pause");
[Only registered and activated users can see links. Click Here To Register...]