简体   繁体   中英

How do I read a structure from a Memory/Pointer object in JNA?

I've been searching for an hour and still haven't found a way to do this. How do I read a structure from a memory/pointer object? I don't see any methods in Pointer to read a structure, and the only methods of Structure that read from memory are protected. I am trying to use a windows function that takes a pointer to a malloc'd structure array to store PHYSICAL_MONITOR's, which is why I need to do this.

Structure defines a Pointer -based constructor.

class MyStructure extends Structure {
    public MyStructure() { 
    } 
    public MyStructure(Pointer p) { 
        super(p);
        read();
    } 

See the JavaDoc for Structure for the available options to control how/when Java fields are synched from native memory.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM