/* GLOBALS ********************************************************************/
+/*
+ * From MSDN:
+ * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
+ * If they are the same, the function fails, and GetLastError returns
+ * ERROR_INVALID_PARAMETER."
+ */
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \
+ ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \
+ ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
typedef struct ConsoleInput_t
/* Validity checks */
ASSERT(Console == InputBuffer->Header.Console);
- ASSERT( (Buffer != NULL && NumCharsToRead > 0) ||
- (Buffer == NULL && NumCharsToRead == 0) );
+ ASSERT((Buffer != NULL) || (Buffer == NULL && NumCharsToRead == 0));
/* We haven't read anything (yet) */
/* Validity checks */
ASSERT(Console == InputBuffer->Header.Console);
- ASSERT( (InputRecord != NULL && NumEventsToRead > 0) ||
- (InputRecord == NULL && NumEventsToRead == 0) );
+ ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToRead == 0));
- // Do NOT do that !! Use the existing number of events already read, if any...
- // if (NumEventsRead) *NumEventsRead = 0;
+ if (NumEventsRead) *NumEventsRead = 0;
if (IsListEmpty(&InputBuffer->InputEvents))
{
/* Only get input if there is any */
CurrentInput = InputBuffer->InputEvents.Flink;
- if (NumEventsRead) i = *NumEventsRead; // We will read the remaining events...
-
+ i = 0;
while ((CurrentInput != &InputBuffer->InputEvents) && (i < NumEventsToRead))
{
Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry);
/* Validity checks */
ASSERT(Console == InputBuffer->Header.Console);
- ASSERT( (InputRecord != NULL && NumEventsToWrite > 0) ||
- (InputRecord == NULL && NumEventsToWrite == 0) );
+ ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToWrite == 0));
- // Do NOT do that !! Use the existing number of events already written, if any...
// if (NumEventsWritten) *NumEventsWritten = 0;
+ // Status = ConioAddInputEvents(Console, InputRecord, NumEventsToWrite, NumEventsWritten, AppendToEnd);
- for (i = (NumEventsWritten ? *NumEventsWritten : 0); i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
+ for (i = 0; i < NumEventsToWrite && NT_SUCCESS(Status); ++i)
{
if (!Unicode)
{