SHARE
TWEET

Untitled

a guest Oct 21st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  
  103. }
  104.  
  105. void Clab2Dlg::OnBnClickedButton2()
  106. {
  107.     // TODO: Add your control notification handler code here
  108.     // TODO: Obsługa przycisku "Brak dostępu"
  109.  
  110. }
  111.  
  112. void Clab2Dlg::OnBnClickedButton3()
  113. {
  114.     DWORD  id;  //identyfikator procesu
  115. CString str;
  116. m_proces.GetWindowText(str);
  117. sscanf((const char *)str,
  118. "%i", &id);
  119. //m_przycisk3.SetWindowText(str);
  120. //m_ekran.SetWindowText();
  121.  
  122.  
  123. HANDLE hProces;  
  124. hProces = OpenProcess(PROCESS_ALL_ACCESS,0,id);
  125.  
  126. unsigned int  n;
  127. char *s;
  128. n = 0;
  129. ShowVMem(hProces,0,&n);
  130. s = (char *)malloc(n);
  131. ShowVMem(hProces,s,&n);
  132. m_ekran.SetWindowText(s);
  133. free(s);
  134.  
  135. CloseHandle(hProces);
  136.     // TODO: Add your control notification handler code here
  137.     // TODO: Obsługa przycisku "Wyświetl"
  138.  
  139. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top