tyranid / oleviewdotnet

A .net OLE/COM viewer and inspector to merge functionality of OleView and Test Container
GNU General Public License v3.0
1.14k stars 185 forks source link

Add and forward server type param from Get-ComClassInterface cmdlet to OOP interface querying #37

Open the-deniss opened 2 years ago

the-deniss commented 2 years ago

Now Get-ComClassInterface tries to instantiate COM class for further querying implemented interfaces with CLSCTX derived from DefaultServerType. But sometimes this results in error:

$UsoClass = Get-ComClass -Clsid B91D5831-B1BD-4608-8198-D72E155020F7                                                                                                                                                                                                                                                                                                                                                                                                                             Get-ComClassInterface -ClassEntry $UsoClass
Exception calling "LoadSupportedInterfaces" with "3" argument(s): "ClassFactory cannot supply requested class"
At C:\Users\User\Documents\MyRepo\oleviewdotnet\bin\Release\OleViewDotNet.psm1:960 char:17
+ ...             $class.LoadSupportedInterfaces($Refresh, $Token, $ServerT ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : Win32Exception

Error occurs due attempt to instantiate this COM-object in-proc because UpdateSessionOrchestrator's DefaultServerType is InProcServer32. And it could be cool if you can manually specify desired server type. With proposed fix it can look like:

Get-ComClassInterface -ClassEntry $UsoClass -ServerType LocalServer32

Name                 IID                                  Module               VTableOffset
----                 ---                                  ------               ------------
IMarshal             00000003-0000-0000-c000-000000000046                      0
IMarshal2            000001cf-0000-0000-c000-000000000046                      0
IUnknown             00000000-0000-0000-c000-000000000046                      0
IUpdateSessionOrc... 07f3afac-7c8a-4ce7-a5e0-3d24ee8a77e0                      0
IMoUsoOrchestrator   c57692f8-8f5f-47cb-9381-34329b40285a                      0

P.S.: In the future, it will be nice to add this parameter to UI, but I'm too lazy for this