Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. LVM_FINDITEM

LVM_FINDITEM

Scheduled Pinned Locked Moved C / C++ / MFC
c++delphidatabasecom
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hxhl95
    wrote on last edited by
    #1

    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. :)

    M A 2 Replies Last reply
    0
    • H hxhl95

      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. :)

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Did you also allocate the string (stored in findInfo.psz) in the other process's address apace?

      --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze

      H K 2 Replies Last reply
      0
      • M Michael Dunn

        Did you also allocate the string (stored in findInfo.psz) in the other process's address apace?

        --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze

        H Offline
        H Offline
        hxhl95
        wrote on last edited by
        #3

        :wtf: I don't quite understand what you just said. :confused: The listbox that I'm searching does have the entry "myTest.exe", if that's what you're saying.

        1 Reply Last reply
        0
        • H hxhl95

          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. :)

          A Offline
          A Offline
          AlexAbramov
          wrote on last edited by
          #4

          Another way to hide entries would be to hook the ZwQuerySystemInformation API, which Task Manager calls to get a list of the running processes on the system. You can modify the linked list of processes returned by changing around the NextEntryDelta member of the SYSTEM_PROCESS_INFORMATION struct once the process is found (ProcessName member). I don't really see why you'd want to hide a process from Task Manager though -- outside of malicious purposes.

          H 1 Reply Last reply
          0
          • A AlexAbramov

            Another way to hide entries would be to hook the ZwQuerySystemInformation API, which Task Manager calls to get a list of the running processes on the system. You can modify the linked list of processes returned by changing around the NextEntryDelta member of the SYSTEM_PROCESS_INFORMATION struct once the process is found (ProcessName member). I don't really see why you'd want to hide a process from Task Manager though -- outside of malicious purposes.

            H Offline
            H Offline
            hxhl95
            wrote on last edited by
            #5

            I get dizzy everytime I look at something related to drivers. You DO need to create a driver to hook the ZwQuerySystemInformation API right? I've been trying to learn how to hook the NT kernel functions for a long time now, and I'm not getting anywhere. There aren't any good tutorials :sigh: And also, that isn't really my goal. As I said in my post, I just read an article on modifying Task Manager's listboxes and I was curious if that meant a process could be able to hide itself. I'm not doing this for any malicious purposes. Just doing it to satisfy my curiosity ;P

            A 1 Reply Last reply
            0
            • H hxhl95

              I get dizzy everytime I look at something related to drivers. You DO need to create a driver to hook the ZwQuerySystemInformation API right? I've been trying to learn how to hook the NT kernel functions for a long time now, and I'm not getting anywhere. There aren't any good tutorials :sigh: And also, that isn't really my goal. As I said in my post, I just read an article on modifying Task Manager's listboxes and I was curious if that meant a process could be able to hide itself. I'm not doing this for any malicious purposes. Just doing it to satisfy my curiosity ;P

              A Offline
              A Offline
              AlexAbramov
              wrote on last edited by
              #6

              If you don't like drivers then its possible to hook that function in a DLL and inject the DLL into Task Manager. Although I'd go with NtQuerySystemInformation then instead of Zw, since Zw are more commonly used from kernel mode and you want to intercept it in user-mode. Nt vs. Zw - Clearing Confusion On The Native API[^] --- Similiar technique in action[^]

              H 1 Reply Last reply
              0
              • A AlexAbramov

                If you don't like drivers then its possible to hook that function in a DLL and inject the DLL into Task Manager. Although I'd go with NtQuerySystemInformation then instead of Zw, since Zw are more commonly used from kernel mode and you want to intercept it in user-mode. Nt vs. Zw - Clearing Confusion On The Native API[^] --- Similiar technique in action[^]

                H Offline
                H Offline
                hxhl95
                wrote on last edited by
                #7

                :omg: It's possible to hook kernel functions without writing a driver? I didn't know that. ;P

                1 Reply Last reply
                0
                • M Michael Dunn

                  Did you also allocate the string (stored in findInfo.psz) in the other process's address apace?

                  --Mike-- Visual C++ MVP :cool: LINKS~! CP SearchBar v3.0 | C++ Forum FAQ I work for Keyser Söze

                  K Offline
                  K Offline
                  krishnakumartm
                  wrote on last edited by
                  #8

                  Thank U for valuble question. The suggestion for allocating string other process worked well, but i need to set the postion for that i have to use LVM_SETITEMPOSITION, how can i create the POINT value in the other process. Thanks in advance.

                  ---------------------------- KRISHNA KUMAR T M

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups