I have a class named NativeMethods.cs which contains all extern methods:
internal static class NativeMethods
{
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool IsWow64Process([In] IntPtr hProcess, [Out] out bool wow64Process);
[DllImport("advapi32.dll", CharSet = CharSet.Auto)]
internal static extern int RegOpenKeyEx(
IntPtr hKey,
string subKey,
int ulOptions,
int samDesired,
out int hkResult);
}
The assembly containing this class has a corresponding .Moles file. All other classes included in the assembly can be moled and stubbed properly, except this one.
There is no MNativeMethods
that we can use for detouring. Is there a special case against the class name "NativeMethods" (Highly unlikely)? Or a special case against extern methods?