Home > Software engineering >  How can I get across processes for listctrl title bar?
How can I get across processes for listctrl title bar?

Time:10-21

I can across processes listctrl rows and columns, all of the content, but can't obtain the content of the title bar, ace to know?

The following code can obtain Listctrl content of cells, but the Header I written, is not.

 WriteProcessMemory (hProcess, pHeaderItem, & amp; HeaderItem, sizeof (HDITEM), NULL); 
: : SendMessage (pHeaderCtrl - & gt; GetSafeHwnd (), LVM_GETITEMTEXT, 0, (LPARAM) pHeaderItem);
ReadProcessMemory (hProcess, pItem ItemBuf, 512, NULL);

CodePudding user response:

You look under the Debug debugging, data are allocated space? Call the above ReadxxxMemory data correct?

CodePudding user response:

BOOL the GetItem (int nPos, HDITEM * pHeaderItem) const;

CodePudding user response:

reference 1st floor VisualEleven response:
you look under the Debug debugging, data are allocated space? Call the above ReadxxxMemory data correct?


Distribution,
 pHeaderItem=(HDITEM *) VirtualAllocEx (hProcess, NULL, sizeof (HDITEM), MEM_COMMIT, PAGE_READWRITE); 
PItem=(char *) VirtualAllocEx (hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
if ((! PHeaderItem) | | (! PItem))
{
: : MessageBox (NULL, "unable to allocate memory!" , "wrong!" , NULL);
}
for (i=0; i{
HeaderItem. CchTextMax=512;
HeaderItem. PszText=pItem;
WriteProcessMemory (hProcess, pHeaderItem, & amp; HeaderItem, sizeof (HDITEM), NULL);
: : SendMessage (pHeaderCtrl - & gt; GetSafeHwnd (), LVM_GETITEMTEXT, 0, (LPARAM) pHeaderItem);
ReadProcessMemory (hProcess, pItem ItemBuf, 512, NULL);
}

//release the memory
The CloseHandle (hProcess);
VirtualFreeEx (hProcess, pHeaderItem, 0, MEM_RELEASE);
VirtualFreeEx (hProcess, pItem, 0, MEM_RELEASE);

CodePudding user response:

refer to the second floor schlafenhamster response:
BOOL the GetItem (int nPos, HDITEM * pHeaderItem) const;


Hello, this can only be used for your application, not across processes read others' dialog box

CodePudding user response:

ListCtrl title may be first to get the title bar window handle ListView_GetHeader
Then use HDM_GETITEM message read content

About the Header Controls

CodePudding user response:

Thank you upstairs, can't across processes

CodePudding user response:

 HeaderItem. Mask=HDI_TEXT; 
HeaderItem. CchTextMax=512;
HeaderItem. PszText=pItem;
for (i=0; i{
WriteProcessMemory (hProcess, pHeaderItem, & amp; HeaderItem, sizeof (HDITEM), NULL);
: : SendMessage (pHeaderCtrl - & gt; GetSafeHwnd (), HDM_GETITEM, 0, (LPARAM) pHeaderItem);
ReadProcessMemory (hProcess, pItem ItemBuf, 512, NULL);
}

CodePudding user response:

 HeaderItem. Mask=HDI_TEXT; 
HeaderItem. CchTextMax=512;
HeaderItem. PszText=pItem;
for (i=0; i{
WriteProcessMemory (hProcess, pHeaderItem, & amp; HeaderItem, sizeof (HDITEM), NULL);
: : SendMessage (pHeaderCtrl - & gt; HDM_GETITEM GetSafeHwnd (), I, (LPARAM) pHeaderItem);
ReadProcessMemory (hProcess, pItem ItemBuf, 512, NULL);
}

CodePudding user response:

 
Void CRemoteListCtrlDlg: : RemoteHeaderItem (HWND HWND)
{
//GetItemCount
Int nHeaderCount=: : SendMessage (hWnd HDM_GETITEMCOUNT, 0, 0);
//Get hProcess
DWORD pid;
GetWindowThreadProcessId (hWnd, & amp; Pid);
HANDLE hProcess=OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
//
HDITEM * pHeaderItem=(HDITEM *) VirtualAllocEx (hProcess, NULL, sizeof (HDITEM), MEM_COMMIT, PAGE_READWRITE);
Char * pItem=(char *) VirtualAllocEx (hProcess, NULL, 512, MEM_COMMIT, PAGE_READWRITE);
if ((! PHeaderItem) | | (! PItem))
{
: : MessageBox (NULL, "unable to allocate memory!" , "wrong!" , NULL);
The CloseHandle (hProcess);
return;
}
//
HDITEM HeaderItem;
HeaderItem. CchTextMax=512;
HeaderItem. Mask=HDI_TEXT;
HeaderItem. PszText=pItem;
//
Char ItemBuf [512].
for(int i=0; i{
HeaderItem. IOrder=I;
WriteProcessMemory (hProcess, pHeaderItem, & amp; HeaderItem, sizeof (HDITEM), NULL);
: : SendMessage (hWnd HDM_GETITEM, I, (LPARAM) pHeaderItem);
ReadProcessMemory (hProcess, pItem ItemBuf, 512, NULL);
AfxDump & lt; & lt; ItemBuf & lt; & lt; "\ n";
}
//release the memory
The CloseHandle (hProcess);
VirtualFreeEx (hProcess, pHeaderItem, 0, MEM_RELEASE);
VirtualFreeEx (hProcess, pItem, 0, MEM_RELEASE);
}


From "HWND HWND=: : WindowFromPoint (point);" Get HeaderCtrl hWnd!

CodePudding user response:

Give a
Typedef struct tagMYLVCOLUMN
{
LVCOLUMNA oldCol;
Char text [80].
} MYLVCOLUMN, FAR * LPMYLVCOLUMN;
,,,,,,,,,,,,,,,,,,,,,,,,,,,
 
//
LPMYLVCOLUMN CRemoteListCtrlDlg: : RemoteLVGetColumn (HWND hLvWnd)
{//GetItemCount
M_hHdWnd=ListView_GetHeader (m_hLvWnd);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related