Does any body can marshal this part of c/c++ code in c# please?
typedef struct
{
BYTE bCommandCode;
BYTE bParameterCode;
struct
{
DWORD dwSize;
LPBYTE lpbBody;
}
Data;
}
COMMAND, *LPCOMMAND;
thanks a lot
First off, declare the above struct as a managed struct - something like:
Though you may have to use the
MarshalAs
attribute here and there to ensure it's actually marshalling them as their proper types. If you want to then read this struct from memory for example, you could do something like:I am assuming you want to read your struct from memory and marshal it into a managed struct, because otherwise you wouldn't even need the
Marshal
at all. Also, make sure to compile the above code with/unsafe
enabled.