ReactOS  0.4.14-dev-52-g6116262
alias.c File Reference
#include "consrv.h"
#include <debug.h>
Include dependency graph for alias.c:

Go to the source code of this file.

Classes

struct  _ALIAS_ENTRY
 
struct  _ALIAS_HEADER
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _ALIAS_ENTRY ALIAS_ENTRY
 
typedef struct _ALIAS_ENTRYPALIAS_ENTRY
 
typedef struct _ALIAS_HEADER ALIAS_HEADER
 
typedef struct _ALIAS_HEADERPALIAS_HEADER
 

Functions

BOOLEAN ConvertInputAnsiToUnicode (PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PWCHAR *Target, PUSHORT TargetLength)
 
BOOLEAN ConvertInputUnicodeToAnsi (PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PCHAR Target, USHORT TargetLength)
 
static PALIAS_HEADER IntFindAliasHeader (PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
 
static PALIAS_HEADER IntCreateAliasHeader (PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
 
static VOID IntInsertAliasHeader (PALIAS_HEADER *RootHeader, PALIAS_HEADER NewHeader)
 
static PALIAS_ENTRY IntGetAliasEntry (PCONSRV_CONSOLE Console, PALIAS_HEADER Header, PVOID Source, USHORT SourceLength, BOOLEAN Unicode)
 
static PALIAS_ENTRY IntCreateAliasEntry (PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PVOID Target, USHORT TargetLength, BOOLEAN Unicode)
 
static VOID IntInsertAliasEntry (PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
 
static VOID IntDeleteAliasEntry (PALIAS_HEADER Header, PALIAS_ENTRY Entry)
 
static UINT IntGetConsoleAliasesExesLength (PALIAS_HEADER RootHeader, BOOLEAN IsUnicode)
 
static UINT IntGetAllConsoleAliasesLength (PALIAS_HEADER Header, BOOLEAN IsUnicode)
 
VOID IntDeleteAllAliases (PCONSRV_CONSOLE Console)
 
 CSR_API (SrvAddConsoleAlias)
 
 CSR_API (SrvGetConsoleAlias)
 
 CSR_API (SrvGetConsoleAliases)
 
 CSR_API (SrvGetConsoleAliasesLength)
 
 CSR_API (SrvGetConsoleAliasExes)
 
 CSR_API (SrvGetConsoleAliasExesLength)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file alias.c.

Typedef Documentation

◆ ALIAS_ENTRY

◆ ALIAS_HEADER

◆ PALIAS_ENTRY

◆ PALIAS_HEADER

Function Documentation

◆ ConvertInputAnsiToUnicode()

BOOLEAN ConvertInputAnsiToUnicode ( PCONSRV_CONSOLE  Console,
PVOID  Source,
USHORT  SourceLength,
PWCHAR Target,
PUSHORT  TargetLength 
)

Definition at line 37 of file alias.c.

43 {
44  ASSERT(Source && Target && TargetLength);
45 
46  /* Use the console input CP for the conversion */
47  *TargetLength = MultiByteToWideChar(Console->InputCodePage, 0,
48  Source, SourceLength,
49  NULL, 0);
50  *Target = ConsoleAllocHeap(0, *TargetLength * sizeof(WCHAR));
51  if (*Target == NULL) return FALSE;
52 
53  MultiByteToWideChar(Console->InputCodePage, 0,
54  Source, SourceLength,
55  *Target, *TargetLength);
56 
57  /* The returned Length was in number of WCHARs, convert it in bytes */
58  *TargetLength *= sizeof(WCHAR);
59 
60  return TRUE;
61 }
#define TRUE
Definition: types.h:120
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167

Referenced by HistoryFindBuffer(), IntCreateAliasEntry(), IntCreateAliasHeader(), IntFindAliasHeader(), and IntGetAliasEntry().

◆ ConvertInputUnicodeToAnsi()

BOOLEAN ConvertInputUnicodeToAnsi ( PCONSRV_CONSOLE  Console,
PVOID  Source,
USHORT  SourceLength,
PCHAR  Target,
USHORT  TargetLength 
)

Definition at line 64 of file alias.c.

70 {
71  ASSERT(Source && Target && TargetLength);
72 
73  /*
74  * From MSDN:
75  * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
76  * If they are the same, the function fails, and GetLastError returns
77  * ERROR_INVALID_PARAMETER."
78  */
80 
81  /* Use the console input CP for the conversion */
82  // *TargetLength = WideCharToMultiByte(Console->InputCodePage, 0,
83  // Source, SourceLength,
84  // NULL, 0, NULL, NULL);
85  // *Target = ConsoleAllocHeap(0, *TargetLength * sizeof(WCHAR));
86  // if (*Target == NULL) return FALSE;
87 
88  WideCharToMultiByte(Console->InputCodePage, 0,
89  Source, SourceLength,
90  /* * */Target, /* * */TargetLength,
91  NULL, NULL);
92 
93  // /* The returned Length was in number of WCHARs, convert it in bytes */
94  // *TargetLength *= sizeof(WCHAR);
95 
96  return TRUE;
97 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167

Referenced by CSR_API().

◆ CSR_API() [1/6]

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:2966
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/6]

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:64
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/6]

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:61
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/6]

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:2966
static PALIAS_HEADER IntFindAliasHeader(PCONSRV_CONSOLE Console, PVOID ExeName, USHORT ExeLength, BOOLEAN UnicodeExe)
Definition: alias.c:105

◆ CSR_API() [5/6]

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:61
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/6]

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

◆ IntCreateAliasEntry()

static PALIAS_ENTRY IntCreateAliasEntry ( PCONSRV_CONSOLE  Console,
PVOID  Source,
USHORT  SourceLength,
PVOID  Target,
USHORT  TargetLength,
BOOLEAN  Unicode 
)
static

Definition at line 269 of file alias.c.

275 {
276  UNICODE_STRING SourceU;
277  UNICODE_STRING TargetU;
278 
280 
281  if (Unicode)
282  {
283  SourceU.Buffer = Source;
284  TargetU.Buffer = Target;
285  /* Length is in bytes */
286  SourceU.MaximumLength = SourceLength;
287  TargetU.MaximumLength = TargetLength;
288  }
289  else
290  {
292  Source, SourceLength,
293  &SourceU.Buffer, &SourceU.MaximumLength))
294  {
295  return NULL;
296  }
297 
299  Target, TargetLength,
300  &TargetU.Buffer, &TargetU.MaximumLength))
301  {
302  ConsoleFreeHeap(SourceU.Buffer);
303  return NULL;
304  }
305  }
306  SourceU.Length = SourceU.MaximumLength;
307  TargetU.Length = TargetU.MaximumLength;
308 
309  Entry = ConsoleAllocHeap(0, sizeof(ALIAS_ENTRY) +
310  SourceU.Length + TargetU.Length);
311  if (!Entry)
312  {
313  if (!Unicode)
314  {
315  ConsoleFreeHeap(TargetU.Buffer);
316  ConsoleFreeHeap(SourceU.Buffer);
317  }
318  return Entry;
319  }
320 
321  Entry->Source.Buffer = (PWSTR)(Entry + 1);
322  Entry->Source.Length = 0;
323  Entry->Source.MaximumLength = SourceU.Length;
324  RtlCopyUnicodeString(&Entry->Source, &SourceU);
325 
326  Entry->Target.Buffer = (PWSTR)((ULONG_PTR)Entry->Source.Buffer + Entry->Source.MaximumLength);
327  Entry->Target.Length = 0;
328  Entry->Target.MaximumLength = TargetU.Length;
329  RtlCopyUnicodeString(&Entry->Target, &TargetU);
330 
331  Entry->Next = NULL;
332 
333  if (!Unicode)
334  {
335  ConsoleFreeHeap(TargetU.Buffer);
336  ConsoleFreeHeap(SourceU.Buffer);
337  }
338  return Entry;
339 }
struct _Entry Entry
Definition: kefuncs.h:640
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:54
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:63
BOOLEAN ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PWCHAR *Target, PUSHORT TargetLength)
Definition: alias.c:37
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1068
Definition: alias.c:19
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
base of all file and directory entries
Definition: entries.h:82

Referenced by CSR_API().

◆ IntCreateAliasHeader()

static PALIAS_HEADER IntCreateAliasHeader ( PCONSRV_CONSOLE  Console,
PVOID  ExeName,
USHORT  ExeLength,
BOOLEAN  UnicodeExe 
)
static

Definition at line 152 of file alias.c.

156 {
157  UNICODE_STRING ExeNameU;
158 
160 
161  if (ExeName == NULL) return NULL;
162 
163  if (UnicodeExe)
164  {
165  ExeNameU.Buffer = ExeName;
166  /* Length is in bytes */
167  ExeNameU.MaximumLength = ExeLength;
168  }
169  else
170  {
172  ExeName, ExeLength,
173  &ExeNameU.Buffer, &ExeNameU.MaximumLength))
174  {
175  return NULL;
176  }
177  }
178  ExeNameU.Length = ExeNameU.MaximumLength;
179 
180  Entry = ConsoleAllocHeap(0, sizeof(ALIAS_HEADER) + ExeNameU.Length);
181  if (!Entry)
182  {
183  if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
184  return Entry;
185  }
186 
187  Entry->ExeName.Buffer = (PWSTR)(Entry + 1);
188  Entry->ExeName.Length = 0;
189  Entry->ExeName.MaximumLength = ExeNameU.Length;
190  RtlCopyUnicodeString(&Entry->ExeName, &ExeNameU);
191 
192  Entry->Data = NULL;
193  Entry->Next = NULL;
194 
195  if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
196  return Entry;
197 }
struct _Entry Entry
Definition: kefuncs.h:640
USHORT MaximumLength
Definition: env_spec_w32.h:370
uint16_t * PWSTR
Definition: typedefs.h:54
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
BOOLEAN ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PWCHAR *Target, PUSHORT TargetLength)
Definition: alias.c:37
smooth NULL
Definition: ftsmooth.c:416
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
base of all file and directory entries
Definition: entries.h:82

Referenced by CSR_API().

◆ IntDeleteAliasEntry()

static VOID IntDeleteAliasEntry ( PALIAS_HEADER  Header,
PALIAS_ENTRY  Entry 
)
static

Definition at line 362 of file alias.c.

364 {
365  PALIAS_ENTRY *LastLink = &Header->Data;
366  PALIAS_ENTRY CurEntry;
367 
368  while ((CurEntry = *LastLink) != NULL)
369  {
370  if (CurEntry == Entry)
371  {
372  *LastLink = Entry->Next;
374  return;
375  }
376  LastLink = &CurEntry->Next;
377  }
378 }
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
Definition: alias.c:19
struct _ALIAS_ENTRY * Next
Definition: alias.c:21
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
base of all file and directory entries
Definition: entries.h:82

Referenced by CSR_API().

◆ IntDeleteAllAliases()

VOID IntDeleteAllAliases ( PCONSRV_CONSOLE  Console)

Definition at line 428 of file alias.c.

429 {
430  PALIAS_HEADER Header, NextHeader;
431  PALIAS_ENTRY Entry, NextEntry;
432 
433  for (Header = Console->Aliases; Header; Header = NextHeader)
434  {
435  NextHeader = Header->Next;
436  for (Entry = Header->Data; Entry; Entry = NextEntry)
437  {
438  NextEntry = Entry->Next;
440  }
442  }
443 }
struct _Entry Entry
Definition: kefuncs.h:640
Definition: Header.h:8
Definition: alias.c:19
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
base of all file and directory entries
Definition: entries.h:82

Referenced by ConDrvDeleteConsole(), and ConSrvDeleteConsole().

◆ IntFindAliasHeader()

static PALIAS_HEADER IntFindAliasHeader ( PCONSRV_CONSOLE  Console,
PVOID  ExeName,
USHORT  ExeLength,
BOOLEAN  UnicodeExe 
)
static

Definition at line 105 of file alias.c.

109 {
110  UNICODE_STRING ExeNameU;
111 
112  PALIAS_HEADER RootHeader = Console->Aliases;
113  INT Diff;
114 
115  if (ExeName == NULL) return NULL;
116 
117  if (UnicodeExe)
118  {
119  ExeNameU.Buffer = ExeName;
120  /* Length is in bytes */
121  ExeNameU.MaximumLength = ExeLength;
122  }
123  else
124  {
126  ExeName, ExeLength,
127  &ExeNameU.Buffer, &ExeNameU.MaximumLength))
128  {
129  return NULL;
130  }
131  }
132  ExeNameU.Length = ExeNameU.MaximumLength;
133 
134  while (RootHeader)
135  {
136  Diff = RtlCompareUnicodeString(&RootHeader->ExeName, &ExeNameU, TRUE);
137  if (!Diff)
138  {
139  if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
140  return RootHeader;
141  }
142  if (Diff > 0) break;
143 
144  RootHeader = RootHeader->Next;
145  }
146 
147  if (!UnicodeExe) ConsoleFreeHeap(ExeNameU.Buffer);
148  return NULL;
149 }
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
int32_t INT
Definition: typedefs.h:56
BOOLEAN ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PWCHAR *Target, PUSHORT TargetLength)
Definition: alias.c:37
smooth NULL
Definition: ftsmooth.c:416
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
UNICODE_STRING ExeName
Definition: alias.c:29
struct _ALIAS_HEADER * Next
Definition: alias.c:28
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15

Referenced by CSR_API().

◆ IntGetAliasEntry()

static PALIAS_ENTRY IntGetAliasEntry ( PCONSRV_CONSOLE  Console,
PALIAS_HEADER  Header,
PVOID  Source,
USHORT  SourceLength,
BOOLEAN  Unicode 
)
static

Definition at line 220 of file alias.c.

225 {
226  UNICODE_STRING SourceU;
227 
229  INT Diff;
230 
231  if (Header == NULL || Source == NULL) return NULL;
232 
233  if (Unicode)
234  {
235  SourceU.Buffer = Source;
236  /* Length is in bytes */
237  SourceU.MaximumLength = SourceLength;
238  }
239  else
240  {
242  Source, SourceLength,
243  &SourceU.Buffer, &SourceU.MaximumLength))
244  {
245  return NULL;
246  }
247  }
248  SourceU.Length = SourceU.MaximumLength;
249 
250  Entry = Header->Data;
251  while (Entry)
252  {
253  Diff = RtlCompareUnicodeString(&Entry->Source, &SourceU, TRUE);
254  if (!Diff)
255  {
256  if (!Unicode) ConsoleFreeHeap(SourceU.Buffer);
257  return Entry;
258  }
259  if (Diff > 0) break;
260 
261  Entry = Entry->Next;
262  }
263 
264  if (!Unicode) ConsoleFreeHeap(SourceU.Buffer);
265  return NULL;
266 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
USHORT MaximumLength
Definition: env_spec_w32.h:370
int32_t INT
Definition: typedefs.h:56
Definition: Header.h:8
BOOLEAN ConvertInputAnsiToUnicode(PCONSRV_CONSOLE Console, PVOID Source, USHORT SourceLength, PWCHAR *Target, PUSHORT TargetLength)
Definition: alias.c:37
smooth NULL
Definition: ftsmooth.c:416
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Definition: alias.c:19
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
base of all file and directory entries
Definition: entries.h:82

Referenced by CSR_API().

◆ IntGetAllConsoleAliasesLength()

static UINT IntGetAllConsoleAliasesLength ( PALIAS_HEADER  Header,
BOOLEAN  IsUnicode 
)
static

Definition at line 403 of file alias.c.

405 {
406  UINT Length = 0;
407  PALIAS_ENTRY CurEntry = Header->Data;
408 
409  while (CurEntry)
410  {
411  Length += CurEntry->Source.Length;
412  Length += CurEntry->Target.Length;
413  Length += 2 * sizeof(WCHAR); // '=' and NULL-termination
414  CurEntry = CurEntry->Next;
415  }
416 
417  /*
418  * Quick and dirty way of getting the number of bytes of the
419  * corresponding ANSI string from the one in UNICODE.
420  */
421  if (!IsUnicode)
422  Length /= sizeof(WCHAR);
423 
424  return Length;
425 }
Definition: Header.h:8
UNICODE_STRING Target
Definition: alias.c:23
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UNICODE_STRING Source
Definition: alias.c:22
Definition: alias.c:19
struct _ALIAS_ENTRY * Next
Definition: alias.c:21
unsigned int UINT
Definition: ndis.h:50

Referenced by CSR_API().

◆ IntGetConsoleAliasesExesLength()

static UINT IntGetConsoleAliasesExesLength ( PALIAS_HEADER  RootHeader,
BOOLEAN  IsUnicode 
)
static

Definition at line 381 of file alias.c.

383 {
384  UINT Length = 0;
385 
386  while (RootHeader)
387  {
388  Length += RootHeader->ExeName.Length + sizeof(WCHAR); // NULL-termination
389  RootHeader = RootHeader->Next;
390  }
391 
392  /*
393  * Quick and dirty way of getting the number of bytes of the
394  * corresponding ANSI string from the one in UNICODE.
395  */
396  if (!IsUnicode)
397  Length /= sizeof(WCHAR);
398 
399  return Length;
400 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UNICODE_STRING ExeName
Definition: alias.c:29
struct _ALIAS_HEADER * Next
Definition: alias.c:28
unsigned int UINT
Definition: ndis.h:50

Referenced by CSR_API().

◆ IntInsertAliasEntry()

static VOID IntInsertAliasEntry ( PALIAS_HEADER  Header,
PALIAS_ENTRY  NewEntry 
)
static

Definition at line 342 of file alias.c.

344 {
345  PALIAS_ENTRY CurrentEntry;
346  PALIAS_ENTRY *LastLink = &Header->Data;
347  INT Diff;
348 
349  while ((CurrentEntry = *LastLink) != NULL)
350  {
351  Diff = RtlCompareUnicodeString(&NewEntry->Source, &CurrentEntry->Source, TRUE);
352  if (Diff < 0) break;
353 
354  LastLink = &CurrentEntry->Next;
355  }
356 
357  *LastLink = NewEntry;
358  NewEntry->Next = CurrentEntry;
359 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
Definition: Header.h:8
smooth NULL
Definition: ftsmooth.c:416
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
UNICODE_STRING Source
Definition: alias.c:22
Definition: alias.c:19
struct _ALIAS_ENTRY * Next
Definition: alias.c:21

Referenced by CSR_API().

◆ IntInsertAliasHeader()

static VOID IntInsertAliasHeader ( PALIAS_HEADER RootHeader,
PALIAS_HEADER  NewHeader 
)
static

Definition at line 200 of file alias.c.

202 {
203  PALIAS_HEADER CurrentHeader;
204  PALIAS_HEADER *LastLink = RootHeader;
205  INT Diff;
206 
207  while ((CurrentHeader = *LastLink) != NULL)
208  {
209  Diff = RtlCompareUnicodeString(&NewHeader->ExeName, &CurrentHeader->ExeName, TRUE);
210  if (Diff < 0) break;
211 
212  LastLink = &CurrentHeader->Next;
213  }
214 
215  *LastLink = NewHeader;
216  NewHeader->Next = CurrentHeader;
217 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
UNICODE_STRING ExeName
Definition: alias.c:29
struct _ALIAS_HEADER * Next
Definition: alias.c:28

Referenced by CSR_API().