The WMI interface cannot retrieve data of array type

haer 20 Reputation points
2025-12-13T07:01:04.16+00:00

I encountered an error while calling the Method of classes in the WMI interface to retrieve array type data from BIOS. My MOF description file contains the following content:

[WMI,
Dynamic,
Provider("WmiProv"),
Locale("MS\\0x409"),
Description("Call BIOS Function through WMI"),
guid("{B66BC8B8-8DE4-4990-B8C8-F73DFF82FF9A}")
]
class OemWMIMethodC
{
[key, read]
string InstanceName;
[read] boolean Active;
[WmiMethodId(1),
Implemented,
read, write,
Description("OEM WMI Function")
] void OemWMIfunC([in, Description("Test2")] uint64 Data, [out, MAX(256)]uint8 u8Output[]);
};

The error message is as follows:

Invoke-CimMethod : Invalid object
At E:\test01.ps1:8 char:10
+     $r = Invoke-CimMethod -InputObject $i -MethodName OemWMIfun -Argu ...
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (OemWMIMethod (I...0C14\EmdWmi_0"):CimInstance) [Invoke-CimMethod], CimExc
   eption
    + FullyQualifiedErrorId : HRESULT 0x8004100f,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand

=== Results ===
[ERROR] Cannot index into a null array.

I ensured through debugging that the Method in the ASL file in the BIOS was executed to the Return (Buffer) step, and I tried to set the buffer size to 256, 80, 64, and 8, but this issue occurred. And when I change the data type defined in MOF from an array of type uin8 to uint64, it can be executed correctly and the data can be obtained. Why is this?

Windows development | Windows Driver Kit (WDK)
0 comments No comments
{count} votes

Answer accepted by question author
  1. Marcin Policht 68,615 Reputation points MVP Volunteer Moderator
    2025-12-13T12:14:43.9566667+00:00

    AFAIK, this behavior is due to limitations in how WMI marshals array output parameters from firmware-provided providers, especially when the provider ultimately bridges to ACPI/BIOS code. The ASL method might execute correctly and return a buffer, the WMI infrastructure is failing while converting that returned buffer into the CIM-compliant array type declared in the MOF. The HRESULT 0x8004100f “Invalid object” is a generic failure that often masks a type-mismatch or marshalling error rather than a logic error in the BIOS method itself.

    If you change the MOF definition to use a scalar uint64 instead of a uint8 array, this might resolve the problem because scalar values are marshaled directly and do not require SAFEARRAY construction. The ACPI buffer is implicitly coerced into a 64-bit integer by the provider, which WMI can transport without ambiguity.

    In practice, the usual workaround is to return a scalar type such as uint64 or string and pack the data manually, or to return a fixed-size structure encoded as multiple scalar outputs. Another approach would be to return a string containing hex-encoded bytes.

    Try the following:

    [WMI, Dynamic, Provider("WmiProv"), Locale("MS\\0x409"),
     guid("{B66BC8B8-8DE4-4990-B8C8-F73DFF82FF9A}")]
    class OemWMIMethodC
    {
        [key, read] string InstanceName;
        [read] boolean Active;
    
        [WmiMethodId(1), Implemented, read, write]
        void OemWMIfunC(
            [in] uint64 Data,
            [out] uint64 PackedOutput
        );
    };
    
    Method (OWMC, 1, Serialized)
    {
        Name (BUF0, Buffer (8) {})
        Store (0x1122334455667788, BUF0)
        Return (BUF0)
    }
    
    $inst = Get-CimInstance -Namespace root\wmi -ClassName OemWMIMethodC
    $r = Invoke-CimMethod -InputObject $inst -MethodName OemWMIfunC -Arguments @{ Data = 1 }
    
    [BitConverter]::GetBytes($r.PackedOutput)
    

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.