ReactOS  0.4.14-dev-384-g5b37caa
api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CSR_API (SrvAddConsoleAlias)
 
 CSR_API (SrvGetConsoleAlias)
 
 CSR_API (SrvGetConsoleAliases)
 
 CSR_API (SrvGetConsoleAliasesLength)
 
 CSR_API (SrvGetConsoleAliasExes)
 
 CSR_API (SrvGetConsoleAliasExesLength)
 
 CSR_API (SrvReadConsole)
 
 CSR_API (SrvGetConsoleInput)
 
 CSR_API (SrvWriteConsoleInput)
 
 CSR_API (SrvFlushConsoleInputBuffer)
 
 CSR_API (SrvGetConsoleNumberOfInputEvents)
 
 CSR_API (SrvInvalidateBitMapRect)
 
 CSR_API (SrvReadConsoleOutput)
 
 CSR_API (SrvWriteConsole)
 
 CSR_API (SrvWriteConsoleOutput)
 
 CSR_API (SrvReadConsoleOutputString)
 
 CSR_API (SrvWriteConsoleOutputString)
 
 CSR_API (SrvFillConsoleOutput)
 
 CSR_API (SrvGetConsoleCursorInfo)
 
 CSR_API (SrvSetConsoleCursorInfo)
 
 CSR_API (SrvSetConsoleCursorPosition)
 
 CSR_API (SrvSetConsoleTextAttribute)
 
 CSR_API (SrvCreateConsoleScreenBuffer)
 
 CSR_API (SrvGetConsoleScreenBufferInfo)
 
 CSR_API (SrvSetConsoleActiveScreenBuffer)
 
 CSR_API (SrvScrollConsoleScreenBuffer)
 
 CSR_API (SrvSetConsoleScreenBufferSize)
 
 CSR_API (SrvAllocConsole)
 
 CSR_API (SrvAttachConsole)
 
 CSR_API (SrvFreeConsole)
 
 CSR_API (SrvGetConsoleMode)
 
 CSR_API (SrvSetConsoleMode)
 
 CSR_API (SrvGetConsoleTitle)
 
 CSR_API (SrvSetConsoleTitle)
 
 CSR_API (SrvGetConsoleHardwareState)
 
 CSR_API (SrvSetConsoleHardwareState)
 
 CSR_API (SrvGetConsoleDisplayMode)
 
 CSR_API (SrvSetConsoleDisplayMode)
 
 CSR_API (SrvGetLargestConsoleWindowSize)
 
 CSR_API (SrvShowConsoleCursor)
 
 CSR_API (SrvSetConsoleCursor)
 
 CSR_API (SrvConsoleMenuControl)
 
 CSR_API (SrvSetConsoleMenuClose)
 
 CSR_API (SrvSetConsoleWindowInfo)
 
 CSR_API (SrvGetConsoleWindow)
 
 CSR_API (SrvSetConsoleIcon)
 
 CSR_API (SrvGetConsoleCP)
 
 CSR_API (SrvSetConsoleCP)
 
 CSR_API (SrvGetConsoleProcessList)
 
 CSR_API (SrvGenerateConsoleCtrlEvent)
 
 CSR_API (SrvGetConsoleSelectionInfo)
 
 CSR_API (SrvOpenConsole)
 
 CSR_API (SrvCloseHandle)
 
 CSR_API (SrvVerifyConsoleIoHandle)
 
 CSR_API (SrvDuplicateHandle)
 
 CSR_API (SrvGetConsoleCommandHistory)
 
 CSR_API (SrvGetConsoleCommandHistoryLength)
 
 CSR_API (SrvExpungeConsoleCommandHistory)
 
 CSR_API (SrvSetConsoleNumberOfCommands)
 
 CSR_API (SrvGetConsoleHistory)
 
 CSR_API (SrvSetConsoleHistory)
 

Function Documentation

◆ CSR_API() [1/61]

CSR_API ( SrvAddConsoleAlias  )

Definition at line 448 of file alias.c.

449 {
451  PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
455  PVOID lpTarget;
456 
457  DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage);
458 
459  if ( !CsrValidateMessageBuffer(ApiMessage,
460  (PVOID*)&ConsoleAliasRequest->Source,
461  ConsoleAliasRequest->SourceLength,
462  sizeof(BYTE)) ||
463  !CsrValidateMessageBuffer(ApiMessage,
464  (PVOID*)&ConsoleAliasRequest->Target,
465  ConsoleAliasRequest->TargetLength,
466  sizeof(BYTE)) ||
467  !CsrValidateMessageBuffer(ApiMessage,
468  (PVOID*)&ConsoleAliasRequest->ExeName,
469  ConsoleAliasRequest->ExeLength,
470  sizeof(BYTE)) )
471  {
473  }
474 
475  lpTarget = (ConsoleAliasRequest->TargetLength != 0 ? ConsoleAliasRequest->Target : NULL);
476 
478  &Console, TRUE);
479  if (!NT_SUCCESS(Status)) return Status;
480 
482 
484  ConsoleAliasRequest->ExeName,
485  ConsoleAliasRequest->ExeLength,
486  ConsoleAliasRequest->Unicode2);
487  if (!Header && lpTarget != NULL)
488  {
490  ConsoleAliasRequest->ExeName,
491  ConsoleAliasRequest->ExeLength,
492  ConsoleAliasRequest->Unicode2);
493  if (!Header)
494  {
496  goto Quit;
497  }
498 
499  IntInsertAliasHeader(&Console->Aliases, Header);
500  }
501 
502  if (lpTarget == NULL) // Delete the entry
503  {
505  ConsoleAliasRequest->Source,
506  ConsoleAliasRequest->SourceLength,
507  ConsoleAliasRequest->Unicode);
508  if (!Entry)
509  {
511  goto Quit;
512  }
513 
515  }
516  else // Add the entry
517  {
519  ConsoleAliasRequest->Source,
520  ConsoleAliasRequest->SourceLength,
521  ConsoleAliasRequest->Target,
522  ConsoleAliasRequest->TargetLength,
523  ConsoleAliasRequest->Unicode);
524  if (!Entry)
525  {
527  goto Quit;
528  }
529 
531  }
532 
533 Quit:
535  return Status;
536 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
static PALIAS_ENTRY IntCreateAliasEntry(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PVOID Target, USHORT TargetLength, BOOLEAN Unicode)
Definition: alias.c:269
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
BOOLEAN Unicode2
Definition: conmsg.h:738
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static VOID IntInsertAliasHeader(PALIAS_HEADER *RootHeader, PALIAS_HEADER NewHeader)
Definition: alias.c:200
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
USHORT SourceLength
Definition: conmsg.h:731
static VOID IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry)
Definition: alias.c:362
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char BYTE
Definition: mem.h:68
Definition: alias.c:19
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static PALIAS_ENTRY IntGetAliasEntry(PCONSRV_CONSOLE Console, PALIAS_HEADER Header, PVOID Source, USHORT SourceLength, BOOLEAN Unicode)
Definition: alias.c:220
USHORT TargetLength
Definition: conmsg.h:732
static PALIAS_HEADER IntCreateAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:152
return STATUS_SUCCESS
Definition: btrfs.c:2938
static VOID IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
Definition: alias.c:342
base of all file and directory entries
Definition: entries.h:82
static PALIAS_HEADER IntFindAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:105

◆ CSR_API() [2/61]

CSR_API ( SrvGetConsoleAlias  )

Definition at line 538 of file alias.c.

539 {
541  PCONSOLE_ADDGETALIAS ConsoleAliasRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAliasRequest;
545  UINT Length;
546  PVOID lpTarget;
547 
548  DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage);
549 
550  if ( !CsrValidateMessageBuffer(ApiMessage,
551  (PVOID*)&ConsoleAliasRequest->Source,
552  ConsoleAliasRequest->SourceLength,
553  sizeof(BYTE)) ||
554  !CsrValidateMessageBuffer(ApiMessage,
555  (PVOID*)&ConsoleAliasRequest->Target,
556  ConsoleAliasRequest->TargetLength,
557  sizeof(BYTE)) ||
558  !CsrValidateMessageBuffer(ApiMessage,
559  (PVOID*)&ConsoleAliasRequest->ExeName,
560  ConsoleAliasRequest->ExeLength,
561  sizeof(BYTE)) )
562  {
564  }
565 
566  lpTarget = ConsoleAliasRequest->Target;
567 
568  if (ConsoleAliasRequest->ExeLength == 0 || lpTarget == NULL ||
569  ConsoleAliasRequest->TargetLength == 0 || ConsoleAliasRequest->SourceLength == 0)
570  {
572  }
573 
575  &Console, TRUE);
576  if (!NT_SUCCESS(Status)) return Status;
577 
579  ConsoleAliasRequest->ExeName,
580  ConsoleAliasRequest->ExeLength,
581  ConsoleAliasRequest->Unicode2);
582  if (!Header)
583  {
585  goto Quit;
586  }
587 
589  ConsoleAliasRequest->Source,
590  ConsoleAliasRequest->SourceLength,
591  ConsoleAliasRequest->Unicode);
592  if (!Entry)
593  {
595  goto Quit;
596  }
597 
598  if (ConsoleAliasRequest->Unicode)
599  {
600  Length = Entry->Target.Length + sizeof(WCHAR);
601  if (Length > ConsoleAliasRequest->TargetLength) // FIXME: Refine computation.
602  {
604  goto Quit;
605  }
606 
607  RtlCopyMemory(lpTarget, Entry->Target.Buffer, Entry->Target.Length);
608  ConsoleAliasRequest->TargetLength = Length;
609  }
610  else
611  {
612  Length = (Entry->Target.Length + sizeof(WCHAR)) / sizeof(WCHAR);
613  if (Length > ConsoleAliasRequest->TargetLength) // FIXME: Refine computation.
614  {
616  goto Quit;
617  }
618 
620  Entry->Target.Buffer, Entry->Target.Length,
621  lpTarget, Entry->Target.Length / sizeof(WCHAR));
622  ConsoleAliasRequest->TargetLength = Length;
623  }
624 
625 Quit:
627  return Status;
628 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _Entry Entry
Definition: kefuncs.h:640
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
BOOLEAN Unicode2
Definition: conmsg.h:738
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
USHORT SourceLength
Definition: conmsg.h:731
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
unsigned char BYTE
Definition: mem.h:68
Definition: alias.c:19
Status
Definition: gdiplustypes.h:24
unsigned int UINT
Definition: ndis.h:50
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PCHAR Target, USHORT TargetLength)
Definition: alias.c:64
static PALIAS_ENTRY IntGetAliasEntry(PCONSRV_CONSOLE Console, PALIAS_HEADER Header, PVOID Source, USHORT SourceLength, BOOLEAN Unicode)
Definition: alias.c:220
USHORT TargetLength
Definition: conmsg.h:732
base of all file and directory entries
Definition: entries.h:82
static PALIAS_HEADER IntFindAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:105

◆ CSR_API() [3/61]

CSR_API ( SrvGetConsoleAliases  )

Definition at line 630 of file alias.c.

631 {
633  PCONSOLE_GETALLALIASES GetAllAliasesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesRequest;
635  ULONG BytesWritten = 0;
637 
638  DPRINT("SrvGetConsoleAliases entered ApiMessage %p\n", ApiMessage);
639 
640  if ( !CsrValidateMessageBuffer(ApiMessage,
641  (PVOID)&GetAllAliasesRequest->ExeName,
642  GetAllAliasesRequest->ExeLength,
643  sizeof(BYTE)) ||
644  !CsrValidateMessageBuffer(ApiMessage,
645  (PVOID)&GetAllAliasesRequest->AliasesBuffer,
646  GetAllAliasesRequest->AliasesBufferLength,
647  sizeof(BYTE)) )
648  {
650  }
651 
653  &Console, TRUE);
654  if (!NT_SUCCESS(Status)) return Status;
655 
657  GetAllAliasesRequest->ExeName,
658  GetAllAliasesRequest->ExeLength,
659  GetAllAliasesRequest->Unicode2);
660  if (!Header) goto Quit;
661 
662  if (IntGetAllConsoleAliasesLength(Header, GetAllAliasesRequest->Unicode) > GetAllAliasesRequest->AliasesBufferLength)
663  {
665  goto Quit;
666  }
667 
668  {
669  LPSTR TargetBufferA;
670  LPWSTR TargetBufferW;
671  UINT TargetBufferLength = GetAllAliasesRequest->AliasesBufferLength;
672 
673  PALIAS_ENTRY CurEntry = Header->Data;
674  UINT Offset = 0;
675  UINT SourceLength, TargetLength;
676 
677  if (GetAllAliasesRequest->Unicode)
678  {
679  TargetBufferW = GetAllAliasesRequest->AliasesBuffer;
680  TargetBufferLength /= sizeof(WCHAR);
681  }
682  else
683  {
684  TargetBufferA = GetAllAliasesRequest->AliasesBuffer;
685  }
686 
687  while (CurEntry)
688  {
689  SourceLength = CurEntry->Source.Length / sizeof(WCHAR);
690  TargetLength = CurEntry->Target.Length / sizeof(WCHAR);
691  if (Offset + TargetLength + SourceLength + 2 > TargetBufferLength)
692  {
694  break;
695  }
696 
697  if (GetAllAliasesRequest->Unicode)
698  {
699  RtlCopyMemory(&TargetBufferW[Offset], CurEntry->Source.Buffer, SourceLength * sizeof(WCHAR));
700  Offset += SourceLength;
701  TargetBufferW[Offset++] = L'=';
702  RtlCopyMemory(&TargetBufferW[Offset], CurEntry->Target.Buffer, TargetLength * sizeof(WCHAR));
703  Offset += TargetLength;
704  TargetBufferW[Offset++] = L'\0';
705  }
706  else
707  {
709  CurEntry->Source.Buffer, SourceLength * sizeof(WCHAR),
710  &TargetBufferA[Offset], SourceLength);
711  Offset += SourceLength;
712  TargetBufferA[Offset++] = '=';
714  CurEntry->Target.Buffer, TargetLength * sizeof(WCHAR),
715  &TargetBufferA[Offset], TargetLength);
716  Offset += TargetLength;
717  TargetBufferA[Offset++] = '\0';
718  }
719 
720  CurEntry = CurEntry->Next;
721  }
722 
723  if (GetAllAliasesRequest->Unicode)
724  BytesWritten = Offset * sizeof(WCHAR);
725  else
727  }
728 
729 Quit:
730  GetAllAliasesRequest->AliasesBufferLength = BytesWritten;
731 
733  return Status;
734 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define PCONSRV_CONSOLE
Definition: conio.h:27
char * LPSTR
Definition: xmlstorage.h:182
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: Header.h:8
ULONG AliasesBufferLength
Definition: conmsg.h:748
void DPRINT(...)
Definition: polytest.cpp:61
UNICODE_STRING Target
Definition: alias.c:23
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
UNICODE_STRING Source
Definition: alias.c:22
Definition: alias.c:19
Status
Definition: gdiplustypes.h:24
struct _ALIAS_ENTRY * Next
Definition: alias.c:21
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned int UINT
Definition: ndis.h:50
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PCHAR Target, USHORT TargetLength)
Definition: alias.c:64
static UINT IntGetAllConsoleAliasesLength(PALIAS_HEADER Header, BOOLEAN IsUnicode)
Definition: alias.c:403
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static PALIAS_HEADER IntFindAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:105

◆ CSR_API() [4/61]

CSR_API ( SrvGetConsoleAliasesLength  )

Definition at line 736 of file alias.c.

737 {
739  PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllAliasesLengthRequest;
742 
743  DPRINT("SrvGetConsoleAliasesLength entered ApiMessage %p\n", ApiMessage);
744 
745  if (!CsrValidateMessageBuffer(ApiMessage,
746  (PVOID)&GetAllAliasesLengthRequest->ExeName,
747  GetAllAliasesLengthRequest->ExeLength,
748  sizeof(BYTE)))
749  {
751  }
752 
754  &Console, TRUE);
755  if (!NT_SUCCESS(Status)) return Status;
756 
758  GetAllAliasesLengthRequest->ExeName,
759  GetAllAliasesLengthRequest->ExeLength,
760  GetAllAliasesLengthRequest->Unicode2);
761  if (Header)
762  {
763  GetAllAliasesLengthRequest->Length =
765  GetAllAliasesLengthRequest->Unicode);
767  }
768  else
769  {
770  GetAllAliasesLengthRequest->Length = 0;
771  }
772 
774  return Status;
775 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
Definition: Header.h:8
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static UINT IntGetAllConsoleAliasesLength(PALIAS_HEADER Header, BOOLEAN IsUnicode)
Definition: alias.c:403
return STATUS_SUCCESS
Definition: btrfs.c:2938
static PALIAS_HEADER IntFindAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:105

◆ CSR_API() [5/61]

CSR_API ( SrvGetConsoleAliasExes  )

Definition at line 777 of file alias.c.

778 {
780  PCONSOLE_GETALIASESEXES GetAliasesExesRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesRequest;
782  UINT BytesWritten = 0;
783 
784  DPRINT("SrvGetConsoleAliasExes entered\n");
785 
786  if (!CsrValidateMessageBuffer(ApiMessage,
787  (PVOID*)&GetAliasesExesRequest->ExeNames,
788  GetAliasesExesRequest->Length,
789  sizeof(BYTE)))
790  {
792  }
793 
795  &Console, TRUE);
796  if (!NT_SUCCESS(Status)) return Status;
797 
798  if (IntGetConsoleAliasesExesLength(Console->Aliases, GetAliasesExesRequest->Unicode) > GetAliasesExesRequest->Length)
799  {
801  goto Quit;
802  }
803 
804  {
805  PALIAS_HEADER RootHeader = Console->Aliases;
806 
807  LPSTR TargetBufferA;
808  LPWSTR TargetBufferW;
809  UINT TargetBufferSize = GetAliasesExesRequest->Length;
810 
811  UINT Offset = 0;
812  UINT Length;
813 
814  if (GetAliasesExesRequest->Unicode)
815  {
816  TargetBufferW = GetAliasesExesRequest->ExeNames;
817  TargetBufferSize /= sizeof(WCHAR);
818  }
819  else
820  {
821  TargetBufferA = GetAliasesExesRequest->ExeNames;
822  }
823 
824  while (RootHeader)
825  {
826  Length = RootHeader->ExeName.Length / sizeof(WCHAR);
827  if (Offset + Length + 1 > TargetBufferSize)
828  {
830  break;
831  }
832 
833  if (GetAliasesExesRequest->Unicode)
834  {
835  RtlCopyMemory(&TargetBufferW[Offset], RootHeader->ExeName.Buffer, Length * sizeof(WCHAR));
836  Offset += Length;
837  TargetBufferW[Offset++] = L'\0';
838  }
839  else
840  {
842  RootHeader->ExeName.Buffer, Length * sizeof(WCHAR),
843  &TargetBufferA[Offset], Length);
844  Offset += Length;
845  TargetBufferA[Offset++] = '\0';
846  }
847 
848  RootHeader = RootHeader->Next;
849  }
850 
851  if (GetAliasesExesRequest->Unicode)
852  BytesWritten = Offset * sizeof(WCHAR);
853  else
855  }
856 
857 Quit:
858  GetAliasesExesRequest->Length = BytesWritten;
859 
861  return Status;
862 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define PCONSRV_CONSOLE
Definition: conio.h:27
char * LPSTR
Definition: xmlstorage.h:182
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
UNICODE_STRING ExeName
Definition: alias.c:29
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
struct _ALIAS_HEADER * Next
Definition: alias.c:28
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
unsigned int UINT
Definition: ndis.h:50
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
BOOLEAN ConvertInputUnicodeToAnsi(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PCHAR Target, USHORT TargetLength)
Definition: alias.c:64
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static UINT IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader, BOOLEAN IsUnicode)
Definition: alias.c:381

◆ CSR_API() [6/61]

CSR_API ( SrvGetConsoleAliasExesLength  )

Definition at line 864 of file alias.c.

865 {
867  PCONSOLE_GETALIASESEXESLENGTH GetAliasesExesLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAliasesExesLengthRequest;
869 
870  DPRINT("SrvGetConsoleAliasExesLength entered ApiMessage %p\n", ApiMessage);
871 
873  &Console, TRUE);
874  if (!NT_SUCCESS(Status)) return Status;
875 
876  GetAliasesExesLengthRequest->Length =
878  GetAliasesExesLengthRequest->Unicode);
879 
881  return Status;
882 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
static UINT IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader, BOOLEAN IsUnicode)
Definition: alias.c:381

◆ CSR_API() [7/61]

CSR_API ( SrvReadConsole  )

Definition at line 551 of file coninput.c.

552 {
554  PCONSOLE_READCONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
556  PVOID HandleEntry;
558  GET_INPUT_INFO InputInfo;
559 
560  DPRINT("SrvReadConsole\n");
561 
562  /*
563  * For optimization purposes, Windows (and hence ReactOS, too, for
564  * compatibility reasons) uses a static buffer if no more than eighty
565  * bytes are read. Otherwise a new buffer is used.
566  * The client-side expects that we know this behaviour.
567  */
568  if (ReadConsoleRequest->CaptureBufferSize <= sizeof(ReadConsoleRequest->StaticBuffer))
569  {
570  /*
571  * Adjust the internal pointer, because its old value points to
572  * the static buffer in the original ApiMessage structure.
573  */
574  // ReadConsoleRequest->Buffer = ReadConsoleRequest->StaticBuffer;
575  }
576  else
577  {
578  if (!CsrValidateMessageBuffer(ApiMessage,
579  (PVOID*)&ReadConsoleRequest->Buffer,
580  ReadConsoleRequest->CaptureBufferSize,
581  sizeof(BYTE)))
582  {
584  }
585  }
586 
587  if (ReadConsoleRequest->InitialNumBytes > ReadConsoleRequest->NumBytes)
588  {
590  }
591 
592  Status = ConSrvGetInputBufferAndHandleEntry(ProcessData, ReadConsoleRequest->InputHandle, &InputBuffer, &HandleEntry, GENERIC_READ, TRUE);
593  if (!NT_SUCCESS(Status)) return Status;
594 
595  InputInfo.CallingThread = CsrGetClientThread();
596  InputInfo.HandleEntry = HandleEntry;
597  InputInfo.InputBuffer = InputBuffer;
598 
599  Status = ReadChars(&InputInfo, ApiMessage, TRUE);
600 
602 
603  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
604 
605  return Status;
606 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
HANDLE InputHandle
Definition: conmsg.h:256
PVOID HandleEntry
Definition: coninput.c:47
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
PCSR_THREAD CallingThread
Definition: coninput.c:46
CHAR StaticBuffer[80]
Definition: conmsg.h:260
CHAR InputBuffer[80]
Definition: conmgr.c:33
ULONG CaptureBufferSize
Definition: conmsg.h:264
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
ULONG InitialNumBytes
Definition: conmsg.h:266
unsigned char BYTE
Definition: mem.h:68
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
#define ConSrvGetInputBufferAndHandleEntry(ProcessData, Handle, Ptr, Entry, Access, LockConsole)
Definition: coninput.c:22
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
PCONSOLE_INPUT_BUFFER InputBuffer
Definition: coninput.c:48
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked)
Definition: coninput.c:25
static NTSTATUS ReadChars(IN PGET_INPUT_INFO InputInfo, IN PCSR_API_MESSAGE ApiMessage, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: coninput.c:312

◆ CSR_API() [8/61]

CSR_API ( SrvGetConsoleInput  )

Definition at line 608 of file coninput.c.

609 {
611  PCONSOLE_GETINPUT GetInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
613  PVOID HandleEntry;
615  GET_INPUT_INFO InputInfo;
616 
617  DPRINT("SrvGetConsoleInput\n");
618 
619  if (GetInputRequest->Flags & ~(CONSOLE_READ_KEEPEVENT | CONSOLE_READ_CONTINUE))
621 
622  /*
623  * For optimization purposes, Windows (and hence ReactOS, too, for
624  * compatibility reasons) uses a static buffer if no more than five
625  * input records are read. Otherwise a new buffer is used.
626  * The client-side expects that we know this behaviour.
627  */
628  if (GetInputRequest->NumRecords <= sizeof(GetInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
629  {
630  /*
631  * Adjust the internal pointer, because its old value points to
632  * the static buffer in the original ApiMessage structure.
633  */
634  // GetInputRequest->RecordBufPtr = GetInputRequest->RecordStaticBuffer;
635  }
636  else
637  {
638  if (!CsrValidateMessageBuffer(ApiMessage,
639  (PVOID*)&GetInputRequest->RecordBufPtr,
640  GetInputRequest->NumRecords,
641  sizeof(INPUT_RECORD)))
642  {
644  }
645  }
646 
647  Status = ConSrvGetInputBufferAndHandleEntry(ProcessData, GetInputRequest->InputHandle, &InputBuffer, &HandleEntry, GENERIC_READ, TRUE);
648  if (!NT_SUCCESS(Status)) return Status;
649 
650  InputInfo.CallingThread = CsrGetClientThread();
651  InputInfo.HandleEntry = HandleEntry;
652  InputInfo.InputBuffer = InputBuffer;
653 
654  Status = ReadInputBuffer(&InputInfo, ApiMessage, TRUE);
655 
657 
658  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
659 
660  return Status;
661 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
ULONG NumRecords
Definition: conmsg.h:568
#define TRUE
Definition: types.h:120
PVOID HandleEntry
Definition: coninput.c:47
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
PCSR_THREAD CallingThread
Definition: coninput.c:46
INPUT_RECORD RecordStaticBuffer[5]
Definition: conmsg.h:566
HANDLE InputHandle
Definition: conmsg.h:565
CHAR InputBuffer[80]
Definition: conmgr.c:33
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
PINPUT_RECORD RecordBufPtr
Definition: conmsg.h:567
#define GENERIC_READ
Definition: compat.h:124
#define CONSOLE_READ_KEEPEVENT
Definition: wincon.h:116
Status
Definition: gdiplustypes.h:24
#define CONSOLE_READ_CONTINUE
Definition: wincon.h:117
#define ConSrvGetInputBufferAndHandleEntry(ProcessData, Handle, Ptr, Entry, Access, LockConsole)
Definition: coninput.c:22
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
PCONSOLE_INPUT_BUFFER InputBuffer
Definition: coninput.c:48
static NTSTATUS ReadInputBuffer(IN PGET_INPUT_INFO InputInfo, IN PCSR_API_MESSAGE ApiMessage, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: coninput.c:475
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked)
Definition: coninput.c:25

◆ CSR_API() [9/61]

CSR_API ( SrvWriteConsoleInput  )

Definition at line 672 of file coninput.c.

673 {
675  PCONSOLE_WRITEINPUT WriteInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteInputRequest;
677  ULONG NumEventsWritten;
678 
679  PINPUT_RECORD InputRecord;
680 
681  DPRINT("SrvWriteConsoleInput\n");
682 
683  /*
684  * For optimization purposes, Windows (and hence ReactOS, too, for
685  * compatibility reasons) uses a static buffer if no more than five
686  * input records are written. Otherwise a new buffer is used.
687  * The client-side expects that we know this behaviour.
688  */
689  if (WriteInputRequest->NumRecords <= sizeof(WriteInputRequest->RecordStaticBuffer)/sizeof(INPUT_RECORD))
690  {
691  /*
692  * Adjust the internal pointer, because its old value points to
693  * the static buffer in the original ApiMessage structure.
694  */
695  // WriteInputRequest->RecordBufPtr = WriteInputRequest->RecordStaticBuffer;
696  InputRecord = WriteInputRequest->RecordStaticBuffer;
697  }
698  else
699  {
700  if (!CsrValidateMessageBuffer(ApiMessage,
701  (PVOID*)&WriteInputRequest->RecordBufPtr,
702  WriteInputRequest->NumRecords,
703  sizeof(INPUT_RECORD)))
704  {
706  }
707 
708  InputRecord = WriteInputRequest->RecordBufPtr;
709  }
710 
712  WriteInputRequest->InputHandle,
714  if (!NT_SUCCESS(Status))
715  {
716  WriteInputRequest->NumRecords = 0;
717  return Status;
718  }
719 
720  /* First translate everything to UNICODE */
721  if (!WriteInputRequest->Unicode)
722  {
723  ULONG i;
724  for (i = 0; i < WriteInputRequest->NumRecords; ++i)
725  {
726  ConioInputEventToUnicode(InputBuffer->Header.Console, &InputRecord[i]);
727  }
728  }
729 
730  /* Now, add the events */
731  NumEventsWritten = 0;
733  // InputBuffer,
734  InputRecord,
735  WriteInputRequest->NumRecords,
736  &NumEventsWritten,
737  WriteInputRequest->AppendToEnd);
738 
739  // Status = ConDrvWriteConsoleInput(InputBuffer->Header.Console,
740  // InputBuffer,
741  // WriteInputRequest->AppendToEnd,
742  // InputRecord,
743  // WriteInputRequest->NumRecords,
744  // &NumEventsWritten);
745 
746  WriteInputRequest->NumRecords = NumEventsWritten;
747 
749  return Status;
750 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
HANDLE InputHandle
Definition: conmsg.h:576
static VOID ConioInputEventToUnicode(PCONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:68
#define PCONSRV_CONSOLE
Definition: conio.h:27
CHAR InputBuffer[80]
Definition: conmgr.c:33
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
PINPUT_RECORD RecordBufPtr
Definition: conmsg.h:578
INPUT_RECORD RecordStaticBuffer[5]
Definition: conmsg.h:577
BOOLEAN AppendToEnd
Definition: conmsg.h:581
static NTSTATUS ConioAddInputEvents(PCONSRV_CONSOLE Console, PINPUT_RECORD InputRecords, ULONG NumEventsToWrite, PULONG NumEventsWritten, BOOLEAN AppendToEnd)
Definition: coninput.c:161
Status
Definition: gdiplustypes.h:24
BOOLEAN Unicode
Definition: conmsg.h:580
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define ConSrvGetInputBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: coninput.c:19
unsigned int ULONG
Definition: retypes.h:1
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked)
Definition: coninput.c:25

◆ CSR_API() [10/61]

CSR_API ( SrvFlushConsoleInputBuffer  )

Definition at line 755 of file coninput.c.

756 {
758  PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest;
760 
761  DPRINT("SrvFlushConsoleInputBuffer\n");
762 
764  FlushInputBufferRequest->InputHandle,
766  if (!NT_SUCCESS(Status)) return Status;
767 
769  InputBuffer);
770 
772  return Status;
773 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CHAR InputBuffer[80]
Definition: conmgr.c:33
NTSTATUS NTAPI ConDrvFlushConsoleInputBuffer(IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer)
Definition: coninput.c:352
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define ConSrvGetInputBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: coninput.c:19
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked)
Definition: coninput.c:25

◆ CSR_API() [11/61]

CSR_API ( SrvGetConsoleNumberOfInputEvents  )

Definition at line 779 of file coninput.c.

780 {
782  PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest;
784 
785  DPRINT("SrvGetConsoleNumberOfInputEvents\n");
786 
788  GetNumInputEventsRequest->InputHandle,
790  if (!NT_SUCCESS(Status)) return Status;
791 
793  InputBuffer,
794  &GetNumInputEventsRequest->NumberOfEvents);
795 
797  return Status;
798 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CHAR InputBuffer[80]
Definition: conmgr.c:33
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define ConSrvGetInputBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: coninput.c:19
NTSTATUS NTAPI ConDrvGetConsoleNumberOfInputEvents(IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer, OUT PULONG NumberOfEvents)
Definition: coninput.c:377
#define ConSrvReleaseInputBuffer(Buff, IsConsoleLocked)
Definition: coninput.c:25

◆ CSR_API() [12/61]

CSR_API ( SrvInvalidateBitMapRect  )

Definition at line 33 of file conoutput.c.

34 {
36  PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.InvalidateDIBitsRequest;
38 
39  DPRINT("SrvInvalidateBitMapRect\n");
40 
42  InvalidateDIBitsRequest->OutputHandle,
44  if (!NT_SUCCESS(Status)) return Status;
45 
46  /* In text-mode only, draw the VDM buffer if present */
47  if (GetType(Buffer) == TEXTMODE_BUFFER && Buffer->Header.Console->VDMBuffer)
48  {
50 
51  /*Status =*/ ConDrvWriteConsoleOutputVDM(Buffer->Header.Console,
52  TextBuffer,
53  Buffer->Header.Console->VDMBuffer,
54  Buffer->Header.Console->VDMBufferSize,
55  &InvalidateDIBitsRequest->Region);
56  }
57 
58  Status = ConDrvInvalidateBitMapRect(Buffer->Header.Console,
59  Buffer,
60  &InvalidateDIBitsRequest->Region);
61 
63  return Status;
64 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define TEXTMODE_BUFFER
Definition: pccons.c:21
NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
Definition: text.c:600
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvInvalidateBitMapRect(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN PSMALL_RECT Region)
Definition: conoutput.c:202
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER

◆ CSR_API() [13/61]

CSR_API ( SrvReadConsoleOutput  )

Definition at line 481 of file conoutput.c.

482 {
484  PCONSOLE_READOUTPUT ReadOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputRequest;
486 
487  ULONG NumCells;
488  PCHAR_INFO CharInfo;
489 
490  DPRINT("SrvReadConsoleOutput\n");
491 
492  NumCells = (ReadOutputRequest->ReadRegion.Right - ReadOutputRequest->ReadRegion.Left + 1) *
493  (ReadOutputRequest->ReadRegion.Bottom - ReadOutputRequest->ReadRegion.Top + 1);
494 
495  /*
496  * For optimization purposes, Windows (and hence ReactOS, too, for
497  * compatibility reasons) uses a static buffer if no more than one
498  * cell is read. Otherwise a new buffer is used.
499  * The client-side expects that we know this behaviour.
500  */
501  if (NumCells <= 1)
502  {
503  /*
504  * Adjust the internal pointer, because its old value points to
505  * the static buffer in the original ApiMessage structure.
506  */
507  // ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer;
508  CharInfo = &ReadOutputRequest->StaticBuffer;
509  }
510  else
511  {
512  if (!CsrValidateMessageBuffer(ApiMessage,
513  (PVOID*)&ReadOutputRequest->CharInfo,
514  NumCells,
515  sizeof(CHAR_INFO)))
516  {
518  }
519 
520  CharInfo = ReadOutputRequest->CharInfo;
521  }
522 
524  ReadOutputRequest->OutputHandle,
526  if (!NT_SUCCESS(Status)) return Status;
527 
528  Status = ConDrvReadConsoleOutput(Buffer->Header.Console,
529  Buffer,
530  ReadOutputRequest->Unicode,
531  CharInfo,
532  &ReadOutputRequest->ReadRegion);
533 
535  return Status;
536 }
HANDLE OutputHandle
Definition: conmsg.h:587
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
BOOLEAN Unicode
Definition: conmsg.h:593
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
PCHAR_INFO CharInfo
Definition: conmsg.h:590
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
SMALL_RECT ReadRegion
Definition: conmsg.h:592
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI ConDrvReadConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
Definition: text.c:467
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
CHAR_INFO StaticBuffer
Definition: conmsg.h:589

◆ CSR_API() [14/61]

CSR_API ( SrvWriteConsole  )

Definition at line 642 of file conoutput.c.

643 {
645  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
646 
647  DPRINT("SrvWriteConsole\n");
648 
649  /*
650  * For optimization purposes, Windows (and hence ReactOS, too, for
651  * compatibility reasons) uses a static buffer if no more than eighty
652  * bytes are written. Otherwise a new buffer is used.
653  * The client-side expects that we know this behaviour.
654  */
655  if (WriteConsoleRequest->UsingStaticBuffer &&
656  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
657  {
658  /*
659  * Adjust the internal pointer, because its old value points to
660  * the static buffer in the original ApiMessage structure.
661  */
662  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
663  }
664  else
665  {
666  if (!CsrValidateMessageBuffer(ApiMessage,
667  (PVOID)&WriteConsoleRequest->Buffer,
668  WriteConsoleRequest->NumBytes,
669  sizeof(BYTE)))
670  {
672  }
673  }
674 
675  Status = DoWriteConsole(ApiMessage, CsrGetClientThread(), TRUE);
676 
677  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
678 
679  return Status;
680 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
static NTSTATUS DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: conoutput.c:392
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
BOOLEAN UsingStaticBuffer
Definition: conmsg.h:246
CHAR StaticBuffer[80]
Definition: conmsg.h:239

◆ CSR_API() [15/61]

CSR_API ( SrvWriteConsoleOutput  )

Definition at line 544 of file conoutput.c.

545 {
547  PCONSOLE_WRITEOUTPUT WriteOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputRequest;
550 
551  ULONG NumCells;
552  PCHAR_INFO CharInfo;
553 
554  DPRINT("SrvWriteConsoleOutput\n");
555 
556  NumCells = (WriteOutputRequest->WriteRegion.Right - WriteOutputRequest->WriteRegion.Left + 1) *
557  (WriteOutputRequest->WriteRegion.Bottom - WriteOutputRequest->WriteRegion.Top + 1);
558 
560  WriteOutputRequest->OutputHandle,
562  if (!NT_SUCCESS(Status)) return Status;
563 
564  /*
565  * Validate the message buffer if we do not use a process' heap buffer
566  * (CsrAllocateCaptureBuffer succeeded because we haven't allocated
567  * a too large (>= 64 kB, size of the CSR heap) data buffer).
568  */
569  if (!WriteOutputRequest->UseVirtualMemory)
570  {
571  /*
572  * For optimization purposes, Windows (and hence ReactOS, too, for
573  * compatibility reasons) uses a static buffer if no more than one
574  * cell is written. Otherwise a new buffer is used.
575  * The client-side expects that we know this behaviour.
576  */
577  if (NumCells <= 1)
578  {
579  /*
580  * Adjust the internal pointer, because its old value points to
581  * the static buffer in the original ApiMessage structure.
582  */
583  // WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer;
584  CharInfo = &WriteOutputRequest->StaticBuffer;
585  }
586  else
587  {
588  if (!CsrValidateMessageBuffer(ApiMessage,
589  (PVOID*)&WriteOutputRequest->CharInfo,
590  NumCells,
591  sizeof(CHAR_INFO)))
592  {
594  goto Quit;
595  }
596 
597  CharInfo = WriteOutputRequest->CharInfo;
598  }
599  }
600  else
601  {
602  /*
603  * This was not the case: we use a heap buffer. Retrieve its contents.
604  */
605  ULONG Size = NumCells * sizeof(CHAR_INFO);
606 
608  if (CharInfo == NULL)
609  {
611  goto Quit;
612  }
613 
614  Status = NtReadVirtualMemory(Process->ProcessHandle,
615  WriteOutputRequest->CharInfo,
616  CharInfo,
617  Size,
618  NULL);
619  if (!NT_SUCCESS(Status))
620  {
621  ConsoleFreeHeap(CharInfo);
622  // Status = STATUS_NO_MEMORY;
623  goto Quit;
624  }
625  }
626 
627  Status = ConDrvWriteConsoleOutput(Buffer->Header.Console,
628  Buffer,
629  WriteOutputRequest->Unicode,
630  CharInfo,
631  &WriteOutputRequest->WriteRegion);
632 
633  /* Free the temporary buffer if we used the process' heap buffer */
634  if (WriteOutputRequest->UseVirtualMemory && CharInfo)
635  ConsoleFreeHeap(CharInfo);
636 
637 Quit:
639  return Status;
640 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOLEAN UseVirtualMemory
Definition: conmsg.h:612
#define GENERIC_WRITE
Definition: nt_native.h:90
struct _CHAR_INFO CHAR_INFO
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
HANDLE OutputHandle
Definition: conmsg.h:599
Definition: bufpool.h:45
NTSTATUS NTAPI ConDrvWriteConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
Definition: text.c:531
SHORT Left
Definition: blue.h:25
CHAR_INFO StaticBuffer
Definition: conmsg.h:601
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
SMALL_RECT WriteRegion
Definition: conmsg.h:604
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2691
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PCHAR_INFO CharInfo
Definition: conmsg.h:602

◆ CSR_API() [16/61]

CSR_API ( SrvReadConsoleOutputString  )

Definition at line 691 of file conoutput.c.

692 {
694  PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputCodeRequest;
696  ULONG CodeSize;
697 
698  PVOID pCode;
699 
700  DPRINT("SrvReadConsoleOutputString\n");
701 
702  switch (ReadOutputCodeRequest->CodeType)
703  {
704  case CODE_ASCII:
705  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
706  break;
707 
708  case CODE_UNICODE:
709  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
710  break;
711 
712  case CODE_ATTRIBUTE:
713  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
714  break;
715 
716  default:
718  }
719 
720  /*
721  * For optimization purposes, Windows (and hence ReactOS, too, for
722  * compatibility reasons) uses a static buffer if no more than eighty
723  * bytes are read. Otherwise a new buffer is used.
724  * The client-side expects that we know this behaviour.
725  */
726  if (ReadOutputCodeRequest->NumCodes * CodeSize <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
727  {
728  /*
729  * Adjust the internal pointer, because its old value points to
730  * the static buffer in the original ApiMessage structure.
731  */
732  // ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
733  pCode = ReadOutputCodeRequest->CodeStaticBuffer;
734  }
735  else
736  {
737  if (!CsrValidateMessageBuffer(ApiMessage,
738  (PVOID*)&ReadOutputCodeRequest->pCode,
739  ReadOutputCodeRequest->NumCodes,
740  CodeSize))
741  {
743  }
744 
745  pCode = ReadOutputCodeRequest->pCode;
746  }
747 
749  ReadOutputCodeRequest->OutputHandle,
751  if (!NT_SUCCESS(Status))
752  {
753  ReadOutputCodeRequest->NumCodes = 0;
754  return Status;
755  }
756 
757  Status = ConDrvReadConsoleOutputString(Buffer->Header.Console,
758  Buffer,
759  ReadOutputCodeRequest->CodeType,
760  pCode,
761  ReadOutputCodeRequest->NumCodes,
762  &ReadOutputCodeRequest->Coord,
763  // &ReadOutputCodeRequest->EndCoord,
764  &ReadOutputCodeRequest->NumCodes);
765 
767  return Status;
768 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CODE_TYPE CodeType
Definition: conmsg.h:535
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
CHAR CodeStaticBuffer[80]
Definition: conmsg.h:536
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
HANDLE OutputHandle
Definition: conmsg.h:532
NTSTATUS NTAPI ConDrvReadConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, OUT PVOID StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:727
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [17/61]

CSR_API ( SrvWriteConsoleOutputString  )

Definition at line 779 of file conoutput.c.

780 {
782  PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputCodeRequest;
784  ULONG CodeSize;
785 
786  PVOID pCode;
787 
788  DPRINT("SrvWriteConsoleOutputString\n");
789 
790  switch (WriteOutputCodeRequest->CodeType)
791  {
792  case CODE_ASCII:
793  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
794  break;
795 
796  case CODE_UNICODE:
797  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
798  break;
799 
800  case CODE_ATTRIBUTE:
801  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
802  break;
803 
804  default:
806  }
807 
808  /*
809  * For optimization purposes, Windows (and hence ReactOS, too, for
810  * compatibility reasons) uses a static buffer if no more than eighty
811  * bytes are written. Otherwise a new buffer is used.
812  * The client-side expects that we know this behaviour.
813  */
814  if (WriteOutputCodeRequest->NumCodes * CodeSize <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
815  {
816  /*
817  * Adjust the internal pointer, because its old value points to
818  * the static buffer in the original ApiMessage structure.
819  */
820  // WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
821  pCode = WriteOutputCodeRequest->CodeStaticBuffer;
822  }
823  else
824  {
825  if (!CsrValidateMessageBuffer(ApiMessage,
826  (PVOID*)&WriteOutputCodeRequest->pCode,
827  WriteOutputCodeRequest->NumCodes,
828  CodeSize))
829  {
831  }
832 
833  pCode = WriteOutputCodeRequest->pCode;
834  }
835 
837  WriteOutputCodeRequest->OutputHandle,
839  if (!NT_SUCCESS(Status))
840  {
841  WriteOutputCodeRequest->NumCodes = 0;
842  return Status;
843  }
844 
845  Status = ConDrvWriteConsoleOutputString(Buffer->Header.Console,
846  Buffer,
847  WriteOutputCodeRequest->CodeType,
848  pCode,
849  WriteOutputCodeRequest->NumCodes,
850  &WriteOutputCodeRequest->Coord,
851  // &WriteOutputCodeRequest->EndCoord,
852  &WriteOutputCodeRequest->NumCodes);
853 
855  return Status;
856 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CODE_TYPE CodeType
Definition: conmsg.h:535
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS NTAPI ConDrvWriteConsoleOutputString(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN PVOID StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:840
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
CHAR CodeStaticBuffer[80]
Definition: conmsg.h:536
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
HANDLE OutputHandle
Definition: conmsg.h:532
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [18/61]

CSR_API ( SrvFillConsoleOutput  )

Definition at line 866 of file conoutput.c.

867 {
869  PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
871  CODE_TYPE CodeType = FillOutputRequest->CodeType;
872 
873  DPRINT("SrvFillConsoleOutput\n");
874 
875  if ( (CodeType != CODE_ASCII ) &&
876  (CodeType != CODE_UNICODE ) &&
877  (CodeType != CODE_ATTRIBUTE) )
878  {
880  }
881 
883  FillOutputRequest->OutputHandle,
885  if (!NT_SUCCESS(Status))
886  {
887  FillOutputRequest->NumCodes = 0;
888  return Status;
889  }
890 
891  Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
892  Buffer,
893  CodeType,
894  FillOutputRequest->Code,
895  FillOutputRequest->NumCodes,
896  &FillOutputRequest->WriteCoord,
897  &FillOutputRequest->NumCodes);
898 
900  return Status;
901 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CODE_ELEMENT Code
Definition: conmsg.h:557
CODE_TYPE CodeType
Definition: conmsg.h:556
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
enum _CODE_TYPE CODE_TYPE
NTSTATUS NTAPI ConDrvFillConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:978

◆ CSR_API() [19/61]

CSR_API ( SrvGetConsoleCursorInfo  )

Definition at line 119 of file conoutput.c.

120 {
122  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
124 
125  DPRINT("SrvGetConsoleCursorInfo\n");
126 
128  CursorInfoRequest->OutputHandle,
130  if (!NT_SUCCESS(Status)) return Status;
131 
132  Status = ConDrvGetConsoleCursorInfo(Buffer->Header.Console,
133  Buffer,
134  &CursorInfoRequest->Info);
135 
137  return Status;
138 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvGetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:263
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [20/61]

CSR_API ( SrvSetConsoleCursorInfo  )

Definition at line 144 of file conoutput.c.

145 {
147  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
149 
150  DPRINT("SrvSetConsoleCursorInfo\n");
151 
153  CursorInfoRequest->OutputHandle,
155  if (!NT_SUCCESS(Status)) return Status;
156 
157  Status = ConDrvSetConsoleCursorInfo(Buffer->Header.Console,
158  Buffer,
159  &CursorInfoRequest->Info);
160 
162  return Status;
163 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
NTSTATUS NTAPI ConDrvSetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:281
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [21/61]

CSR_API ( SrvSetConsoleCursorPosition  )

Definition at line 169 of file conoutput.c.

170 {
172  PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorPositionRequest;
174 
175  DPRINT("SrvSetConsoleCursorPosition\n");
176 
178  SetCursorPositionRequest->OutputHandle,
180  if (!NT_SUCCESS(Status)) return Status;
181 
182  Status = ConDrvSetConsoleCursorPosition(Buffer->Header.Console,
183  Buffer,
184  &SetCursorPositionRequest->Position);
185 
187  return Status;
188 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
NTSTATUS NTAPI ConDrvSetConsoleCursorPosition(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Position)
Definition: conoutput.c:311
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [22/61]

CSR_API ( SrvSetConsoleTextAttribute  )

Definition at line 942 of file conoutput.c.

943 {
945  PCONSOLE_SETTEXTATTRIB SetTextAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetTextAttribRequest;
947 
948  DPRINT("SrvSetConsoleTextAttribute\n");
949 
951  SetTextAttribRequest->OutputHandle,
953  if (!NT_SUCCESS(Status)) return Status;
954 
955  Status = ConDrvSetConsoleTextAttribute(Buffer->Header.Console,
956  Buffer,
957  SetTextAttribRequest->Attributes);
958 
960  return Status;
961 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
Definition: text.c:1099
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [23/61]

CSR_API ( SrvCreateConsoleScreenBuffer  )

Definition at line 190 of file conoutput.c.

191 {
193  PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CreateScreenBufferRequest;
198 
200  TEXTMODE_BUFFER_INFO TextModeInfo = {{80, 25},
203  TRUE,
205  GRAPHICS_BUFFER_INFO GraphicsInfo;
206  GraphicsInfo.Info = CreateScreenBufferRequest->GraphicsBufferInfo; // HACK for MSVC
207 
208  DPRINT("SrvCreateConsoleScreenBuffer\n");
209 
210  Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
211  if (!NT_SUCCESS(Status)) return Status;
212 
213  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_TEXTMODE_BUFFER)
214  {
215  ScreenBufferInfo = &TextModeInfo;
216 
217  /*
218  if (Console->ActiveBuffer)
219  {
220  TextModeInfo.ScreenBufferSize = Console->ActiveBuffer->ScreenBufferSize;
221  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 80;
222  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 25;
223 
224  TextModeInfo.ScreenAttrib = Console->ActiveBuffer->ScreenBuffer.TextBuffer.ScreenDefaultAttrib;
225  TextModeInfo.PopupAttrib = Console->ActiveBuffer->ScreenBuffer.TextBuffer.PopupDefaultAttrib;
226 
227  TextModeInfo.IsCursorVisible = Console->ActiveBuffer->CursorInfo.bVisible;
228  TextModeInfo.CursorSize = Console->ActiveBuffer->CursorInfo.dwSize;
229  }
230  */
231 
232  /*
233  * This is Windows' behaviour
234  */
235 
236  /* Use the current console size. Regularize it if needed. */
237  TextModeInfo.ScreenBufferSize = Console->ConsoleSize;
238  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 1;
239  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 1;
240 
241  /* If we have an active screen buffer, use its attributes as the new ones */
242  if (Console->ActiveBuffer && GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
243  {
245 
246  TextModeInfo.ScreenAttrib = Buffer->ScreenDefaultAttrib;
247  TextModeInfo.PopupAttrib = Buffer->PopupDefaultAttrib;
248 
249  TextModeInfo.IsCursorVisible = Buffer->CursorInfo.bVisible;
250  TextModeInfo.CursorSize = Buffer->CursorInfo.dwSize;
251  }
252  }
253  else if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
254  {
255  /* Get infos from the graphics buffer information structure */
256  if (!CsrValidateMessageBuffer(ApiMessage,
257  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo,
258  CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength,
259  sizeof(BYTE)))
260  {
262  goto Quit;
263  }
264 
265  ScreenBufferInfo = &GraphicsInfo;
266 
267  /* Initialize shared variables */
268  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
269  CreateScreenBufferRequest->hMutex = GraphicsInfo.Info.hMutex = INVALID_HANDLE_VALUE;
270  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
271  CreateScreenBufferRequest->lpBitMap = GraphicsInfo.Info.lpBitMap = NULL;
272 
273  /* A graphics screen buffer is never inheritable */
274  CreateScreenBufferRequest->InheritHandle = FALSE;
275  }
276 
278  (PCONSOLE)Console,
279  Process->ProcessHandle,
280  CreateScreenBufferRequest->ScreenBufferType,
282  if (!NT_SUCCESS(Status)) goto Quit;
283 
284  /* Insert the new handle inside the process handles table */
286 
287  Status = ConSrvInsertObject(ProcessData,
288  &CreateScreenBufferRequest->OutputHandle,
289  &Buff->Header,
290  CreateScreenBufferRequest->DesiredAccess,
291  CreateScreenBufferRequest->InheritHandle,
292  CreateScreenBufferRequest->ShareMode);
293 
295 
296  if (!NT_SUCCESS(Status)) goto Quit;
297 
298  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
299  {
301  /*
302  * Initialize the graphics buffer information structure
303  * and give it back to the client.
304  */
305  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
306  CreateScreenBufferRequest->hMutex = Buffer->ClientMutex;
307  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
308  CreateScreenBufferRequest->lpBitMap = Buffer->ClientBitMap;
309  }
310 
311 Quit:
313  return Status;
314 }
CONSOLE_GRAPHICS_BUFFER_INFO Info
Definition: conio.h:167
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
BOOLEAN IsCursorVisible
Definition: conio.h:147
NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle OPTIONAL, IN ULONG BufferType, IN PVOID ScreenBufferInfo)
Definition: conoutput.c:79
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define CSR_DEFAULT_CURSOR_SIZE
Definition: settings.c:26
struct _GRAPHICS_SCREEN_BUFFER * PGRAPHICS_SCREEN_BUFFER
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
Definition: conmsg.h:456
unsigned char BYTE
Definition: mem.h:68
USHORT PopupAttrib
Definition: conio.h:145
Status
Definition: gdiplustypes.h:24
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:60
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS ConSrvInsertObject(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PHANDLE Handle, IN PCONSOLE_IO_OBJECT Object, IN ULONG Access, IN BOOLEAN Inheritable, IN ULONG ShareMode)
Definition: handle.c:310
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
COORD ScreenBufferSize
Definition: conio.h:143
USHORT ScreenAttrib
Definition: conio.h:144
RTL_CRITICAL_SECTION HandleTableLock
Definition: consrv.h:48

◆ CSR_API() [24/61]

CSR_API ( SrvGetConsoleScreenBufferInfo  )

Definition at line 912 of file conoutput.c.

913 {
915  PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest;
917 
918  DPRINT("SrvGetConsoleScreenBufferInfo\n");
919 
921  ScreenBufferInfoRequest->OutputHandle,
923  if (!NT_SUCCESS(Status)) return Status;
924 
926  Buffer,
927  &ScreenBufferInfoRequest->ScreenBufferSize,
928  &ScreenBufferInfoRequest->CursorPosition,
929  &ScreenBufferInfoRequest->ViewOrigin,
930  &ScreenBufferInfoRequest->ViewSize,
931  &ScreenBufferInfoRequest->MaximumViewSize,
932  &ScreenBufferInfoRequest->Attributes);
933 
935  return Status;
936 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
Definition: text.c:1059
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [25/61]

CSR_API ( SrvSetConsoleActiveScreenBuffer  )

Definition at line 319 of file conoutput.c.

320 {
322  PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferRequest;
324 
325  DPRINT("SrvSetConsoleActiveScreenBuffer\n");
326 
328  SetScreenBufferRequest->OutputHandle,
330  if (!NT_SUCCESS(Status)) return Status;
331 
333  Buffer);
334 
336  return Status;
337 }
NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:170
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [26/61]

CSR_API ( SrvScrollConsoleScreenBuffer  )

Definition at line 997 of file conoutput.c.

998 {
1000  PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScrollScreenBufferRequest;
1002 
1003  DPRINT("SrvScrollConsoleScreenBuffer\n");
1004 
1006  ScrollScreenBufferRequest->OutputHandle,
1008  if (!NT_SUCCESS(Status)) return Status;
1009 
1010  Status = ConDrvScrollConsoleScreenBuffer(Buffer->Header.Console,
1011  Buffer,
1012  ScrollScreenBufferRequest->Unicode,
1013  &ScrollScreenBufferRequest->ScrollRectangle,
1014  ScrollScreenBufferRequest->UseClipRectangle,
1015  &ScrollScreenBufferRequest->ClipRectangle,
1016  &ScrollScreenBufferRequest->DestinationOrigin,
1017  ScrollScreenBufferRequest->Fill);
1018 
1020  return Status;
1021 }
SMALL_RECT ScrollRectangle
Definition: conmsg.h:501
SMALL_RECT ClipRectangle
Definition: conmsg.h:502
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
Definition: text.c:1133
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [27/61]

CSR_API ( SrvSetConsoleScreenBufferSize  )

Definition at line 967 of file conoutput.c.

968 {
970  PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferSizeRequest;
972 
973  DPRINT("SrvSetConsoleScreenBufferSize\n");
974 
976  SetScreenBufferSizeRequest->OutputHandle,
978  if (!NT_SUCCESS(Status)) return Status;
979 
981  Buffer,
982  &SetScreenBufferSizeRequest->Size);
983 
985  return Status;
986 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
Definition: text.c:1114
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [28/61]

CSR_API ( SrvAllocConsole  )

Definition at line 986 of file console.c.

987 {
989  PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AllocConsoleRequest;
990  PCSR_PROCESS CsrProcess = CsrGetClientThread()->Process;
991  PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
992  CONSOLE_INIT_INFO ConsoleInitInfo;
993 
994  if (ProcessData->ConsoleHandle != NULL)
995  {
996  DPRINT1("Process already has a console\n");
997  return STATUS_ACCESS_DENIED;
998  }
999 
1000  if ( !CsrValidateMessageBuffer(ApiMessage,
1001  (PVOID*)&AllocConsoleRequest->ConsoleStartInfo,
1002  1,
1003  sizeof(CONSOLE_START_INFO)) ||
1004  !CsrValidateMessageBuffer(ApiMessage,
1005  (PVOID*)&AllocConsoleRequest->ConsoleTitle,
1006  AllocConsoleRequest->TitleLength,
1007  sizeof(BYTE)) ||
1008  !CsrValidateMessageBuffer(ApiMessage,
1009  (PVOID*)&AllocConsoleRequest->Desktop,
1010  AllocConsoleRequest->DesktopLength,
1011  sizeof(BYTE)) ||
1012  !CsrValidateMessageBuffer(ApiMessage,
1013  (PVOID*)&AllocConsoleRequest->CurDir,
1014  AllocConsoleRequest->CurDirLength,
1015  sizeof(BYTE)) ||
1016  !CsrValidateMessageBuffer(ApiMessage,
1017  (PVOID*)&AllocConsoleRequest->AppName,
1018  AllocConsoleRequest->AppNameLength,
1019  sizeof(BYTE)) )
1020  {
1021  return STATUS_INVALID_PARAMETER;
1022  }
1023 
1024  /* Initialize the console initialization info structure */
1025  ConsoleInitInfo.ConsoleStartInfo = AllocConsoleRequest->ConsoleStartInfo;
1026  ConsoleInitInfo.IsWindowVisible = TRUE; // The console window is always visible.
1027  ConsoleInitInfo.TitleLength = AllocConsoleRequest->TitleLength;
1028  ConsoleInitInfo.ConsoleTitle = AllocConsoleRequest->ConsoleTitle;
1029  ConsoleInitInfo.DesktopLength = AllocConsoleRequest->DesktopLength;
1030  ConsoleInitInfo.Desktop = AllocConsoleRequest->Desktop;
1031  ConsoleInitInfo.AppNameLength = AllocConsoleRequest->AppNameLength;
1032  ConsoleInitInfo.AppName = AllocConsoleRequest->AppName;
1033  ConsoleInitInfo.CurDirLength = AllocConsoleRequest->CurDirLength;
1034  ConsoleInitInfo.CurDir = AllocConsoleRequest->CurDir;
1035 
1036  /* Initialize a new Console owned by the Console Leader Process */
1037  Status = ConSrvAllocateConsole(ProcessData,
1038  &AllocConsoleRequest->ConsoleStartInfo->InputHandle,
1039  &AllocConsoleRequest->ConsoleStartInfo->OutputHandle,
1040  &AllocConsoleRequest->ConsoleStartInfo->ErrorHandle,
1041  &ConsoleInitInfo);
1042  if (!NT_SUCCESS(Status))
1043  {
1044  DPRINT1("Console allocation failed\n");
1045  return Status;
1046  }
1047 
1048  /* Set the Property-Dialog and Control-Dispatcher handlers */
1049  ProcessData->PropRoutine = AllocConsoleRequest->PropRoutine;
1050  ProcessData->CtrlRoutine = AllocConsoleRequest->CtrlRoutine;
1051 
1052  return STATUS_SUCCESS;
1053 }
HANDLE OutputHandle
Definition: conmsg.h:173
HANDLE ErrorHandle
Definition: conmsg.h:174
HANDLE ConsoleHandle
Definition: consrv.h:45
PWCHAR Desktop
Definition: console.h:19
PCONSOLE_START_INFO ConsoleStartInfo
Definition: console.h:13
#define CsrGetClientThread()
Definition: csrsrv.h:77
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
#define TRUE
Definition: types.h:120
ULONG CurDirLength
Definition: console.h:22
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: consrv.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:285
ULONG AppNameLength
Definition: console.h:20
PWCHAR AppName
Definition: console.h:21
ULONG TitleLength
Definition: console.h:16
smooth NULL
Definition: ftsmooth.c:416
PWCHAR ConsoleTitle
Definition: console.h:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
unsigned char BYTE
Definition: mem.h:68
ULONG DesktopLength
Definition: console.h:18
Status
Definition: gdiplustypes.h:24
BOOLEAN IsWindowVisible
Definition: console.h:14
HANDLE InputHandle
Definition: conmsg.h:172
#define DPRINT1
Definition: precomp.h:8
NTSTATUS ConSrvAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData, PHANDLE pInputHandle, PHANDLE pOutputHandle, PHANDLE pErrorHandle, PCONSOLE_INIT_INFO ConsoleInitInfo)
Definition: handle.c:474
return STATUS_SUCCESS
Definition: btrfs.c:2938
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274

◆ CSR_API() [29/61]

CSR_API ( SrvAttachConsole  )

Definition at line 1055 of file console.c.

1056 {
1058  PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AttachConsoleRequest;
1059  PCSR_PROCESS SourceProcess = NULL; // The parent process.
1060  PCSR_PROCESS TargetProcess = CsrGetClientThread()->Process; // Ourselves.
1061  HANDLE ProcessId = ULongToHandle(AttachConsoleRequest->ProcessId);
1062  PCONSOLE_PROCESS_DATA SourceProcessData, TargetProcessData;
1063 
1064  TargetProcessData = ConsoleGetPerProcessData(TargetProcess);
1065 
1066  if (TargetProcessData->ConsoleHandle != NULL)
1067  {
1068  DPRINT1("Process already has a console\n");
1069  return STATUS_ACCESS_DENIED;
1070  }
1071 
1072  if (!CsrValidateMessageBuffer(ApiMessage,
1073  (PVOID*)&AttachConsoleRequest->ConsoleStartInfo,
1074  1,
1075  sizeof(CONSOLE_START_INFO)))
1076  {
1077  return STATUS_INVALID_PARAMETER;
1078  }
1079 
1080  /* Check whether we try to attach to the parent's console */
1081  if (ProcessId == ULongToHandle(ATTACH_PARENT_PROCESS))
1082  {
1083  PROCESS_BASIC_INFORMATION ProcessInfo;
1084  ULONG Length = sizeof(ProcessInfo);
1085 
1086  /* Get the real parent's PID */
1087 
1090  &ProcessInfo,
1091  Length, &Length);
1092  if (!NT_SUCCESS(Status))
1093  {
1094  DPRINT1("SrvAttachConsole - Cannot retrieve basic process info, Status = 0x%08lx\n", Status);
1095  return Status;
1096  }
1097 
1099  }
1100 
1101  /* Lock the source process via its PID */
1102  Status = CsrLockProcessByClientId(ProcessId, &SourceProcess);
1103  if (!NT_SUCCESS(Status)) return Status;
1104 
1105  SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
1106 
1107  if (SourceProcessData->ConsoleHandle == NULL)
1108  {
1110  goto Quit;
1111  }
1112 
1113  /*
1114  * Inherit the console from the parent,
1115  * if any, otherwise return an error.
1116  */
1117  Status = ConSrvInheritConsole(TargetProcessData,
1118  SourceProcessData->ConsoleHandle,
1119  TRUE,
1120  &AttachConsoleRequest->ConsoleStartInfo->InputHandle,
1121  &AttachConsoleRequest->ConsoleStartInfo->OutputHandle,
1122  &AttachConsoleRequest->ConsoleStartInfo->ErrorHandle,
1123  AttachConsoleRequest->ConsoleStartInfo);
1124  if (!NT_SUCCESS(Status))
1125  {
1126  DPRINT1("Console inheritance failed\n");
1127  goto Quit;
1128  }
1129 
1130  /* Set the Property-Dialog and Control-Dispatcher handlers */
1131  TargetProcessData->PropRoutine = AttachConsoleRequest->PropRoutine;
1132  TargetProcessData->CtrlRoutine = AttachConsoleRequest->CtrlRoutine;
1133 
1135 
1136 Quit:
1137  /* Unlock the "source" process and exit */
1138  CsrUnlockProcess(SourceProcess);
1139  return Status;
1140 }
HANDLE OutputHandle
Definition: conmsg.h:173
HANDLE ErrorHandle
Definition: conmsg.h:174
HANDLE ConsoleHandle
Definition: consrv.h:45
#define ULongToHandle(h)
Definition: basetsd.h:81
#define CsrGetClientThread()
Definition: csrsrv.h:77
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: consrv.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtQueryInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:59
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
NTSTATUS ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData, HANDLE ConsoleHandle, BOOLEAN CreateNewHandlesTable, PHANDLE pInputHandle, PHANDLE pOutputHandle, PHANDLE pErrorHandle, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: handle.c:605
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
HANDLE ProcessHandle
Definition: csrsrv.h:46
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
ULONG_PTR InheritedFromUniqueProcessId
Definition: pstypes.h:340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
Status
Definition: gdiplustypes.h:24
HANDLE InputHandle
Definition: conmsg.h:172
#define DPRINT1
Definition: precomp.h:8
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1398

◆ CSR_API() [30/61]

CSR_API ( SrvFreeConsole  )

Definition at line 1142 of file console.c.

1143 {
1145 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
Definition: handle.c:735
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [31/61]

CSR_API ( SrvGetConsoleMode  )

Definition at line 1151 of file console.c.

1152 {
1153  NTSTATUS Status;
1154  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1156 
1157  PULONG ConsoleMode = &ConsoleModeRequest->Mode;
1158 
1160  ConsoleModeRequest->Handle,
1161  &Object, NULL, GENERIC_READ, TRUE, 0);
1162  if (!NT_SUCCESS(Status)) return Status;
1163 
1164  /* Get the standard console modes */
1166  ConsoleMode);
1167  if (NT_SUCCESS(Status))
1168  {
1169  /*
1170  * If getting the console modes succeeds, then retrieve
1171  * the extended CONSRV-specific input modes.
1172  */
1173  if (INPUT_BUFFER == Object->Type)
1174  {
1175  if (Object->Console->InsertMode || Object->Console->QuickEdit)
1176  {
1177  /* Windows also adds ENABLE_EXTENDED_FLAGS, even if it's not documented on MSDN */
1178  *ConsoleMode |= ENABLE_EXTENDED_FLAGS;
1179 
1180  if (Object->Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
1181  if (Object->Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
1182  }
1183  }
1184  }
1185 
1187  return Status;
1188 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvGetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, OUT PULONG ConsoleMode)
Definition: console.c:426
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
static IUnknown Object
Definition: main.c:512
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS ConSrvGetObject(IN PCONSOLE_PROCESS_DATA ProcessData, IN HANDLE Handle, OUT PCONSOLE_IO_OBJECT *Object, OUT PVOID *Entry OPTIONAL, IN ULONG Access, IN BOOLEAN LockConsole, IN CONSOLE_IO_OBJECT_TYPE Type)
Definition: handle.c:401
#define ENABLE_INSERT_MODE
Definition: wincon.h:80
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
unsigned int * PULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID ConSrvReleaseObject(IN PCONSOLE_IO_OBJECT Object, IN BOOLEAN IsConsoleLocked)
Definition: handle.c:465
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81

◆ CSR_API() [32/61]

CSR_API ( SrvSetConsoleMode  )

Definition at line 1194 of file console.c.

1195 {
1196 #define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | \
1197  ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
1198 
1199  NTSTATUS Status;
1200  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1202 
1203  ULONG ConsoleMode = ConsoleModeRequest->Mode;
1204 
1206  ConsoleModeRequest->Handle,
1207  &Object, NULL, GENERIC_WRITE, TRUE, 0);
1208  if (!NT_SUCCESS(Status)) return Status;
1209 
1210  /* Set the standard console modes (without the CONSRV-specific input modes) */
1211  ConsoleMode &= ~CONSOLE_VALID_CONTROL_MODES; // Remove CONSRV-specific input modes.
1213  ConsoleMode);
1214  if (NT_SUCCESS(Status))
1215  {
1216  /*
1217  * If setting the console modes succeeds, then set
1218  * the extended CONSRV-specific input modes.
1219  */
1220  if (INPUT_BUFFER == Object->Type)
1221  {
1222  ConsoleMode = ConsoleModeRequest->Mode;
1223 
1224  if (ConsoleMode & CONSOLE_VALID_CONTROL_MODES)
1225  {
1226  /*
1227  * If we use control mode flags without ENABLE_EXTENDED_FLAGS,
1228  * then consider the flags invalid.
1229  */
1230  if ((ConsoleMode & ENABLE_EXTENDED_FLAGS) == 0)
1231  {
1233  }
1234  else
1235  {
1236  Object->Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
1237  Object->Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
1238  }
1239  }
1240  }
1241  }
1242 
1244  return Status;
1245 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvSetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, IN ULONG ConsoleMode)
Definition: console.c:459
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define CONSOLE_VALID_CONTROL_MODES
static IUnknown Object
Definition: main.c:512
Status
Definition: gdiplustypes.h:24
NTSTATUS ConSrvGetObject(IN PCONSOLE_PROCESS_DATA ProcessData, IN HANDLE Handle, OUT PCONSOLE_IO_OBJECT *Object, OUT PVOID *Entry OPTIONAL, IN ULONG Access, IN BOOLEAN LockConsole, IN CONSOLE_IO_OBJECT_TYPE Type)
Definition: handle.c:401
#define ENABLE_INSERT_MODE
Definition: wincon.h:80
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID ConSrvReleaseObject(IN PCONSOLE_IO_OBJECT Object, IN BOOLEAN IsConsoleLocked)
Definition: handle.c:465
unsigned int ULONG
Definition: retypes.h:1
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81

◆ CSR_API() [33/61]

CSR_API ( SrvGetConsoleTitle  )

Definition at line 1247 of file console.c.

1248 {
1249  NTSTATUS Status;
1250  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1252  ULONG Length;
1253 
1254  if (!CsrValidateMessageBuffer(ApiMessage,
1255  (PVOID)&TitleRequest->Title,
1256  TitleRequest->Length,
1257  sizeof(BYTE)))
1258  {
1259  return STATUS_INVALID_PARAMETER;
1260  }
1261 
1263  if (!NT_SUCCESS(Status))
1264  {
1265  DPRINT1("Can't get console, status %lx\n", Status);
1266  return Status;
1267  }
1268 
1269  /* Copy title of the console to the user title buffer */
1270  if (TitleRequest->Unicode)
1271  {
1272  if (TitleRequest->Length >= sizeof(WCHAR))
1273  {
1274  Length = min(TitleRequest->Length - sizeof(WCHAR), Console->Title.Length);
1275  RtlCopyMemory(TitleRequest->Title, Console->Title.Buffer, Length);
1276  ((PWCHAR)TitleRequest->Title)[Length / sizeof(WCHAR)] = UNICODE_NULL;
1277  TitleRequest->Length = Length;
1278  }
1279  else
1280  {
1281  TitleRequest->Length = Console->Title.Length;
1282  }
1283  }
1284  else
1285  {
1286  if (TitleRequest->Length >= sizeof(CHAR))
1287  {
1288  Length = min(TitleRequest->Length - sizeof(CHAR), Console->Title.Length / sizeof(WCHAR));
1289  Length = WideCharToMultiByte(Console->InputCodePage, 0,
1290  Console->Title.Buffer, Length,
1291  TitleRequest->Title, Length,
1292  NULL, NULL);
1293  ((PCHAR)TitleRequest->Title)[Length] = ANSI_NULL;
1294  TitleRequest->Length = Length;
1295  }
1296  else
1297  {
1298  TitleRequest->Length = Console->Title.Length / sizeof(WCHAR);
1299  }
1300  }
1301 
1303  return Status;
1304 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define WideCharToMultiByte
Definition: compat.h:101
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define UNICODE_NULL
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
#define PCHAR
Definition: match.c:90
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1

◆ CSR_API() [34/61]

CSR_API ( SrvSetConsoleTitle  )

Definition at line 1306 of file console.c.

1307 {
1308  NTSTATUS Status;
1309  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1311 
1312  PWCHAR Buffer;
1313  ULONG Length;
1314 
1315  if (!CsrValidateMessageBuffer(ApiMessage,
1316  (PVOID)&TitleRequest->Title,
1317  TitleRequest->Length,
1318  sizeof(BYTE)))
1319  {
1320  return STATUS_INVALID_PARAMETER;
1321  }
1322 
1324  if (!NT_SUCCESS(Status))
1325  {
1326  DPRINT1("Can't get console, status %lx\n", Status);
1327  return Status;
1328  }
1329 
1330  if (TitleRequest->Unicode)
1331  {
1332  /* Length is in bytes */
1333  Length = TitleRequest->Length;
1334  }
1335  else
1336  {
1337  /* Use the console input CP for the conversion */
1338  Length = MultiByteToWideChar(Console->InputCodePage, 0,
1339  TitleRequest->Title, TitleRequest->Length,
1340  NULL, 0);
1341  /* The returned Length was in number of wchars, convert it in bytes */
1342  Length *= sizeof(WCHAR);
1343  }
1344 
1345  /* Allocate a new buffer to hold the new title (NULL-terminated) */
1347  if (!Buffer)
1348  {
1350  goto Quit;
1351  }
1352 
1353  /* Free the old title */
1355 
1356  /* Copy title to console */
1357  Console->Title.Buffer = Buffer;
1358  Console->Title.Length = Length;
1359  Console->Title.MaximumLength = Console->Title.Length + sizeof(WCHAR);
1360 
1361  if (TitleRequest->Unicode)
1362  {
1363  RtlCopyMemory(Console->Title.Buffer, TitleRequest->Title, Console->Title.Length);
1364  }
1365  else
1366  {
1367  MultiByteToWideChar(Console->InputCodePage, 0,
1368  TitleRequest->Title, TitleRequest->Length,
1369  Console->Title.Buffer,
1370  Console->Title.Length / sizeof(WCHAR));
1371  }
1372 
1373  /* NULL-terminate */
1374  Console->Title.Buffer[Console->Title.Length / sizeof(WCHAR)] = UNICODE_NULL;
1375 
1378 
1379 Quit:
1381  return Status;
1382 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static VOID ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
Definition: console.c:233
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
uint16_t * PWCHAR
Definition: typedefs.h:54
#define TermChangeTitle(Console)
Definition: term.h:46
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [35/61]

CSR_API ( SrvGetConsoleHardwareState  )

Definition at line 55 of file frontendctl.c.

56 {
57 #if 0
59  PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
62 
64  HardwareStateRequest->OutputHandle,
65  &Buff,
67  TRUE);
68  if (!NT_SUCCESS(Status))
69  {
70  DPRINT1("Failed to get console handle in SrvGetConsoleHardwareState\n");
71  return Status;
72  }
73 
74  Console = Buff->Header.Console;
75  HardwareStateRequest->State = Console->HardwareState;
76 
78  return Status;
79 #else
82 #endif
83 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define UNIMPLEMENTED
Definition: debug.h:114

◆ CSR_API() [36/61]

CSR_API ( SrvSetConsoleHardwareState  )

Definition at line 85 of file frontendctl.c.

86 {
87 #if 0
89  PCONSOLE_GETSETHWSTATE HardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
92 
94  HardwareStateRequest->OutputHandle,
95  &Buff,
97  TRUE);
98  if (!NT_SUCCESS(Status))
99  {
100  DPRINT1("Failed to get console handle in SrvSetConsoleHardwareState\n");
101  return Status;
102  }
103 
104  DPRINT("Setting console hardware state.\n");
105  Console = Buff->Header.Console;
106  Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
107 
109  return Status;
110 #else
112  return STATUS_NOT_IMPLEMENTED;
113 #endif
114 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define GENERIC_WRITE
Definition: nt_native.h:90
BOOL WINAPI SetConsoleHardwareState(HANDLE hConsoleOutput, DWORD Flags, DWORD State)
Definition: console.c:944
void DPRINT(...)
Definition: polytest.cpp:61
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define UNIMPLEMENTED
Definition: debug.h:114

◆ CSR_API() [37/61]

CSR_API ( SrvGetConsoleDisplayMode  )

Definition at line 116 of file frontendctl.c.

117 {
119  PCONSOLE_GETDISPLAYMODE GetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetDisplayModeRequest;
121 
123  &Console, TRUE);
124  if (!NT_SUCCESS(Status)) return Status;
125 
126  GetDisplayModeRequest->DisplayMode = TermGetDisplayMode(Console);
127 
129  return STATUS_SUCCESS;
130 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define TermGetDisplayMode(Console)
Definition: term.h:56
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [38/61]

CSR_API ( SrvSetConsoleDisplayMode  )

Definition at line 132 of file frontendctl.c.

133 {
135  PCONSOLE_SETDISPLAYMODE SetDisplayModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetDisplayModeRequest;
138 
140  SetDisplayModeRequest->OutputHandle,
141  &Buff,
143  TRUE);
144  if (!NT_SUCCESS(Status)) return Status;
145 
147 
148  if (TermSetDisplayMode(Console, SetDisplayModeRequest->DisplayMode))
149  {
150  SetDisplayModeRequest->NewSBDim = Buff->ScreenBufferSize;
152  }
153  else
154  {
156  }
157 
159  return Status;
160 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermSetDisplayMode(Console, NewMode)
Definition: term.h:58
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
COORD ScreenBufferSize
Definition: conio.h:87
#define GENERIC_WRITE
Definition: nt_native.h:90
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [39/61]

CSR_API ( SrvGetLargestConsoleWindowSize  )

Definition at line 162 of file frontendctl.c.

163 {
165  PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetLargestWindowSizeRequest;
166  PCONSOLE /*PCONSRV_CONSOLE*/ Console;
168 
170  GetLargestWindowSizeRequest->OutputHandle,
171  &Buff,
172  GENERIC_READ,
173  TRUE);
174  if (!NT_SUCCESS(Status)) return Status;
175 
176  Console = Buff->Header.Console;
177 
178  /*
179  * Retrieve the largest possible console window size, without
180  * taking into account the size of the console screen buffer
181  * (thus differs from ConDrvGetConsoleScreenBufferInfo).
182  */
183  TermGetLargestConsoleWindowSize(Console, &GetLargestWindowSizeRequest->Size);
184 
186  return STATUS_SUCCESS;
187 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [40/61]

CSR_API ( SrvShowConsoleCursor  )

Definition at line 189 of file frontendctl.c.

190 {
192  PCONSOLE_SHOWCURSOR ShowCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ShowCursorRequest;
193  PCONSOLE /*PCONSRV_CONSOLE*/ Console;
195 
197  ShowCursorRequest->OutputHandle,
198  &Buff,
200  TRUE);
201  if (!NT_SUCCESS(Status)) return Status;
202 
203  Console = Buff->Header.Console;
204 
205  ShowCursorRequest->RefCount = TermShowMouseCursor(Console, ShowCursorRequest->Show);
206 
208  return STATUS_SUCCESS;
209 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define GENERIC_WRITE
Definition: nt_native.h:90
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define TermShowMouseCursor(Console, Show)
Definition: term.h:38
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
HANDLE OutputHandle
Definition: conmsg.h:330
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [41/61]

CSR_API ( SrvSetConsoleCursor  )

Definition at line 211 of file frontendctl.c.

212 {
214  BOOL Success;
215  PCONSOLE_SETCURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest;
218 
219  // NOTE: Tests show that this function is used only for graphics screen buffers
220  // and otherwise it returns FALSE and sets last error to ERROR_INVALID_HANDLE.
221  // I find that behaviour is ridiculous but ok, let's accept it at the moment...
223  SetCursorRequest->OutputHandle,
224  &Buff,
226  TRUE);
227  if (!NT_SUCCESS(Status)) return Status;
228 
230 
231  Success = TermSetMouseCursor(Console, SetCursorRequest->CursorHandle);
232 
235 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
HCURSOR CursorHandle
Definition: conmsg.h:339
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
HANDLE OutputHandle
Definition: conmsg.h:338
Status
Definition: gdiplustypes.h:24
#define ConSrvGetGraphicsBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:19
#define TermSetMouseCursor(Console, CursorHandle)
Definition: term.h:60
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [42/61]

CSR_API ( SrvConsoleMenuControl  )

Definition at line 237 of file frontendctl.c.

238 {
240  PCONSOLE_MENUCONTROL MenuControlRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.MenuControlRequest;
243 
245  MenuControlRequest->OutputHandle,
246  &Buff,
248  TRUE);
249  if (!NT_SUCCESS(Status)) return Status;
250 
252 
253  MenuControlRequest->MenuHandle = TermMenuControl(Console,
254  MenuControlRequest->CmdIdLow,
255  MenuControlRequest->CmdIdHigh);
256 
258  return STATUS_SUCCESS;
259 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE * Console
Definition: conio.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
HANDLE OutputHandle
Definition: conmsg.h:693
#define PCONSRV_CONSOLE
Definition: conio.h:27
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define GENERIC_WRITE
Definition: nt_native.h:90
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
#define TermMenuControl(Console, CmdIdLow, CmdIdHigh)
Definition: term.h:62
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [43/61]

CSR_API ( SrvSetConsoleMenuClose  )

Definition at line 261 of file frontendctl.c.

262 {
264  BOOL Success;
265  PCONSOLE_SETMENUCLOSE SetMenuCloseRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetMenuCloseRequest;
267 
269  &Console, TRUE);
270  if (!NT_SUCCESS(Status)) return Status;
271 
272  Success = TermSetMenuClose(Console, SetMenuCloseRequest->Enable);
273 
276 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define TermSetMenuClose(Console, Enable)
Definition: term.h:64
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
unsigned int BOOL
Definition: ntddk_ex.h:94
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [44/61]

CSR_API ( SrvSetConsoleWindowInfo  )

Definition at line 1028 of file conoutput.c.

1029 {
1030  NTSTATUS Status;
1031  PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest;
1032  // PCONSOLE_SCREEN_BUFFER Buffer;
1034 
1035  DPRINT1("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
1036  SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
1037  SetWindowInfoRequest->WindowRect.Left ,
1038  SetWindowInfoRequest->WindowRect.Top ,
1039  SetWindowInfoRequest->WindowRect.Right,
1040  SetWindowInfoRequest->WindowRect.Bottom);
1041 
1042  // ConSrvGetScreenBuffer
1044  SetWindowInfoRequest->OutputHandle,
1045  &Buffer, GENERIC_READ, TRUE);
1046  if (!NT_SUCCESS(Status)) return Status;
1047 
1048  Status = ConDrvSetConsoleWindowInfo(Buffer->Header.Console,
1049  Buffer,
1050  SetWindowInfoRequest->Absolute,
1051  &SetWindowInfoRequest->WindowRect);
1052 
1054  return Status;
1055 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
SMALL_RECT WindowRect
Definition: conmsg.h:710
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
Definition: text.c:1221
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [45/61]

CSR_API ( SrvGetConsoleWindow  )

Definition at line 314 of file frontendctl.c.

315 {
317  PCONSOLE_GETWINDOW GetWindowRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetWindowRequest;
319 
321  &Console, TRUE);
322  if (!NT_SUCCESS(Status)) return Status;
323 
324  GetWindowRequest->WindowHandle = TermGetConsoleWindowHandle(Console);
325 
327  return STATUS_SUCCESS;
328 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define TermGetConsoleWindowHandle(Console)
Definition: term.h:52
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938

◆ CSR_API() [46/61]

CSR_API ( SrvSetConsoleIcon  )

Definition at line 330 of file frontendctl.c.

331 {
333  PCONSOLE_SETICON SetIconRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetIconRequest;
335 
337  &Console, TRUE);
338  if (!NT_SUCCESS(Status)) return Status;
339 
340  Status = (TermChangeIcon(Console, SetIconRequest->IconHandle)
343 
345  return Status;
346 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2938
HICON IconHandle
Definition: conmsg.h:723
#define TermChangeIcon(Console, IconHandle)
Definition: term.h:48

◆ CSR_API() [47/61]

CSR_API ( SrvGetConsoleCP  )

Definition at line 1388 of file console.c.

1389 {
1390  NTSTATUS Status;
1391  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleCPRequest;
1393 
1394  DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
1395  GetConsoleCPRequest->OutputCP ? "Output" : "Input");
1396 
1398  if (!NT_SUCCESS(Status)) return Status;
1399 
1401  &GetConsoleCPRequest->CodePage,
1402  GetConsoleCPRequest->OutputCP);
1403 
1405  return Status;
1406 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvGetConsoleCP(IN PCONSOLE Console, OUT PUINT CodePage, IN BOOLEAN OutputCP)
Definition: console.c:513
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [48/61]

CSR_API ( SrvSetConsoleCP  )

Definition at line 1412 of file console.c.

1413 {
1415  PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleCPRequest;
1417 
1418  DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
1419  SetConsoleCPRequest->OutputCP ? "Output" : "Input");
1420 
1422  if (!NT_SUCCESS(Status)) return Status;
1423 
1425  SetConsoleCPRequest->CodePage,
1426  SetConsoleCPRequest->OutputCP);
1427 
1429  return Status;
1430 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296