59{
63 string DetailsOfSource;
65 PLIST_ENTRY TempList = 0;
67 HANDLE SourceHandle = INVALID_HANDLE_VALUE;
69 HMODULE Module =
NULL;
70
71 if ((CommandTokens.size() != 1 && CommandTokens.size() <= 2) || CommandTokens.size() >= 6)
72 {
73 ShowMessages("incorrect use of the '%s'\n\n",
76 return;
77 }
78
79
80
81
82 if (CommandTokens.size() == 1)
83 {
84 IndexToShowList = 0;
85
87 {
89
91 {
92 TempList = TempList->Blink;
93
96
97
98
99
100 IndexToShowList++;
101
102 string TempStateString = "";
103 string TempTypeString = "";
104
105 if (CurrentOutputSourceDetails->
State ==
107 {
108 TempStateString = "not opened";
109 }
110 else if (CurrentOutputSourceDetails->
State ==
112 {
113 TempStateString = "opened ";
114 }
115 else if (CurrentOutputSourceDetails->
State ==
117 {
118 TempStateString = "closed ";
119 }
120
122 {
123 TempTypeString = "namedpipe";
124 }
126 {
127 TempTypeString = "file ";
128 }
130 {
131 TempTypeString = "tcp ";
132 }
134 {
135 TempTypeString = "module ";
136 }
137
138 ShowMessages(
"%x %s %s\t%s\n", IndexToShowList, TempTypeString.c_str(), TempStateString.c_str(), CurrentOutputSourceDetails->
Name);
139 }
140 }
141 else
142 {
143 ShowMessages("output forwarding list is empty\n");
144 }
145
146 return;
147 }
148
149
150
151
153 {
154
155
156
157
158
159
160
161 if (CommandTokens.size() <= 4)
162 {
163 ShowMessages("incorrect use of the '%s'\n\n",
166 return;
167 }
168
169
170
171
173 {
175 }
177 {
179 }
181 {
183 }
185 {
187 }
188 else
189 {
190 ShowMessages("incorrect type near '%s'\n\n",
193 return;
194 }
195
196
197
198
201 {
202 ShowMessages("name of the output cannot exceed form %d characters\n\n",
205 return;
206 }
207
208
209
210
211
212
214 {
216
218 {
219 TempList = TempList->Flink;
220
223
224 if (strcmp(CurrentOutputSourceDetails->
Name,
226 {
227
228
229
230 OutputSourceFound =
TRUE;
231
232
233
234
235 break;
236 }
237 }
238
239
240
241
242 if (OutputSourceFound)
243 {
244 ShowMessages("err, the name you entered, already exists, please choose "
245 "another name\n");
246 return;
247 }
248 }
249
250
251
252
254
256
257
258
259
260 if (SourceHandle == INVALID_HANDLE_VALUE)
261 {
262 ShowMessages(
263 "err, invalid address or cannot open or find the address\n");
264 return;
265 }
266
267
268
269
270 EventForwardingObject =
272
273 if (EventForwardingObject == NULL)
274 {
275 ShowMessages("err, in allocating memory for event forwarding\n");
276 return;
277 }
278
280
281
282
283
285
286
287
288
289 EventForwardingObject->
Type = Type;
290
291
292
293
295
296
297
298
299
301 {
302 EventForwardingObject->
Socket = Socket;
303 }
305 {
306 EventForwardingObject->
Module = Module;
307
308
309
310
311 EventForwardingObject->
Handle = SourceHandle;
312 }
313 else
314 {
315 EventForwardingObject->
Handle = SourceHandle;
316 }
317
318
319
320
321 strcpy_s(EventForwardingObject->
Name,
323
324
325
326
328 {
331 }
332
333
334
335
338 }
340 {
341
342
343
345 {
346 ShowMessages("err, the name you entered, not found\n");
347 return;
348 }
349
350
351
352
353
355
357 {
358 TempList = TempList->Flink;
359
361 TempList,
363 OutputSourcesList);
364
365 if (strcmp(CurrentOutputSourceDetails->
Name,
367 {
368
369
370
371 OutputSourceFound =
TRUE;
372
373
374
375
377
379 {
380 ShowMessages("err, the name you entered was already closed\n");
381 return;
382 }
384 {
385 ShowMessages("err, the name you entered was already opened\n");
386 return;
387 }
388 else if (Status !=
390 {
391 ShowMessages("err, unable to open the output source\n");
392 return;
393 }
394
395
396
397
398 break;
399 }
400 }
401
402 if (!OutputSourceFound)
403 {
404 ShowMessages("err, the name you entered, not found\n");
405 return;
406 }
407 }
409 {
410
411
412
414 {
415 ShowMessages("err, the name you entered, not found\n");
416 return;
417 }
418
419
420
421
422
424
426 {
427 TempList = TempList->Flink;
428
430 TempList,
432 OutputSourcesList);
433
434 if (strcmp(CurrentOutputSourceDetails->
Name,
436 {
437
438
439
440 OutputSourceFound =
TRUE;
441
442
443
444
446
448 {
449 ShowMessages("err, the name you entered was already closed\n");
450 return;
451 }
453 {
454 ShowMessages("err, unable to close the source\n");
455 return;
456 }
457 else if (Status !=
459 {
460 ShowMessages("err, unable to close the source\n");
461 return;
462 }
463
464
465
466
467 break;
468 }
469 }
470
471 if (!OutputSourceFound)
472 {
473 ShowMessages("err, the name you entered, not found\n");
474 return;
475 }
476 }
477 else
478 {
479
480
481
482 ShowMessages("incorrect option at '%s'\n\n",
485 return;
486 }
487}
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN CompareLowerCaseStrings(CommandToken TargetToken, const CHAR *StringToCompare)
Compare lower case strings.
Definition common.cpp:503
DEBUGGER_OUTPUT_SOURCE_STATUS ForwardingCloseOutputSource(PDEBUGGER_EVENT_FORWARDING SourceDescriptor)
Closes the output source.
Definition forwarding.cpp:110
DEBUGGER_OUTPUT_SOURCE_STATUS ForwardingOpenOutputSource(PDEBUGGER_EVENT_FORWARDING SourceDescriptor)
Opens the output source.
Definition forwarding.cpp:40
UINT64 ForwardingGetNewOutputSourceTag()
Get the output source tag and increase the global variable for tag.
Definition forwarding.cpp:28
PVOID ForwardingCreateOutputSource(DEBUGGER_EVENT_FORWARDING_TYPE SourceType, const string &Description, SOCKET *Socket, HMODULE *Module)
Create a new source (create handle from the source).
Definition forwarding.cpp:215
struct _DEBUGGER_EVENT_FORWARDING DEBUGGER_EVENT_FORWARDING
structures hold the detail of event forwarding
@ EVENT_FORWARDING_STATE_OPENED
Definition forwarding.h:54
@ EVENT_FORWARDING_CLOSED
Definition forwarding.h:55
@ EVENT_FORWARDING_STATE_NOT_OPENED
Definition forwarding.h:53
enum _DEBUGGER_EVENT_FORWARDING_TYPE DEBUGGER_EVENT_FORWARDING_TYPE
event forwarding type
#define MAXIMUM_CHARACTERS_FOR_EVENT_FORWARDING_NAME
maximum characters for event forwarding source names
Definition forwarding.h:32
@ DEBUGGER_OUTPUT_SOURCE_STATUS_SUCCESSFULLY_OPENED
Definition forwarding.h:67
@ DEBUGGER_OUTPUT_SOURCE_STATUS_UNKNOWN_ERROR
Definition forwarding.h:71
@ DEBUGGER_OUTPUT_SOURCE_STATUS_ALREADY_OPENED
Definition forwarding.h:69
@ DEBUGGER_OUTPUT_SOURCE_STATUS_SUCCESSFULLY_CLOSED
Definition forwarding.h:68
@ DEBUGGER_OUTPUT_SOURCE_STATUS_ALREADY_CLOSED
Definition forwarding.h:70
enum _DEBUGGER_OUTPUT_SOURCE_STATUS DEBUGGER_OUTPUT_SOURCE_STATUS
output source status
@ EVENT_FORWARDING_TCP
Definition forwarding.h:42
@ EVENT_FORWARDING_MODULE
Definition forwarding.h:43
@ EVENT_FORWARDING_FILE
Definition forwarding.h:41
@ EVENT_FORWARDING_NAMEDPIPE
Definition forwarding.h:40
struct _DEBUGGER_EVENT_FORWARDING * PDEBUGGER_EVENT_FORWARDING
NULL()
Definition test-case-generator.py:530
#define CONTAINING_RECORD(address, type, field)
Definition nt-list.h:36
VOID CommandOutputHelp()
help of the output command
Definition output.cpp:26
LIST_ENTRY g_OutputSources
Holds a list of output sources created by output command.
Definition globals.h:427
BOOLEAN g_OutputSourcesInitialized
it shows whether the debugger started using output sources or not or in other words,...
Definition globals.h:418
LIST_ENTRY OutputSourcesList
Definition forwarding.h:88
DEBUGGER_EVENT_FORWARDING_TYPE Type
Definition forwarding.h:81
DEBUGGER_EVENT_FORWARDING_STATE State
Definition forwarding.h:82
CHAR Name[MAXIMUM_CHARACTERS_FOR_EVENT_FORWARDING_NAME]
Definition forwarding.h:89
SOCKET Socket
Definition forwarding.h:84
HMODULE Module
Definition forwarding.h:85
UINT64 OutputUniqueTag
Definition forwarding.h:86
VOID * Handle
Definition forwarding.h:83