@@ -17,51 +17,67 @@ Module Name:
1717#include " uefiext.h"
1818
1919HRESULT CALLBACK
20- info (
20+ monitor (
2121 PDEBUG_CLIENT4 Client,
2222 PCSTR args
2323 )
2424{
25+ PSTR Response;
26+ ULONG Len;
27+ const CHAR *TruncateTag = " #T#" ;
28+ const ULONG TruncateTagLen = sizeof (" #T#" ) - 1 ; // Exclude the null terminator.
29+ ULONG Offset;
30+
2531 INIT_API ();
2632
27- g_ExtControl->Execute (
28- DEBUG_OUTCTL_ALL_CLIENTS,
29- " .exdicmd target:0:?" ,
30- DEBUG_EXECUTE_DEFAULT
31- );
33+ Offset = 0 ;
34+
35+ // Loop on the command until the entire response is received.
36+ while (TRUE ) {
37+ Response = MonitorCommandWithOutput (Client, args, Offset);
38+
39+ // Strip of the trailing newline character if it exists since this in injected
40+ // by windbg and is not part of the response.
41+ Len = (ULONG)strlen (Response);
42+ if ((Len > 0 ) && (Response[Len - 1 ] == ' \n ' )) {
43+ Len--;
44+ }
45+
46+ if (Len > TruncateTagLen) {
47+ if (strncmp (Response + Len - TruncateTagLen, TruncateTag, TruncateTagLen) == 0 ) {
48+ // The response was truncated, so we need to read more.
49+ Response[Len - TruncateTagLen] = 0 ; // Remove the truncate tag.
50+ dprintf (" %s" , Response);
51+ Offset += Len - TruncateTagLen;
52+ continue ;
53+ }
54+ }
55+
56+ break ;
57+ }
58+
59+ dprintf (" %s\n " , Response);
3260
3361 EXIT_API ();
3462 return S_OK;
3563}
3664
3765HRESULT CALLBACK
38- modulebreak (
66+ info (
3967 PDEBUG_CLIENT4 Client,
4068 PCSTR args
4169 )
4270{
43- CHAR Command[512 ];
44-
4571 INIT_API ();
4672
47- if (RUST == gUefiEnv ) {
48- sprintf_s (Command, sizeof (Command), " .exdicmd target:0:mod break %s" , args);
49- } else {
50- sprintf_s (Command, sizeof (Command), " .exdicmd target:0:b%s" , args);
51- }
52-
53- g_ExtControl->Execute (
54- DEBUG_OUTCTL_ALL_CLIENTS,
55- Command,
56- DEBUG_EXECUTE_DEFAULT
57- );
73+ monitor (Client, " ?" );
5874
5975 EXIT_API ();
6076 return S_OK;
6177}
6278
6379HRESULT CALLBACK
64- readmsr (
80+ modulebreak (
6581 PDEBUG_CLIENT4 Client,
6682 PCSTR args
6783 )
@@ -70,23 +86,20 @@ readmsr (
7086
7187 INIT_API ();
7288
73- if (strlen (args) == 0 ) {
74- dprintf (" Must provide MSR index in HEX!" );
89+ if (RUST == gUefiEnv ) {
90+ sprintf_s (Command, sizeof (Command), " mod break %s" , args);
91+ } else {
92+ sprintf_s (Command, sizeof (Command), " b%s" , args);
7593 }
7694
77- sprintf_s (Command, sizeof (Command), " .exdicmd target:0:m%s" , args);
78- g_ExtControl->Execute (
79- DEBUG_OUTCTL_ALL_CLIENTS,
80- Command,
81- DEBUG_EXECUTE_DEFAULT
82- );
95+ monitor (Client, Command);
8396
8497 EXIT_API ();
8598 return S_OK;
8699}
87100
88101HRESULT CALLBACK
89- readvar (
102+ readmsr (
90103 PDEBUG_CLIENT4 Client,
91104 PCSTR args
92105 )
@@ -96,15 +109,11 @@ readvar (
96109 INIT_API ();
97110
98111 if (strlen (args) == 0 ) {
99- dprintf (" Must provide variable name! " );
112+ dprintf (" Must provide MSR index in HEX! E.g. 0x1234 \n " );
100113 }
101114
102- sprintf_s (Command, sizeof (Command), " .exdicmd target:0:v%s" , args);
103- g_ExtControl->Execute (
104- DEBUG_OUTCTL_ALL_CLIENTS,
105- Command,
106- DEBUG_EXECUTE_DEFAULT
107- );
115+ sprintf_s (Command, sizeof (Command), " m%s" , args);
116+ monitor (Client, Command);
108117
109118 EXIT_API ();
110119 return S_OK;
@@ -143,49 +152,3 @@ reboot (
143152 EXIT_API ();
144153 return S_OK;
145154}
146-
147- HRESULT CALLBACK
148- monitor (
149- PDEBUG_CLIENT4 Client,
150- PCSTR args
151- )
152- {
153- PSTR Response;
154- ULONG Len;
155- const CHAR *TruncateTag = " #T#" ;
156- const ULONG TruncateTagLen = sizeof (" #T#" ) - 1 ; // Exclude the null terminator.
157- ULONG Offset;
158-
159- INIT_API ();
160-
161- Offset = 0 ;
162-
163- // Loop on the command until the entire response is received.
164- while (TRUE ) {
165- Response = MonitorCommandWithOutput (Client, args, Offset);
166-
167- // Strip of the trailing newline character if it exists since this in injected
168- // by windbg and is not part of the response.
169- Len = (ULONG)strlen (Response);
170- if ((Len > 0 ) && (Response[Len - 1 ] == ' \n ' )) {
171- Len--;
172- }
173-
174- if (Len > TruncateTagLen) {
175- if (strncmp (Response + Len - TruncateTagLen, TruncateTag, TruncateTagLen) == 0 ) {
176- // The response was truncated, so we need to read more.
177- Response[Len - TruncateTagLen] = 0 ; // Remove the truncate tag.
178- dprintf (" %s" , Response);
179- Offset += Len - TruncateTagLen;
180- continue ;
181- }
182- }
183-
184- break ;
185- }
186-
187- dprintf (" %s\n " , Response);
188-
189- EXIT_API ();
190- return S_OK;
191- }
0 commit comments