It seems that class and interfaces imported from COM - and that is all that can be COM imported - can be grepped with a simple regular expression (or what findstr
considers a regular expression - note the escaped space, which would otherwise be taken for an "OR" - i.e. a |
in most regex languages):
> ildasm /text NetClient.exe | findstr "\.class.*\ import "
.class interface private abstract auto ansi import NetClient.IServer
.class interface private abstract auto ansi import NetClient.Server
.class private auto ansi import beforefieldinit NetClient.ServerClass
I've tested this with a bunch of dlls already and there was no false positive - I only hope there were no false negatives either...
Also - thanks Simon in the comments - CreateInstance() can be used to load dlls dynamically at runtime, so it should be checked as well (using grep
this time instead of findstr
, due to the latter's unusual and limited regexp syntax):
> ildasm /text file.dll \
| grep -E 'call.*System.Activator|Reflection.Assembly)::CreateInstance'
N.B. ildasm
should come installed with Visual Studio, and is easiest to call when using the Visual Studio Developer Command Prompt.