public NativeFunctions(IntPtr ntCreateFile, IntPtr ntReadFile, IntPtr ntSetInformationFile, IntPtr ntQueryInformationFile, IReloadedHooks hooks) { NtCreateFile = hooks.CreateFunction <NtCreateFile>((long)ntCreateFile); NtReadFile = hooks.CreateFunction <NtReadFile>((long)ntReadFile); SetFilePointer = hooks.CreateFunction <NtSetInformationFile>((long)ntSetInformationFile); GetFileSize = hooks.CreateFunction <NtQueryInformationFile>((long)ntQueryInformationFile); }
public static NativeFunctions GetInstance(IReloadedHooks hooks) { if (_instanceMade) { return(_instance); } var ntdllHandle = LoadLibraryW("ntdll"); var ntCreateFilePointer = GetProcAddress(ntdllHandle, "NtCreateFile"); var ntReadFilePointer = GetProcAddress(ntdllHandle, "NtReadFile"); var ntSetInformationFile = GetProcAddress(ntdllHandle, "NtSetInformationFile"); var ntQueryInformationFile = GetProcAddress(ntdllHandle, "NtQueryInformationFile"); _instance = new NativeFunctions() { NtCreateFile = hooks.CreateFunction <NtCreateFile>((long)ntCreateFilePointer), NtReadFile = hooks.CreateFunction <NtReadFile>((long)ntReadFilePointer), NtSetInformationFile = hooks.CreateFunction <NtSetInformationFile>((long)ntSetInformationFile), NtQueryInformationFile = hooks.CreateFunction <NtQueryInformationFile>((long)ntQueryInformationFile), }; _instanceMade = true; return(_instance); }
public ReloadedHooksTest() { _nativeCalculator = new NativeCalculator(); _hooks = new ReloadedHooks(); _addFunction = _hooks.CreateFunction <AddFunction>((long)_nativeCalculator.Add); _subtractFunction = _hooks.CreateFunction <SubtractFunction>((long)_nativeCalculator.Subtract); _divideFunction = _hooks.CreateFunction <DivideFunction>((long)_nativeCalculator.Divide); _multiplyFunction = _hooks.CreateFunction <MultiplyFunction>((long)_nativeCalculator.Multiply); }
public NativeFunctions(IntPtr ntCreateFile, IntPtr ntReadFile, IntPtr ntSetInformationFile, IntPtr ntQueryInformationFile, IntPtr setFilePointer, IntPtr closeHandle, IReloadedHooks hooks) { NtCreateFile = hooks.CreateFunction <NtCreateFile>((long)ntCreateFile); NtReadFile = hooks.CreateFunction <NtReadFile>((long)ntReadFile); NtSetInformationFile = hooks.CreateFunction <NtSetInformationFile>((long)ntSetInformationFile); NtQueryinformationFile = hooks.CreateFunction <NtQueryInformationFile>((long)ntQueryInformationFile); SetFilePointer = hooks.CreateFunction <SetFilePointer>(( long )setFilePointer); CloseHandle = hooks.CreateFunction <CloseHandleDelegate>(( long )closeHandle); }