21 September, 2011

[Advanced]Editing desktop icons text

So here is what i got (code not 100% mine):
Code:
int main()
{
    HWND task;
    task = FindWindow(NULL, TEXT("Program Manager"));
    task = FindWindowEx(task, NULL, TEXT("SHELLDLL_DefView"), NULL);
    task = FindWindowEx(task, NULL, NULL, TEXT("FolderView"));

    int count=(int)SendMessage(task, LVM_GETITEMCOUNT, 0, 0);
    int i;

    LVITEM lvi, *_lvi;
    char item[512], *_item;

    unsigned long pid;
    HANDLE process;

    GetWindowThreadProcessId(task, &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);

    lvi.iSubItem=0;
    lvi.pszText=_item;

    for(i=0; i<count; i++)
    {
        strcpy(item, "Hacked by zoro59");
        lvi.cchTextMax=NULL;
        WriteProcessMemory(process, _item, &item, sizeof(char[512]), NULL);       
        WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
        SendMessage(task, LVM_SETITEMTEXT, (WPARAM)i, (LPARAM)_lvi);

        lvi.cchTextMax=512;
        WriteProcessMemory(process, _lvi, &lvi, sizeof(LVITEM), NULL);
        SendMessage(task, LVM_GETITEMTEXT, (WPARAM)i, (LPARAM)_lvi);
        ReadProcessMemory(process, _item, item, 512, NULL);

        printf("%s\n", item);
    }

    VirtualFreeEx(process, _lvi, 0, MEM_RELEASE);
    VirtualFreeEx(process, _item, 0, MEM_RELEASE);

    return 0;

}
This section works great when it has to read the data, but fails to change it. Things i've tried: adding MEM_RESERVE flag, using lvi.pszText = "smth", writing the data directly into "process", without using another variable, but it all failed.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home