Passing address to Writeprocessmemory

Asked

Viewed 79 times

1

I’m trying to pass a memory address to WriteProcessMemory(), only that this address should be typed by the user, I am in doubt of how I can do this, I tried with strings, wstring, did not succeed.

int isSuccessful = WriteProcessMemory(hproc, /*VALOR DIGITADO PELO USUARIO(LPVOID)0x002bf55c*/, &NewValue, (DWORD)sizeof(NewValue), NULL);
  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

1 answer

3

Are you sure you want to do this? It seems that you are wanting to do something very advanced and dangerous and are having a very basic doubt. This combination doesn’t usually work.

Does the application have write permission in this area of memory? Luckily the operating system controls this and thankfully it does not let the application write anywhere in the memory. You cannot write in other applications and not even in certain parts of your own application.

The variables used were correctly arrows? I will consider that yes, after all you did not put all part of the program and should consider that there is a problem just on this line.

So just read one whole and use it as pointer as you were already trying to do. Probably the problem is that you were reading a string.

int endereco;
scanf("%d", &endereco);
int isSuccessful = WriteProcessMemory(hproc, (LPVOID)endereco, &NewValue, (DWORD)sizeof(NewValue), NULL);

I put in the Github for future reference.

  • more and the hexa ?

  • 0xENDERION, does not pass as string?

  • I already tried to do it this way also that you passed. the address has characters, I was in doubt now. ex: 0x002BF55C

  • or, I don’t need to pass it as hexadecimal?

  • So your problem is another, you need a converter string in hexadecimal format for an integer number to use somewhere, no matter the place. What you asked I answered. If you still need to know how to do the converter see if you have not answered on website. If you don’t ask a question asking it.

  • when I use the following (LPVOID)0x002bf55c, it works but having to keep compiling the code and exchanging this value all the time is pretty boring, so I’m trying to do it in a way where I can provide this value during the program

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.