Jacek Caban : ntdll: Implement DbgUiIssueRemoteBreakin.

Alexandre Julliard julliard at winehq.org
Fri Jul 5 14:49:18 CDT 2019


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Jul  5 13:21:14 2019 +0200

ntdll: Implement DbgUiIssueRemoteBreakin.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/misc.c              |  8 --------
 dlls/ntdll/ntdll.spec          |  2 +-
 dlls/ntdll/process.c           | 29 +++++++++++++++++++++++++++++
 dlls/ntdll/server.c            |  5 +++++
 include/wine/server_protocol.h | 10 ++++++++--
 include/winternl.h             |  2 ++
 server/protocol.def            |  8 +++++++-
 server/thread.c                |  1 +
 server/trace.c                 |  6 ++++++
 9 files changed, 59 insertions(+), 12 deletions(-)

diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c
index 9b29c88..152b2cf 100644
--- a/dlls/ntdll/misc.c
+++ b/dlls/ntdll/misc.c
@@ -584,14 +584,6 @@ ULONG WINAPIV EtwTraceMessage( TRACEHANDLE handle, ULONG flags, LPGUID guid, USH
     return ret;
 }
 
-/***********************************************************************
- *		    DbgUiRemoteBreakin (NTDLL.@)
- */
-void WINAPI DbgUiRemoteBreakin( void *arg )
-{
-    FIXME("stub\n");
-}
-
 NTSTATUS WINAPI NtCreateLowBoxToken(HANDLE *token_handle, HANDLE existing_token_handle, ACCESS_MASK desired_access,
                                     OBJECT_ATTRIBUTES *object_attributes, SID *package_sid, ULONG capability_count,
                                     SID_AND_ATTRIBUTES *capabilities, ULONG handle_count, HANDLE *handle)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 299bfac..323d5ea 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -39,7 +39,7 @@
 @ stub DbgUiConvertStateChangeStructure
 # @ stub DbgUiDebugActiveProcess
 # @ stub DbgUiGetThreadDebugObject
-# @ stub DbgUiIssueRemoteBreakin
+@ stdcall DbgUiIssueRemoteBreakin(long)
 @ stdcall DbgUiRemoteBreakin(ptr)
 # @ stub DbgUiSetThreadDebugObject
 # @ stub DbgUiStopDebugging
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index c1570a5..8b9d5bc 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -1365,3 +1365,32 @@ done:
     RtlFreeHeap( GetProcessHeap(), 0, unixdir );
     return status;
 }
+
+/***********************************************************************
+ *      DbgUiRemoteBreakin (NTDLL.@)
+ */
+void WINAPI DbgUiRemoteBreakin( void *arg )
+{
+    TRACE( "\n" );
+    if (NtCurrentTeb()->Peb->BeingDebugged) DbgBreakPoint();
+    RtlExitUserThread( STATUS_SUCCESS );
+}
+
+/***********************************************************************
+ *      DbgUiIssueRemoteBreakin (NTDLL.@)
+ */
+NTSTATUS WINAPI DbgUiIssueRemoteBreakin( HANDLE process )
+{
+    apc_call_t call;
+    apc_result_t result;
+    NTSTATUS status;
+
+    TRACE( "(%p)\n", process );
+
+    memset( &call, 0, sizeof(call) );
+
+    call.type = APC_BREAK_PROCESS;
+    status = server_queue_process_apc( process, &call, &result );
+    if (status) return status;
+    return result.break_process.status;
+}
diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index 8274f11..b82fbc5 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -575,6 +575,11 @@ BOOL invoke_apc( const apc_call_t *call, apc_result_t *result )
         else result->create_thread.status = STATUS_INVALID_PARAMETER;
         break;
     }
+    case APC_BREAK_PROCESS:
+        result->type = APC_BREAK_PROCESS;
+        result->break_process.status = RtlCreateUserThread( NtCurrentProcess(), NULL, FALSE, NULL, 0, 0,
+                                                            DbgUiRemoteBreakin, NULL, NULL, NULL );
+        break;
     default:
         server_protocol_error( "get_apc_request: bad type %d\n", call->type );
         break;
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 15ad91c..f67b09a 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -449,7 +449,8 @@ enum apc_type
     APC_VIRTUAL_UNLOCK,
     APC_MAP_VIEW,
     APC_UNMAP_VIEW,
-    APC_CREATE_THREAD
+    APC_CREATE_THREAD,
+    APC_BREAK_PROCESS
 };
 
 typedef union
@@ -638,6 +639,11 @@ typedef union
         thread_id_t      tid;
         obj_handle_t     handle;
     } create_thread;
+    struct
+    {
+        enum apc_type    type;
+        unsigned int     status;
+    } break_process;
 } apc_result_t;
 
 enum irp_type
@@ -6702,6 +6708,6 @@ union generic_reply
     struct resume_process_reply resume_process_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 585
+#define SERVER_PROTOCOL_VERSION 586
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/include/winternl.h b/include/winternl.h
index b87aa22..2a9ca65 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -2294,6 +2294,8 @@ NTSYSAPI void WINAPI DbgUserBreakPoint(void);
 #endif  /* __i386__ && __GNUC__ */
 NTSYSAPI NTSTATUS WINAPIV DbgPrint(LPCSTR fmt, ...);
 NTSYSAPI NTSTATUS WINAPIV DbgPrintEx(ULONG iComponentId, ULONG Level, LPCSTR fmt, ...);
+NTSYSAPI NTSTATUS  WINAPI DbgUiIssueRemoteBreakin(HANDLE);
+NTSYSAPI void      WINAPI DbgUiRemoteBreakin(void*);
 NTSYSAPI NTSTATUS  WINAPI LdrAccessResource(HMODULE,const IMAGE_RESOURCE_DATA_ENTRY*,void**,PULONG);
 NTSYSAPI NTSTATUS  WINAPI LdrAddRefDll(ULONG,HMODULE);
 NTSYSAPI NTSTATUS  WINAPI LdrFindResourceDirectory_U(HMODULE,const LDR_RESOURCE_INFO*,ULONG,const IMAGE_RESOURCE_DIRECTORY**);
diff --git a/server/protocol.def b/server/protocol.def
index e450388..58a7545 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -465,7 +465,8 @@ enum apc_type
     APC_VIRTUAL_UNLOCK,
     APC_MAP_VIEW,
     APC_UNMAP_VIEW,
-    APC_CREATE_THREAD
+    APC_CREATE_THREAD,
+    APC_BREAK_PROCESS
 };
 
 typedef union
@@ -654,6 +655,11 @@ typedef union
         thread_id_t      tid;       /* thread id */
         obj_handle_t     handle;    /* handle to new thread */
     } create_thread;
+    struct
+    {
+        enum apc_type    type;      /* APC_BREAK_PROCESS */
+        unsigned int     status;    /* status returned by call */
+    } break_process;
 } apc_result_t;
 
 enum irp_type
diff --git a/server/thread.c b/server/thread.c
index 7057c9b..63eea94 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1643,6 +1643,7 @@ DECL_HANDLER(queue_apc)
         }
         break;
     case APC_CREATE_THREAD:
+    case APC_BREAK_PROCESS:
         process = get_process_from_handle( req->handle, PROCESS_CREATE_THREAD );
         break;
     default:
diff --git a/server/trace.c b/server/trace.c
index 8d3de65..d4a35e4 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -218,6 +218,9 @@ static void dump_apc_call( const char *prefix, const apc_call_t *call )
         dump_uint64( ",commit=", &call->create_thread.commit );
         fprintf( stderr, ",suspend=%u", call->create_thread.suspend );
         break;
+    case APC_BREAK_PROCESS:
+        fprintf( stderr, "APC_BREAK_PROCESS" );
+        break;
     default:
         fprintf( stderr, "type=%u", call->type );
         break;
@@ -298,6 +301,9 @@ static void dump_apc_result( const char *prefix, const apc_result_t *result )
                  get_status_name( result->create_thread.status ),
                  result->create_thread.tid, result->create_thread.handle );
         break;
+    case APC_BREAK_PROCESS:
+        fprintf( stderr, "APC_BREAK_PROCESS,status=%s", get_status_name( result->break_process.status ) );
+        break;
     default:
         fprintf( stderr, "type=%u", result->type );
         break;




More information about the wine-cvs mailing list