Share via

Remove string from process memory using Adress

Vadym Sydorchuk 1 Reputation point
2023-01-05T16:51:44.077+00:00

I want to remove string from one of the process with adress method. I got a ProcID and tried to get adress with which I can to change all string of process memory, but something doesn't enough. I know that it isn't a full code of this remover but i can't to search more info on this topic for C++

int procname;  
uintptr_t adress;  
string ValueToWrite;  
  
int main()  
{  
	SetConsoleTitle("String Remover");  
  
	cout << "Enter process PID: \t";  
	cin >> procname;  
	cout << "\n" << "\n";  
  
	HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, procname);  
  
	if (!hProc)  
	{  
		cout << "Iinvalid PID.";  
		return -1;  
	}  
	else  
	{  
		cout << "Process succsesfully opened." << endl;  
		cout << "\n";  
	}  
  
	SIZE_T BytesToWrite = ValueToWrite.length() + 1;  
  
	cout << "Enterr adress: \t";  
	cin >> adress;  
	cout << "\n" << "\n";  
  
  
	if (ReadProcessMemory(hProc, (void*)adress, (LPVOID)ValueToWrite.c_str(), BytesToWrite, 0))  
	{  
		WriteProcessMemory(hProc, (void*)adress, (LPCVOID)ValueToWrite.c_str(), BytesToWrite, 0);  
	}  
	else  
	{  
		cout << "Invalid adress.";  
		return -1;  
	}  
}  

I tried to ReadProcessMemory after PID that program could to check about process strings. I had an idea to "if person will enter adress and it will be check by ReadProcessMemory and it will not invalid adress => WriteProcessMemory (i wanted to change by this function all string and it will be change it).
Maybe i should to add some functions. Can you help me with this and tell me what to do?
I recently started to learn about process memory so don't be so angry for me

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Minxin Yu 13,516 Reputation points Microsoft External Staff
    2023-01-06T07:04:16.1+00:00

    Hi, @Vadym Sydorchuk

    You could refer to the similar thread's answer.

    you have to fill the difference in character length with \0.

    It is not recommended that writing string into memory.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.