// lab2Dlg.cpp : implementation file // #include "stdafx.h" #include "lab2.h" #include "lab2Dlg.h" #include "lab2lib.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // Clab2Dlg dialog Clab2Dlg::Clab2Dlg(CWnd* pParent /*=NULL*/) : CDialog(Clab2Dlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void Clab2Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_BUTTON1, m_przycisk1); DDX_Control(pDX, IDC_BUTTON2, m_przycisk2); DDX_Control(pDX, IDC_BUTTON3, m_przycisk3); DDX_Control(pDX, IDC_EDIT1, m_ekran); DDX_Control(pDX, IDC_EDIT2, m_proces); DDX_Control(pDX, IDC_EDIT3, m_strona); } BEGIN_MESSAGE_MAP(Clab2Dlg, CDialog) ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3) ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1) ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2) END_MESSAGE_MAP() // Clab2Dlg message handlers BOOL Clab2Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void Clab2Dlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR Clab2Dlg::OnQueryDragIcon() { return static_cast(m_hIcon); } void Clab2Dlg::OnBnClickedButton1() { // TODO: Add your control notification handler code here // TODO: Obsługa przycisku "Do odczytu" HANDLE hProces; DWORD n; char *s; DWORD id; CString str,str2; DWORD adres; m_proces.GetWindowText(str); sscanf((const char *)str,"%i", &id); m_strona.GetWindowText(str2); sscanf((const char *)str2,"%i", &adres); hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id); VirtualProtectEx(hProces,(void *)adres,4095,PAGE_READONLY,&n); CloseHandle(hProces); } void Clab2Dlg::OnBnClickedButton2() { // TODO: Add your control notification handler code here // TODO: Obsługa przycisku "Brak dostępu" HANDLE hProces; DWORD n; char *s; DWORD id; CString str,str2; DWORD adres; m_proces.GetWindowText(str); sscanf((const char *)str,"%i", &id); m_strona.GetWindowText(str2); sscanf((const char *)str2,"%i", &adres); hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id); VirtualProtectEx(hProces,(void *)adres,4095,PAGE_NOACCESS,&n); CloseHandle(hProces); } void Clab2Dlg::OnBnClickedButton3() { // TODO: Add your control notification handler code here // TODO: Obsługa przycisku "Wyświetl" HANDLE hProces; unsigned int n; DWORD id; char *s; n = 0; CString str; m_proces.GetWindowText(str); sscanf((const char *)str,"%i", &id); hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id); ShowVMem(hProces,0,&n); s = (char *)malloc(n); ShowVMem(hProces,s,&n); m_ekran.SetWindowText(s); free(s); CloseHandle(hProces); }