Как я могу использовать cin для записи processmemory?
#include <windows.h> #include <iostream> #include "stdafx.h" #include <stdio.h> #include <tchar.h> #include <psapi.h> #include <string> #include <cstring> #include <stdio.h> using namespace std; int main(){ string Direction, a="exit", b="Exit"; string Address1="008FF790",Var1="008FF790", Address2="00C20F50", Var2="00C20F50", Addon="0x"; cout<<"Enter Memory Address #1"; ----> getline(cin, Address1); if(Address1.empty()){Address1= Address1+Var1;} cout<<"Enter Memory Address #2"; ----> getline(cin, Address2); if(Address2.empty()){Address2= Address2+Var2;} Address1= Addon+Address1; Address2= Addon+Address2; cout<<"Working on "<<Address1<<" and "<<Address2<<endl; DWORD pId; int newValue = 5; HWND wind= FindWindow(NULL, "Hitleap Viewer 3.1.29 | jacobglaw | 184.218.62.87"); if(wind == NULL){ cerr<< "Cannot find window"; }else{ GetWindowThreadProcessId(wind, &pId); HANDLE proc= OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId); if(!proc){ cerr<< "Cannot open proccess."; }else{ while(true){ cout<<"Enter exit to quit. Otherwise press enter to continue."<<endl; getline(cin, Direction);LPVOID lpBuffer1 = (LPVOID)Address1.c_str(); LPVOID lpBuffer3 = (LPVOID)Address2.c_str(); while(Direction.compare(a)==0 & Direction.compare(b)==0){ break; } int isSuccessful= ----> WriteProcessMemory (proc, (LPVOID)(Address1), &newValue, (DWORD)sizeof(newValue), NULL); ----> WriteProcessMemory (proc, (LPVOID)(Address2), &newValue, (DWORD)sizeof(newValue), NULL); if(isSuccessful>0){clog<<"Memory written."<<endl; } else { cerr<<"Unable to write to memory"; } ; } }CloseHandle(proc);} }
Что я уже пробовал:
#include <windows.h> #include <iostream> #include "stdafx.h" #include <stdio.h> #include <tchar.h> #include <psapi.h> #include <string> #include <cstring> #include <stdio.h> using namespace std; int main() { string Direction, a="exit", b="Exit"; string Address1="008FF790",Var1="008FF790", Address2="00C20F50", Var2="00C20F50", Addon="0x"; cout<<"Enter Memory Address #1"; ----> getline(cin, Address1); if(Address1.empty()) { Address1 = Address1 + Var1; } cout<<"Enter Memory Address #2"; ----> getline(cin, Address2); if(Address2.empty()) { Address2 = Address2 + Var2; } Address1 = Addon + Address1; Address2 = Addon + Address2; cout<<"Working on "<<Address1<<" and "<<Address2<<endl; DWORD pId; int newValue = 5; HWND wind= FindWindow(NULL, "Hitleap Viewer 3.1.29 | jacobglaw | 184.218.62.87"); if(wind == NULL) { cerr<< "Cannot find window"; } else { GetWindowThreadProcessId(wind, &pId); HANDLE proc= OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId); if(!proc) { cerr<< "Cannot open proccess."; } else { while(true) { cout<<"Enter exit to quit. Otherwise press enter to continue."<<endl; getline(cin, Direction); LPVOID lpBuffer1 = (LPVOID)Address1.c_str(); LPVOID lpBuffer3 = (LPVOID)Address2.c_str(); while(Direction.compare(a)==0 & Direction.compare(b)==0) { break; } ----> int isSuccessful1 = WriteProcessMemory( proc, (LPVOID) Address1), &newValue, (DWORD)sizeof(newValue), NULL); ----> int isSuccessful2 = WriteProcessMemory( proc, (LPVOID)(Address2), &newValue, (DWORD)sizeof(newValue), NULL ); if( isSuccessful1 > 0 ) { clog<<"Memory written."<<endl; } else { cerr<<"Unable to write to memory"; } ; // ??? } } CloseHandle(proc); } }
Richard MacCutchan
Вы не можете использовать приведение для преобразования строки в числовое значение. Вы должны использовать метод преобразования.