Skip to content

Commit 54be297

Browse files
committed
Trying to improve print output when stubborn call fails
1 parent 5da27a7 commit 54be297

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

tests/test_orpc.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@
1616
# A second check about in parameters can be done with put_Left / get_Left or put_Visible
1717
def test_orpc_iexplore():
1818
iid = gdef.IWebBrowser2.IID
19-
client, ipid = windows.rpc.stubborn.stubborn_create_instance("0002DF01-0000-0000-C000-000000000046", iid)
19+
try:
20+
client, ipid = windows.rpc.stubborn.stubborn_create_instance("0002DF01-0000-0000-C000-000000000046", iid)
21+
except Exception as e:
22+
dbginfo = getattr(e, "stubborn_info", None)
23+
if dbginfo:
24+
for x in dbginfo.items():
25+
print(x)
26+
raise
2027

2128
# get_FullName
2229
addrep = client.call(iid, 38, b"", ipid=ipid)
@@ -45,7 +52,14 @@ def test_orpc_iexplore():
4552
def test_orpc_network_manager():
4653
"""ORPC: Testing ORPCTHAT size using a method that takes no arguments and returns a single bytes"""
4754
iid = gdef.GUID.from_string("D0074FFD-570F-4A9B-8D69-199FDBA5723B")
48-
client, ipid = windows.rpc.stubborn.stubborn_create_instance("A47979D2-C419-11D9-A5B4-001185AD2B89", iid)
55+
try:
56+
client, ipid = windows.rpc.stubborn.stubborn_create_instance("A47979D2-C419-11D9-A5B4-001185AD2B89", iid)
57+
except Exception as e:
58+
dbginfo = getattr(e, "stubborn_info", None)
59+
if dbginfo:
60+
for x in dbginfo.items():
61+
print(x)
62+
raise
4963
response = client.call(iid, 17, b"", ipid=ipid)
5064
assert response[0] not in (b"\x00", 0)
5165

windows/rpc/stubborn.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,18 @@ def stubborn_create_instance(clsid, iid):
7373
# Bad alignement for everythin -> Legacy
7474
resolver_info = ctypes.cast(rpiv_infoptr, gdef.PPRIV_RESOLVER_INFO_LEGACY)[0]
7575

76-
psa = resolver_info.OxidInfo.psa[0] # Retrieve the bidings to our COM server
76+
try:
77+
psa = resolver_info.OxidInfo.psa[0] # Retrieve the bidings to our COM server
78+
except ValueError as e:
79+
# Seen case of NULL DEREF
80+
# Embed more value to the except for better debugging
81+
e.stubborn_info = {
82+
"resolver_info.OxidInfo.containerVersion.version": resolver_info.OxidInfo.containerVersion.version,
83+
"dcomversion": (dcomversionstruct.MajorVersion, dcomversionstruct.MinorVersion),
84+
"resolver_info": resolver_info,
85+
}
86+
raise
87+
7788
# print("psa.bidings: {0}".format(psa.bidings))
7889
# ipidRemUnknown = resolver_info.OxidInfo.ipidRemUnknown # Useful for IRemQueryInterface
7990

0 commit comments

Comments
 (0)