I try to marshal NdisGetCurrentSystemTime
result to a C# program via ioctl.
LARGE_INTEGER data;
NdisGetCurrentSystemTime (&data );
marshal_data->time = (UINT64)(data.QuadPart / 10^6);
DBGPRINT(("Time: %64u", marshal_data->time));
At C# receiver side, the time field is defined as uint64; there's also a couple of other uint64 fields in the marshalled structure. However, when doing
String.Format(("Time was {0}", recv_data->time))
I get unexpectedly large number that differs from the one in DBGPRINT.
C#:
[StructLayout(LayoutKind.Sequential)]
...
public UInt64 time
C:
struct _marshalme {
...
UINT64 time
...
}
Is there anything going weird with a byte order?
LARGE_INTEGER
represents a 64-bit signed integer . I expect your problems come from using UInt64
instead of Int64
.
The problem was mainly in improper struct alignment thus different size; but for some reason, it seems to keep damaging data at transfer (eg last DBGPRINT prints saved value correctly) for int32, int64 cases even when size is same; I've been forced to use
long startTime;
long padding;
to receive proper value as C#'s long, other ways of marshalling that value failed. Will post more completed sample later, unless that - the question is closed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.