Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: dll/win32/kernel32/client/console/readwrite.c * PURPOSE: Win32 Console Client read-write functions * PROGRAMMERS: Emanuele Aliberti * Marty Dill * Filip Navara (xnavara@volny.cz) * Thomas Weidenmueller (w3seek@reactos.org) * Jeffrey Morlan */
/* INCLUDES *******************************************************************/
#include <k32.h>
#define NDEBUG#include <debug.h>
/* See consrv/include/rect.h */#define ConioRectHeight(Rect) \ (((Rect)->Top > (Rect)->Bottom) ? 0 : ((Rect)->Bottom - (Rect)->Top + 1))#define ConioRectWidth(Rect) \ (((Rect)->Left > (Rect)->Right) ? 0 : ((Rect)->Right - (Rect)->Left + 1))
/* PRIVATE FUNCTIONS **********************************************************/
/****************** * Read functions * ******************/
staticBOOLIntReadConsole(IN HANDLE hConsoleInput, OUT PVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL, IN BOOLEAN bUnicode){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_READCONSOLE ReadConsoleRequest = &ApiMessage.Data.ReadConsoleRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL; ULONG CharSize, SizeBytes;
DPRINT("IntReadConsole\n");
/* Set up the data to send to the Console Server */ ReadConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; ReadConsoleRequest->InputHandle = hConsoleInput; ReadConsoleRequest->Unicode = bUnicode;
/* * Retrieve the (current) Input EXE name string and length, * not NULL-terminated (always in UNICODE format). */ ReadConsoleRequest->ExeLength = GetCurrentExeName((PWCHAR)ReadConsoleRequest->StaticBuffer, sizeof(ReadConsoleRequest->StaticBuffer));
/*** For DEBUGGING purposes ***/ { UNICODE_STRING ExeName; ExeName.Length = ExeName.MaximumLength = ReadConsoleRequest->ExeLength; ExeName.Buffer = (PWCHAR)ReadConsoleRequest->StaticBuffer; DPRINT("IntReadConsole(ExeName = %wZ)\n", &ExeName); } /******************************/
/* Determine the needed size */ CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); SizeBytes = nNumberOfCharsToRead * CharSize;
ReadConsoleRequest->CaptureBufferSize = ReadConsoleRequest->NumBytes = SizeBytes;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than eighty * bytes are read. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (SizeBytes <= sizeof(ReadConsoleRequest->StaticBuffer)) { ReadConsoleRequest->Buffer = ReadConsoleRequest->StaticBuffer; // CaptureBuffer = NULL; } else { /* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, SizeBytes, (PVOID*)&ReadConsoleRequest->Buffer); }
ReadConsoleRequest->InitialNumBytes = 0; ReadConsoleRequest->CtrlWakeupMask = 0; ReadConsoleRequest->ControlKeyState = 0;
/* * From MSDN (ReadConsole function), the description * for pInputControl says: * "This parameter requires Unicode input by default. * For ANSI mode, set this parameter to NULL." */ _SEH2_TRY { if (bUnicode && pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) { /* Sanity check */ if (pInputControl->nInitialChars <= nNumberOfCharsToRead) { ReadConsoleRequest->InitialNumBytes = pInputControl->nInitialChars * sizeof(WCHAR); // CharSize
if (pInputControl->nInitialChars != 0) { /* * It is possible here to overwrite the static buffer, in case * the number of bytes to read was smaller than the static buffer. * In this case, this means we are continuing a pending read, * and we do not need in fact the executable name that was * stored in the static buffer because it was first grabbed when * we started the first read. */ RtlCopyMemory(ReadConsoleRequest->Buffer, lpBuffer, ReadConsoleRequest->InitialNumBytes); }
ReadConsoleRequest->CtrlWakeupMask = pInputControl->dwCtrlWakeupMask; } else { // Status = STATUS_INVALID_PARAMETER; } } else { /* We are in a situation where pInputControl has no meaning */ pInputControl = NULL; } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { // HACK if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer); SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END;
/* FIXME: Check for sanity *//* if (!NT_SUCCESS(Status) && pInputControl) { // Free CaptureBuffer if needed // Set last error to last status // Return FALSE }*/
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsole), sizeof(*ReadConsoleRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Retrieve the results */ if (Success) { _SEH2_TRY { *lpNumberOfCharsRead = ReadConsoleRequest->NumBytes / CharSize;
if (bUnicode && pInputControl) pInputControl->dwControlKeyState = ReadConsoleRequest->ControlKeyState;
RtlCopyMemory(lpBuffer, ReadConsoleRequest->Buffer, ReadConsoleRequest->NumBytes); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END; } else { BaseSetLastNTError(ApiMessage.Status); }
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
if (Success) { /* Yield execution to another thread if Ctrl-C or Ctrl-Break happened */ if (ApiMessage.Status == STATUS_ALERTED /* || ApiMessage.Status == STATUS_CANCELLED */) { NtYieldExecution(); SetLastError(ERROR_OPERATION_ABORTED); // STATUS_CANCELLED } }
/* Return success status */ return Success;}
staticBOOLIntGetConsoleInput(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags, IN BOOLEAN bUnicode){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_GETINPUT GetInputRequest = &ApiMessage.Data.GetInputRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
if (!IsConsoleHandle(hConsoleInput)) { _SEH2_TRY { *lpNumberOfEventsRead = 0; SetLastError(ERROR_INVALID_HANDLE); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); } _SEH2_END;
return FALSE; }
DPRINT("IntGetConsoleInput: %lx %p\n", nLength, lpNumberOfEventsRead);
/* Set up the data to send to the Console Server */ GetInputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; GetInputRequest->InputHandle = hConsoleInput; GetInputRequest->NumRecords = nLength; GetInputRequest->Flags = wFlags; GetInputRequest->Unicode = bUnicode;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than five * input records are read. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (nLength <= sizeof(GetInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD)) { GetInputRequest->RecordBufPtr = GetInputRequest->RecordStaticBuffer; // CaptureBuffer = NULL; } else { ULONG Size = nLength * sizeof(INPUT_RECORD);
/* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, Size, (PVOID*)&GetInputRequest->RecordBufPtr); }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetConsoleInput), sizeof(*GetInputRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Retrieve the results */ _SEH2_TRY { DPRINT("Events read: %lx\n", GetInputRequest->NumRecords); *lpNumberOfEventsRead = GetInputRequest->NumRecords;
if (Success) { RtlCopyMemory(lpBuffer, GetInputRequest->RecordBufPtr, GetInputRequest->NumRecords * sizeof(INPUT_RECORD)); } else { BaseSetLastNTError(ApiMessage.Status); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Return success status */ return Success;}
staticBOOLIntReadConsoleOutput(IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion, IN BOOLEAN bUnicode){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_READOUTPUT ReadOutputRequest = &ApiMessage.Data.ReadOutputRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
SHORT SizeX, SizeY; ULONG NumCells;
/* Set up the data to send to the Console Server */ ReadOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; ReadOutputRequest->OutputHandle = hConsoleOutput; ReadOutputRequest->Unicode = bUnicode;
/* Update lpReadRegion */ _SEH2_TRY { SizeX = min(dwBufferSize.X - dwBufferCoord.X, ConioRectWidth(lpReadRegion)); SizeY = min(dwBufferSize.Y - dwBufferCoord.Y, ConioRectHeight(lpReadRegion)); if (SizeX <= 0 || SizeY <= 0) { SetLastError(ERROR_INVALID_PARAMETER); _SEH2_YIELD(return FALSE); } lpReadRegion->Right = lpReadRegion->Left + SizeX - 1; lpReadRegion->Bottom = lpReadRegion->Top + SizeY - 1;
ReadOutputRequest->ReadRegion = *lpReadRegion; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END;
NumCells = SizeX * SizeY; DPRINT("IntReadConsoleOutput: (%d x %d)\n", SizeX, SizeY);
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than one * cell is read. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (NumCells <= 1) { ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer; // CaptureBuffer = NULL; } else { ULONG Size = NumCells * sizeof(CHAR_INFO);
/* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed with size %ld!\n", Size); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, Size, (PVOID*)&ReadOutputRequest->CharInfo); }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsoleOutput), sizeof(*ReadOutputRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Retrieve the results */ _SEH2_TRY { *lpReadRegion = ReadOutputRequest->ReadRegion;
if (Success) {#if 0 SHORT x, X;#endif SHORT y, Y;
/* Copy into the buffer */
SizeX = ConioRectWidth(&ReadOutputRequest->ReadRegion);
for (y = 0, Y = ReadOutputRequest->ReadRegion.Top; Y <= ReadOutputRequest->ReadRegion.Bottom; ++y, ++Y) { RtlCopyMemory(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + dwBufferCoord.X, ReadOutputRequest->CharInfo + y * SizeX, SizeX * sizeof(CHAR_INFO));#if 0 for (x = 0, X = ReadOutputRequest->ReadRegion.Left; X <= ReadOutputRequest->ReadRegion.Right; ++x, ++X) { *(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + (x + dwBufferCoord.X)) = *(ReadOutputRequest->CharInfo + y * SizeX + x); }#endif } } else { BaseSetLastNTError(ApiMessage.Status); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Return success status */ return Success;}
staticBOOLIntReadConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, OUT PVOID pCode, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCodesRead){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &ApiMessage.Data.ReadOutputCodeRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL; ULONG CodeSize, SizeBytes;
DPRINT("IntReadConsoleOutputCode\n");
if ( (CodeType != CODE_ASCII ) && (CodeType != CODE_UNICODE ) && (CodeType != CODE_ATTRIBUTE) ) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
/* Set up the data to send to the Console Server */ ReadOutputCodeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; ReadOutputCodeRequest->OutputHandle = hConsoleOutput; ReadOutputCodeRequest->Coord = dwReadCoord; ReadOutputCodeRequest->NumCodes = nLength;
/* Determine the needed size */ ReadOutputCodeRequest->CodeType = CodeType; switch (CodeType) { case CODE_ASCII: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar); break;
case CODE_UNICODE: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar); break;
case CODE_ATTRIBUTE: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute); break; } SizeBytes = nLength * CodeSize;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than eighty * bytes are read. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (SizeBytes <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer)) { ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer; // CaptureBuffer = NULL; } else { /* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, SizeBytes, (PVOID*)&ReadOutputCodeRequest->pCode); }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsoleOutputString), sizeof(*ReadOutputCodeRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Retrieve the results */ _SEH2_TRY { *lpNumberOfCodesRead = ReadOutputCodeRequest->NumCodes;
if (Success) { RtlCopyMemory(pCode, ReadOutputCodeRequest->pCode, ReadOutputCodeRequest->NumCodes * CodeSize); } else { BaseSetLastNTError(ApiMessage.Status); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Return success status */ return Success;}
/******************* * Write functions * *******************/
staticBOOLIntWriteConsole(IN HANDLE hConsoleOutput, IN PVOID lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved, IN BOOLEAN bUnicode){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITECONSOLE WriteConsoleRequest = &ApiMessage.Data.WriteConsoleRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL; ULONG CharSize, SizeBytes;
DPRINT("IntWriteConsole\n");
/* Set up the data to send to the Console Server */ WriteConsoleRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; WriteConsoleRequest->OutputHandle = hConsoleOutput; WriteConsoleRequest->Unicode = bUnicode;
/* Those members are unused by the client, on Windows */ WriteConsoleRequest->Reserved1 = 0; // WriteConsoleRequest->Reserved2 = {0};
/* Determine the needed size */ CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); SizeBytes = nNumberOfCharsToWrite * CharSize;
WriteConsoleRequest->NumBytes = SizeBytes;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than eighty * bytes are written. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (SizeBytes <= sizeof(WriteConsoleRequest->StaticBuffer)) { WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer; // CaptureBuffer = NULL; WriteConsoleRequest->UsingStaticBuffer = TRUE;
_SEH2_TRY { RtlCopyMemory(WriteConsoleRequest->Buffer, lpBuffer, SizeBytes); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END; } else { /* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Capture the buffer to write */ CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpBuffer, SizeBytes, (PVOID*)&WriteConsoleRequest->Buffer); WriteConsoleRequest->UsingStaticBuffer = FALSE; }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsole), sizeof(*WriteConsoleRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Retrieve the results. NOTE: lpNumberOfCharsWritten optional since Vista+ */ if (Success && lpNumberOfCharsWritten) { _SEH2_TRY { *lpNumberOfCharsWritten = WriteConsoleRequest->NumBytes / CharSize; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END; } else if (!Success) { BaseSetLastNTError(ApiMessage.Status); }
/* Return success status */ return Success;}
staticBOOLIntWriteConsoleInput(IN HANDLE hConsoleInput, IN PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten, IN BOOLEAN bUnicode, IN BOOLEAN bAppendToEnd){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITEINPUT WriteInputRequest = &ApiMessage.Data.WriteInputRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
DPRINT("IntWriteConsoleInput: %lx %p\n", nLength, lpNumberOfEventsWritten);
/* Set up the data to send to the Console Server */ WriteInputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; WriteInputRequest->InputHandle = hConsoleInput; WriteInputRequest->NumRecords = nLength; WriteInputRequest->Unicode = bUnicode; WriteInputRequest->AppendToEnd = bAppendToEnd;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than five * input records are written. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (nLength <= sizeof(WriteInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD)) { WriteInputRequest->RecordBufPtr = WriteInputRequest->RecordStaticBuffer; // CaptureBuffer = NULL;
_SEH2_TRY { RtlCopyMemory(WriteInputRequest->RecordBufPtr, lpBuffer, nLength * sizeof(INPUT_RECORD)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END; } else { ULONG Size = nLength * sizeof(INPUT_RECORD);
/* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Capture the user buffer */ CsrCaptureMessageBuffer(CaptureBuffer, lpBuffer, Size, (PVOID*)&WriteInputRequest->RecordBufPtr); }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleInput), sizeof(*WriteInputRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Retrieve the results */ _SEH2_TRY { DPRINT("Events written: %lx\n", WriteInputRequest->NumRecords); *lpNumberOfEventsWritten = WriteInputRequest->NumRecords;
if (!Success) BaseSetLastNTError(ApiMessage.Status); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Return success status */ return Success;}
staticBOOLIntWriteConsoleOutput(IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion, IN BOOLEAN bUnicode){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITEOUTPUT WriteOutputRequest = &ApiMessage.Data.WriteOutputRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL;
SHORT SizeX, SizeY; ULONG NumCells;
/* Set up the data to send to the Console Server */ WriteOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; WriteOutputRequest->OutputHandle = hConsoleOutput; WriteOutputRequest->Unicode = bUnicode;
/* Update lpWriteRegion */ _SEH2_TRY { SizeX = min(dwBufferSize.X - dwBufferCoord.X, ConioRectWidth(lpWriteRegion)); SizeY = min(dwBufferSize.Y - dwBufferCoord.Y, ConioRectHeight(lpWriteRegion)); if (SizeX <= 0 || SizeY <= 0) { SetLastError(ERROR_INVALID_PARAMETER); _SEH2_YIELD(return FALSE); } lpWriteRegion->Right = lpWriteRegion->Left + SizeX - 1; lpWriteRegion->Bottom = lpWriteRegion->Top + SizeY - 1;
WriteOutputRequest->WriteRegion = *lpWriteRegion; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END;
NumCells = SizeX * SizeY; DPRINT("IntWriteConsoleOutput: (%d x %d)\n", SizeX, SizeY);
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than one * cell is written. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (NumCells <= 1) { WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer; // CaptureBuffer = NULL; WriteOutputRequest->UseVirtualMemory = FALSE; } else { ULONG Size = NumCells * sizeof(CHAR_INFO);
/* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); if (CaptureBuffer) { /* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, Size, (PVOID*)&WriteOutputRequest->CharInfo); WriteOutputRequest->UseVirtualMemory = FALSE; } else { /* * CsrAllocateCaptureBuffer failed because we tried to allocate * a too large (>= 64 kB, size of the CSR heap) data buffer. * To circumvent this, Windows uses a trick (that we reproduce for * compatibility reasons): we allocate a heap buffer in the process' * memory, and CSR will read it via NtReadVirtualMemory. */ DPRINT1("CsrAllocateCaptureBuffer failed with size %ld, let's use local heap buffer...\n", Size);
WriteOutputRequest->CharInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, Size); WriteOutputRequest->UseVirtualMemory = TRUE;
/* Bail out if we still cannot allocate memory */ if (WriteOutputRequest->CharInfo == NULL) { DPRINT1("Failed to allocate heap buffer with size %ld!\n", Size); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } } }
/* Capture the user buffer contents */ _SEH2_TRY {#if 0 SHORT x, X;#endif SHORT y, Y;
/* Copy into the buffer */
SizeX = ConioRectWidth(&WriteOutputRequest->WriteRegion);
for (y = 0, Y = WriteOutputRequest->WriteRegion.Top; Y <= WriteOutputRequest->WriteRegion.Bottom; ++y, ++Y) { RtlCopyMemory(WriteOutputRequest->CharInfo + y * SizeX, lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + dwBufferCoord.X, SizeX * sizeof(CHAR_INFO));#if 0 for (x = 0, X = WriteOutputRequest->WriteRegion.Left; X <= WriteOutputRequest->WriteRegion.Right; ++x, ++X) { *(WriteOutputRequest->CharInfo + y * SizeX + x) = *(lpBuffer + (y + dwBufferCoord.Y) * dwBufferSize.X + (x + dwBufferCoord.X)); }#endif } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END;
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleOutput), sizeof(*WriteOutputRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Release the capture buffer if needed */ if (CaptureBuffer) { CsrFreeCaptureBuffer(CaptureBuffer); } else { /* If we used a heap buffer, free it */ if (WriteOutputRequest->UseVirtualMemory) RtlFreeHeap(RtlGetProcessHeap(), 0, WriteOutputRequest->CharInfo); }
/* Retrieve the results */ _SEH2_TRY { *lpWriteRegion = WriteOutputRequest->WriteRegion;
if (!Success) BaseSetLastNTError(ApiMessage.Status); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Return success status */ return Success;}
staticBOOLIntWriteConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CONST VOID *pCode, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &ApiMessage.Data.WriteOutputCodeRequest; PCSR_CAPTURE_BUFFER CaptureBuffer = NULL; ULONG CodeSize, SizeBytes;
if ( (CodeType != CODE_ASCII ) && (CodeType != CODE_UNICODE ) && (CodeType != CODE_ATTRIBUTE) ) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
DPRINT("IntWriteConsoleOutputCode\n");
/* Set up the data to send to the Console Server */ WriteOutputCodeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; WriteOutputCodeRequest->OutputHandle = hConsoleOutput; WriteOutputCodeRequest->Coord = dwWriteCoord; WriteOutputCodeRequest->NumCodes = nLength;
/* Determine the needed size */ WriteOutputCodeRequest->CodeType = CodeType; switch (CodeType) { case CODE_ASCII: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar); break;
case CODE_UNICODE: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar); break;
case CODE_ATTRIBUTE: CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute); break; } SizeBytes = nLength * CodeSize;
/* * For optimization purposes, Windows (and hence ReactOS, too, for * compatibility reasons) uses a static buffer if no more than eighty * bytes are written. Otherwise a new buffer is allocated. * This behaviour is also expected in the server-side. */ if (SizeBytes <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer)) { WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer; // CaptureBuffer = NULL;
_SEH2_TRY { RtlCopyMemory(WriteOutputCodeRequest->pCode, pCode, SizeBytes); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); _SEH2_YIELD(return FALSE); } _SEH2_END; } else { /* Allocate a Capture Buffer */ CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; }
/* Capture the buffer to write */ CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)pCode, SizeBytes, (PVOID*)&WriteOutputCodeRequest->pCode); }
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepWriteConsoleOutputString), sizeof(*WriteOutputCodeRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Release the capture buffer if needed */ if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
/* Retrieve the results */ _SEH2_TRY { *lpNumberOfCodesWritten = WriteOutputCodeRequest->NumCodes;
if (!Success) BaseSetLastNTError(ApiMessage.Status); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Return success status */ return Success;}
staticBOOLIntFillConsoleOutputCode(IN HANDLE hConsoleOutput, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCodesWritten){ BOOL Success; CONSOLE_API_MESSAGE ApiMessage; PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
DPRINT("IntFillConsoleOutputCode\n");
if ( (CodeType != CODE_ASCII ) && (CodeType != CODE_UNICODE ) && (CodeType != CODE_ATTRIBUTE) ) { SetLastError(ERROR_INVALID_PARAMETER); return FALSE; }
/* Set up the data to send to the Console Server */ FillOutputRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle; FillOutputRequest->OutputHandle = hConsoleOutput; FillOutputRequest->WriteCoord = dwWriteCoord; FillOutputRequest->CodeType = CodeType; FillOutputRequest->Code = Code; FillOutputRequest->NumCodes = nLength;
/* Call the server */ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, NULL, CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepFillConsoleOutput), sizeof(*FillOutputRequest));
/* Check for success */ Success = NT_SUCCESS(ApiMessage.Status);
/* Retrieve the results */ _SEH2_TRY { *lpNumberOfCodesWritten = FillOutputRequest->NumCodes;
if (!Success) BaseSetLastNTError(ApiMessage.Status); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { SetLastError(ERROR_INVALID_ACCESS); Success = FALSE; } _SEH2_END;
/* Return success status */ return Success;}
/* FUNCTIONS ******************************************************************/
/****************** * Read functions * ******************/
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleW(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL){ return IntReadConsole(hConsoleInput, lpBuffer, nNumberOfCharsToRead, lpNumberOfCharsRead, pInputControl, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleA(IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN PCONSOLE_READCONSOLE_CONTROL pInputControl OPTIONAL){ return IntReadConsole(hConsoleInput, lpBuffer, nNumberOfCharsToRead, lpNumberOfCharsRead, NULL, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHPeekConsoleInputW(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, CONSOLE_READ_NOREMOVE | CONSOLE_READ_NOWAIT, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHPeekConsoleInputA(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, CONSOLE_READ_NOREMOVE | CONSOLE_READ_NOWAIT, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleInputW(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, 0, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleInputA(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, 0, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleInputExW(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, wFlags, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleInputExA(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN WORD wFlags){ return IntGetConsoleInput(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead, wFlags, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleOutputW(IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion){ return IntReadConsoleOutput(hConsoleOutput, lpBuffer, dwBufferSize, dwBufferCoord, lpReadRegion, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleOutputA(IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion){ return IntReadConsoleOutput(hConsoleOutput, lpBuffer, dwBufferSize, dwBufferCoord, lpReadRegion, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleOutputCharacterW(IN HANDLE hConsoleOutput, OUT LPWSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead){ return IntReadConsoleOutputCode(hConsoleOutput, CODE_UNICODE, lpCharacter, nLength, dwReadCoord, lpNumberOfCharsRead);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleOutputCharacterA(IN HANDLE hConsoleOutput, OUT LPSTR lpCharacter, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfCharsRead){ return IntReadConsoleOutputCode(hConsoleOutput, CODE_ASCII, lpCharacter, nLength, dwReadCoord, lpNumberOfCharsRead);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHReadConsoleOutputAttribute(IN HANDLE hConsoleOutput, OUT LPWORD lpAttribute, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfAttrsRead){ return IntReadConsoleOutputCode(hConsoleOutput, CODE_ATTRIBUTE, lpAttribute, nLength, dwReadCoord, lpNumberOfAttrsRead);}
/******************* * Write functions * *******************/
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleW(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved){ return IntWriteConsole(hConsoleOutput, (PVOID)lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleA(IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, LPVOID lpReserved){ return IntWriteConsole(hConsoleOutput, (PVOID)lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleInputW(IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten){ return IntWriteConsoleInput(hConsoleInput, (PINPUT_RECORD)lpBuffer, nLength, lpNumberOfEventsWritten, TRUE, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleInputA(IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten){ return IntWriteConsoleInput(hConsoleInput, (PINPUT_RECORD)lpBuffer, nLength, lpNumberOfEventsWritten, FALSE, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleInputVDMW(IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten){ return IntWriteConsoleInput(hConsoleInput, (PINPUT_RECORD)lpBuffer, nLength, lpNumberOfEventsWritten, TRUE, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleInputVDMA(IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten){ return IntWriteConsoleInput(hConsoleInput, (PINPUT_RECORD)lpBuffer, nLength, lpNumberOfEventsWritten, FALSE, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleOutputW(IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion){ return IntWriteConsoleOutput(hConsoleOutput, lpBuffer, dwBufferSize, dwBufferCoord, lpWriteRegion, TRUE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleOutputA(IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpWriteRegion){ return IntWriteConsoleOutput(hConsoleOutput, lpBuffer, dwBufferSize, dwBufferCoord, lpWriteRegion, FALSE);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN LPCWSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten){ return IntWriteConsoleOutputCode(hConsoleOutput, CODE_UNICODE, lpCharacter, nLength, dwWriteCoord, lpNumberOfCharsWritten);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN LPCSTR lpCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten){ return IntWriteConsoleOutputCode(hConsoleOutput, CODE_ASCII, lpCharacter, nLength, dwWriteCoord, lpNumberOfCharsWritten);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHWriteConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN CONST WORD *lpAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten){ return IntWriteConsoleOutputCode(hConsoleOutput, CODE_ATTRIBUTE, lpAttribute, nLength, dwWriteCoord, lpNumberOfAttrsWritten);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHFillConsoleOutputCharacterW(IN HANDLE hConsoleOutput, IN WCHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfCharsWritten){ CODE_ELEMENT Code; Code.UnicodeChar = cCharacter; return IntFillConsoleOutputCode(hConsoleOutput, CODE_UNICODE, Code, nLength, dwWriteCoord, lpNumberOfCharsWritten);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHFillConsoleOutputCharacterA(IN HANDLE hConsoleOutput, IN CHAR cCharacter, IN DWORD nLength, IN COORD dwWriteCoord, LPDWORD lpNumberOfCharsWritten){ CODE_ELEMENT Code; Code.AsciiChar = cCharacter; return IntFillConsoleOutputCode(hConsoleOutput, CODE_ASCII, Code, nLength, dwWriteCoord, lpNumberOfCharsWritten);}
/* * @implemented */BOOLWINAPIDECLSPEC_HOTPATCHFillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten){ CODE_ELEMENT Code; Code.Attribute = wAttribute; return IntFillConsoleOutputCode(hConsoleOutput, CODE_ATTRIBUTE, Code, nLength, dwWriteCoord, lpNumberOfAttrsWritten);}
/* EOF */