Skip to content

Bug in RPCClient._get_response_effective_data for 32b process #137

Bug in RPCClient._get_response_effective_data for 32b process

Bug in RPCClient._get_response_effective_data for 32b process #137

GitHub Actions / PyTest Results for 3.11-32 failed May 5, 2025 in 0s

1 fail, 77 skipped, 437 pass in 3m 7s

515 tests   437 ✅  3m 7s ⏱️
  1 suites   77 💤
  1 files      1 ❌

Results for commit b0d6003.

Annotations

Check warning on line 0 in test_rpc

See this annotation in the file changed.

@github-actions github-actions / PyTest Results for 3.11-32

test_rpc_response_as_view (test_rpc) failed

junit/test-results.xml [took 0s]
Raw output
ValueError: RPC Response error 0x6f7 (RPC_X_BAD_STUB_DATA(0x6f7))
def test_rpc_response_as_view():
        """Check that parsing response as view in RPC Client works. Testing after a bug in 32b RPCCLient"""
        # We test what by using a RPC endpoint that returns a lot of info : forcing a response in a view
        # In this case we use the Firewall RPC and we list all Firerules.
        # We use a custom RPCClient subclasse to track if last response was a view
        client = windows.rpc.find_alpc_endpoint_and_connect(FIREWALL_RPC_IID, sid=gdef.WinLocalSid)
        client.__class__ = DbgRpcClient
        iid = client.bind(FIREWALL_RPC_IID)
    
        # https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fasp/230d1ae7-b42e-4d9c-b997-b1463aaa0ded
        # !\x02\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00
        # Binaryversion : 0x022f
        # FW_STORE_TYPE_LOCAL
        # FW_POLICY_ACCESS_RIGHT_READ
        # Flags = 0
        resp1 = client.call(iid, Proc0_RPC_FWOpenPolicyStore, params=b"!\x02\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00")
        rawpolstore = resp1[:20]
        assert not client.last_response_was_view
    
        # Proc99_RPC_FWEnumFirewallRules2_33
        # \x00\x00\x03\x00\xff\xff\xff\x7f\x07\x00
        # https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fasp/36cddff4-c427-4863-a58d-3d913a12b221
        # FW_PROFILE_TYPE_ALL : 0x7FFFFFFF
        # FW_RULE_STATUS_CLASS_OK +  FW_RULE_STATUS_PARTIALLY_IGNORED = 0x00010000 + 0x00020000
        # Flags = 7 ?
>       resp2 = client.call(iid, Proc99_RPC_FWEnumFirewallRules2_33, params=rawpolstore + b"\x00\x00\x03\x00\xff\xff\xff\x7f\x07\x00")

tests\test_rpc.py:158: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
windows\rpc\client.py:139: in call
    request_type = self._get_request_type(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tests.test_rpc.DbgRpcClient object at 0x07E4ADD0>
response = <windows.alpc.AlpcMessage object at 0x07E4A950>

    def _get_request_type(self, response):
        """Response is a `AlpcMessage`"""
        "raise if request_type == RESPONSE_TYPE_FAIL"
        request_type = struct.unpack("<I", response.data[:4])[0]
        if request_type == gdef.RPC_RESPONSE_TYPE_FAIL:
            effective_error_code = error_code = struct.unpack("<5I", response.data)[2]
            # https://learn.microsoft.com/en-us/windows/win32/com/structure-of-com-error-codes
            if gdef.HRESULT_FACILITY(error_code) == gdef.FACILITY_WIN32:
                effective_error_code = effective_error_code & 0xffff
>           raise ValueError("RPC Response error {0:#x} ({1!r})".format(error_code, KNOWN_RPC_ERROR_CODE[effective_error_code]))
E           ValueError: RPC Response error 0x6f7 (RPC_X_BAD_STUB_DATA(0x6f7))

windows\rpc\client.py:212: ValueError