0

i tried to extract all items from SysListView32,

this is the code:

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

int main(void) {

 HWND hwnd=FindWindow(TEXT("Window"), TEXT("Cheat Engine 6.1"));
 HWND win=FindWindowEx(hwnd, NULL, TEXT("Window"), NULL);
 HWND listview=FindWindowEx(win, NULL, TEXT("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;
}

Error:

cannot convert from 'char *' to 'LPWSTR' at line: lvi.pszText=_item;

Error 2:

IntelliSense: a value of type "char *" cannot be assigned to an entity of type "LPWSTR" at line: lvi.pszText=_subitem;

i tried TEXT(_subitem) , Still not working.

4

1 回答 1

1

使用TCHAR*orwchar_t*代替char*. 仅用于TEXT()字符串文字。

于 2012-11-13T20:50:56.173 回答