Skip to content

Commit

Permalink
Read correct member of SYSTEM_INFO.processorArchitecture union
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Sep 13, 2019
1 parent f7d3c94 commit 73b8d66
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Bug Fixes
* [#1127](https://github.com/java-native-access/jna/issues/1127): Windows needs a wide string in `c.s.j.p.win32.COM.IShellFolder#ParseDisplayName` - [@dbwiddis](https://github.com/dbwiddis).
* [#1128](https://github.com/java-native-access/jna/issues/1128): KEY_ALL_ACCESS value is incorrect in `c.s.j.p.win32.WinNT.java` - [@trevormaggs](https://github.com/trevormaggs).
* [#1133](https://github.com/java-native-access/jna/issues/1133): Ensure JARs created from the build system don't contain invalid `Info-ZIP Unicode Path` extra info - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1134](https://github.com/java-native-access/jna/issues/1134): Read correct member of `WinBase.SYSTEM_INFO.processorArchitecture` union - [@dbwiddis](https://github.com/dbwiddis).

Release 5.4.0
=============
Expand Down
8 changes: 8 additions & 0 deletions contrib/platform/src/com/sun/jna/platform/win32/WinBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,14 @@ public static class ByReference extends UNION implements Structure.ByReference {
* Architecture-dependent processor revision.
*/
public WORD wProcessorRevision;

// the dwOemID union member is obsolete. Force read of pi instead.
@Override
public void read() {
super.read();
processorArchitecture.setType(PI.class);
processorArchitecture.read();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ public void testGetSystemInfo() {
SYSTEM_INFO lpSystemInfo = new SYSTEM_INFO();
Kernel32.INSTANCE.GetSystemInfo(lpSystemInfo);
assertTrue(lpSystemInfo.dwNumberOfProcessors.intValue() > 0);
// the dwOemID member is obsolete, but gets a value.
// the pi member is a structure and isn't read by default
assertEquals(lpSystemInfo.processorArchitecture.dwOemID.getLow(),
lpSystemInfo.processorArchitecture.pi.wProcessorArchitecture);
}

public void testGetSystemTimes() {
Expand Down

0 comments on commit 73b8d66

Please sign in to comment.