From b86e64f36acba98840027910ff60714af3df5501 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:10:01 +0100 Subject: [PATCH 1/2] Fix incorrect flags in NtDuplicateObject --- src/core/kernel/exports/EmuKrnlNt.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/kernel/exports/EmuKrnlNt.cpp b/src/core/kernel/exports/EmuKrnlNt.cpp index 84b796bfe..d151dfd6d 100644 --- a/src/core/kernel/exports/EmuKrnlNt.cpp +++ b/src/core/kernel/exports/EmuKrnlNt.cpp @@ -702,9 +702,7 @@ XBSYSAPI EXPORTNUM(197) xbox::ntstatus_xt NTAPI xbox::NtDuplicateObject } else { - // TODO : What arguments should we use? - const ACCESS_MASK DesiredAccess = 0; - const ULONG Attributes = 0; + // On the xbox, the duplicated handle always has the same access rights of the source handle // redirect to Win2k/XP ret = NtDll::NtDuplicateObject( @@ -712,9 +710,9 @@ XBSYSAPI EXPORTNUM(197) xbox::ntstatus_xt NTAPI xbox::NtDuplicateObject SourceHandle, /*TargetProcessHandle=*/g_CurrentProcessHandle, TargetHandle, - DesiredAccess, - Attributes, - Options); + 0, + 0, + (Options | DUPLICATE_SAME_ATTRIBUTES | DUPLICATE_SAME_ACCESS)); } if (ret != xbox::status_success) From f5ed14d2764e4f58f1087510122248e484e05fd9 Mon Sep 17 00:00:00 2001 From: ergo720 <45463469+ergo720@users.noreply.github.com> Date: Mon, 7 Dec 2020 21:49:25 +0100 Subject: [PATCH 2/2] Address review remark --- src/core/kernel/exports/EmuKrnlNt.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/kernel/exports/EmuKrnlNt.cpp b/src/core/kernel/exports/EmuKrnlNt.cpp index d151dfd6d..9a04a8995 100644 --- a/src/core/kernel/exports/EmuKrnlNt.cpp +++ b/src/core/kernel/exports/EmuKrnlNt.cpp @@ -702,7 +702,10 @@ XBSYSAPI EXPORTNUM(197) xbox::ntstatus_xt NTAPI xbox::NtDuplicateObject } else { - // On the xbox, the duplicated handle always has the same access rights of the source handle + // On the xbox, the duplicated handle always has the same access rigths of the source handle + const ACCESS_MASK DesiredAccess = 0; + const ULONG Attributes = 0; + Options |= (DUPLICATE_SAME_ATTRIBUTES | DUPLICATE_SAME_ACCESS); // redirect to Win2k/XP ret = NtDll::NtDuplicateObject( @@ -710,9 +713,9 @@ XBSYSAPI EXPORTNUM(197) xbox::ntstatus_xt NTAPI xbox::NtDuplicateObject SourceHandle, /*TargetProcessHandle=*/g_CurrentProcessHandle, TargetHandle, - 0, - 0, - (Options | DUPLICATE_SAME_ATTRIBUTES | DUPLICATE_SAME_ACCESS)); + DesiredAccess, + Attributes, + Options); } if (ret != xbox::status_success)