Compare commits
3 Commits
3347b4495e
...
d528764473
Author | SHA1 | Date |
---|---|---|
Adrian | d528764473 | |
Gliniak | 11f14e8488 | |
Adrian | fbac8dc0e5 |
|
@ -41,7 +41,8 @@ void InputSystem::AddDriver(std::unique_ptr<InputDriver> driver) {
|
|||
void InputSystem::UpdateUsedSlot(InputDriver* driver, uint8_t slot,
|
||||
bool connected) {
|
||||
if (slot == XUserIndexAny) {
|
||||
slot = 0;
|
||||
XELOGW("{} received requrest for slot any! Unsupported", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (connected_slots.test(slot) == connected) {
|
||||
|
@ -136,18 +137,16 @@ X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
|
||||
bool any_connected = false;
|
||||
for (auto& driver : drivers_) {
|
||||
// connected_slots
|
||||
X_RESULT result = driver->GetKeystroke(user_index, flags, out_keystroke);
|
||||
if (result == X_ERROR_INVALID_PARAMETER) {
|
||||
if (result == X_ERROR_INVALID_PARAMETER ||
|
||||
result == X_ERROR_DEVICE_NOT_CONNECTED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (result != X_ERROR_DEVICE_NOT_CONNECTED) {
|
||||
any_connected = true;
|
||||
}
|
||||
|
||||
if (result == X_ERROR_SUCCESS || result == X_ERROR_EMPTY) {
|
||||
UpdateUsedSlot(driver.get(), user_index, any_connected);
|
||||
|
||||
if (result == X_ERROR_SUCCESS) {
|
||||
last_used_slot = user_index;
|
||||
}
|
||||
|
@ -158,7 +157,6 @@ X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
continue;
|
||||
}
|
||||
}
|
||||
UpdateUsedSlot(nullptr, user_index, any_connected);
|
||||
return any_connected ? X_ERROR_EMPTY : X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace xe {
|
|||
namespace hid {
|
||||
namespace winkey {
|
||||
|
||||
bool static IsPassthroughEnabled(uint32_t user_index) {
|
||||
bool static IsPassthroughEnabled() {
|
||||
return static_cast<KeyboardMode>(cvars::keyboard_mode) ==
|
||||
KeyboardMode::Passthrough;
|
||||
}
|
||||
|
@ -272,6 +272,14 @@ X_RESULT WinKeyInputDriver::SetState(uint32_t user_index,
|
|||
|
||||
X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_KEYSTROKE* out_keystroke) {
|
||||
if (!is_active()) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if (!IsKeyboardForUserEnabled(user_index) && !IsPassthroughEnabled()) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
// Pop from the queue.
|
||||
KeyEvent evt;
|
||||
{
|
||||
|
@ -284,15 +292,6 @@ X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
key_events_.pop();
|
||||
}
|
||||
|
||||
if (!IsKeyboardForUserEnabled(user_index) &&
|
||||
!IsPassthroughEnabled(user_index)) {
|
||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
if (!is_active()) {
|
||||
return X_ERROR_EMPTY;
|
||||
}
|
||||
|
||||
X_RESULT result = X_ERROR_EMPTY;
|
||||
|
||||
ui::VirtualKey xinput_virtual_key = ui::VirtualKey::kNone;
|
||||
|
@ -302,7 +301,7 @@ X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
|
||||
bool capital = IsKeyToggled(VK_CAPITAL) || IsKeyDown(VK_SHIFT);
|
||||
|
||||
if (!IsPassthroughEnabled(user_index)) {
|
||||
if (!IsPassthroughEnabled()) {
|
||||
if (IsKeyboardForUserEnabled(user_index)) {
|
||||
for (const KeyBinding& b : key_bindings_) {
|
||||
if (b.input_key == evt.virtual_key &&
|
||||
|
@ -338,7 +337,7 @@ X_RESULT WinKeyInputDriver::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
keystroke_flags |= 0x0002; // XINPUT_KEYSTROKE_KEYUP
|
||||
}
|
||||
|
||||
if (IsPassthroughEnabled(user_index)) {
|
||||
if (IsPassthroughEnabled()) {
|
||||
if (GetKeyboardState(key_map_)) {
|
||||
WCHAR buf;
|
||||
if (ToUnicode(uint8_t(xinput_virtual_key), 0, key_map_, &buf, 1, 0) ==
|
||||
|
@ -373,7 +372,8 @@ void WinKeyInputDriver::WinKeyWindowInputListener::OnKeyUp(ui::KeyEvent& e) {
|
|||
}
|
||||
|
||||
void WinKeyInputDriver::OnKey(ui::KeyEvent& e, bool is_down) {
|
||||
if (!is_active()) {
|
||||
if (!is_active() || static_cast<KeyboardMode>(cvars::keyboard_mode) ==
|
||||
KeyboardMode::Disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -861,6 +861,79 @@ dword_result_t XamProfileFindAccount_entry(
|
|||
}
|
||||
DECLARE_XAM_EXPORT1(XamProfileFindAccount, kUserProfiles, kImplemented);
|
||||
|
||||
// https://github.com/TeaModz/XeLiveStealth-Full-Source/blob/d4a7439ac6241c4a13e883a6f156623d1c08f6eb/XeLive/Utils.cpp#L416
|
||||
dword_result_t XamUserLogon_entry(lpqword_t xuids_ptr, dword_t flags,
|
||||
pointer_t<XAM_OVERLAPPED> overlapped_ptr) {
|
||||
assert_true(flags == X_USER_LOGON_SIGNIN || flags == X_USER_LOGON_SIGNIN_2 ||
|
||||
flags == X_USER_LOGON_SIGNOUT ||
|
||||
flags == X_USER_LOGON_SIGNOUT_2 ||
|
||||
flags == X_USER_LOGON_SIGNOUT_3);
|
||||
|
||||
if (!xuids_ptr) {
|
||||
return X_ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
auto run = [xuids_ptr, flags](uint32_t& extended_error,
|
||||
uint32_t& length) -> X_RESULT {
|
||||
auto const profile_manager = kernel_state()->xam_state()->profile_manager();
|
||||
|
||||
X_STATUS result = X_ERROR_FUNCTION_FAILED;
|
||||
|
||||
for (uint32_t user_index = 0; user_index < XUserMaxUserCount;
|
||||
user_index++) {
|
||||
const uint64_t xuid = xuids_ptr[user_index];
|
||||
|
||||
const bool xuid_entry = xuid;
|
||||
|
||||
if ((flags & X_USER_LOGON_SIGNIN) == X_USER_LOGON_SIGNIN ||
|
||||
(flags & X_USER_LOGON_SIGNIN_2) == X_USER_LOGON_SIGNIN_2) {
|
||||
// XUID available
|
||||
if (xuid_entry) {
|
||||
if (!kernel_state()->xam_state()->IsUserSignedIn(xuid)) {
|
||||
profile_manager->Login(xuid, XUserIndexAny, true);
|
||||
}
|
||||
}
|
||||
|
||||
result = X_ERROR_SUCCESS;
|
||||
} else if ((flags & X_USER_LOGON_SIGNOUT) == X_USER_LOGON_SIGNOUT) {
|
||||
// XUID not available
|
||||
if (!xuid_entry) {
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(user_index)) {
|
||||
profile_manager->Logout(user_index, true);
|
||||
}
|
||||
}
|
||||
|
||||
result = X_ERROR_SUCCESS;
|
||||
} else if ((flags & X_USER_LOGON_SIGNOUT_2) == X_USER_LOGON_SIGNOUT_2 ||
|
||||
(flags & X_USER_LOGON_SIGNOUT_3) == X_USER_LOGON_SIGNOUT_3) {
|
||||
// XUID available
|
||||
if (kernel_state()->xam_state()->IsUserSignedIn(xuid)) {
|
||||
const uint8_t assigned_index =
|
||||
profile_manager->GetUserIndexAssignedToProfile(xuid);
|
||||
|
||||
profile_manager->Logout(assigned_index, true);
|
||||
}
|
||||
|
||||
result = X_ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
extended_error = X_HRESULT_FROM_WIN32(result);
|
||||
length = 0;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
if (!overlapped_ptr) {
|
||||
uint32_t extended_error, length = 0;
|
||||
return run(extended_error, length);
|
||||
} else {
|
||||
kernel_state()->CompleteOverlappedDeferredEx(run, overlapped_ptr);
|
||||
return X_ERROR_IO_PENDING;
|
||||
}
|
||||
}
|
||||
DECLARE_XAM_EXPORT1(XamUserLogon, kUserProfiles, kImplemented);
|
||||
|
||||
} // namespace xam
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -128,6 +128,13 @@ typedef uint32_t X_HRESULT;
|
|||
#define X_E_NOTFOUND X_HRESULT_FROM_WIN32(X_ERROR_NOT_FOUND)
|
||||
#define X_E_NO_SUCH_USER X_HRESULT_FROM_WIN32(X_ERROR_NO_SUCH_USER)
|
||||
|
||||
#define X_USER_LOGON_SIGNOUT 0x23
|
||||
#define X_USER_LOGON_SIGNOUT_2 0x48 // Blades
|
||||
#define X_USER_LOGON_SIGNOUT_3 0x13 // Testing Network
|
||||
#define X_USER_LOGON_SIGNIN 0x424
|
||||
#define X_USER_LOGON_SIGNIN_2 0x25 // NXE
|
||||
#define X_USER_LOGON_SIGNIN_3 0x14 // Blades OOBE profile creation
|
||||
|
||||
//IOCTL_, used by NtDeviceIoControlFile
|
||||
constexpr uint32_t X_IOCTL_DISK_GET_DRIVE_GEOMETRY = 0x70000;
|
||||
constexpr uint32_t X_IOCTL_DISK_GET_PARTITION_INFO = 0x74004;
|
||||
|
|
Loading…
Reference in New Issue