Added WBEM methods and a class.#1474
Added WBEM methods and a class.#1474matthiasblaesing merged 1 commit intojava-native-access:masterfrom
Conversation
|
Following this kind suggestion: https://stackoverflow.com/questions/72265941/calling-iwbemservices-getobject-with-jna-and-java |
matthiasblaesing
left a comment
There was a problem hiding this comment.
Please have a look at the inline comments.
contrib/platform/src/com/sun/jna/platform/win32/COM/Wbemcli.java
Outdated
Show resolved
Hide resolved
contrib/platform/src/com/sun/jna/platform/win32/COM/Wbemcli.java
Outdated
Show resolved
Hide resolved
contrib/platform/src/com/sun/jna/platform/win32/COM/Wbemcli.java
Outdated
Show resolved
Hide resolved
contrib/platform/src/com/sun/jna/platform/win32/COM/Wbemcli.java
Outdated
Show resolved
Hide resolved
|
Thank you for the updates. Could you please check if you can create tests for the new methods? You can extend the existing test accordingly: https://github.com/java-native-access/jna/blob/master/contrib/platform/test/com/sun/jna/platform/win32/COM/WbemcliTest.java |
|
Thank you. Looks good to me. I pushed the PR to appveyor and that came back clean. The last little nitpick: The new test is locale dependent. Could you please check this patch, which should fix that? # This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- a/contrib/platform/test/com/sun/jna/platform/win32/COM/WbemcliTest.java
+++ b/contrib/platform/test/com/sun/jna/platform/win32/COM/WbemcliTest.java
@@ -49,6 +49,7 @@
import com.sun.jna.platform.win32.OaIdl.SAFEARRAY;
import com.sun.jna.platform.win32.WTypes;
import com.sun.jna.platform.win32.Kernel32;
+import com.sun.jna.platform.win32.WinNT;
import com.sun.jna.ptr.IntByReference;
import java.util.Arrays;
import java.util.HashSet;
@@ -327,7 +328,7 @@
boolean foundWin32_Process = false;
try {
- svc = WbemcliUtil.connectServer(WbemcliUtil.DEFAULT_NAMESPACE);
+ svc = connectServerEnglishLocale(WbemcliUtil.DEFAULT_NAMESPACE);
enumRes = svc.ExecQuery(
"WQL",
"SELECT * FROM meta_class",
@@ -428,4 +429,25 @@
assertEquals(currentPid, pVal.longValue());
}
+ /**
+ * Copy from WbemcliUtil#connectServer with American English selected as
+ * locale.
+ */
+ private static Wbemcli.IWbemServices connectServerEnglishLocale(String namespace) {
+ Wbemcli.IWbemLocator loc = Wbemcli.IWbemLocator.create();
+ if (loc == null) {
+ throw new COMException("Failed to create WbemLocator object.");
}
+
+ Wbemcli.IWbemServices services = loc.ConnectServer(namespace, null, null, "MS_409", 0, null, null);
+ loc.Release();
+
+ WinNT.HRESULT hres = Ole32.INSTANCE.CoSetProxyBlanket(services, Ole32.RPC_C_AUTHN_WINNT, Ole32.RPC_C_AUTHZ_NONE, null,
+ Ole32.RPC_C_AUTHN_LEVEL_CALL, Ole32.RPC_C_IMP_LEVEL_IMPERSONATE, null, Ole32.EOAC_NONE);
+ if (COMUtils.FAILED(hres)) {
+ services.Release();
+ throw new COMException("Could not set proxy blanket.", hres);
+ }
+ return services;
+ }
+}It would be nice if you could include this (if it does not cause issues on your locale). If it works, please include it, squash all commits into a single commit, add an entry to |
57cf499 to
cc92ed6
Compare
…ded IWbemQualifierSet.
cc92ed6 to
58dc89d
Compare
|
Appveyor and Travis are both happy with this and my local test also worked ok. Thank you for your contribution! |
|
All the pleasure is for me. Many thanks again for your patience and help. |
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [net.java.dev.jna:jna](https://github.com/java-native-access/jna) | compile | minor | `5.12.1` -> `5.13.0` | --- ### Release Notes <details> <summary>java-native-access/jna</summary> ### [`v5.13.0`](https://github.com/java-native-access/jna/blob/HEAD/CHANGES.md#Release-5130) [Compare Source](java-native-access/jna@5.12.1...5.13.0) \================ ## Features - [#​1454](java-native-access/jna#1454): Add `c.s.j.p.win32.Psapi.QueryWorkingSetEx` and associated Types - [@​crain-32](https://github.com/Crain-32). - [#​1459](java-native-access/jna#1459): Add `VirtualLock` and `VirtualUnlock` in `c.s.j.p.win32.Kernel32` - [@​matthiasblaesing](https://github.com/matthiasblaesing). - [#​1471](java-native-access/jna#1471): Add `c.s.j.p.win32.Advapi32Util#isCurrentProcessElevated` and associated Types - [@​dbwiddis](https://github.com/dbwiddis). - [#​1474](java-native-access/jna#1474): Add `c.s.j.p.win32.WbemCli#IWbemClassObject.IWbemQualifierSet`, `IWbemServices.GetObject`, `IWbemContext.SetValue` and associated methods - [@​rchateauneu](https://github.com/rchateauneu). - [#​1482](java-native-access/jna#1482): Add multilingual support of `Kernel32Util.formatMessage` - [@​overpathz](https://github.com/overpathz). - [#​1490](java-native-access/jna#1490): Adds support for a custom `SymbolProvider` in `NativeLibrary` & `Library` - [@​soywiz](https://github.com/soywiz). - [#​1491](java-native-access/jna#1491): Update libffi to v3.4.4 - [@​matthiasblaesing](https://github.com/matthiasblaesing). - [#​1487](java-native-access/jna#1487): Add 'uses' information to OSGI metadata in MANIFEST.MF to improve stability of package resolution - [@​sratz](https://github.com/sratz). ## Bug Fixes - [#​1452](java-native-access/jna#1452): Fix memory allocation/handling for error message generation in native library code (`dispatch.c`) - [@​matthiasblaesing](https://github.com/matthiasblaesing). - [#​1460](java-native-access/jna#1460): Fix win32 variant date conversion in DST offest window and with millisecond values - [@​eranl](https://github.com/eranl). - [#​1472](java-native-access/jna#1472): Fix incorrect bitmask in `c.s.j.Pointer#createConstant(int)` - [@​dbwiddis](https://github.com/dbwiddis). - [#​1481](java-native-access/jna#1481): Fix NPE in NativeLibrary when unpacking from classpath is disabled - [@​trespasserw](https://github.com/trespasserw). - [#​1489](java-native-access/jna#1489): Fixes typo in `OpenGL32Util#wglGetProcAddress`, instead of parameter `procName` the hardcoded value `wglEnumGpusNV` was used - [@​soywiz](https://github.com/soywiz). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
Added methods to IWbemContext, IWbemServices and IWbemClassObject. Added IWbemQualifierSet.