Comments (2)
On May 21, 2012, at 5:18 PM, GiGurra wrote:
The FAQ states:
"
How do I map a native long type?
Actually, no one ever asks this question, but they really need the answer. Do not use Java long!On Windows, you can use a Java int, since the native long type is always 32 bits. On any other platform, the type may be 32 or 64 bits, so you should use the NativeLong type to ensure the proper size is used.
"This is incorrect. I am not aware if this was the case on previous windows version but it certainly isn't the case on my windows 7 machine (a standard i7 on windows 7 64bit).
I'm not sure what you're referring to. A "long" on windows is 32 bits whether on 32-bit or 64-bit windows. This has been the case since 64-bit windows was introduced.
ALSO MORE WORRYING
The JNA source assumes DWORD and NativeLong are always 4 byte sized, also wrong, and this leads to big errors.
Example: I cannot use mappings like
public static class MEMORY_BASIC_INFORMATION extends Structure {
public Pointer BaseAddress;
public Pointer AllocationBase;
public NativeLong AllocationProtect;
public NativeLong RegionSize;
public NativeLong State;
public NativeLong Protect;
public NativeLong Type;
}
Nor should you. The platform.jar from the contrib directory defines DWORD and SIZE_T. RegionSize is of type SIZE_T, which is equivalent to neither DWORD nor NativeLong.
I don't understand how this has not been caught ......
Perhaps because it's not a bug. I don't understand how your incorrect mappings were not caught. No, wait, you forgot to write corresponding tests, that must be it.
This issue is closed.
from jna.
Interesting!
You indeed seem to be correct here. Turns out that my eclipse somehow opened the mingw variant of winnt.h (although I use ms VC compiler in eclipse), and that defines MEMORY_BASIC_INFORMATION as:
typedef struct _MEMORY_BASIC_INFORMATION {
PVOID BaseAddress;
PVOID AllocationBase;
DWORD AllocationProtect;
DWORD RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
} MEMORY_BASIC_INFORMATION,*PMEMORY_BASIC_INFORMATION;
from msdn:
typedef struct _MEMORY_BASIC_INFORMATION {
PVOID BaseAddress;
PVOID AllocationBase;
DWORD AllocationProtect;
SIZE_T RegionSize;
DWORD State;
DWORD Protect;
DWORD Type;
} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION;
I was sure I tested sizeof(long), but I can't have since it works with size_t...
With Size_T instead it all works. Thank you for pointing me in the right direction :).
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.