I have the following situation, the user must enter a memory address:
(I'M USING THIS METHOD, IT MAY NOT BE CORRECT FOR THE FOLLOWING SITUATION)
std::string TEMP_MEMORY_ADDRESS;
std::string MEMORY_ADDRESS = "0x";
std::cout << "Digite o endereco de Memoria: ";
std::getline(std::cin, TEMP_MEMORY_ADDRESS);
MEMORY_ADDRESS.append(TEMP_MEMORY_ADDRESS);
Beauty, we now have the memory address requested by the user and in Hexadecimal, the problem is: I have to throw this address in the WriteProcessMemory () function, and according to MICROSOFT this address must be in the following parameters:
BOOL WINAPI WriteProcessMemory(
_In_ HANDLE hProcess,
_In_ LPVOID lpBaseAddress,
_In_ LPCVOID lpBuffer,
_In_ SIZE_T nSize,
_Out_ SIZE_T *lpNumberOfBytesWritten
);
lpBaseAddress [in] = A pointer to the base address in the specified process where data is written
In this question, my question goes only to LPVOID lpBaseAddress which is where we need to embed the memory address entered by the user, and that's where my problem comes in: The method I am using is not working when I play the string in lpBaseAddress.
EXAMPLE:
int isSuccessful = WriteProcessMemory(hproc, (LPVOID)MEMORY_ADDRESS.c_str(), &NewValue, (DWORD)sizeof(NewValue), NULL);
Trying to play in the data output what I had in (LPVOID) MEMORY_ADDRESS.c_str () I noticed that it had a random value, and it was not exactly the address I had provided.
It seems like a silly question, but I'm having difficulty in how I should provide the exact value of the memory address for the WriteProcessMemory () function