Click here to Skip to main content
15,886,664 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: why segmentation fault ! Pin
wbgxx29-Jun-10 7:46
wbgxx29-Jun-10 7:46 
GeneralRe: why segmentation fault ! Pin
Aescleal29-Jun-10 8:53
Aescleal29-Jun-10 8:53 
AnswerRe: why segmentation fault ! Pin
Niklas L29-Jun-10 8:37
Niklas L29-Jun-10 8:37 
QuestionSysListView32 help needed Pin
iceeeeman29-Jun-10 7:02
iceeeeman29-Jun-10 7:02 
QuestionRe: SysListView32 help needed Pin
David Crow29-Jun-10 7:16
David Crow29-Jun-10 7:16 
AnswerRe: SysListView32 help needed Pin
iceeeeman29-Jun-10 7:28
iceeeeman29-Jun-10 7:28 
GeneralRe: SysListView32 help needed Pin
Luc Pattyn29-Jun-10 7:50
sitebuilderLuc Pattyn29-Jun-10 7:50 
GeneralRe: SysListView32 help needed Pin
iceeeeman29-Jun-10 7:57
iceeeeman29-Jun-10 7:57 
Already using ReadProcessMemory, here's the code (source: Stealing Program's Memory[^])

#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>

int main(void) {
 HWND hwnd=FindWindow(NULL, "Stealing Program's Memory: ListView");
 HWND listview=FindWindowEx(hwnd, NULL, "SysListView32", NULL);

 int count=(int)SendMessage(listview, LVM_GETITEMCOUNT, 0, 0);
 int i;

 LVITEM lvi, *_lvi;
 char item[512], subitem[512];
 char *_item, *_subitem;
 unsigned long pid;
 HANDLE process;

 GetWindowThreadProcessId(listview, &pid);
 process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|
                     PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);

 _lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM),
                              MEM_COMMIT, PAGE_READWRITE);
 _item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
                             PAGE_READWRITE);
 _subitem=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
                                PAGE_READWRITE);

 lvi.cchTextMax=512;

 for(i=0; i<count; i++) {
  lvi.iSubItem=0;
  lvi.pszText=_item;
  WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
  SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)_lvi);

  lvi.iSubItem=1;
  lvi.pszText=_subitem;
  WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
  SendMessage(listview, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)_lvi);

  ReadProcessMemory(process, _item, item, 512, NULL);
  ReadProcessMemory(process, _subitem, subitem, 512, NULL);

  printf("%s - %s\n", item, subitem);
 }

 VirtualFreeEx(process, _lvi, 0, MEM_RELEASE);
 VirtualFreeEx(process, _item, 0, MEM_RELEASE);
 VirtualFreeEx(process, _subitem, 0, MEM_RELEASE);

 return 0;
}


Its working fine for the demo application, I used create a from in VB and used it, it worked there fine too, but not sure what's causing it to show null values for one the application that has AFX window !!
QuestionRe: SysListView32 help needed Pin
David Crow29-Jun-10 8:02
David Crow29-Jun-10 8:02 
AnswerRe: SysListView32 help needed Pin
iceeeeman29-Jun-10 8:06
iceeeeman29-Jun-10 8:06 
AnswerRe: SysListView32 help needed Pin
Luc Pattyn29-Jun-10 8:12
sitebuilderLuc Pattyn29-Jun-10 8:12 
AnswerRe: SysListView32 help needed Pin
David Crow29-Jun-10 8:18
David Crow29-Jun-10 8:18 
AnswerRe: SysListView32 help needed Pin
iceeeeman29-Jun-10 8:09
iceeeeman29-Jun-10 8:09 
AnswerRe: SysListView32 help needed Pin
iceeeeman29-Jun-10 20:16
iceeeeman29-Jun-10 20:16 
GeneralRe: SysListView32 help needed Pin
David Crow30-Jun-10 3:08
David Crow30-Jun-10 3:08 
GeneralRe: SysListView32 help needed Pin
iceeeeman30-Jun-10 3:49
iceeeeman30-Jun-10 3:49 
QuestionHow i can Save Cimage file+ shapes & text on it? Pin
humais29-Jun-10 5:51
humais29-Jun-10 5:51 
AnswerRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany29-Jun-10 8:13
Alan Balkany29-Jun-10 8:13 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais29-Jun-10 8:30
humais29-Jun-10 8:30 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany29-Jun-10 8:38
Alan Balkany29-Jun-10 8:38 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais29-Jun-10 8:47
humais29-Jun-10 8:47 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany29-Jun-10 9:45
Alan Balkany29-Jun-10 9:45 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais30-Jun-10 4:52
humais30-Jun-10 4:52 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany1-Jul-10 5:59
Alan Balkany1-Jul-10 5:59 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais1-Jul-10 19:38
humais1-Jul-10 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.