I have the following code involving a struct
including pointer variables and I am not able to retrieve the correct contents of each variable.
Someone can help me please?
struct MyData
{
ULONG Value[3];
wchar_t *Str1;
int Str1Len;
wchar_t *Str2;
int Str2Len;
};
// In the driver, on method that receives commands i have following:
struct MyData *pData = (struct MyData*) Irp->AssociatedIrp.SystemBuffer;
DbgPrint("0x%x \n 0x%x \n 0x%x \n %s \n %d \n %s \n %d", &pData->Value[0], &pData->Value[1], &pData->Value[2], &pData.Str1, &pData->Str1Len, &pData->Str2, &pData->Str2Len);
DbgPrint
is called very much like printf
is called, so you should pass the values, not the address of the values. So
DbgPrint("0x%x \n 0x%x \n 0x%x \n %s \n %d \n %s \n %d", &pData->Value[0], // etc...
should be
DbgPrint("0x%x \n 0x%x \n 0x%x \n %s \n %d \n %s \n %d", pData->Value[0], // etc...