78e2279114a18d9b6c70a777e897d23b96fec485
[reactos.git] / lib / kernel32 / misc / debug.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS system libraries
5  * FILE:            lib/kernel32/misc/debug.c
6  * PURPOSE:         Application debugger support functions
7  * PROGRAMMER:      ???
8  */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <k32.h>
13
14
15 /* FUNCTIONS *****************************************************************/
16
17 WINBOOL
18 STDCALL
19 ContinueDebugEvent (
20         DWORD   dwProcessId,
21         DWORD   dwThreadId,
22         DWORD   dwContinueStatus
23         )
24 {
25         CLIENT_ID ClientId;
26         NTSTATUS Status;
27
28         ClientId.UniqueProcess = (HANDLE)dwProcessId;
29         ClientId.UniqueThread = (HANDLE)dwThreadId;
30
31         Status = DbgUiContinue (&ClientId,
32                                 dwContinueStatus);
33         if (!NT_SUCCESS(Status))
34         {
35                 SetLastErrorByStatus (Status);
36                 return FALSE;
37         }
38         return TRUE;
39 }
40
41
42 WINBOOL
43 STDCALL
44 DebugActiveProcess (
45         DWORD   dwProcessId
46         )
47 {
48         SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
49         return FALSE;
50 }
51
52
53 VOID
54 STDCALL
55 DebugBreak (
56         VOID
57         )
58 {
59         DbgBreakPoint ();
60 }
61
62
63 WINBOOL
64 STDCALL
65 IsDebuggerPresent (
66         VOID
67         )
68 {
69         return (WINBOOL)NtCurrentPeb ()->BeingDebugged;
70 }
71
72
73 /*
74  * NOTE: Don't call DbgService()!
75  *       It's a ntdll internal function and is NOT exported!
76  */
77
78 VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString)
79 {
80    DbgPrint( (PSTR)lpOutputString );
81 }
82
83 VOID STDCALL OutputDebugStringW(LPCWSTR lpOutputString)
84 {
85    UNICODE_STRING UnicodeOutput;
86    ANSI_STRING AnsiString;
87    char buff[512];
88
89    UnicodeOutput.Buffer = (WCHAR *)lpOutputString;
90    UnicodeOutput.Length = lstrlenW(lpOutputString)*sizeof(WCHAR);
91    UnicodeOutput.MaximumLength = UnicodeOutput.Length;
92    AnsiString.Buffer = buff;
93    AnsiString.MaximumLength = 512;
94    AnsiString.Length = 0;
95    if( UnicodeOutput.Length > 512 )
96      UnicodeOutput.Length = 512;
97    if( NT_SUCCESS( RtlUnicodeStringToAnsiString( &AnsiString, &UnicodeOutput, FALSE ) ) )
98      DbgPrint( AnsiString.Buffer );
99 }
100
101
102 WINBOOL
103 STDCALL
104 WaitForDebugEvent (
105         LPDEBUG_EVENT   lpDebugEvent,
106         DWORD           dwMilliseconds
107         )
108 {
109         SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
110         return FALSE;
111 }
112
113 /* EOF */