C # p / invoke, Reading data from the Collected List field

I have a window "Extracted list of owners" in an external application (America Online), in which I need to obtain data for creating a component to help people with its ease of use. (the utility will make access to some things easier, etc.).

Note

My knowledge of C ++ is very poor . I am a C # programmer.

I have hWnd in the List box, but it looks like it's drawn by the owner. Using LB_GETTEXT returns bad data, I just get garbage (it displays in my debugger as a bunch of Chinese characters), and through LB_GETITEMDATA returns the same.

I believe that this is due to the fact that the owner of the drawn list has graphics. While doing a lot of digging, I discovered others in the past with this problem. I unearthed the following code that should fix this problem. However, it is not. The code is posted below, as well as problems underneath.

 void GetListItemData( HWND hListWnd, long index, char *outputResult ) { int result; DWORD processID; HANDLE hProcess; char *itemData; char sDataRead[5]; DWORD bytes; DWORD lListItemHold, lListItemDataHold; *outputResult=0; if( hListWnd ) { GetWindowThreadProcessId( hListWnd, &processID ); hProcess=OpenProcess( 0x10|0xf0000|PROCESS_VM_READ, 0, processID ); if( hProcess ) { lListItemHold=(DWORD)SendMessage( hListWnd, LB_GETITEMDATA, index-1, 0 ); lListItemHold=lListItemHold+24; result=ReadProcessMemory( hProcess, (void *)lListItemHold, &sDataRead, 4, &bytes ); if( !result ) { RaiseWinErr(); } memcpy( &lListItemDataHold, &sDataRead, 4 ); lListItemDataHold=lListItemDataHold+6; ReadProcessMemory( hProcess, (void *)lListItemDataHold, outputResult, 16, &bytes ); CloseHandle( hProcess ); } } } 

My understanding, however, is that lListItemHold=lListItemHold+24 tries to take into account that the "structure" is in the ListBox and goes through the first 24 bytes, and returns what remains. However, this does not seem to work for me.

Can anyone shed some light on what I could try? I know I grab onto the straw as it is. I encode this in C #, so this function is used using p/invoke , for example as follows:

  [DllImport("GetListItemData.dll", CallingConvention = CallingConvention.Cdecl)] internal static extern void RetrieveListItem( System.IntPtr hWnd, System.Int32 index, [MarshalAs(UnmanagedType.LPArray)]byte[] buffer ); [DllImport("GetListItemData.dll", CallingConvention = CallingConvention.Cdecl)] internal static extern void RetrieveListItem( System.IntPtr hWnd, System.Int32 index, [MarshalAs(UnmanagedType.LPTStr)]System.Text.StringBuilder buffer ); 
+1
source share
1 answer

I have two related blog posts

http://taylorza.blogspot.com/2009/08/archive-hacking-my-way-across-process.html http://taylorza.blogspot.com/2010/06/crossing-process-boundary-with-net .html

However, they are intended for the ListView control, but you can take a look at the code. The second article uses P / Invoke to achieve this goal in .NET.

1- Why are you adding 24 to lListItemHold?

2- Are you sure that lListItemhold is a pointer to a string, this may be some internal structure of the application.

+1
source

All Articles