Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with DWORD

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hallo,

I have the following C++ code:


typedef struct tagIOCTLParams
{
DWORD dioc_IOCtlCode;
PVOID dioc_InBuf;
} IOCTLPARAMS, *PIOCTLPARAMS;

...
PIOCTLPARAMS p;
char buf[128];

_snprintf (buf, 128,
"IOCTL is: %i",
p->dioc_IOCtlCode);

But %i seemed to be wrong, because I get a value like "-1475374670" instead of "-2080374773".

What have I done wrong?

Bye Tim
 
Greetinx!

Here your code:
PIOCTLPARAMS p;
char buf[128];
_snprintf (buf, 128, "IOCTL is: %i", p->dioc_IOCtlCode);

and where are you allocate memory for IOCTLPARAMS structure?
So if not you must allocate memory and define parameters of the structure.




Happy programming!))
 
Also, is 128 bytes right? Once you have allocated the memory for the structure, if it is still wrong, I would check the math there. that looks fishy to me.

Good Luck..
 
Hallo,

thank you for reply, but there is no need to allocate memory, it seems that it is done automatically.
Now I found out "%i" is wrong because DWORD is unsigned and so you had to use "%u".

The next problem I have is that the code:

typedef struct tagIOCTLParams
{
PCLIENT_STRUCT dioc_pcrs;
VMHANDLE dioc_hvm;
DWORD dioc_VxdDDB;
DWORD dioc_IOCtlCode;

PVOID dioc_InBuf;

DWORD dioc_cbInBuf;
PVOID dioc_OutBuf;
DWORD dioc_cbOutBuf;
PDWORD dioc_bytesret;
OVERLAPPED* dioc_ovrlp;
DWORD dioc_hDevice;
DWORD dioc_ppdb;
} IOCTLPARAMS, *PIOCTLPARAMS;

.. and the method I try to analyse "dioc_InBuf" isn't right as well. "%s" and the sructure of "dioc_InBuf" seemed to be wrong in the following code:

_snprintf (buf, 128,
"dwIoCtrlCode: %u\t lpInBuf: %s\t lpOutBuf %s\t lpdBytesRet: %d\n",
p->dioc_IOCtlCode,

p->dioc_InBuf,

p->dioc_OutBuf,
p->dioc_bytesret);

"InBuf" seemed not be a string (I just get values like "o0_*..." - maybe it's a structure like this EXAMPLE:

#pragma pack(1)
typedef struct {
ULONG seq;
char text[32];
} ENTRY, *PENTRY;
#pragma pack()
...

PENTRY->seq = 1;
PENTRY->text = 'hallo;

p->dioc_InBuf = PENTRY;


Now it's the question if it is possible to get the structure of "p->dioc_InBuf", that means the right struture of PENTRY?


Bye Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top