Monday, 15 May 2017

Pointer of Buffer in a structure ref-struct (actually pointer)

I am using NodeJs to call a char driver through ioctl.

I need to send a structure containing a pointer. I found out that the only way for the driver to know the address and then being able to write in the memory is to use a Buffer (since we cannot get the address for object).

What is the type of a pointer ?

var testptr = new Buffer(50);
var structtmpdata = StructType({
    a : ref.types.uint,
    length : ref.types.uint,
    datavalue : HERE.THE.POINTER (ref.types.pointer_of_a_char)
});

 var info = new structtmpdata();
 info.a = 5;
 info.length = 50;
 info.datavalue = testptr.ref();
 or
 info.datavalue = testptr.address();

Or if you have any other example...

Thank you !



via Alexis_FR_JP

No comments:

Post a Comment