ReactOS  0.4.13-dev-482-ge57f103
util.c File Reference
#include "sacdrv.h"
#include <ndk/rtlfuncs.h>
Include dependency graph for util.c:

Go to the source code of this file.

Functions

BOOLEAN NTAPI SacTranslateUtf8ToUnicode (IN CHAR Utf8Char, IN PCHAR Utf8Buffer, OUT PWCHAR Utf8Value)
 
BOOLEAN NTAPI SacTranslateUnicodeToUtf8 (IN PWCHAR SourceBuffer, IN ULONG SourceBufferLength, OUT PCHAR DestinationBuffer, IN ULONG DestinationBufferSize, OUT PULONG UTF8Count, OUT PULONG ProcessedCount)
 
PWCHAR NTAPI GetMessage (IN ULONG MessageIndex)
 
NTSTATUS NTAPI UTF8EncodeAndSend (IN PWCHAR String)
 
VOID NTAPI SacFormatMessage (IN PWCHAR FormattedString, IN PWCHAR MessageString, IN ULONG MessageSize)
 
NTSTATUS NTAPI PreloadGlobalMessageTable (IN PVOID ImageBase)
 
NTSTATUS NTAPI TearDownGlobalMessageTable (VOID)
 
NTSTATUS NTAPI GetRegistryValueBuffer (IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
 
NTSTATUS NTAPI SetRegistryValue (IN PCWSTR KeyName, IN PWCHAR ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
 
NTSTATUS NTAPI CopyRegistryValueData (IN PVOID *Buffer, IN PKEY_VALUE_PARTIAL_INFORMATION PartialInfo)
 
NTSTATUS NTAPI TranslateMachineInformationXML (IN PWCHAR *Buffer, IN PWCHAR ExtraData)
 
VOID NTAPI InitializeMachineInformation (VOID)
 
NTSTATUS NTAPI GetCommandConsoleLaunchingPermission (OUT PBOOLEAN Permission)
 
NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy (VOID)
 
VOID NTAPI InitializeCmdEventInfo (VOID)
 
NTSTATUS NTAPI RegisterBlueScreenMachineInformation (VOID)
 
VOID NTAPI FreeMachineInformation (VOID)
 
BOOLEAN NTAPI VerifyEventWaitable (IN HANDLE Handle, OUT PVOID *WaitObject, OUT PVOID *ActualWaitObject)
 
NTSTATUS NTAPI SerialBufferGetChar (OUT PCHAR Char)
 
ULONG NTAPI GetMessageLineCount (IN ULONG MessageIndex)
 
ULONG ConvertAnsiToUnicode (IN PWCHAR pwch, IN PCHAR pch, IN ULONG length)
 
BOOLEAN IsCmdEventRegistrationProcess (IN PFILE_OBJECT FileObject)
 
NTSTATUS InvokeUserModeService (VOID)
 
NTSTATUS TranslateMachineInformationText (IN PWCHAR Buffer)
 
NTSTATUS CopyAndInsertStringAtInterval (IN PWCHAR SourceStr, IN ULONG Interval, IN PWCHAR InsertStr, OUT PWCHAR pDestStr)
 
NTSTATUS RegisterSacCmdEvent (IN PVOID Object, IN PKEVENT SetupCmdEvent[])
 
NTSTATUS UnregisterSacCmdEvent (IN PFILE_OBJECT FileObject)
 

Variables

PCHAR Utf8ConversionBuffer
 
ULONG Utf8ConversionBufferSize = PAGE_SIZE
 
PSAC_MACHINE_INFO MachineInformation
 
PVOID RequestSacCmdEventObjectBody
 
PKEVENT RequestSacCmdEventWaitObjectBody
 
PVOID RequestSacCmdSuccessEventObjectBody
 
PKEVENT RequestSacCmdSuccessEventWaitObjectBody
 
PVOID RequestSacCmdFailureEventObjectBody
 
PKEVENT RequestSacCmdFailureEventWaitObjectBody
 
PFILE_OBJECT ServiceProcessFileObject
 
BOOLEAN HaveUserModeServiceCmdEventInfo
 
PSAC_MESSAGE_ENTRY GlobalMessageTable
 
ULONG GlobalMessageTableCount
 
LONG SerialPortConsumerIndex
 
LONG SerialPortProducerIndex
 
PCHAR SerialPortBuffer
 

Function Documentation

◆ ConvertAnsiToUnicode()

ULONG ConvertAnsiToUnicode ( IN PWCHAR  pwch,
IN PCHAR  pch,
IN ULONG  length 
)

Definition at line 1248 of file util.c.

1253 {
1254  return STATUS_NOT_IMPLEMENTED;
1255 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ CopyAndInsertStringAtInterval()

NTSTATUS CopyAndInsertStringAtInterval ( IN PWCHAR  SourceStr,
IN ULONG  Interval,
IN PWCHAR  InsertStr,
OUT PWCHAR  pDestStr 
)

Definition at line 1281 of file util.c.

1287 {
1288  return STATUS_NOT_IMPLEMENTED;
1289 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ CopyRegistryValueData()

NTSTATUS NTAPI CopyRegistryValueData ( IN PVOID Buffer,
IN PKEY_VALUE_PARTIAL_INFORMATION  PartialInfo 
)

Definition at line 511 of file util.c.

513 {
516  CHECK_PARAMETER2(PartialInfo);
517 
518  /* Allocate space for registry data */
519  *Buffer = SacAllocatePool(PartialInfo->DataLength, GLOBAL_BLOCK_TAG);
520  if (*Buffer)
521  {
522  /* Copy the data into the buffer */
523  RtlCopyMemory(*Buffer, PartialInfo->Data, PartialInfo->DataLength);
524  }
525  else
526  {
527  /* Set the correct error code */
528  SAC_DBG(SAC_DBG_UTIL, "SAC CopyRegistryValueBuffer: Failed ALLOCATE.\n");
530  }
531 
532  /* Return the result */
533  return Status;
534 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
Definition: bufpool.h:45
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
#define SAC_DBG_UTIL
Definition: sacdrv.h:33
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by ImposeSacCmdServiceStartTypePolicy(), and InitializeMachineInformation().

◆ FreeMachineInformation()

VOID NTAPI FreeMachineInformation ( VOID  )

Definition at line 1153 of file util.c.

1154 {
1156 
1157  /* Free every cached string of machine information */
1165 }
PWCHAR BuildNumber
Definition: sacdrv.h:497
PWCHAR ServicePack
Definition: sacdrv.h:499
PWCHAR ProcessorArchitecture
Definition: sacdrv.h:495
PWCHAR MachineName
Definition: sacdrv.h:493
PWCHAR MajorVersion
Definition: sacdrv.h:496
PSAC_MACHINE_INFO MachineInformation
Definition: util.c:20
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PWCHAR MachineGuid
Definition: sacdrv.h:494
PWCHAR ProductType
Definition: sacdrv.h:498

Referenced by FreeGlobalData().

◆ GetCommandConsoleLaunchingPermission()

NTSTATUS NTAPI GetCommandConsoleLaunchingPermission ( OUT PBOOLEAN  Permission)

Definition at line 978 of file util.c.

979 {
982 
983  /* Assume success and read the key */
984  *Permission = TRUE;
985  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacdrv",
986  L"DisableCmdSessions",
987  &Dummy);
989  {
990  /* The default is success */
992  }
993  else
994  {
995  /* Only if the key is present and set, do we disable permission */
996  if (NT_SUCCESS(Status)) *Permission = FALSE;
997  }
998 
999  /* Return status */
1000  return Status;
1001 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI GetRegistryValueBuffer(IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
Definition: util.c:392
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by InitializeGlobalData().

◆ GetMessage()

PWCHAR NTAPI GetMessage ( IN ULONG  MessageIndex)

Definition at line 139 of file util.c.

140 {
141  PSAC_MESSAGE_ENTRY MessageEntry;
142  ULONG i;
143  PWCHAR MessageData = NULL;
144 
145  /* Loop all cached messages */
146  for (i = 0; i < GlobalMessageTableCount; i++)
147  {
148  /* Check if this one matches the index */
149  MessageEntry = &GlobalMessageTable[i];
150  if (MessageEntry->Index == MessageIndex)
151  {
152  /* It does, return the buffer */
153  MessageData = MessageEntry->Buffer;
154  break;
155  }
156  }
157 
158  /* We should always find it */
159  if (!MessageData) ASSERT(FALSE);
160  return MessageData;
161 }
Definition: sacdrv.h:204
PSAC_MESSAGE_ENTRY GlobalMessageTable
Definition: util.c:31
ULONG GlobalMessageTableCount
Definition: util.c:32
PWCHAR Buffer
Definition: sacdrv.h:207
uint16_t * PWCHAR
Definition: typedefs.h:54
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
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Index
Definition: sacdrv.h:206
unsigned int ULONG
Definition: retypes.h:1

Referenced by GetMessageLineCount(), and InitializeMachineInformation().

◆ GetMessageLineCount()

ULONG NTAPI GetMessageLineCount ( IN ULONG  MessageIndex)

Definition at line 1230 of file util.c.

1231 {
1232  ULONG LineCount = 0;
1233  PWCHAR Buffer;
1234 
1235  /* Get the message buffer */
1236  Buffer = GetMessage(MessageIndex);
1237  if (Buffer)
1238  {
1239  /* Scan it looking for new lines, and increment the count each time */
1240  while (*Buffer) if (*Buffer++ == L'\n') ++LineCount;
1241  }
1242 
1243  /* Return the line count */
1244  return LineCount;
1245 }
uint16_t * PWCHAR
Definition: typedefs.h:54
Definition: bufpool.h:45
static const WCHAR L[]
Definition: oid.c:1250
PWCHAR NTAPI GetMessage(IN ULONG MessageIndex)
Definition: util.c:139
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by PrintHelpMessage().

◆ GetRegistryValueBuffer()

NTSTATUS NTAPI GetRegistryValueBuffer ( IN PCWSTR  KeyName,
IN PWCHAR  ValueName,
IN PKEY_VALUE_PARTIAL_INFORMATION Buffer 
)

Definition at line 392 of file util.c.

395 {
399  HANDLE Handle;
400  ULONG ResultLength = 0;
401  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: Entering.\n");
404 
405  /* Open the specified key */
410  NULL,
411  NULL);
412  Status = ZwOpenKey(&Handle,
415  if (!NT_SUCCESS(Status))
416  {
417  /* Bail out on failure */
418  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed ZwOpenKey: %X.\n", Status);
419  return Status;
420  }
421 
422  /* Query the size of the key */
424  Status = ZwQueryValueKey(Handle,
427  NULL,
428  0,
429  &ResultLength);
430  if (!ResultLength) return Status;
431 
432  /* Allocate the buffer for the partial info structure and our integer data */
433  ResultLength += sizeof(ULONG);
435  if (!*Buffer)
436  {
437  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed allocation\n");
438  return Status;
439  }
440 
441  /* Now read the data */
442  Status = ZwQueryValueKey(Handle,
445  *Buffer,
446  ResultLength,
447  &ResultLength);
448  if (!NT_SUCCESS(Status))
449  {
450  /* Free the buffer if we couldn't read the data */
451  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC GetRegistryValueBuffer: failed ZwQueryValueKey: %X.\n", Status);
453  }
454 
455  /* Return the result */
456  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
457  return Status;
458 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
LONG NTSTATUS
Definition: precomp.h:26
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
static ULONG
Definition: util.c:35
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
#define KEY_WRITE
Definition: nt_native.h:1031
_In_ HANDLE Handle
Definition: extypes.h:390
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106

Referenced by GetCommandConsoleLaunchingPermission(), ImposeSacCmdServiceStartTypePolicy(), and InitializeMachineInformation().

◆ ImposeSacCmdServiceStartTypePolicy()

NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy ( VOID  )

Definition at line 1005 of file util.c.

1006 {
1007  NTSTATUS Status;
1009  PULONG Data;
1010 
1011  /* Read the service start type*/
1012  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1013  L"Start",
1014  &Buffer);
1015  if (!NT_SUCCESS(Status)) return Status;
1016 
1017  /* If there's no start type, fail, as this is unusual */
1018  if (!Buffer) return STATUS_UNSUCCESSFUL;
1019 
1020  /* Read the value */
1023  if (!NT_SUCCESS(Status)) return Status;
1024 
1025  /* Check what the current start type is */
1026  switch (*Data)
1027  {
1028  /* It's boot, system, or disabled */
1029  case 1:
1030  case 2:
1031  case 4:
1032  /* Leave it as is */
1033  return Status;
1034 
1035  case 3:
1036 
1037  /* It's set to automatic, set it to system instead */
1038  *Data = 2;
1039  Status = SetRegistryValue(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1040  L"Start",
1041  REG_DWORD,
1042  Data,
1043  sizeof(ULONG));
1044  if (!NT_SUCCESS(Status))
1045  {
1046  SAC_DBG(SAC_DBG_INIT, "SAC ImposeSacCmdServiceStartTypePolicy: Failed SetRegistryValue: %X\n", Status);
1047  }
1048  break;
1049 
1050  default:
1051  ASSERT(FALSE);
1052  }
1053 
1054  return Status;
1055 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI CopyRegistryValueData(IN PVOID *Buffer, IN PKEY_VALUE_PARTIAL_INFORMATION PartialInfo)
Definition: util.c:511
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI GetRegistryValueBuffer(IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
Definition: util.c:392
Status
Definition: gdiplustypes.h:24
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI SetRegistryValue(IN PCWSTR KeyName, IN PWCHAR ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: util.c:462
unsigned int ULONG
Definition: retypes.h:1
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by InitializeGlobalData().

◆ InitializeCmdEventInfo()

VOID NTAPI InitializeCmdEventInfo ( VOID  )

Definition at line 1059 of file util.c.

1060 {
1061  /* Check if we were already initialized */
1063  {
1064  /* Full state expected */
1068 
1069  /* Dereference each wait object in turn */
1071  {
1073  }
1074 
1076  {
1078  }
1079 
1081  {
1083  }
1084  }
1085 
1086  /* Claer everything */
1094 
1095  /* Reset state */
1097 }
PKEVENT RequestSacCmdFailureEventWaitObjectBody
Definition: util.c:27
PVOID RequestSacCmdSuccessEventObjectBody
Definition: util.c:24
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
smooth NULL
Definition: ftsmooth.c:416
PFILE_OBJECT ServiceProcessFileObject
Definition: util.c:28
BOOLEAN HaveUserModeServiceCmdEventInfo
Definition: util.c:29
PKEVENT RequestSacCmdSuccessEventWaitObjectBody
Definition: util.c:25
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PKEVENT RequestSacCmdEventWaitObjectBody
Definition: util.c:23
PVOID RequestSacCmdEventObjectBody
Definition: util.c:22
PVOID RequestSacCmdFailureEventObjectBody
Definition: util.c:26

Referenced by InitializeGlobalData().

◆ InitializeMachineInformation()

VOID NTAPI InitializeMachineInformation ( VOID  )

Definition at line 689 of file util.c.

690 {
692  PWCHAR GuidString, MajorVersion, ServicePack, BuildNumber, MessageBuffer;
693  PWCHAR ProductType;
694  ULONG SuiteTypeMessage;
695  BOOLEAN SetupInProgress = FALSE;
696  GUID SystemGuid;
697  SIZE_T RealSize, Size, OutputSize;
698  PKEY_VALUE_PARTIAL_INFORMATION PartialInfo;
699  RTL_OSVERSIONINFOEXW VersionInformation;
700  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Entering.\n");
701 
702  /* Don't do anything if we already queried this */
703  if (MachineInformation)
704  {
705  SAC_DBG(SAC_DBG_MACHINE, "SAC Initialize Machine Information:: MachineInformationBuffer already initialized.\n");
706  return;
707  }
708 
709  /* Allocate the machine information */
712  if (!MachineInformation)
713  {
714  goto Fail;
715  }
716 
717  /* Zero it out for now */
719 
720  /* Query OS version */
721  RtlZeroMemory(&VersionInformation, sizeof(VersionInformation));
722  VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation);
723  Status = RtlGetVersion((PRTL_OSVERSIONINFOW)&VersionInformation);
724  if (!NT_SUCCESS(Status))
725  {
726  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (2).\n");
727  goto Fail;
728  }
729 
730  /* Check if setup is in progress */
731  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\Setup",
732  L"SystemSetupInProgress",
733  &PartialInfo);
734  if (NT_SUCCESS(Status))
735  {
736  /* The key is there, is the value set? */
737  if (*(PULONG)PartialInfo->Data) SetupInProgress = TRUE;
738  SacFreePool(PartialInfo);
739  if (SetupInProgress)
740  {
741  /* Yes, so we'll use a special hostname to identify this */
742  MessageBuffer = GetMessage(SAC_UNINITIALIZED_MSG);
743  Size = wcslen(MessageBuffer);
744  ASSERT(Size > 0);
745  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
746 
747  /* Make room for it and copy it in there */
751  {
752  wcscpy(MachineInformation->MachineName, MessageBuffer);
753  }
754  }
755  }
756 
757  /* If we are not in setup mode, or if we failed to check... */
758  if (!SetupInProgress)
759  {
760  /* Query the computer name */
761  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
762  L"CurrentControlSet\\Control\\"
763  L"ComputerName\\ComputerName",
764  L"ComputerName",
765  &PartialInfo);
766  if (!NT_SUCCESS(Status))
767  {
768  /* It's not critical, but we won't have it */
769  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get machine name.\n");
770  }
771  else
772  {
773  /* We have the name, copy it from the registry */
775  MachineName,
776  PartialInfo);
777  SacFreePool(PartialInfo);
778  if (!NT_SUCCESS(Status))
779  {
780  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (20).\n");
781  goto Fail;
782  }
783  }
784  }
785 
786  /* Next step, try to get the machine GUID */
787  RtlZeroMemory(&SystemGuid, sizeof(SystemGuid));
788  OutputSize = sizeof(SystemGuid);
790  NULL,
791  0,
792  &SystemGuid,
793  &OutputSize);
794  if (!NT_SUCCESS(Status))
795  {
796  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get Machine GUID.\n");
797  }
798  else
799  {
800  /* We have it -- make room for it */
802  if (!GuidString)
803  {
804  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (31).\n");
805  goto Fail;
806  }
807 
808  /* Build the string with the GUID in it, and save the ppointer to it */
810  L"%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
811  SystemGuid.Data1,
812  SystemGuid.Data2,
813  SystemGuid.Data3,
814  SystemGuid.Data4[0],
815  SystemGuid.Data4[1],
816  SystemGuid.Data4[2],
817  SystemGuid.Data4[3],
818  SystemGuid.Data4[4],
819  SystemGuid.Data4[5],
820  SystemGuid.Data4[6],
821  SystemGuid.Data4[7]);
823  }
824 
825  /* Next, query the processor architecture */
826  Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
827  L"CurrentControlSet\\Control\\"
828  L"Session Manager\\Environment",
829  L"PROCESSOR_ARCHITECTURE",
830  &PartialInfo);
831  if (!NT_SUCCESS(Status))
832  {
833  /* It's not critical, but we won't have it */
834  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
835  }
836  else
837  {
838  /* We have it! Copy the value from the registry */
840  ProcessorArchitecture,
841  PartialInfo);
842  SacFreePool(PartialInfo);
843  if (!NT_SUCCESS(Status))
844  {
845  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
846  goto Fail;
847  }
848  }
849 
850  /* Now allocate a buffer for the OS version number */
852  if (!MajorVersion)
853  {
854  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (50).\n");
855  goto Fail;
856  }
857 
858  /* Build the buffer and set a pointer to it */
860  L"%d.%d",
861  VersionInformation.dwMajorVersion,
862  VersionInformation.dwMinorVersion);
864 
865  /* Now allocate a buffer for the OS build number */
867  if (!BuildNumber)
868  {
869  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (60).\n");
870  goto Fail;
871  }
872 
873  /* Build the buffer and set a pointer to it */
874  swprintf(BuildNumber, L"%d", VersionInformation.dwBuildNumber);
876 
877  /* Now check what kind of SKU this is */
879  {
880  SuiteTypeMessage = SAC_DATACENTER_SUITE_MSG;
881  }
882  else if (ExVerifySuite(EmbeddedNT))
883  {
884  SuiteTypeMessage = SAC_EMBEDDED_SUITE_MSG;
885  }
886  else if (ExVerifySuite(Enterprise))
887  {
888  SuiteTypeMessage = SAC_ENTERPRISE_SUITE_MSG;
889  }
890  else
891  {
892  /* Unknown or perhaps a client SKU */
893  SuiteTypeMessage = SAC_NO_SUITE_MSG;
894  }
895 
896  /* Get the string that corresponds to the SKU type */
897  MessageBuffer = GetMessage(SuiteTypeMessage);
898  if (!MessageBuffer)
899  {
900  /* We won't have it, but this isn't critical */
901  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed to get product type.\n");
902  }
903  else
904  {
905  /* Calculate the size we need to hold the string */
906  Size = wcslen(MessageBuffer);
907  ASSERT(Size > 0);
908  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
909 
910  /* Allocate a buffer for it */
911  ProductType = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
912  if (!ProductType)
913  {
914  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed product type memory allocation.\n");
915  goto Fail;
916  }
917 
918  /* Copy the string and set the pointer */
919  RtlCopyMemory(ProductType, MessageBuffer, RealSize);
920  MachineInformation->ProductType = ProductType;
921  }
922 
923  /* Check if this is a SP version or RTM version */
924  if (VersionInformation.wServicePackMajor)
925  {
926  /* This is a service pack, allocate a buffer for the version */
927  ServicePack = SacAllocatePool(0x18, GLOBAL_BLOCK_TAG);
928  if (ServicePack)
929  {
930  /* Build the buffer and set a pointer to it */
931  swprintf(ServicePack,
932  L"%d.%d",
933  VersionInformation.wServicePackMajor,
934  VersionInformation.wServicePackMinor);
935  MachineInformation->ServicePack = ServicePack;
936 
937  /* We've collected all the machine info and are done! */
938  return;
939  }
940 
941  /* This is the failure path */
942  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
943  }
944  else
945  {
946  /* Get a generic string that indicates there's no service pack */
947  MessageBuffer = GetMessage(SAC_NO_DATA_MSG);
948  Size = wcslen(MessageBuffer);
949  ASSERT(Size > 0);
950  RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
951 
952  /* Allocate memory for the "no service pack" string */
953  ServicePack = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
954  if (ServicePack)
955  {
956  /* Copy the buffer and set a pointer to it */
957  RtlCopyMemory(ServicePack, MessageBuffer, RealSize);
958  MachineInformation->ServicePack = ServicePack;
959 
960  /* We've collected all the machine info and are done! */
961  return;
962  }
963 
964  SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
965  }
966 
967 Fail:
968  /* In the failure path, always cleanup the machine information buffer */
969  if (MachineInformation)
970  {
972  }
973  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Exiting with error.\n");
974 }
ULONG dwBuildNumber
Definition: rtltypes.h:268
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
static PWSTR GuidString
Definition: apphelp.c:91
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG MajorVersion
Definition: ros_glue.cpp:4
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
ULONG dwMinorVersion
Definition: rtltypes.h:267
PWCHAR BuildNumber
Definition: sacdrv.h:497
LONG NTSTATUS
Definition: precomp.h:26
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1286
PWCHAR ServicePack
Definition: sacdrv.h:499
uint16_t * PWCHAR
Definition: typedefs.h:54
BOOLEAN NTAPI ExVerifySuite(SUITE_TYPE SuiteType)
Definition: sysinfo.c:377
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
ULONG dwMajorVersion
Definition: rtltypes.h:266
PWCHAR MachineName
Definition: sacdrv.h:493
#define UNICODE_NULL
unsigned char BOOLEAN
PWCHAR MajorVersion
Definition: sacdrv.h:496
smooth NULL
Definition: ftsmooth.c:416
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI CopyRegistryValueData(IN PVOID *Buffer, IN PKEY_VALUE_PARTIAL_INFORMATION PartialInfo)
Definition: util.c:511
PSAC_MACHINE_INFO MachineInformation
Definition: util.c:20
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
#define SAC_DBG_MACHINE
Definition: sacdrv.h:36
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI GetRegistryValueBuffer(IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
Definition: util.c:392
PWCHAR NTAPI GetMessage(IN ULONG MessageIndex)
Definition: util.c:139
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
PWCHAR MachineGuid
Definition: sacdrv.h:494
Status
Definition: gdiplustypes.h:24
ULONG BuildNumber
Definition: ros_glue.cpp:6
Definition: hiveinit.c:368
ULONG_PTR SIZE_T
Definition: typedefs.h:78
USHORT wServicePackMajor
Definition: rtltypes.h:271
unsigned int * PULONG
Definition: retypes.h:1
PWCHAR ProductType
Definition: sacdrv.h:498
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
USHORT wServicePackMinor
Definition: rtltypes.h:272

Referenced by InitializeGlobalData().

◆ InvokeUserModeService()

NTSTATUS InvokeUserModeService ( VOID  )

Definition at line 1266 of file util.c.

1269 {
1270  return STATUS_NOT_IMPLEMENTED;
1271 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ IsCmdEventRegistrationProcess()

BOOLEAN IsCmdEventRegistrationProcess ( IN PFILE_OBJECT  FileObject)

Definition at line 1258 of file util.c.

1261 {
1262  return FALSE;
1263 }

◆ PreloadGlobalMessageTable()

NTSTATUS NTAPI PreloadGlobalMessageTable ( IN PVOID  ImageBase)

Definition at line 280 of file util.c.

281 {
282  NTSTATUS Status, Status2;
283  ULONG MessageId, TotalLength, TextSize, i;
285  PMESSAGE_RESOURCE_ENTRY MessageEntry;
286  PAGED_CODE();
287  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC PreloadGlobalMessageTable: Entering.\n");
288 
289  /* Nothing to do if we already have a table */
291  if (GlobalMessageTable) goto Exit;
292 
293  /* Loop through up to 200 messages */
294  TotalLength = 0;
295  for (MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
296  {
297  /* Find this message ID in the string table*/
298  Status2 = RtlFindMessage(ImageBase,
299  11,
300  LANG_NEUTRAL,
301  MessageId,
302  &MessageEntry);
303  if (NT_SUCCESS(Status2))
304  {
305  /* Make sure it's Unicode */
306  ASSERT(MessageEntry->Flags & MESSAGE_RESOURCE_UNICODE);
307 
308  /* Remove the space taken up by the OS header, and add our own */
309  TotalLength += MessageEntry->Length -
311  sizeof(SAC_MESSAGE_ENTRY);
312 
313  /* One more in the table */
315  }
316  }
317 
318  /* We should've found at least one message... */
319  if (!TotalLength)
320  {
321  /* Bail out otherwise */
322  SAC_DBG(SAC_DBG_INIT, "SAC PreloadGlobalMessageTable: No Messages.\n");
324  goto Exit;
325  }
326 
327  /* Allocate space for the buffers and headers */
329  if (!GlobalMessageTable)
330  {
331  /* Bail out if we couldn't allocate it */
333  goto Exit;
334  }
335 
336  /* All the buffers are going to be at the end of the table */
338 
339  /* Now loop over our entries again */
340  for (i = 0, MessageId = 1; MessageId != SAC_MAX_MESSAGES; MessageId++)
341  {
342  /* Make sure the message is still there...! */
343  Status2 = RtlFindMessage(ImageBase,
344  11,
345  LANG_NEUTRAL,
346  MessageId,
347  &MessageEntry);
348  if (NT_SUCCESS(Status2))
349  {
350  /* Write the entry in the message table*/
351  GlobalMessageTable[i].Index = MessageId;
353 
354  /* The structure includes the size of the header, elide it */
355  TextSize = MessageEntry->Length -
357 
358  /* Format the message into the entry. It should be same or smaller */
359  SacFormatMessage(StringBuffer, (PWCHAR)MessageEntry->Text, TextSize);
360  ASSERT((ULONG)(wcslen(StringBuffer)*sizeof(WCHAR)) <= TextSize);
361 
362  /* Move to the next buffer space */
363  StringBuffer += (TextSize / sizeof(WCHAR));
364 
365  /* Move to the next entry, make sure the status is full success */
366  i++;
368  }
369  }
370 
371 Exit:
372  /* All done, return the status code */
373  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Exiting with status 0x%0x\n", Status);
374  return Status;
375 }
struct _SAC_MESSAGE_ENTRY SAC_MESSAGE_ENTRY
#define MESSAGE_RESOURCE_UNICODE
Definition: rtltypes.h:354
Definition: rtltypes.h:1827
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define LANG_NEUTRAL
Definition: nls.h:22
LONG NTSTATUS
Definition: precomp.h:26
PSAC_MESSAGE_ENTRY GlobalMessageTable
Definition: util.c:31
ULONG GlobalMessageTableCount
Definition: util.c:32
NTSYSAPI NTSTATUS NTAPI RtlFindMessage(_In_ PVOID BaseAddress, _In_ ULONG Type, _In_ ULONG Language, _In_ ULONG MessageId, _Out_ PMESSAGE_RESOURCE_ENTRY *MessageResourceEntry)
PWCHAR Buffer
Definition: sacdrv.h:207
uint16_t * PWCHAR
Definition: typedefs.h:54
_In_ ULONG TotalLength
Definition: usbdlib.h:145
USHORT Flags
Definition: rtltypes.h:1830
#define PAGED_CODE()
Definition: video.h:57
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
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 SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1831
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
USHORT Length
Definition: rtltypes.h:1829
Status
Definition: gdiplustypes.h:24
ULONG Index
Definition: sacdrv.h:206
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
VOID NTAPI SacFormatMessage(IN PWCHAR FormattedString, IN PWCHAR MessageString, IN ULONG MessageSize)
Definition: util.c:202
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
return STATUS_SUCCESS
Definition: btrfs.c:2777
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
char * Text
Definition: combotst.c:136
#define SAC_MAX_MESSAGES
Definition: sacdrv.h:155

Referenced by InitializeGlobalData().

◆ RegisterBlueScreenMachineInformation()

NTSTATUS NTAPI RegisterBlueScreenMachineInformation ( VOID  )

Definition at line 1101 of file util.c.

1102 {
1103  PWCHAR XmlBuffer;
1105  SIZE_T Length, HeaderLength, TotalLength;
1106  NTSTATUS Status;
1107  ULONG i;
1108 
1109  /* Create the XML buffer and make sure it's OK */
1113 
1114  /* Compute the sizes and allocate a buffer for it */
1115  Length = wcslen(XmlBuffer);
1116  HeaderLength = strlen("MACHINEINFO");
1117  TotalLength = HeaderLength +
1118  Length +
1119  sizeof(*BsBuffer) +
1120  2 * sizeof(ANSI_NULL);
1123 
1124  /* Copy the XML property name */
1125  strcpy((PCHAR)BsBuffer->Data, "MACHINEINFO");
1126  BsBuffer->ValueIndex = HeaderLength + sizeof(ANSI_NULL);
1127 
1128  /* Copy the data and NULL-terminate it */
1129  for (i = 0; i < Length; i++)
1130  {
1131  BsBuffer->Data[BsBuffer->ValueIndex + i] = XmlBuffer[i];
1132  }
1133  BsBuffer->Data[BsBuffer->ValueIndex + i] = ANSI_NULL;
1134 
1135  /* Let the OS save the buffer for later */
1137  BsBuffer,
1138  TotalLength,
1139  NULL,
1140  NULL);
1141 
1142  /* Failure or not, we don't need this anymore */
1143  SacFreePool(BsBuffer);
1144  SacFreePool(XmlBuffer);
1145 
1146  /* Return the result */
1147  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information: Exiting.\n");
1148  return Status;
1149 }
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS NTAPI TranslateMachineInformationXML(IN PWCHAR *Buffer, IN PWCHAR ExtraData)
Definition: util.c:538
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
_In_ ULONG TotalLength
Definition: usbdlib.h:145
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
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 ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CHECK_PARAMETER_WITH_STATUS(Condition, Status)
Definition: sacdrv.h:47
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by InitializeGlobalData().

◆ RegisterSacCmdEvent()

NTSTATUS RegisterSacCmdEvent ( IN PVOID  Object,
IN PKEVENT  SetupCmdEvent[] 
)

Definition at line 1292 of file util.c.

1296 {
1297  return STATUS_NOT_IMPLEMENTED;
1298 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ SacFormatMessage()

VOID NTAPI SacFormatMessage ( IN PWCHAR  FormattedString,
IN PWCHAR  MessageString,
IN ULONG  MessageSize 
)

Definition at line 202 of file util.c.

205 {
206  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Entering.\n");
207 
208  /* Check if any of the parameters are NULL or zero */
209  if (!(MessageString) || !(FormattedString) || !(MessageSize))
210  {
211  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Exiting with invalid parameters.\n");
212  return;
213  }
214 
215  /* Keep going as long as there's still characters */
216  while ((MessageString[0]) && (MessageSize))
217  {
218  /* Is it a non-formatting character? */
219  if (MessageString[0] != L'%')
220  {
221  /* Just write it back into the buffer and keep going */
222  *FormattedString++ = MessageString[0];
223  MessageString++;
224  }
225  else
226  {
227  /* Go over the format characters we recognize */
228  switch (MessageString[1])
229  {
230  case L'0':
231  *FormattedString = UNICODE_NULL;
232  return;
233 
234  case L'%':
235  *FormattedString++ = L'%';
236  break;
237 
238  case L'\\':
239  *FormattedString++ = L'\r';
240  *FormattedString++ = L'\n';
241  break;
242 
243  case L'r':
244  *FormattedString++ = L'\r';
245  break;
246 
247  case L'b':
248  *FormattedString++ = L' ';
249  break;
250 
251  case L'.':
252  *FormattedString++ = L'.';
253  break;
254 
255  case L'!':
256  *FormattedString++ = L'!';
257  break;
258 
259  default:
260  /* Only move forward one character */
261  MessageString--;
262  break;
263  }
264 
265  /* Move forward two characters */
266  MessageString += 2;
267  }
268 
269  /* Move to the next character*/
270  MessageSize--;
271  }
272 
273  /* All done */
274  *FormattedString = UNICODE_NULL;
275  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SacFormatMessage: Exiting.\n");
276 }
#define UNICODE_NULL
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

Referenced by PreloadGlobalMessageTable().

◆ SacTranslateUnicodeToUtf8()

BOOLEAN NTAPI SacTranslateUnicodeToUtf8 ( IN PWCHAR  SourceBuffer,
IN ULONG  SourceBufferLength,
OUT PCHAR  DestinationBuffer,
IN ULONG  DestinationBufferSize,
OUT PULONG  UTF8Count,
OUT PULONG  ProcessedCount 
)

Definition at line 91 of file util.c.

97 {
98  *UTF8Count = 0;
99  *ProcessedCount = 0;
100 
101  while ((*SourceBuffer) &&
102  (*UTF8Count < DestinationBufferSize) &&
103  (*ProcessedCount < SourceBufferLength))
104  {
105  if (*SourceBuffer & 0xFF80)
106  {
107  if (*SourceBuffer & 0xF800)
108  {
109  if ((*UTF8Count + 3) >= DestinationBufferSize) break;
110  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 12) & 0xF) | 0xE0;
111  ++*UTF8Count;
112  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 0x3F) | 0x80;
113  }
114  else
115  {
116  if ((*UTF8Count + 2) >= DestinationBufferSize) break;
117  DestinationBuffer[*UTF8Count] = ((*SourceBuffer >> 6) & 31) | 0xC0;
118  }
119  ++*UTF8Count;
120  DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x3F) | 0x80;
121  }
122  else
123  {
124  DestinationBuffer[*UTF8Count] = (*SourceBuffer & 0x7F);
125  }
126 
127  ++*UTF8Count;
128  ++*ProcessedCount;
129  ++SourceBuffer;
130  }
131 
132  ASSERT(*ProcessedCount <= SourceBufferLength);
133  ASSERT(*UTF8Count <= DestinationBufferSize);
134  return TRUE;
135 }
#define TRUE
Definition: types.h:120
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_In_ ULONG _In_ ULONG _In_ ULONG DestinationBufferSize
Definition: tdikrnl.h:1006

Referenced by UTF8EncodeAndSend(), VTUTF8ChannelOEcho(), and VTUTF8ChannelOFlush().

◆ SacTranslateUtf8ToUnicode()

BOOLEAN NTAPI SacTranslateUtf8ToUnicode ( IN CHAR  Utf8Char,
IN PCHAR  Utf8Buffer,
OUT PWCHAR  Utf8Value 
)

Definition at line 41 of file util.c.

44 {
45  ULONG i;
46 
47  /* Find out how many valid characters we have in the buffer */
48  i = 0;
49  while (Utf8Buffer[i++] && (i < 3));
50 
51  /* If we have at least 3, shift everything by a byte */
52  if (i >= 3)
53  {
54  /* The last input character goes at the end */
55  Utf8Buffer[0] = Utf8Buffer[1];
56  Utf8Buffer[1] = Utf8Buffer[2];
57  Utf8Buffer[2] = Utf8Char;
58  }
59  else
60  {
61  /* We don't have more than 3 characters, place the input at the index */
62  Utf8Buffer[i] = Utf8Char;
63  }
64 
65  /* Print to debugger */
66  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SacTranslateUtf8ToUnicode - About to decode the UTF8 buffer.\n");
67  SAC_DBG(SAC_DBG_ENTRY_EXIT, " UTF8[0]: 0x%02lx UTF8[1]: 0x%02lx UTF8[2]: 0x%02lx\n",
68  Utf8Buffer[0],
69  Utf8Buffer[1],
70  Utf8Buffer[2]);
71 
72  /* Is this a simple ANSI character? */
73  if (!(Utf8Char & 0x80))
74  {
75  /* Return it as Unicode, nothing left to do */
76  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SACDRV: SacTranslateUTf8ToUnicode - Case1\n");
77  *Utf8Value = (WCHAR)Utf8Char;
78  Utf8Buffer[0] = Utf8Buffer[1];
79  Utf8Buffer[1] = Utf8Buffer[2];
80  Utf8Buffer[2] = UNICODE_NULL;
81  return TRUE;
82  }
83 
84  /* Anything else is not yet supported */
85  ASSERT(FALSE);
86  return FALSE;
87 }
#define TRUE
Definition: types.h:120
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 UNICODE_NULL
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

Referenced by VTUTF8ChannelIWrite().

◆ SerialBufferGetChar()

NTSTATUS NTAPI SerialBufferGetChar ( OUT PCHAR  Char)

Definition at line 1209 of file util.c.

1210 {
1211  /* Check if nothing's been produced yet */
1213  {
1214  return STATUS_NO_DATA_DETECTED;
1215  }
1216 
1217  /* Consume the produced character and clear it*/
1220 
1221  /* Advance the index and return success */
1223  (SerialPortConsumerIndex + 1) &
1225  return STATUS_SUCCESS;
1226 }
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
#define ANSI_NULL
char Char
Definition: bzip2.c:161
LONG SerialPortProducerIndex
Definition: util.c:34
LONG SerialPortConsumerIndex
Definition: util.c:34
#define STATUS_NO_DATA_DETECTED
Definition: udferr_usr.h:131
PCHAR SerialPortBuffer
Definition: util.c:35
#define SAC_SERIAL_PORT_BUFFER_SIZE
Definition: sacdrv.h:154
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by ConMgrSerialPortConsumer().

◆ SetRegistryValue()

NTSTATUS NTAPI SetRegistryValue ( IN PCWSTR  KeyName,
IN PWCHAR  ValueName,
IN ULONG  Type,
IN PVOID  Data,
IN ULONG  DataSize 
)

Definition at line 462 of file util.c.

467 {
471  HANDLE Handle;
472  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Entering.\n");
476 
477  /* Open the specified key */
482  NULL,
483  NULL);
484  Status = ZwOpenKey(&Handle,
487  if (!NT_SUCCESS(Status))
488  {
489  /* Bail out on failure */
490  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: failed ZwOpenKey: %X.\n", Status);
491  return Status;
492  }
493 
494  /* Set the specified value */
496  Status = ZwSetValueKey(Handle, &DestinationString, 0, Type, Data, DataSize);
497  if (!NT_SUCCESS(Status))
498  {
499  /* Print error on failure */
500  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: failed ZwSetValueKey: %X.\n", Status);
501  }
502 
503  /* Close the handle and exit */
504  NtClose(Handle);
505  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC SetRegistryValue: Exiting.\n");
506  return Status;
507 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
Type
Definition: Type.h:6
#define KEY_READ
Definition: nt_native.h:1023
LONG NTSTATUS
Definition: precomp.h:26
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
_In_ HANDLE Handle
Definition: extypes.h:390
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define CHECK_PARAMETER4(x)
Definition: sacdrv.h:62
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751

Referenced by ImposeSacCmdServiceStartTypePolicy().

◆ TearDownGlobalMessageTable()

NTSTATUS NTAPI TearDownGlobalMessageTable ( VOID  )

Definition at line 379 of file util.c.

380 {
381  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Entering.\n");
382 
383  /* Free the table if one existed */
385 
386  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC TearDownGlobalMessageTable: Exiting\n");
387  return STATUS_SUCCESS;
388 }
PSAC_MESSAGE_ENTRY GlobalMessageTable
Definition: util.c:31
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by FreeGlobalData(), and InitializeGlobalData().

◆ TranslateMachineInformationText()

NTSTATUS TranslateMachineInformationText ( IN PWCHAR  Buffer)

Definition at line 1274 of file util.c.

1276 {
1277  return STATUS_NOT_IMPLEMENTED;
1278 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ TranslateMachineInformationXML()

NTSTATUS NTAPI TranslateMachineInformationXML ( IN PWCHAR Buffer,
IN PWCHAR  ExtraData 
)

Definition at line 538 of file util.c.

540 {
542  SIZE_T Size;
543  PWCHAR p;
545 
546  /* Start by believing the world is beautiful */
548 
549  /* First, the header */
550  Size = wcslen(L"<machine-info>\r\n");
551 
552  /* Do we have a machine name? */
554  {
555  /* Go and add it in */
557  Size += wcslen(L"<name>%s</name>\r\n");
558  }
559 
560  /* Do we have a GUID? */
562  {
563  /* Go and add it in */
565  Size += wcslen(L"<guid>%s</guid>\r\n");
566  }
567 
568  /* Do we know the processor? */
570  {
571  /* Go and add it in */
573  Size += wcslen(L"<processor-architecture>%s</processor-architecture>\r\n");
574  }
575 
576  /* Do we have the version? */
578  {
579  /* Go and add it in */
581  Size += wcslen(L"<os-version>%s</os-version>\r\n");
582  }
583 
584  /* Do we have the build? */
586  {
587  /* Go and add it in */
589  Size += wcslen(L"<os-build-number>%s</os-build-number>\r\n");
590  }
591 
592  /* Do we have the product type? */
594  {
595  /* Go and add it in */
597  Size += wcslen(L"<os-product>%s</os-product>\r\n");
598  }
599 
600  /* Do we have a service pack? */
602  {
603  /* Go and add it in */
605  Size += wcslen(L"<os-service-pack>%s</os-service-pack>\r\n");
606  }
607 
608  /* Anything else we need to know? Add it in too */
609  if (ExtraData) Size += wcslen(ExtraData);
610 
611  /* Finally, add the footer */
612  Size += wcslen(L"</machine-info>\r\n");
613 
614  /* Convert to bytes and add a NULL */
615  Size += sizeof(ANSI_NULL);
616  Size *= sizeof(WCHAR);
617 
618  /* Allocate space for the buffer */
620  *Buffer = p;
621  if (!p) return STATUS_NO_MEMORY;
622 
623  wcscpy(p, L"<machine-info>\r\n");
624  p += wcslen(L"<machine-info>\r\n");
625 
627  {
628  p += swprintf(p,
629  L"<name>%s</name>\r\n",
631  }
632 
634  {
635  p += swprintf(p,
636  L"<guid>%s</guid>\r\n",
638  }
639 
641  {
642  p += swprintf(p,
643  L"<processor-architecture>%s</processor-architecture>\r\n",
645  }
646 
648  {
649  p += swprintf(p,
650  L"<os-version>%s</os-version>\r\n",
652  }
653 
655  {
656  p += swprintf(p,
657  L"<os-build-number>%s</os-build-number>\r\n",
659  }
660 
662  {
663  p += swprintf(p,
664  L"<os-product>%s</os-product>\r\n",
666  }
667 
669  {
670  p += swprintf(p,
671  L"<os-service-pack>%s</os-service-pack>\r\n",
673  }
674 
675  if (ExtraData)
676  {
677  wcscpy(p, ExtraData);
678  p += wcslen(ExtraData);
679  }
680 
681  wcscpy(p, L"</machine-info>\r\n");
682  SAC_DBG(SAC_DBG_ENTRY_EXIT, "MachineInformation: %S\n", *Buffer);
683  ASSERT((((ULONG)wcslen(*Buffer) + 1) * sizeof(WCHAR)) <= Size);
684  return Status;
685 }
PWCHAR BuildNumber
Definition: sacdrv.h:497
LONG NTSTATUS
Definition: precomp.h:26
PWCHAR ServicePack
Definition: sacdrv.h:499
uint16_t * PWCHAR
Definition: typedefs.h:54
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
PWCHAR ProcessorArchitecture
Definition: sacdrv.h:495
PWCHAR MachineName
Definition: sacdrv.h:493
#define ANSI_NULL
PWCHAR MajorVersion
Definition: sacdrv.h:496
Definition: bufpool.h:45
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
PSAC_MACHINE_INFO MachineInformation
Definition: util.c:20
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
PWCHAR MachineGuid
Definition: sacdrv.h:494
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
PWCHAR ProductType
Definition: sacdrv.h:498
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
GLfloat GLfloat p
Definition: glext.h:8902
return STATUS_SUCCESS
Definition: btrfs.c:2777
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by InitializeDeviceData(), and RegisterBlueScreenMachineInformation().

◆ UnregisterSacCmdEvent()

NTSTATUS UnregisterSacCmdEvent ( IN PFILE_OBJECT  FileObject)

Definition at line 1301 of file util.c.

1304 {
1305  return STATUS_NOT_IMPLEMENTED;
1306 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ UTF8EncodeAndSend()

NTSTATUS NTAPI UTF8EncodeAndSend ( IN PWCHAR  String)

Definition at line 165 of file util.c.

166 {
167  ULONG ProcessedCount, Utf8Count, i;
169 
170  /* Call the translator routine */
172  wcslen(String),
175  &Utf8Count,
176  &ProcessedCount))
177  {
178  /* Loop every character */
179  for (i = 0; i < Utf8Count; i++)
180  {
181  /* Send it to the terminal */
184  sizeof(Utf8ConversionBuffer[i]),
185  NULL,
186  NULL);
187  if (!NT_SUCCESS(Status)) break;
188  }
189  }
190  else
191  {
192  /* Conversion failed */
194  }
195 
196  /* All done */
197  return Status;
198 }
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR String[]
Definition: stringtable.c:55
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
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
smooth NULL
Definition: ftsmooth.c:416
PCHAR Utf8ConversionBuffer
Definition: util.c:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG Utf8ConversionBufferSize
Definition: util.c:18
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777
BOOLEAN NTAPI SacTranslateUnicodeToUtf8(IN PWCHAR SourceBuffer, IN ULONG SourceBufferLength, OUT PCHAR DestinationBuffer, IN ULONG DestinationBufferSize, OUT PULONG UTF8Count, OUT PULONG ProcessedCount)
Definition: util.c:91
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by InitializeDeviceData().

◆ VerifyEventWaitable()

BOOLEAN NTAPI VerifyEventWaitable ( IN HANDLE  Handle,
OUT PVOID WaitObject,
OUT PVOID ActualWaitObject 
)

Definition at line 1169 of file util.c.

1172 {
1173  PVOID Object;
1174  NTSTATUS Status;
1176 
1177  /* Reference the object */
1180  NULL,
1181  KernelMode,
1182  &Object,
1183  NULL);
1184  *WaitObject = Object;
1185  if (!NT_SUCCESS(Status))
1186  {
1187  SAC_DBG(SAC_DBG_INIT, "SAC VerifyEventWaitable: Unable to reference event object (%lx)\n", Status);
1188  return FALSE;
1189  }
1190 
1191  /* Check if the object itself is NOT being used */
1193  if (ObjectType->TypeInfo.UseDefaultObject == FALSE)
1194  {
1195  /* Get the actual object that's being used for the wait */
1196  *ActualWaitObject = (PVOID)((ULONG_PTR)Object +
1197  (ULONG_PTR)ObjectType->DefaultObject);
1198  return TRUE;
1199  }
1200 
1201  /* Drop the reference we took */
1202  SAC_DBG(SAC_DBG_INIT, "SAC VerifyEventWaitable: event object not waitable!\n");
1203  ObDereferenceObject(*WaitObject);
1204  return FALSE;
1205 }
ObjectType
Definition: metafile.c:80
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define OBJECT_TO_OBJECT_HEADER(o)
Definition: obtypes.h:111
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
_In_ HANDLE Handle
Definition: extypes.h:390
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static IUnknown Object
Definition: main.c:512
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
#define ULONG_PTR
Definition: config.h:101

Variable Documentation

◆ GlobalMessageTable

PSAC_MESSAGE_ENTRY GlobalMessageTable

Definition at line 31 of file util.c.

Referenced by GetMessage(), PreloadGlobalMessageTable(), and TearDownGlobalMessageTable().

◆ GlobalMessageTableCount

ULONG GlobalMessageTableCount

Definition at line 32 of file util.c.

Referenced by GetMessage(), and PreloadGlobalMessageTable().

◆ HaveUserModeServiceCmdEventInfo

BOOLEAN HaveUserModeServiceCmdEventInfo

Definition at line 29 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ MachineInformation

PSAC_MACHINE_INFO MachineInformation

◆ RequestSacCmdEventObjectBody

PVOID RequestSacCmdEventObjectBody

Definition at line 22 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ RequestSacCmdEventWaitObjectBody

PKEVENT RequestSacCmdEventWaitObjectBody

Definition at line 23 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ RequestSacCmdFailureEventObjectBody

PVOID RequestSacCmdFailureEventObjectBody

Definition at line 26 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ RequestSacCmdFailureEventWaitObjectBody

PKEVENT RequestSacCmdFailureEventWaitObjectBody

Definition at line 27 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ RequestSacCmdSuccessEventObjectBody

PVOID RequestSacCmdSuccessEventObjectBody

Definition at line 24 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ RequestSacCmdSuccessEventWaitObjectBody

PKEVENT RequestSacCmdSuccessEventWaitObjectBody

Definition at line 25 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ SerialPortBuffer

PCHAR SerialPortBuffer

Definition at line 35 of file util.c.

Referenced by FreeGlobalData(), InitializeGlobalData(), SerialBufferGetChar(), and TimerDpcRoutine().

◆ SerialPortConsumerIndex

LONG SerialPortConsumerIndex

Definition at line 34 of file util.c.

Referenced by SerialBufferGetChar().

◆ SerialPortProducerIndex

LONG SerialPortProducerIndex

Definition at line 34 of file util.c.

Referenced by SerialBufferGetChar(), and TimerDpcRoutine().

◆ ServiceProcessFileObject

PFILE_OBJECT ServiceProcessFileObject

Definition at line 28 of file util.c.

Referenced by InitializeCmdEventInfo().

◆ Utf8ConversionBuffer

PCHAR Utf8ConversionBuffer

◆ Utf8ConversionBufferSize

ULONG Utf8ConversionBufferSize = PAGE_SIZE