Click here to Skip to main content
15,900,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to save a process's state and resume it later Pin
Cedric Moonen18-Oct-08 23:56
Cedric Moonen18-Oct-08 23:56 
QuestionPathFileExists() and GetFileAttributes() both hang when a network path doesn't exist. Pin
TragicComic18-Oct-08 13:00
TragicComic18-Oct-08 13:00 
AnswerRe: PathFileExists() and GetFileAttributes() both hang when a network path doesn't exist. Pin
David Crow18-Oct-08 13:50
David Crow18-Oct-08 13:50 
Questionhow to change "file alignemnt" in the PE file format? Pin
Joseph Marzbani18-Oct-08 7:46
Joseph Marzbani18-Oct-08 7:46 
AnswerRe: how to change "file alignemnt" in the PE file format? Pin
Mark Salsbery18-Oct-08 8:52
Mark Salsbery18-Oct-08 8:52 
AnswerRe: how to change "file alignemnt" in the PE file format? Pin
Mike Dimmick19-Oct-08 1:17
Mike Dimmick19-Oct-08 1:17 
GeneralRe: how to change "file alignemnt" in the PE file format? Pin
Joseph Marzbani21-Oct-08 3:27
Joseph Marzbani21-Oct-08 3:27 
QuestionLVM_FINDITEM Pin
hxhl9518-Oct-08 5:53
hxhl9518-Oct-08 5:53 
I just read this article: http://www.codeproject.com/KB/system/Hack_Windows_Task_Manager.aspx[^], and I thought it would be quite interesting if an app is able to modify one entry in task manager's listbox, thus hiding itself. It sounded easy enough to replace LVM_DELETECOLUMN with LVM_DELETEITEM, but I'm getting strange errors with SendMessage.

So right now I have something like this:
LVFINDINFO findInfo;
	ZeroMemory(&findInfo, sizeof(LVFINDINFO));
	findInfo.flags=LVFI_STRING;
	findInfo.psz=(LPCSTR)"myTest.exe";


Then I tried this (hWnd is for Windows Task Manager, not my app):
int index = ::SendMessage(hWnd,LVM_FINDITEM,(WPARAM)0,(LPARAM)(const LVFINDINFO FAR*)&findInfo);
				if (index!=-1) ::SendMessage(hWnd,LVM_DELETEITEM,index,0);


It crashes taskmgr.

I was browsing through the comments on that article when I found a piece of code in Delphi that supposedly does what I'm trying to do. After my attempt to translate it into C++, it looks like this:
DWORD ProcessID;
		GetWindowThreadProcessId(hWnd,&ProcessID); 
		HANDLE pHandle=OpenProcess(PROCESS_ALL_ACCESS,FALSE, ProcessID);
		if (pHandle!=NULL){
			LPVOID address=VirtualAllocEx(pHandle,NULL,sizeof(findInfo),MEM_RESERVE | MEM_COMMIT,PAGE_READWRITE);
			if (WriteProcessMemory(pHandle,address,&findInfo,sizeof(findInfo),NULL)!=FALSE){
				int index = ::SendMessage((HWND)pHandle,LVM_FINDITEM,(WPARAM)0,(LPARAM)(const LVFINDINFO FAR*)address);
				if (index!=-1) ::SendMessage(hWnd,LVM_DELETEITEM,index,0);
			}
			CloseHandle(pHandle);
			VirtualFreeEx(pHandle,NULL,sizeof(findInfo),MEM_DECOMMIT);
			
		}

Unfortunately, that doesn't work either. The LVM_FINDITEM SendMessage returns 0, so all it's doing right now is deleting the first entry off taskmgr every 10 milliseconds.

If anyone could correct me on my usage of SendMessage with LVM_FINDITEM that would be appreciated. Smile | :)
AnswerRe: LVM_FINDITEM Pin
Michael Dunn18-Oct-08 17:13
sitebuilderMichael Dunn18-Oct-08 17:13 
GeneralRe: LVM_FINDITEM Pin
hxhl9518-Oct-08 18:01
hxhl9518-Oct-08 18:01 
GeneralRe: LVM_FINDITEM Pin
krishnakumartm23-Feb-10 2:19
krishnakumartm23-Feb-10 2:19 
AnswerAnother approach Pin
AlexAbramov18-Oct-08 18:34
AlexAbramov18-Oct-08 18:34 
GeneralRe: Another approach Pin
hxhl9518-Oct-08 20:02
hxhl9518-Oct-08 20:02 
GeneralRe: Another approach Pin
AlexAbramov18-Oct-08 20:54
AlexAbramov18-Oct-08 20:54 
GeneralRe: Another approach Pin
hxhl9519-Oct-08 6:42
hxhl9519-Oct-08 6:42 
QuestionHow to Add Asterik Symbol( * ) in the Dialog Name !!!!! Pin
phanindra varma18-Oct-08 4:12
phanindra varma18-Oct-08 4:12 
AnswerRe: How to Add Asterik Symbol( * ) in the Dialog Name !!!!! Pin
Mark Salsbery18-Oct-08 9:15
Mark Salsbery18-Oct-08 9:15 
AnswerRe: How to Add Asterik Symbol( * ) in the Dialog Name !!!!! Pin
David Crow18-Oct-08 13:57
David Crow18-Oct-08 13:57 
QuestionHow to access servlet in C++? Pin
AnithaSubramani18-Oct-08 3:39
AnithaSubramani18-Oct-08 3:39 
AnswerRe: How to access servlet in C++? Pin
Moak19-Oct-08 8:43
Moak19-Oct-08 8:43 
GeneralRe: How to access servlet in C++? Pin
AnithaSubramani19-Oct-08 20:22
AnithaSubramani19-Oct-08 20:22 
GeneralRe: How to access servlet in C++? Pin
David Crow2-Dec-08 3:27
David Crow2-Dec-08 3:27 
Questionstoring the largest number Pin
trioum18-Oct-08 2:33
trioum18-Oct-08 2:33 
AnswerRe: storing the largest number Pin
Rajesh R Subramanian18-Oct-08 2:39
professionalRajesh R Subramanian18-Oct-08 2:39 
GeneralRe: storing the largest number Pin
trioum18-Oct-08 2:43
trioum18-Oct-08 2:43 

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.