コード例 #1
0
ファイル: XInput.cs プロジェクト: ng08000/Vortice.Windows
 static XInput()
 {
     if (IsUAP())
     {
         s_xInput = new XInput14();
         Version  = XInputVersion.Version14;
     }
     if (LoadLibrary("xinput1_4.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput14();
         Version  = XInputVersion.Version14;
     }
     else if (LoadLibrary("xinput1_3.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput13();
         Version  = XInputVersion.Version13;
     }
     else if (LoadLibrary("xinput9_1_0.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput910();
         Version  = XInputVersion.Version910;
     }
     else
     {
         throw new PlatformNotSupportedException("XInput is not supported");
     }
 }
コード例 #2
0
        public void Run(
            RemoteHooking.IContext aInContext,
            String aInArg1)
        {
            _interface.Ping(RemoteHooking.GetCurrentProcessId(), "Payload installed. Running payload loop.");

            foreach (var xinputVersion in Enum.GetValues(typeof(XInputVersion)))
            {
                try
                {
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Trying to hook {xinputVersion}.dll");
                    _xinputSetStateHookObj = LocalHook.Create(
                        LocalHook.GetProcAddress($"{xinputVersion}.dll", "XInputSetState"),
                        new XInputSetStateDelegate(XInputSetStateHookFunc),
                        null);
                    _hookedVersion = (XInputVersion)xinputVersion;
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Hooked {xinputVersion}.dll");
                    break;
                }
                catch
                {
                    // noop
                    _interface.Ping(RemoteHooking.GetCurrentProcessId(), $"Hooking {xinputVersion}.dll failed");
                }
            }
            if (_xinputSetStateHookObj == null)
            {
                _interface.ReportError(RemoteHooking.GetCurrentProcessId(), new Exception("No viable DLL to hook, payload exiting"));
                return;
            }
            // Set hook for all threads.
            _xinputSetStateHookObj.ThreadACL.SetExclusiveACL(new Int32[1]);
            try
            {
                while (_interface.Ping(RemoteHooking.GetCurrentProcessId(), ""))
                {
                    Thread.Sleep(1);

                    if (_messageQueue.Count > 0)
                    {
                        lock (_messageQueue)
                        {
                            _interface.Report(RemoteHooking.GetCurrentProcessId(), _messageQueue);
                            _messageQueue.Clear();
                        }
                    }
                    if (_ex != null)
                    {
                        _interface.ReportError(RemoteHooking.GetCurrentProcessId(), _ex);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                _interface.ReportError(RemoteHooking.GetCurrentProcessId(), e);
            }
            _interface.Ping(RemoteHooking.GetCurrentProcessId(), "Exiting payload loop");
            _interface.Exit();
        }
コード例 #3
0
ファイル: XInput.cs プロジェクト: Aminator/Vortice.Windows
 static XInput()
 {
     if (LoadLibrary("xinput1_4.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput14();
         Version  = XInputVersion.Version14;
     }
     else if (LoadLibrary("xinput1_3.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput13();
         Version  = XInputVersion.Version13;
     }
     else if (LoadLibrary("xinput9_1_0.dll") != IntPtr.Zero)
     {
         s_xInput = new XInput910();
         Version  = XInputVersion.Version910;
     }
 }
コード例 #4
0
		private static List<GameController> Initialize()
		{
			var list = new List<GameController>( GameController.MaxControllerCount );
			try
			{
				if( version == XInputVersion.XInput14 )
				{
					for( var c = 0; c < GameController.MaxControllerCount; c++ )
						list.Add( new XInput14GameController( (GameControllerIndex)c ) );
				}
				else if( version == XInputVersion.XInput13 )
				{
					for( var c = 0; c < GameController.MaxControllerCount; c++ )
						list.Add( new XInput13GameController( (GameControllerIndex)c ) );
				}
			}
			catch( NotSupportedException )
			{
				list.Clear();
				version = XInputVersion.NotSupported;
			}
			return list;
		}