예제 #1
0
        public static int Start(string infomartion)
        {
            try
            {
                Console.WriteLine(infomartion);
                LoadDlls();
                var mainHwnd = Process.GetCurrentProcess().MainWindowHandle;
                CallWndProcHook.Hook();
                CallWndProcHook.SendDataMessage(mainHwnd, Encoding.Default.GetBytes("CallWndProc Hooked!"));

                var address = AddressManager.GetAddress();
                if (address == null)
                {
                    Console.WriteLine("Addr NotFound!");
                }
                else
                {
                    var nAddr = address.Value;
                    Console.WriteLine($"DemoClass_SendMsg Addr: {nAddr.DemoClass_SendMsg.ToString("X")}");
                    DemoClass_SendMsgHook.Hook(nAddr.DemoClass_SendMsg);
                }
                Console.ReadKey();
                CallWndProcHook.UnHook();
                DemoClass_SendMsgHook.UnHook();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(1);
        }
예제 #2
0
        public GlobalHooks(IntPtr handle)
        {
            _Handle = handle;

            _CBT = new CBTHook(_Handle);
            _Shell = new ShellHook(_Handle);
            _CallWndProc = new CallWndProcHook(_Handle);
            _GetMsg = new GetMsgHook(_Handle);
        }
예제 #3
0
        public GlobalHooks(IntPtr Handle)
        {
            _Handle = Handle;

            source = HwndSource.FromHwnd(Handle);
            source.AddHook(WndProc);

            _CBT         = new CBTHook(_Handle);
            _Shell       = new ShellHook(_Handle);
            _CallWndProc = new CallWndProcHook(_Handle);
            _GetMsg      = new GetMsgHook(_Handle);
        }
예제 #4
0
		public GlobalHooks(IntPtr Handle)
		{
			_Handle = Handle;

			_CBT = new CBTHook(_Handle);
			_Shell = new ShellHook(_Handle);
			_Keyboard = new KeyboardHook(_Handle);
			_Mouse = new MouseHook(_Handle);
			_KeyboardLL = new KeyboardLLHook(_Handle);
			_MouseLL = new MouseLLHook(_Handle);
			_CallWndProc = new CallWndProcHook(_Handle);
			_GetMsg = new GetMsgHook(_Handle);
		}
        public GlobalHooks(IntPtr Handle)
        {
            _Handle = Handle;

            _CBT         = new CBTHook(_Handle);
            _Shell       = new ShellHook(_Handle);
            _Keyboard    = new KeyboardHook(_Handle);
            _Mouse       = new MouseHook(_Handle);
            _KeyboardLL  = new KeyboardLLHook(_Handle);
            _MouseLL     = new MouseLLHook(_Handle);
            _CallWndProc = new CallWndProcHook(_Handle);
            _GetMsg      = new GetMsgHook(_Handle);
        }
예제 #6
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

#if WIN32
            if (Environment.Is64BitOperatingSystem)
            {
                var resourceName  = "SmartSystemMenu.SmartSystemMenu64.exe";
                var fileName      = "SmartSystemMenu64.exe";
                var directoryName = Path.GetDirectoryName(AssemblyUtils.AssemblyLocation);
                var filePath      = Path.Combine(directoryName, fileName);
                try
                {
                    if (!File.Exists(filePath))
                    {
                        AssemblyUtils.ExtractFileFromAssembly(resourceName, filePath);
                    }
                    _64BitProcess = Process.Start(filePath);
                }
                catch
                {
                    string message = string.Format("Failed to load {0} process!", fileName);
                    MessageBox.Show(message, AssemblyUtils.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }
            }

            if (_settings.ShowSystemTrayIcon)
            {
                _systemTrayMenu = new SystemTrayMenu(_settings.Language);
                _systemTrayMenu.MenuItemAutoStartClick += MenuItemAutoStartClick;
                _systemTrayMenu.MenuItemSettingsClick  += MenuItemSettingsClick;
                _systemTrayMenu.MenuItemAboutClick     += MenuItemAboutClick;
                _systemTrayMenu.MenuItemExitClick      += MenuItemExitClick;
                _systemTrayMenu.Create();
                _systemTrayMenu.CheckMenuItemAutoStart(AutoStarter.IsAutoStartByRegisterEnabled(AssemblyUtils.AssemblyProductName, AssemblyUtils.AssemblyLocation));
            }

            var moduleName = Process.GetCurrentProcess().MainModule.ModuleName;

            _hotKeyHook         = new HotKeyHook();
            _hotKeyHook.Hooked += HotKeyHooked;
            if (_settings.MenuItems.Items.Flatten(x => x.Items).Any(x => x.Type == MenuItemType.Item && x.Key3 != VirtualKey.None && x.Show) || _settings.MenuItems.WindowSizeItems.Any(x => x.Key3 != VirtualKey.None))
            {
                _hotKeyHook.Start(moduleName, _settings.MenuItems);
            }

            _hotKeyMouseHook         = new HotKeys.MouseHook();
            _hotKeyMouseHook.Hooked += HotKeyMouseHooked;
            if (_settings.Closer.MouseButton != MouseButton.None)
            {
                _hotKeyMouseHook.Start(moduleName, _settings.Closer.Key1, _settings.Closer.Key2, _settings.Closer.MouseButton);
            }
#endif
            _windows = EnumWindows.EnumAllWindows(_settings, _windowSettings, new string[] { SHELL_WINDOW_NAME }).ToList();

            foreach (var window in _windows)
            {
                var processPath = window.Process?.GetMainModuleFileName() ?? string.Empty;
                var fileName    = Path.GetFileName(processPath);
                if (!string.IsNullOrEmpty(fileName) && _settings.ProcessExclusions.Contains(fileName.ToLower()))
                {
                    continue;
                }

                var isAdded = window.Menu.Create();
                if (isAdded)
                {
                    window.Menu.CheckMenuItem(window.ProcessPriority.GetMenuItemId(), true);
                    if (window.AlwaysOnTop)
                    {
                        window.Menu.CheckMenuItem(MenuItemId.SC_TOPMOST, true);
                    }

                    if (window.IsExToolWindow)
                    {
                        window.Menu.CheckMenuItem(MenuItemId.SC_HIDE_FOR_ALT_TAB, true);
                    }

                    var windowClassName = window.GetClassName();
                    var states          = _windowSettings.Find(windowClassName, processPath);
                    if (states.Any())
                    {
                        window.ApplyState(states[0], _settings.SaveSelectedItems, _settings.MenuItems.WindowSizeItems);
                        window.Menu.CheckMenuItem(MenuItemId.SC_SAVE_SELECTED_ITEMS, true);
                    }
                }
            }

            _callWndProcHook              = new CallWndProcHook(Handle, MenuItemId.SC_DRAG_BY_MOUSE);
            _callWndProcHook.CallWndProc += WindowProc;
            _callWndProcHook.Start();

            _getMsgHook         = new GetMsgHook(Handle, MenuItemId.SC_DRAG_BY_MOUSE);
            _getMsgHook.GetMsg += WindowGetMsg;
            _getMsgHook.Start();

            _shellHook = new ShellHook(Handle, MenuItemId.SC_DRAG_BY_MOUSE);
            _shellHook.WindowCreated   += WindowCreated;
            _shellHook.WindowDestroyed += WindowDestroyed;
            _shellHook.Start();

            _cbtHook = new CBTHook(Handle, MenuItemId.SC_DRAG_BY_MOUSE);
            _cbtHook.WindowCreated   += WindowCreated;
            _cbtHook.WindowDestroyed += WindowDestroyed;
            _cbtHook.MoveSize        += WindowMoveSize;
            _cbtHook.MinMax          += WindowMinMax;
            _cbtHook.Start();


            _mouseHook = new Hooks.MouseHook(Handle, MenuItemId.SC_DRAG_BY_MOUSE);
            var dragByMouseItemName = MenuItemId.GetName(MenuItemId.SC_DRAG_BY_MOUSE);
            if (_settings.MenuItems.Items.Flatten(x => x.Items).Any(x => x.Type == MenuItemType.Item && x.Name == dragByMouseItemName && x.Show))
            {
                _mouseHook.Start();
            }

            Hide();
        }