Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. // lab2Dlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "lab2.h"
  6. #include "lab2Dlg.h"
  7. #include "lab2lib.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #endif
  12.  
  13.  
  14. // Clab2Dlg dialog
  15.  
  16.  
  17.  
  18. Clab2Dlg::Clab2Dlg(CWnd* pParent /*=NULL*/)
  19. : CDialog(Clab2Dlg::IDD, pParent)
  20. {
  21. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  22. }
  23.  
  24. void Clab2Dlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. DDX_Control(pDX, IDC_BUTTON1, m_przycisk1);
  28. DDX_Control(pDX, IDC_BUTTON2, m_przycisk2);
  29. DDX_Control(pDX, IDC_BUTTON3, m_przycisk3);
  30. DDX_Control(pDX, IDC_EDIT1, m_ekran);
  31. DDX_Control(pDX, IDC_EDIT2, m_proces);
  32. DDX_Control(pDX, IDC_EDIT3, m_strona);
  33. }
  34.  
  35. BEGIN_MESSAGE_MAP(Clab2Dlg, CDialog)
  36. ON_WM_PAINT()
  37. ON_WM_QUERYDRAGICON()
  38. //}}AFX_MSG_MAP
  39. ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
  40. ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
  41. ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
  42. END_MESSAGE_MAP()
  43.  
  44.  
  45. // Clab2Dlg message handlers
  46.  
  47. BOOL Clab2Dlg::OnInitDialog()
  48. {
  49. CDialog::OnInitDialog();
  50.  
  51. // Set the icon for this dialog. The framework does this automatically
  52. // when the application's main window is not a dialog
  53. SetIcon(m_hIcon, TRUE); // Set big icon
  54. SetIcon(m_hIcon, FALSE); // Set small icon
  55.  
  56. // TODO: Add extra initialization here
  57.  
  58. return TRUE; // return TRUE unless you set the focus to a control
  59. }
  60.  
  61. // If you add a minimize button to your dialog, you will need the code below
  62. // to draw the icon. For MFC applications using the document/view model,
  63. // this is automatically done for you by the framework.
  64.  
  65. void Clab2Dlg::OnPaint()
  66. {
  67. if (IsIconic())
  68. {
  69. CPaintDC dc(this); // device context for painting
  70.  
  71. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  72.  
  73. // Center icon in client rectangle
  74. int cxIcon = GetSystemMetrics(SM_CXICON);
  75. int cyIcon = GetSystemMetrics(SM_CYICON);
  76. CRect rect;
  77. GetClientRect(&rect);
  78. int x = (rect.Width() - cxIcon + 1) / 2;
  79. int y = (rect.Height() - cyIcon + 1) / 2;
  80.  
  81. // Draw the icon
  82. dc.DrawIcon(x, y, m_hIcon);
  83. }
  84. else
  85. {
  86. CDialog::OnPaint();
  87. }
  88. }
  89.  
  90. // The system calls this function to obtain the cursor to display while the user drags
  91. // the minimized window.
  92. HCURSOR Clab2Dlg::OnQueryDragIcon()
  93. {
  94. return static_cast<HCURSOR>(m_hIcon);
  95. }
  96.  
  97.  
  98. void Clab2Dlg::OnBnClickedButton1()
  99. {
  100. // TODO: Add your control notification handler code here
  101. // TODO: Obsługa przycisku "Do odczytu"
  102. DWORD id;
  103. CString str;
  104.  
  105. m_proces.GetWindowText(str);
  106. sscanf((const char *)str,"%i",&id);
  107.  
  108. void *adres;
  109. m_strona.GetWindowText(str);
  110. sscanf((const char *)str,"%i",&adres);
  111.  
  112.  
  113.  
  114.  
  115.  
  116. HANDLE hProces;
  117. DWORD n;
  118. hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id);
  119.  
  120. VirtualProtectEx(hProces,adres,4095,PAGE_READONLY,&n);
  121.  
  122. CloseHandle(hProces);
  123.  
  124.  
  125.  
  126.  
  127. }
  128.  
  129. void Clab2Dlg::OnBnClickedButton2()
  130. {
  131. // TODO: Add your control notification handler code here
  132. // TODO: Obsługa przycisku "Brak dostępu"
  133.  
  134. DWORD id;
  135. CString str;
  136.  
  137. m_proces.GetWindowText(str);
  138. sscanf((const char *)str,"%i",&id);
  139.  
  140. void *adres;
  141. m_strona.GetWindowText(str);
  142. sscanf((const char *)str,"%i",&adres);
  143.  
  144.  
  145.  
  146.  
  147.  
  148. HANDLE hProces;
  149. DWORD n;
  150. hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id);
  151.  
  152. VirtualProtectEx(hProces,adres,4095,PAGE_NOACCESS,&n);
  153.  
  154. CloseHandle(hProces);
  155.  
  156.  
  157.  
  158.  
  159.  
  160. }
  161.  
  162. void Clab2Dlg::OnBnClickedButton3()
  163. {
  164. // TODO: Add your control notification handler code here
  165. // TODO: Obsługa przycisku "Wyświetl"
  166.  
  167. DWORD id;
  168. CString str;
  169.  
  170. m_proces.GetWindowText(str);
  171. sscanf((const char *)str,"%i",&id);
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. HANDLE hProces;
  179. //DWORD id;
  180.  
  181. hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id);
  182. unsigned int n;
  183. char *s;
  184.  
  185. n=0;
  186. ShowVMem(hProces,0,&n);
  187. s=(char *)malloc(n);
  188. ShowVMem(hProces,s,&n);
  189. m_ekran.SetWindowText(s);
  190. free(s);
  191.  
  192.  
  193.  
  194. CloseHandle(hProces);
  195.  
  196.  
  197.  
  198.  
  199.  
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement