update for HEAD-2002110401
[reactos.git] / ntoskrnl / dbg / user.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /*
20  * PROJECT:         ReactOS kernel
21  * FILE:            ntoskrnl/dbg/user.c
22  * PURPOSE:         User mode debugging
23  * PROGRAMMER:      David Welch (welch@cwcom.net)
24  * PORTABILITY:     Unchecked
25  */
26
27 /* INCLUDES ******************************************************************/
28
29 #include <internal/ntoskrnl.h>
30 #include <napi/dbg.h>
31 #include <internal/ps.h>
32 #include <internal/dbg.h>
33
34 #include <internal/debug.h>
35
36 /* FUNCTIONS *****************************************************************/
37
38 VOID
39 DbgkCreateThread(PVOID StartAddress)
40 {
41   LPC_DBG_MESSAGE Message;
42   LPC_DBG_MESSAGE Reply;
43   NTSTATUS Status;
44
45   if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL)
46     {
47       return;
48     }
49
50   Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE);
51   Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) - 
52     sizeof(LPC_MESSAGE);
53   Message.Type = DBG_EVENT_CREATE_THREAD;
54   Message.Status = STATUS_SUCCESS;
55   Message.Data.CreateThread.Reserved = 0;
56   Message.Data.CreateThread.StartAddress = StartAddress;
57   
58   /* FIXME: Freeze all threads in process */
59
60   /* Send the message to the process's debug port and wait for a reply */
61   Status = 
62     LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort,
63                             &Message,
64                             &Reply);
65   if (!NT_SUCCESS(Status))
66     {
67       return;
68     }
69
70   /* FIXME: Examine reply */
71   return;
72 }
73
74 ULONG
75 DbgkForwardException(EXCEPTION_RECORD Er, ULONG FirstChance)
76 {
77   LPC_DBG_MESSAGE Message;
78   LPC_DBG_MESSAGE Reply;
79   NTSTATUS Status;
80
81   if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL)
82     {
83       return(0);
84     }
85
86   Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE);
87   Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) - 
88     sizeof(LPC_MESSAGE);
89   Message.Type = DBG_EVENT_EXCEPTION;
90   Message.Status = STATUS_SUCCESS;
91   Message.Data.Exception.ExceptionRecord = Er;
92   Message.Data.Exception.FirstChance = FirstChance;
93   
94   /* FIXME: Freeze all threads in process */
95
96   /* Send the message to the process's debug port and wait for a reply */
97   Status = 
98     LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort,
99                             &Message,
100                             &Reply);
101   if (!NT_SUCCESS(Status))
102     {
103       return(0);
104     }
105
106   /* FIXME: Examine reply */
107   return(0);
108 }
109
110 /* EOF */