挖井

类库大魔王的挖井日记

挖一口属于自己的井


编程读取其它进程中ListView的内容

void __fastcall TMainForm::GetListViewContent()
{
        //TODO: Add your source code here
    //*
    int nColumnCount;
    int nItemCount;
    int i,j;
    char chBuffer[1024];
    DWORD dwProcessID;
    HANDLE hProcess;
    void * Pointer;
    SIZE_T nNumberOfBytesRead;
    AnsiString s;
    TLVItem Item;
    void * lpItem;

    nColumnCount = Header_GetItemCount(ListView_GetHeader(hWindow));
    //if(nColumnCount <= 0) return;    
    //这一行不能加,不然在第一次读取非REPORT风格的内容时,会返回
    nItemCount = ListView_GetItemCount(hWindow);
    GetWindowThreadProcessId(hWindow, &dwProcessID);
    hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE,
                    false,
                    dwProcessID);
    Pointer = VirtualAllocEx(hProcess,
                            NULL,
                            1024,
                            MEM_RESERVE | MEM_COMMIT,
                            PAGE_READWRITE);
    lpItem = VirtualAllocEx(hProcess,
                            NULL,
                            sizeof(TLVItem),
                            MEM_RESERVE | MEM_COMMIT,
                            PAGE_READWRITE);
    try
    {
    for(i= 0 ; i < nItemCount ; ++i)
    {
      s = "";
      for(j=0; j <=nColumnCount; ++j)
      {
       ZeroMemory(chBuffer, sizeof(chBuffer)*sizeof(char));
       WriteProcessMemory(hProcess,
                    Pointer,
                    chBuffer,
                    sizeof(chBuffer)*sizeof(char),
                    &nNumberOfBytesRead);
       Item.mask = LVIF_TEXT;
       Item.iItem = i;
       Item.iSubItem = j;
       Item.cchTextMax = sizeof(chBuffer);
       Item.pszText = (LPSTR)Pointer;
       nNumberOfBytesRead = 0;
       WriteProcessMemory(hProcess,
                    lpItem,
                    (LPVOID)&Item,
                    sizeof(TLVItem),
                    (LPDWORD)&nNumberOfBytesRead);
       SendMessage(hWindow, LVM_GETITEMTEXT, i, (LPARAM)lpItem);
       ReadProcessMemory(hProcess,
                    (void *)Pointer,
                    chBuffer,
                    sizeof(chBuffer),
                    &nNumberOfBytesRead);      
       s += chBuffer;
       s +="\t";
      }
      ContentMemo->Lines->Add(s);
    }//for(i...
    }//try
    __finally
    {
      VirtualFreeEx(hProcess,
                    Pointer,
                    0,
                    MEM_RELEASE);
      VirtualFreeEx(hProcess,
                    lpItem,
                    0,
                    MEM_RELEASE);
      CloseHandle(hProcess);
    }
}

本文地址:

https://minidump.info/blog/2005/02/E7-BC-96-E7-A8-8B-E8-AF-BB-E5-8F-96-E5-85-B6-E5-AE-83-E8-BF-9B-E7-A8-8B-E4-B8-ADListView-E7-9A-84-E5-86-85-E5-AE-B9/

感觉本文不错,不妨小额鼓励我一下!
上一篇

LLYF ProcessHelper增强及LLYF Spy开始

在CSDN的论坛上看到一些老较经典的帖子,就把代码用在自己的程序里了,给LLYF ProcessHelper 添加了一个特性,就是显示进程的完整命令行,真是个有意思的功能。不过,之后,发现VCLSkin 太不稳定了,要出错,也许是用的crack 的原因吧,索性就不用VCLSkin 了,这样程序...…

imported from CSDN 全文阅读
下一篇

编程读取其它进程中StatusBar的内容

void __fastcall TMainForm::GetStatusBarContent(){ //TODO: Add your source code here int nItemCount; int i; char chBuffer[256]; D...…

imported from CSDN 全文阅读