Rémi Bernon : ntdll: Return failure from RtlQueryProcessDebugInformation.

Alexandre Julliard julliard at winehq.org
Thu Nov 26 16:30:59 CST 2020


Module: wine
Branch: master
Commit: 97825b9c5311fd8f9b39fb6904fff06266de89b6
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=97825b9c5311fd8f9b39fb6904fff06266de89b6

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu Nov 26 11:26:53 2020 +0100

ntdll: Return failure from RtlQueryProcessDebugInformation.

Some DRM call it with GetCurrentThreadId(), although they don't seem to
mind about the result.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/debugbuffer.c | 13 +++++++++++--
 dlls/ntdll/tests/rtl.c   | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/debugbuffer.c b/dlls/ntdll/debugbuffer.c
index 3ac765d454e..9f5d214aacb 100644
--- a/dlls/ntdll/debugbuffer.c
+++ b/dlls/ntdll/debugbuffer.c
@@ -114,7 +114,16 @@ NTSTATUS WINAPI RtlDestroyQueryDebugBuffer(IN PDEBUG_BUFFER iBuf)
 
 NTSTATUS WINAPI RtlQueryProcessDebugInformation(IN ULONG iProcessId, IN ULONG iDebugInfoMask, IN OUT PDEBUG_BUFFER iBuf) 
 {
-   NTSTATUS nts = STATUS_SUCCESS;
+    CLIENT_ID cid;
+    NTSTATUS status;
+    HANDLE process;
+
+    cid.UniqueProcess = ULongToHandle( iProcessId );
+    cid.UniqueThread = 0;
+
+    if ((status = NtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, NULL, &cid ))) return status;
+    NtClose( process );
+
    FIXME("(%d, %x, %p): stub\n", iProcessId, iDebugInfoMask, iBuf);
    iBuf->InfoClassMask = iDebugInfoMask;
    
@@ -139,5 +148,5 @@ NTSTATUS WINAPI RtlQueryProcessDebugInformation(IN ULONG iProcessId, IN ULONG iD
    }
    TRACE("returns:%p\n", iBuf);
    dump_DEBUG_BUFFER(iBuf);
-   return nts;
+   return status;
 }
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 897be4fcd12..28dd02fd118 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -132,6 +132,24 @@ static void InitFunctionPtrs(void)
     ok(strlen(src) == 15, "Source must be 16 bytes long!\n");
 }
 
+static void test_RtlQueryProcessDebugInformation(void)
+{
+    DEBUG_BUFFER *buffer;
+    NTSTATUS status;
+
+    buffer = RtlCreateQueryDebugBuffer( 0, 0 );
+    ok( buffer != NULL, "RtlCreateQueryDebugBuffer returned NULL" );
+
+    status = RtlQueryProcessDebugInformation( GetCurrentThreadId(), PDI_HEAPS | PDI_HEAP_BLOCKS, buffer );
+    ok( status == STATUS_INVALID_CID, "RtlQueryProcessDebugInformation returned %x\n", status );
+
+    status = RtlQueryProcessDebugInformation( GetCurrentProcessId(), PDI_HEAPS | PDI_HEAP_BLOCKS, buffer );
+    ok( !status, "RtlQueryProcessDebugInformation returned %x\n", status );
+
+    status = RtlDestroyQueryDebugBuffer( buffer );
+    ok( !status, "RtlDestroyQueryDebugBuffer returned %x\n", status );
+}
+
 #define COMP(str1,str2,cmplen,len) size = RtlCompareMemory(str1, str2, cmplen); \
   ok(size == len, "Expected %ld, got %ld\n", size, (SIZE_T)len)
 
@@ -3668,6 +3686,7 @@ START_TEST(rtl)
 {
     InitFunctionPtrs();
 
+    test_RtlQueryProcessDebugInformation();
     test_RtlCompareMemory();
     test_RtlCompareMemoryUlong();
     test_RtlMoveMemory();




More information about the wine-cvs mailing list