Click here to Skip to main content
15,915,093 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys,
Currently I am using ReadProcessMemory API to read the values of variables from an exe and I am also getting the types of the variables using DBGhelp.lib API's.
But as of now I am able to handle primitive dataTypes.
But now I want to read structure data. I am unable to figure out how to make it work.

Below is the structure in which I want to read the values.
C++
typedef struct RXDATA
{
  CAN_DATA Rx_Data;
  unsigned char abc;
  unsigned char bcd_Type ;
} CAN_TS_RECEIVE;
Posted
Updated 20-Sep-11 23:55pm
v2
Comments
Sergey Alexandrovich Kryukov 21-Sep-11 9:50am    
What is CAN_DATA? another structure? Is anything allocated in heap?
--SA

1 solution

Please see my comment to the question.

A single call to ReadProcessMemory reads consecutive block of memory from the foreign process. So, if you have structured data in the form of structure composed of primitive types and other structures, and all of the composed structures are also like that, your target structure is in the consecutive block of memory and could be transferred in one call. Use sizeof operator to find the value for the nSize parameter.

If this is not the case, the problem is a bit more complex but also not too hard; you will need to find all pointers pointing to a separate block of memory (in heap, for example) and call this API several times and than assemble the result in the structure of your calling process, allocating memory where needed. You just need to picture the memory structure of your data type clearly.

—SA
 
Share this answer
 
Comments
explorerC 22-Sep-11 9:33am    
thanks for the wonderful suggesstion Sarko
Sergey Alexandrovich Kryukov 22-Sep-11 10:33am    
You are welcome.
Good luck, call again.
--SA
explorerC 25-Sep-11 23:44pm    
hi sarko im getting the info about child nodes but im nt able to determine the correct type of child nodes.....Im using TI_GET_TYPE (dbghelp.lib ver 6) to retrieve types.But the values im getting are not constant

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900