Click here to Skip to main content
15,914,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Log-in event Pin
Green Fuze19-Oct-08 22:26
Green Fuze19-Oct-08 22:26 
GeneralRe: Log-in event Pin
Mark Salsbery20-Oct-08 6:00
Mark Salsbery20-Oct-08 6:00 
QuestionCreate a C program in Visual Studio 2005 Pin
bigdenny20019-Oct-08 0:53
bigdenny20019-Oct-08 0:53 
AnswerRe: Create a C program in Visual Studio 2005 [modified] Pin
Perspx19-Oct-08 1:00
Perspx19-Oct-08 1:00 
AnswerRe: Create a C program in Visual Studio 2005 Pin
Mike Dimmick19-Oct-08 1:07
Mike Dimmick19-Oct-08 1:07 
QuestionHow to resize column in CDatagrid Pin
Max++18-Oct-08 21:47
Max++18-Oct-08 21:47 
QuestionHow to save a process's state and resume it later Pin
susandy18-Oct-08 17:08
susandy18-Oct-08 17:08 
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 

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.