0

Given a DLL, how can I make sure it does (or does not) use P/Invoke, with a command line tool?

riQQ
  • 9,878
  • 7
  • 49
  • 66
Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156
  • What is the true intent here? That the .NET assembly accesses _any form of native code?_ If so don't forget native COM. Even though Microsoft's _Dependency Walker_ may highlight COM dlls exports of 4 functions, they are generally not called directly via callers to create an object and have nothing to do with invoking it. –  Jun 08 '22 at 05:36
  • @MickyD COM is indeed next on my list. (I have already asked about unsafe code: https://stackoverflow.com/q/72540440/709537 ) – Evgeniy Berezovsky Jun 08 '22 at 05:42

1 Answers1

2
ildasm /text file.dll | findstr pinvokeimpl

If the result is empty, pinvoke is not being used by the dll (or exe), otherwise it is.

N.B. ildasm should come installed with Visual Studio, and is easiest to call when using the Visual Studio Developer Command Prompt.

Evgeniy Berezovsky
  • 18,571
  • 13
  • 82
  • 156