Example #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //ShowExplorerTaskbar();
            //return;


            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            Kbh = new HookEngine();
            Kbh.OnKeyPressed   += kbh_OnKeyPressed;
            Kbh.OnKeyUnpressed += kbh_OnKeyUnpressed;
            Kbh.HookKeyboard();


            stBar = new StatusBarWindow();
            tkBar = new TaskbarWindow();
            vlFly = new VolumeAudioFlyout();

            DPI = (float)VisualTreeHelper.GetDpi(stBar).DpiScaleX;

            stBar.Show();
            tkBar.Show();

            Configure();
        }
        public Task <int> SaveChangesAsync(bool invalidateSecondLevelCache, CancellationToken cancellationToken)
        {
            ChangeTracker.DetectChanges();

            AutoDetectChangesEnabled = false;

            var hookEngine = new HookEngine(this);

            hookEngine.ExecutePreActionHooks();

            var changedEntityNames = ChangeTracker.GetChangedEntityNames();

            var result = base.SaveChangesAsync(cancellationToken);

            hookEngine.ExecutePostActionHooks();

            AutoDetectChangesEnabled = true;

            if (!invalidateSecondLevelCache)
            {
                return(result);
            }

            InvalidateSecondLevelCache(changedEntityNames);

            return(result);
        }
Example #3
0
        public void TestOpenProcessHook()
        {
            IntPtr result;

            using (var engine = new HookEngine())
            {
                OpenProcess_orig = engine.CreateHook("kernel32.dll", "OpenProcess", new OpenProcessDelegate(OpenProcess_Detour));
                engine.EnableHooks();

                result = OpenProcess(0x001F0FFF, false, Process.GetCurrentProcess().Id);
            }

            Assert.AreEqual(_testValue, result);
        }
Example #4
0
        internal static void InitHookEngine(IntPtr contextHandle, uint dumpSizeLimit, int lsassPid, IntPtr lsassHandle)
        {
            hookEngine = new HookEngine();
            dumpContexts[contextHandle] = new DumpContext(dumpSizeLimit);
            MiniDumpToMem.lsassPid      = lsassPid;
            MiniDumpToMem.lsassHandle   = lsassHandle;

            SetFilePointer_detour = new SetFilePointerDelegate(SetFilePointer);
            GetFileSize_detour    = new GetFileSizeDelegate(GetFileSize);
            WriteFile_detour      = new WriteFileDelegate(WriteFile);
            NtOpenProcess_detour  = new NtOpenProcessDelegate(NtOpenProcess);

            NtOpenProcess_orig  = hookEngine.CreateHook("ntdll.dll", "NtOpenProcess", NtOpenProcess_detour);
            SetFilePointer_orig = hookEngine.CreateHook("kernelbase.dll", "SetFilePointer", SetFilePointer_detour);
            GetFileSize_orig    = hookEngine.CreateHook("kernelbase.dll", "GetFileSize", GetFileSize_detour);
            WriteFile_orig      = hookEngine.CreateHook("kernelbase.dll", "WriteFile", WriteFile_detour);

            hookEngine.EnableHooks();
        }