Comments (5)
This could be a bug in the declaration of SYSTEM_INFO.
from jna.
I took a look at the sources, but couldn´t find anything wrong in the SYSTEM_INFO structure.
from jna.
Your hint towards the SYSTEM_INFO structure was right. I finally got it working on a 64 bit-system by modifying the SYSTEM_INFO structure to the following code:
public static class SYSTEM_INFO extends Structure {
public static class ByReference extends SYSTEM_INFO implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public SYSTEM_INFO() {
setAlignType(Structure.ALIGN_MSVC);
}
public SYSTEM_INFO(Pointer memory) {
setAlignType(Structure.ALIGN_MSVC);
useMemory(memory);
read();
}
public static class SYSTEM_UNION_STRUCT extends Structure {
public static class ByReference extends SYSTEM_UNION_STRUCT implements Structure.ByReference {
public ByReference() {
}
public ByReference(Pointer memory) {
super(memory);
}
}
public SYSTEM_UNION_STRUCT() {
setAlignType(Structure.ALIGN_MSVC);
}
public SYSTEM_UNION_STRUCT(Pointer memory) {
setAlignType(Structure.ALIGN_MSVC);
useMemory(memory);
read();
}
public WORD wProcessorArchitecture;
public WORD wReserved;
}
public static class SYSTEM_UNION extends Union {
public SYSTEM_UNION() {
}
public SYSTEM_UNION(Pointer memory) {
useMemory(memory);
read();
}
public DWORD dwOemId;
public SYSTEM_UNION_STRUCT systemUnionStruct = new SYSTEM_UNION_STRUCT();
}
/**
* Processor architecture.
*/
public SYSTEM_UNION processorArchitecture = new SYSTEM_UNION();
/**
* Page size and the granularity of page protection and commitment.
*/
public DWORD dwPageSize;
/**
* Pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).
*/
public Pointer lpMinimumApplicationAddress;
/**
* Pointer to the highest memory address accessible to applications and DLLs.
*/
public Pointer lpMaximumApplicationAddress;
/**
* Mask representing the set of processors configured into the system. Bit 0 is processor 0; bit 31 is processor 31.
*/
public DWORD_PTR dwActiveProcessorMask;
/**
* Number of processors in the system.
*/
public DWORD dwNumberOfProcessors;
/**
* An obsolete member that is retained for compatibility with Windows NT 3.5 and Windows Me/98/95.
* Use the wProcessorArchitecture, wProcessorLevel, and wProcessorRevision members to determine
* the type of processor.
* PROCESSOR_INTEL_386
* PROCESSOR_INTEL_486
* PROCESSOR_INTEL_PENTIUM
*/
public DWORD dwProcessorType;
/**
* Granularity for the starting address at which virtual memory can be allocated.
*/
public DWORD dwAllocationGranularity;
/**
* System's architecture-dependent processor level. It should be used only for display purposes.
* To determine the feature set of a processor, use the IsProcessorFeaturePresent function.
* If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_INTEL, wProcessorLevel is defined by the CPU vendor.
* If wProcessorArchitecture is PROCESSOR_ARCHITECTURE_IA64, wProcessorLevel is set to 1.
*/
public WORD wProcessorLevel;
/**
* Architecture-dependent processor revision.
*/
public WORD wProcessorRevision;
}
I had a look at other structures and ended up in adding the ByReference-Constructors to the Union and Structure-Objects. Furthermore i initialized Union and Structure Objects directly with the new operator instead of using the previous static ByReference-construct. Don´t know if this solution is "good jna-style" - but it works ;)
from jna.
Can you please create a failing test, apply a fix and make a pull request?
from jna.
I got a Windows 7 64-bit here and the code in 3.4.x works as expected. There were quite a few changes around these structures. I am going to close this for now, please reopen if you still see this problem in newer JNA.
from jna.
Related Issues (20)
- Unnecessary synchronisation? HOT 1
- Unnecessary synchronisation? HOT 1
- Unsafe increment of static field HOT 2
- Unsafe increment of mutable static field HOT 1
- Loading dll crashing + not up to date complation HOT 1
- IndexOutOfBoundsException in ELFSectionHeaders runnning on old IcedTea Java 8 version on ARMv7 HOT 7
- Monitor JNA's security posture with the Scorecard Action HOT 5
- Android Unable to load library from android-aarch64 HOT 1
- The free_callback function has a JNI weak global reference leak problem HOT 6
- loongarch64 need glibc2.36 HOT 27
- Consider adding M1 test on CI HOT 5
- Cannot run unsigned DLLs from user writeable PATH (windows) HOT 2
- Appveyor CI is broken HOT 3
- Enable RELRO HOT 4
- Collate License File Content HOT 1
- struct get different result with same code and process same data HOT 1
- JNA 7.0.0 Incompatible Native Library. HOT 1
- Segfault in jnadispatch.dll HOT 4
- Please provide a method for getting the NativeLibrary instance from Library interface
- Very heavy lock contention under load
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jna.