I'm using some code to start the CLR Runtime inside a native process, then call my .NET DLL to load another .NET executable inside that process.
To load the other .NET executable I'm using reflection, like so:
Assembly.Load(file).EntryPoint.Invoke(null, null);
Now, I inject a C++ dll that starts the runtime, it then calls the .NET dll which uses Assembly.Load to load another .NET executable into memory and execute it.
Once the dll loads my .NET executable, calling:
System.Reflection.Assembly.GetExecutingAssembly().Location;
or even
Process.GetCurrentProcess().MainModule.FileName;
This, of course, returns the location of the executable itself, even though its running inside another host process. Is there any way I can grab the name of that host process? Process explorer shows it as running inside the host process so I know I have that part working correctly.
Of course if I were to run these commands inside the .NET DLL that was loaded first then it would show the proper process name.
Thanks.
EDIT:
I have tried GetEntryAssembly()
and GetCallingAssembly()
as well.