Пример #1
0
        public void InitializeDlll(string path)
        {
            //TO DO FIX
            dllHandle = WindowsUtilities.LoadLibrary(Path.Combine(path, "HookCostume.dll"));
            if (dllHandle != null)
            {
                var initGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "InitGame");
                if (initGameAddress != IntPtr.Zero)
                {
                    initGame = (InitGame)Marshal.GetDelegateForFunctionPointer(initGameAddress, typeof(InitGame));
                }

                var closeGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "CloseGame");
                if (closeGameAddress != IntPtr.Zero)
                {
                    closeGame = (CloseGame)Marshal.GetDelegateForFunctionPointer(closeGameAddress, typeof(CloseGame));
                }

                var setUserHWndAddress = WindowsUtilities.GetProcAddress(dllHandle, "SetUserHWND");
                if (setUserHWndAddress != IntPtr.Zero)
                {
                    setUserHWnd =
                        (SetUserHWND)Marshal.GetDelegateForFunctionPointer(setUserHWndAddress, typeof(SetUserHWND));
                }

                var executeCmdAddress = WindowsUtilities.GetProcAddress(dllHandle, "ExecuteCommand");
                if (executeCmdAddress != IntPtr.Zero)
                {
                    executeCmd =
                        (ExecuteCommand)
                        Marshal.GetDelegateForFunctionPointer(executeCmdAddress, typeof(ExecuteCommand));
                }

                var getHoveredNPCInfoAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetHoveredNPCInfo");
                if (getHoveredNPCInfoAddress != IntPtr.Zero)
                {
                    getHoveredNPCInfo =
                        (GetHoveredNPCInfo)
                        Marshal.GetDelegateForFunctionPointer(getHoveredNPCInfoAddress, typeof(GetHoveredNPCInfo));
                }

                var getMouseXYZInGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetMouseXYZInGame");
                if (getMouseXYZInGameAddress != IntPtr.Zero)
                {
                    getMouseXYZInGame =
                        (GetMouseXYZInGame)
                        Marshal.GetDelegateForFunctionPointer(getMouseXYZInGameAddress, typeof(GetMouseXYZInGame));
                }

                var checkGameDoneAddress = WindowsUtilities.GetProcAddress(dllHandle, "CheckGameDone");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    checkIfGameLoaded =
                        (CheckIfGameLoaded)
                        Marshal.GetDelegateForFunctionPointer(checkGameDoneAddress, typeof(CheckIfGameLoaded));
                }

                var detectCollisionAddress = WindowsUtilities.GetProcAddress(dllHandle, "CollisionDetection");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    detectCollision =
                        (DetectCollision)
                        Marshal.GetDelegateForFunctionPointer(detectCollisionAddress, typeof(DetectCollision));
                }
            }
        }
        static IconInteractionUtility()
        {
            string hookCostumePath = Path.Combine(Settings.Default.CityOfHeroesGameDirectory, "HookCostume.dll");

            //Shared.Logging.FileLogManager.ForceLog(hookCostumePath);
            dllHandle = WindowsUtilities.LoadLibrary(hookCostumePath);
            if (dllHandle != null)
            {
                IntPtr initGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "InitGame");
                if (initGameAddress != IntPtr.Zero)
                {
                    initGame = (InitGame)(Marshal.GetDelegateForFunctionPointer(initGameAddress, typeof(InitGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Init Game Located");
                }

                IntPtr closeGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "CloseGame");
                if (closeGameAddress != IntPtr.Zero)
                {
                    closeGame = (CloseGame)(Marshal.GetDelegateForFunctionPointer(closeGameAddress, typeof(CloseGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Close Game Located");
                }

                IntPtr setUserHWndAddress = WindowsUtilities.GetProcAddress(dllHandle, "SetUserHWND");
                if (setUserHWndAddress != IntPtr.Zero)
                {
                    setUserHWnd = (SetUserHWND)(Marshal.GetDelegateForFunctionPointer(setUserHWndAddress, typeof(SetUserHWND)));
                    //Shared.Logging.FileLogManager.ForceLog("Set User HWND Located");
                }

                IntPtr executeCmdAddress = WindowsUtilities.GetProcAddress(dllHandle, "ExecuteCommand");
                if (executeCmdAddress != IntPtr.Zero)
                {
                    executeCmd = (ExecuteCommand)(Marshal.GetDelegateForFunctionPointer(executeCmdAddress, typeof(ExecuteCommand)));
                    //Shared.Logging.FileLogManager.ForceLog("Execute Command Located");
                }

                IntPtr getHoveredNPCInfoAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetHoveredNPCInfo");
                if (getHoveredNPCInfoAddress != IntPtr.Zero)
                {
                    getHoveredNPCInfo = (GetHoveredNPCInfo)(Marshal.GetDelegateForFunctionPointer(getHoveredNPCInfoAddress, typeof(GetHoveredNPCInfo)));
                    //Shared.Logging.FileLogManager.ForceLog("Get Hovered NPC Info Located");
                }

                IntPtr getMouseXYZInGameAddress = WindowsUtilities.GetProcAddress(dllHandle, "GetMouseXYZInGame");
                if (getMouseXYZInGameAddress != IntPtr.Zero)
                {
                    getMouseXYZInGame = (GetMouseXYZInGame)(Marshal.GetDelegateForFunctionPointer(getMouseXYZInGameAddress, typeof(GetMouseXYZInGame)));
                    //Shared.Logging.FileLogManager.ForceLog("Get Mouse XYZ Located");
                }

                IntPtr checkGameDoneAddress = WindowsUtilities.GetProcAddress(dllHandle, "CheckGameDone");
                if (checkGameDoneAddress != IntPtr.Zero)
                {
                    checkIfGameLoaded = (CheckIfGameLoaded)(Marshal.GetDelegateForFunctionPointer(checkGameDoneAddress, typeof(CheckIfGameLoaded)));
                    //Shared.Logging.FileLogManager.ForceLog("Check Game Done Located");
                }

                IntPtr detectCollisionAddress = WindowsUtilities.GetProcAddress(dllHandle, "CollisionDetection");
                if (detectCollisionAddress != IntPtr.Zero)
                {
                    detectCollision = (DetectCollision)(Marshal.GetDelegateForFunctionPointer(detectCollisionAddress, typeof(DetectCollision)));
                    //Shared.Logging.FileLogManager.ForceLog("Collision Detection Located");
                }
            }
        }
Пример #3
0
 public void ExitGame()
 {
     CloseGame.Do();
 }
Пример #4
0
 private void btnCloseGame_Click(object sender, RoutedEventArgs e)
 {
     CloseGame?.Invoke(this, EventArgs.Empty);
 }
Пример #5
0
 public Task CloseGame(CloseGame command) => Send(command);
 private void buttonGameOver_Click(object sender, RoutedEventArgs e)
 {
     CloseGame?.Invoke();
 }