2

Closed

Compiling 2.7 on VS 2012 fails with some issues

description

My original attempt was to get the FileMon.exe NetFX 4.0 sample running on a Windows 7 64 bit machine.
I've created a link to it, checked execute as admin and added the PID for explorer.exe
The result was a crashing FileMon.exe without message. EventLog did not generate more information except standard protocol.

So I grabbed the 2.7 trunk with my VS 2012 SP 3. Converted the solutions to 2012 and started a build.
After many many warnings compiling of EasyHookDll failed with LNK2026 module unsafe for SAFESEH image.

So I disabled SAFESEH for EasyHookDll and rebuilt the thing which resulted in
Error 1 error LNK2005: ___report_gsfailure already defined in GS_x86.lib(gs_report.obj) D:\temp\EasyHook\EasyHookDll\LIBCMTD.lib(gs_report.obj)
Error 2 error LNK1169: one or more multiply defined symbols found D:\temp\EasyHook\Debug\x86\EasyHook32.dll 1

Adding libcmtd.lib to ignored libs results in even more linker issues. This looks like an issue mixing dlls which have static and dynamic crt linking enabled.

Well I ignored the the issues for now and only compiled FileMon.exe and copied the official binary releases of EasyHook etc to see where the problem is.

Funny enough the
Config.Register(
                        "A FileMon like demo application.",
                        "FileMon.exe",
                        "FileMonInject.dll");
code fails because if (!File.Exists(AsmPath)) (Config.cs:175) seems to return true for the very first location which was added by
Files.Add(typeof(Config).Assembly.Location);
Now, if I debug this line and add it to Watch list the if condition does not return true however even with the debugger attached the if condition is triggered resulting in a file not found exception.
Closed Feb 6, 2014 at 10:57 PM by spazzarama
Project now compiles with Visual Studio 2012

comments

spazzarama wrote Oct 17, 2013 at 10:36 AM

Try using the approach that doesn't use the GAC (see the ProcessMonitor for an example), this may simplify it and make it easier to sort out.

Seikilos wrote Oct 17, 2013 at 4:33 PM

More info: After I used the source distribution for 2.7 instead of getting a source snapshot of 2.7 I was able to compile everything after removing SAFESEH.

Now hooking explorer.exe will be fun :)

Thanks

Seikilos wrote Oct 17, 2013 at 4:34 PM

I forgot to mention that 2.7 crashes when the sample ProcMon application exits.

spazzarama wrote Oct 17, 2013 at 10:25 PM

Is that for 64-bit, if so it is a known issue and there is a solution for this in the discussions.

Seikilos wrote Oct 18, 2013 at 8:06 AM

Yes it is 64-bit indeed. Thanks for pointing it out.

spazzarama wrote Dec 26, 2013 at 3:24 AM

This compile issue can be resolved by setting the MASM "Use Safe Exception Handlers" option to Yes.

The setting is located within the EasyHookDLL project properties within the Microsoft Macro Assembler -> Advanced property group.

wrote Feb 6, 2014 at 10:53 PM

wrote Feb 6, 2014 at 10:56 PM

Fixed on changeset 73762

wrote Feb 6, 2014 at 10:57 PM