Code contains logical bug: if exists registry value \Software\Classes\Clsid\CLSID\LocalServer32\ServerExecutable, then value for command line is retrieved from it. But it's incorrect. Registry value \Software\Classes\Clsid\CLSID\LocalServer32\ServerExecutable contains the path to the server executable. And \Software\Classes\Clsid\CLSID\LocalServer32(Default) contains the command line to invoke an out-of-proc COM server
Code contains logical bug: if exists registry value \Software\Classes\Clsid\CLSID\LocalServer32\ServerExecutable, then value for command line is retrieved from it. But it's incorrect. Registry value \Software\Classes\Clsid\CLSID\LocalServer32\ServerExecutable contains the path to the server executable. And \Software\Classes\Clsid\CLSID\LocalServer32(Default) contains the command line to invoke an out-of-proc COM server
Steps to reproduce:
COM-object hosted in rundll32 without any command line looks weird.. With the proposed fix the output looks like: