private static IsWow64ProcessDelegate CreateIsWow64ProcessDelegate() { var isWow64ProcessPointer = NativeFunctions.GetProcAddress(GetModuleHandle("kernel32"), "IsWow64Process"); if (isWow64ProcessPointer == null) { bool IsWow64ProcessOn32Process(IntPtr hProcess, out bool Wow64Process) { Wow64Process = false; return(false); } return(IsWow64ProcessOn32Process); } else { return(Marshal.GetDelegateForFunctionPointer <IsWow64ProcessDelegate>(isWow64ProcessPointer)); } }
public IHook <TDelegate> Hook <TDelegate>(string moduleName, string funcName, TDelegate hookFunc) where TDelegate : notnull { var module = NativeFunctions.GetModuleHandle(moduleName); if (module == IntPtr.Zero) { module = NativeFunctions.LoadLibrary(moduleName); if (module == IntPtr.Zero) { throw new MoguException($"Not found module '{moduleName}'"); } } var nativeFunc = NativeFunctions.GetProcAddress(module, funcName); if (nativeFunc == IntPtr.Zero) { throw new MoguException($"Not found function '{funcName}'"); } return(Hook(nativeFunc, hookFunc)); }