Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 1881

LoadLibraryW call hangs on IIS

$
0
0

I am building a sample MVC 5 web app that makes some P/Invoke calls to an unmanaged library (loaded via LoadLibraryW function).

It all works well inside visual studio with IIS Express, but once I publish it and run it with the local instance of IIS, the call to LoadLibraryW function hangs indefinitely.

To make sure the problem isn't with my unmanaged library, I created a new "dummy" one with just a simple message box on DllMain function, but it also hangs...

I have tried a lot of things, from enabling 32 bits on the AppPool, to changing the AppPool user, etc.

The AppPool runs in integrated mode, and it is running on a Windows 10 machine.

Is there any sort of configuration or special permissions for p/invoke calls inside IIS that I am missing?

This is how I am P/Invoking the LoadLibraryW function:

[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibraryW(string fileName);

var moduleHandle = LoadLibraryW(@"c:\dummy\dummy.dll"); // This call hangs forever

Has this to do with CAS? The AppPool .NET Trust Levels are set to Full (internal) and I even changed the AppPool identity to LocalSystem so I don't understand.

The issue is very simple to reproduce. Create a regular MVC 5 app, place the LoadLibraryW call inside the Index method of the HomeController, publish the app to your local IIS. When you hit the app url the app hangs forever. Anyone with this behaviour?

Thank you.


Viewing all articles
Browse latest Browse all 1881

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>