![]() |
Я тренируюсь взаимойдествовать с памятью,и я полный 0 в этом всем. По этому тренируюсь и учусь вместе с ИИШкой. У меня получился вот такой вот код.
C++: [CODE] #include #include #include #include #include uintptr_t GetModuleBaseAddress ( DWORD procId , const wchar_t * modName ) { uintptr_t modBaseAddr = 0 ; HANDLE hSnap = CreateToolhelp32Snapshot ( TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32 , procId ) ; if ( hSnap != INVALID_HANDLE_VALUE ) { MODULEENTRY32 modEntry ; modEntry . dwSize = sizeof ( modEntry ) ; if ( Module32First ( hSnap , & modEntry ) ) { do { if ( ! _wcsicmp ( modEntry . szModule , modName ) ) { modBaseAddr = ( uintptr_t ) modEntry . modBaseAddr ; break ; } } while ( Module32Next ( hSnap , & modEntry ) ) ; } } CloseHandle ( hSnap ) ; return modBaseAddr ; } int main ( ) { _setmode ( _fileno ( stdout ) , _O_U16TEXT ) ; while ( true ) { HWND hNotepad = FindWindow ( L "Notepad" , NULL ) ; if ( hNotepad ) { DWORD pid ; // we creating variable for process id GetWindowThreadProcessId ( hNotepad , & pid ) ; // we getting process id of notepad //Open the process with all access rights //PROCESS_ALL_ACCESS is a constant that gives us all possible access rights to the process HANDLE hProcess = OpenProcess ( PROCESS_ALL_ACCESS , FALSE , pid ) ; if ( hProcess ) { system ( "cls" ) ; // we clear console every time we read memory, you can remove this if you want //add reading and writing memory here if you want uintptr_t baseModule = GetModuleBaseAddress ( pid , L "textinputframework.dll" ) ; uintptr_t address = baseModule + 0xE8400 ; wchar_t buffer [ 128 ] = { 0 } ; // here we download 16 bytes of memory from notepad, you can change it to whatever you want ReadProcessMemory ( hProcess , ( LPCVOID ) address , buffer , sizeof ( buffer ) , NULL ) ; // we read memory from notepad and save it in buffer variable RECT rect ; GetWindowRect ( hNotepad , & rect ) ; int width = rect . right - rect . left ; int height = rect . bottom - rect . top ; std :: wcout Можете дать какие то советы или еще что то? Буду очень благодарен |
Не используй deprecated функции (начинающиеся с _) а так же system().
Вместо Sleep: #include #include std::this_thread::sleep_for(std::chrono::milliseco nds(500)); +можешь делать дефайны на адреса, чтобы код лучше читался |
| Время: 19:29 |