ReactOS 0.4.15-dev-5836-g942b022
sacdrv.h File Reference
#include <ntifs.h>
#include <stdio.h>
#include <ntoskrnl/include/internal/hdl.h>
#include <sacmsg.h>
Include dependency graph for sacdrv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SAC_MEMORY_ENTRY
 
struct  _SAC_MEMORY_LIST
 
struct  _SAC_MESSAGE_ENTRY
 
struct  _SAC_CHANNEL_ID
 
struct  _SAC_CHANNEL_LOCK
 
struct  _SAC_CELL_DATA
 
struct  _SAC_VTUTF8_SCREEN
 
struct  _SAC_STATIC_ESCAPE_STRING
 
struct  _SAC_CHANNEL
 
struct  _SAC_CHANNEL_ATTRIBUTES
 
struct  _SAC_MACHINE_INFO
 
struct  _SAC_DEVICE_EXTENSION
 

Macros

#define SacAllocatePool(Length, Tag)    MyAllocatePool(Length, Tag, __FILE__, __LINE__)
 
#define SacFreePool(Pointer)    MyFreePool((PVOID*)(&Pointer))
 
#define SAC_DBG_ENTRY_EXIT   0x01
 
#define SAC_DBG_UTIL   0x02
 
#define SAC_DBG_INIT   0x04
 
#define SAC_DBG_MM   0x1000
 
#define SAC_DBG_MACHINE   0x2000
 
#define SAC_DBG(x, ...)
 
#define CHECK_PARAMETER_WITH_STATUS(Condition, Status)
 
#define CHECK_PARAMETER(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER)
 
#define CHECK_PARAMETER1(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_1)
 
#define CHECK_PARAMETER2(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_2)
 
#define CHECK_PARAMETER3(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_3)
 
#define CHECK_PARAMETER4(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_INVALID_PARAMETER_4)
 
#define CHECK_ALLOCATION(x)    CHECK_PARAMETER_WITH_STATUS(x, STATUS_NO_MEMORY)
 
#define ChannelInitializeEvent(Channel, Attributes, x)
 
#define ChannelUninitializeEvent(Channel, x, f)
 
#define ChannelSetEvent(Channel, x)
 
#define ChannelClearEvent(Channel, x)
 
#define GENERIC_TAG   '?pcR'
 
#define ALLOC_BLOCK_TAG   'ApcR'
 
#define INITIAL_BLOCK_TAG   'IpcR'
 
#define SECURITY_BLOCK_TAG   'SpcR'
 
#define FREE_POOL_TAG   'FpcR'
 
#define GLOBAL_BLOCK_TAG   'GpcR'
 
#define CHANNEL_BLOCK_TAG   'CpcR'
 
#define LOCAL_MEMORY_SIGNATURE   'SSEL'
 
#define GLOBAL_MEMORY_SIGNATURE   'DAEH'
 
#define SAC_MEMORY_LIST_SIZE   (1 * 1024 * 1024)
 
#define SAC_OBUFFER_SIZE   (2 * 1024)
 
#define SAC_CHANNEL_NAME_SIZE   64
 
#define SAC_CHANNEL_DESCRIPTION_SIZE   256
 
#define SAC_MAX_CHANNELS   10
 
#define SAC_SERIAL_PORT_BUFFER_SIZE   1024
 
#define SAC_MAX_MESSAGES   200
 
#define SAC_VTUTF8_COL_WIDTH   80
 
#define SAC_VTUTF8_COL_HEIGHT   25
 
#define SAC_VTUTF8_ROW_HEIGHT   24
 
#define MAX_UTF8_ENCODE_BLOCK_LENGTH   (Utf8ConversionBufferSize / 3 - 1)
 
#define SAC_VTUTF8_OBUFFER_SIZE   0x2D00
 
#define SAC_VTUTF8_IBUFFER_SIZE   0x2000
 
#define SAC_RAW_OBUFFER_SIZE   0x2000
 
#define SAC_RAW_IBUFFER_SIZE   0x2000
 
#define SAC_CHANNEL_FLAG_INTERNAL   0x1
 
#define SAC_CHANNEL_FLAG_CLOSE_EVENT   0x2
 
#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT   0x4
 
#define SAC_CHANNEL_FLAG_LOCK_EVENT   0x8
 
#define SAC_CHANNEL_FLAG_REDRAW_EVENT   0x10
 
#define SAC_CHANNEL_FLAG_APPLICATION   0x20
 
#define SAC_CELL_FLAG_BLINK   1
 
#define SAC_CELL_FLAG_BOLD   2
 
#define SAC_CELL_FLAG_INVERTED   4
 
#define ChannelLockCreates()   SacAcquireLock(&ChannelCreateLock);
 
#define ChannelUnlockCreates()   SacReleaseLock(&ChannelCreateLock);
 
#define ChannelLockOBuffer(x)   SacAcquireLock(&x->ChannelOBufferLock);
 
#define ChannelUnlockOBuffer(x)   SacReleaseLock(&x->ChannelOBufferLock);
 
#define ChannelLockIBuffer(x)   SacAcquireLock(&x->ChannelIBufferLock);
 
#define ChannelUnlockIBuffer(x)   SacReleaseLock(&x->ChannelIBufferLock);
 
#define ChannelLockAttributes(x)   SacAcquireLock(&x->ChannelAttributeLock);
 
#define ChannelUnlockAttributes(x)   SacReleaseLock(&x->ChannelAttributeLock);
 
#define ChannelSlotLock(x)   SacAcquireLock(&ChannelSlotLock[x]);
 
#define ChannelSlotUnlock(x)   SacReleaseLock(&ChannelSlotLock[x]);
 
#define VT_ANSI_ESCAPE   L'\x1B'
 
#define VT_ANSI_COMMAND   L'['
 
#define VT_ANSI_CURSOR_UP_CHAR   L'A'
 
#define VT_ANSI_CURSOR_UP   L"[A"
 
#define VT_ANSI_CURSOR_DOWN_CHAR   L'B'
 
#define VT_ANSI_CURSOR_DOWN   L"[B"
 
#define VT_ANSI_CURSOR_RIGHT_CHAR   L'C'
 
#define VT_ANSI_CURSOR_RIGHT   L"[C"
 
#define VT_ANSI_CURSOR_LEFT_CHAR   L'D'
 
#define VT_ANSI_CURSOR_LEFT   L"[D"
 
#define VT_ANSI_ERASE_LINE_CHAR   L'K'
 
#define VT_ANSI_ERASE_END_LINE   L"[K"
 
#define VT_ANSI_ERASE_START_LINE   L"[1K"
 
#define VT_ANSI_ERASE_ENTIRE_LINE   L"[2K"
 
#define VT_ANSI_ERASE_SCREEN_CHAR   L'J'
 
#define VT_ANSI_ERASE_DOWN_SCREEN   L"[J"
 
#define VT_ANSI_ERASE_UP_SCREEN   L"[1J"
 
#define VT_ANSI_ERASE_ENTIRE_SCREEN   L"[2J"
 
#define VT_ANSI_BACKTAB_CHAR   L'Z'
 
#define VT_220_BACKTAB   L"[0Z"
 
#define VT_ANSI_SET_ATTRIBUTE_CHAR   L'm'
 
#define VT_ANSI_SEPARATOR_CHAR   L';'
 
#define VT_ANSI_HVP_CURSOR_CHAR   L'f'
 
#define VT_ANSI_CUP_CURSOR_CHAR   L'H'
 
#define VT_ANSI_SCROLL_CHAR   L'r'
 

Typedefs

typedef struct _SAC_MEMORY_ENTRY SAC_MEMORY_ENTRY
 
typedef struct _SAC_MEMORY_ENTRYPSAC_MEMORY_ENTRY
 
typedef struct _SAC_MEMORY_LIST SAC_MEMORY_LIST
 
typedef struct _SAC_MEMORY_LISTPSAC_MEMORY_LIST
 
typedef struct _SAC_MESSAGE_ENTRY SAC_MESSAGE_ENTRY
 
typedef struct _SAC_MESSAGE_ENTRYPSAC_MESSAGE_ENTRY
 
typedef enum _SAC_ANSI_COMMANDS SAC_ANSI_COMMANDS
 
typedef enum _SAC_ANSI_DISPATCH SAC_ANSI_DISPATCH
 
typedef enum _SAC_POST_COMMANDS SAC_POST_COMMANDS
 
typedef enum _SAC_CHANNEL_TYPE SAC_CHANNEL_TYPE
 
typedef enum _SAC_CHANNEL_STATUS SAC_CHANNEL_STATUS
 
typedef enum _SAC_CHANNEL_STATUSPSAC_CHANNEL_STATUS
 
typedef struct _SAC_CHANNEL_ID SAC_CHANNEL_ID
 
typedef struct _SAC_CHANNEL_IDPSAC_CHANNEL_ID
 
typedef struct _SAC_CHANNEL_LOCK SAC_CHANNEL_LOCK
 
typedef struct _SAC_CHANNEL_LOCKPSAC_CHANNEL_LOCK
 
typedef struct _SAC_CELL_DATA SAC_CELL_DATA
 
typedef struct _SAC_CELL_DATAPSAC_CELL_DATA
 
typedef struct _SAC_VTUTF8_SCREEN SAC_VTUTF8_SCREEN
 
typedef struct _SAC_VTUTF8_SCREENPSAC_VTUTF8_SCREEN
 
typedef struct _SAC_STATIC_ESCAPE_STRING SAC_STATIC_ESCAPE_STRING
 
typedef struct _SAC_STATIC_ESCAPE_STRINGPSAC_STATIC_ESCAPE_STRING
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_CREATE) (IN struct _SAC_CHANNEL *Channel)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_DESTROY) (IN struct _SAC_CHANNEL *Channel)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_OREAD) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_OECHO) (IN struct _SAC_CHANNEL *Channel, IN PCHAR String, IN ULONG Length)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_OFLUSH) (IN struct _SAC_CHANNEL *Channel)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_OWRITE) (IN struct _SAC_CHANNEL *Channel, IN PCHAR String, IN ULONG Length)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_IREAD) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_IBUFFER_FULL) (IN struct _SAC_CHANNEL *Channel, OUT PBOOLEAN BufferStatus)
 
typedef ULONG(NTAPIPSAC_CHANNEL_IBUFFER_LENGTH) (IN struct _SAC_CHANNEL *Channel)
 
typedef WCHAR(NTAPIPSAC_CHANNEL_IREAD_LAST) (IN struct _SAC_CHANNEL *Channel)
 
typedef NTSTATUS(NTAPIPSAC_CHANNEL_IWRITE) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
typedef struct _SAC_CHANNEL SAC_CHANNEL
 
typedef struct _SAC_CHANNELPSAC_CHANNEL
 
typedef struct _SAC_CHANNEL_ATTRIBUTES SAC_CHANNEL_ATTRIBUTES
 
typedef struct _SAC_CHANNEL_ATTRIBUTESPSAC_CHANNEL_ATTRIBUTES
 
typedef struct _SAC_MACHINE_INFO SAC_MACHINE_INFO
 
typedef struct _SAC_MACHINE_INFOPSAC_MACHINE_INFO
 
typedef struct _SAC_DEVICE_EXTENSION SAC_DEVICE_EXTENSION
 
typedef struct _SAC_DEVICE_EXTENSIONPSAC_DEVICE_EXTENSION
 
typedef enum _VT_ANSI_ATTRIBUTES VT_ANSI_ATTRIBUTES
 

Enumerations

enum  _SAC_ANSI_COMMANDS {
  SacCursorUp , SacCursorDown , SacCursorRight , SacCursorLeft ,
  SacFontNormal , SacFontBlink , SacFontBlinkOff , SacFontBold ,
  SacFontBoldOff , SacFontInverse , SacFontInverseOff , SacBackTab ,
  SacEraseEndOfLine , SacEraseStartOfLine , SacEraseLine , SacEraseEndOfScreen ,
  SacEraseStartOfScreen , SacEraseScreen , SacSetCursorPosition , SacSetScrollRegion ,
  SacSetColors , SacSetBackgroundColor , SacSetFontColor , SacSetColorsAndAttributes
}
 
enum  _SAC_ANSI_DISPATCH {
  SacAnsiClearScreen , SacAnsiClearEndOfScreen , SacAnsiClearEndOfLine , SacAnsiSetColors ,
  SacAnsiSetPosition , SacAnsiClearAttributes , SacAnsiSetInverseAttribute , SacAnsiClearInverseAttribute ,
  SacAnsiSetBlinkAttribute , SacAnsiClearBlinkAttribute , SacAnsiSetBoldAttribute , SacAnsiClearBoldAttribute
}
 
enum  _SAC_POST_COMMANDS { Nothing , Shutdown , Close , Restart }
 
enum  _SAC_CHANNEL_TYPE { VtUtf8 , Cmd , Raw }
 
enum  _SAC_CHANNEL_STATUS { Inactive , Active }
 
enum  _VT_ANSI_ATTRIBUTES {
  Normal , Bold , Faint , Italic ,
  Underline , SlowBlink , FastBlink , Inverse ,
  Conceal , Strikethrough , PrimaryFont , AlternateFont1 ,
  AlternateFont2 , AlternateFont3 , Alternatefont4 , AlternateFont5 ,
  AlternateFont6 , AlternateFont7 , AlternateFont8 , AlternateFont9 ,
  Fraktur , DoubleUnderline , BoldOff , ItalicOff ,
  UnderlineOff , BlinkOff , Reserved , InverseOff ,
  ConcealOff , StrikethroughOff , SetColorStart , SetColorBlack = SetColorStart ,
  SetColorRed , SetColorGreen , SetColorYellow , SetColorBlue ,
  SetcolorMAgent , SetColorCyan , SetColorWhite , SetColorMax = SetColorWhite ,
  SetColor256 , SeTextColorDefault , SetBackColorStart , SetBackColorBlack = SetBackColorStart ,
  SetBackColorRed , SetBackColorGreen , SetBackColorYellow , SetBackColorBlue ,
  SetBackcolorMAgent , SetBackColorCyan , SetBackColorWhite , SetBackColorMax = SetBackColorWhite ,
  SetBackColor256 , SetBackColorDefault , Reserved1 , Framed ,
  Encircled , Overlined , FramedOff , OverlinedOff ,
  Reserved2 , Reserved3 , Reserved4 , Reserved5
}
 

Functions

 C_ASSERT (sizeof(SAC_CELL_DATA)==6)
 
NTSTATUS NTAPI Dispatch (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DispatchDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DispatchShutdownControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI UnloadHandler (IN PDRIVER_OBJECT DriverObject)
 
VOID NTAPI FreeGlobalData (VOID)
 
VOID NTAPI FreeDeviceData (IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI InitializeDeviceData (IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI InitializeGlobalData (IN PUNICODE_STRING RegistryPath, IN PDRIVER_OBJECT DriverObject)
 
BOOLEAN NTAPI InitializeMemoryManagement (VOID)
 
VOID NTAPI FreeMemoryManagement (VOID)
 
VOID NTAPI InitializeCmdEventInfo (VOID)
 
VOID NTAPI InitializeMachineInformation (VOID)
 
NTSTATUS NTAPI PreloadGlobalMessageTable (IN PVOID ImageBase)
 
NTSTATUS NTAPI TearDownGlobalMessageTable (VOID)
 
NTSTATUS NTAPI GetCommandConsoleLaunchingPermission (OUT PBOOLEAN Permission)
 
NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy (VOID)
 
NTSTATUS NTAPI RegisterBlueScreenMachineInformation (VOID)
 
VOID NTAPI FreeMachineInformation (VOID)
 
VOID NTAPI TimerDpcRoutine (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
PVOID NTAPI MyAllocatePool (IN SIZE_T PoolSize, IN ULONG Tag, IN PCHAR File, IN ULONG Line)
 
VOID NTAPI MyFreePool (IN PVOID *Block)
 
NTSTATUS NTAPI ConMgrInitialize (VOID)
 
VOID NTAPI ConMgrWorkerProcessEvents (IN PSAC_DEVICE_EXTENSION DeviceExtension)
 
NTSTATUS NTAPI ConMgrShutdown (VOID)
 
BOOLEAN NTAPI ConMgrSimpleEventMessage (IN ULONG MessageIndex, IN BOOLEAN LockHeld)
 
BOOLEAN NTAPI SacPutSimpleMessage (IN ULONG MessageIndex)
 
VOID NTAPI SacPutString (IN PWCHAR String)
 
NTSTATUS NTAPI ConMgrWriteData (IN PSAC_CHANNEL Channel, IN PVOID Buffer, IN ULONG BufferLength)
 
NTSTATUS NTAPI ConMgrFlushData (IN PSAC_CHANNEL Channel)
 
BOOLEAN NTAPI ConMgrIsWriteEnabled (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ConMgrHandleEvent (IN ULONG EventCode, IN PSAC_CHANNEL Channel, OUT PVOID Data)
 
NTSTATUS NTAPI ChanMgrInitialize (VOID)
 
NTSTATUS NTAPI ChanMgrShutdown (VOID)
 
NTSTATUS NTAPI ChanMgrCreateChannel (OUT PSAC_CHANNEL *Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes)
 
NTSTATUS NTAPI ChanMgrGetByHandle (IN SAC_CHANNEL_ID ChannelId, OUT PSAC_CHANNEL *TargetChannel)
 
NTSTATUS NTAPI ChanMgrReleaseChannel (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChanMgrGetNextActiveChannel (IN PSAC_CHANNEL CurrentChannel, IN PULONG TargetIndex, OUT PSAC_CHANNEL *TargetChannel)
 
NTSTATUS NTAPI ChanMgrCloseChannel (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelClose (IN PSAC_CHANNEL Channel)
 
BOOLEAN NTAPI ChannelIsEqual (IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ID ChannelId)
 
NTSTATUS NTAPI ChannelOWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
NTSTATUS NTAPI ChannelOFlush (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelSetRedrawEvent (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelClearRedrawEvent (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelHasRedrawEvent (IN PSAC_CHANNEL Channel, OUT PBOOLEAN Present)
 
BOOLEAN NTAPI ChannelIsActive (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelGetName (IN PSAC_CHANNEL Channel, OUT PWCHAR *Name)
 
NTSTATUS NTAPI ChannelCreate (IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes, IN SAC_CHANNEL_ID ChannelId)
 
NTSTATUS NTAPI ChannelDestroy (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelIWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
WCHAR NTAPI ChannelIReadLast (IN PSAC_CHANNEL Channel)
 
ULONG NTAPI ChannelIBufferLength (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI ChannelIRead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN OUT PULONG ResultBufferSize)
 
NTSTATUS NTAPI RawChannelCreate (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI RawChannelDestroy (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI RawChannelORead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)
 
NTSTATUS NTAPI RawChannelOEcho (IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
 
NTSTATUS NTAPI RawChannelOFlush (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI RawChannelOWrite (IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
 
NTSTATUS NTAPI RawChannelIRead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)
 
NTSTATUS NTAPI RawChannelIBufferIsFull (IN PSAC_CHANNEL Channel, OUT PBOOLEAN BufferStatus)
 
ULONG NTAPI RawChannelIBufferLength (IN PSAC_CHANNEL Channel)
 
WCHAR NTAPI RawChannelIReadLast (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI RawChannelIWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
NTSTATUS NTAPI VTUTF8ChannelCreate (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI VTUTF8ChannelDestroy (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI VTUTF8ChannelORead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)
 
NTSTATUS NTAPI VTUTF8ChannelOEcho (IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
 
NTSTATUS NTAPI VTUTF8ChannelOFlush (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI VTUTF8ChannelOWrite (IN PSAC_CHANNEL Channel, IN PCHAR String, IN ULONG Length)
 
NTSTATUS NTAPI VTUTF8ChannelIRead (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)
 
NTSTATUS NTAPI VTUTF8ChannelIBufferIsFull (IN PSAC_CHANNEL Channel, OUT PBOOLEAN BufferStatus)
 
ULONG NTAPI VTUTF8ChannelIBufferLength (IN PSAC_CHANNEL Channel)
 
WCHAR NTAPI VTUTF8ChannelIReadLast (IN PSAC_CHANNEL Channel)
 
NTSTATUS NTAPI VTUTF8ChannelIWrite (IN PSAC_CHANNEL Channel, IN PCHAR Buffer, IN ULONG BufferSize)
 
BOOLEAN NTAPI SacTranslateUtf8ToUnicode (IN CHAR Utf8Char, IN PCHAR Utf8Buffer, OUT PWCHAR Utf8Value)
 
ULONG NTAPI GetMessageLineCount (IN ULONG MessageIndex)
 
NTSTATUS NTAPI SerialBufferGetChar (OUT PCHAR Char)
 
NTSTATUS NTAPI UTF8EncodeAndSend (IN PWCHAR String)
 
NTSTATUS NTAPI TranslateMachineInformationXML (IN PWCHAR *Buffer, IN PWCHAR ExtraData)
 
PWCHAR NTAPI GetMessage (IN ULONG MessageIndex)
 
BOOLEAN NTAPI VerifyEventWaitable (IN HANDLE Handle, OUT PVOID *WaitObject, OUT PVOID *ActualWaitObject)
 
BOOLEAN NTAPI SacTranslateUnicodeToUtf8 (IN PWCHAR SourceBuffer, IN ULONG SourceBufferLength, OUT PCHAR DestinationBuffer, IN ULONG DestinationBufferSize, OUT PULONG UTF8Count, OUT PULONG ProcessedCount)
 
VOID NTAPI DoRebootCommand (IN BOOLEAN Reboot)
 
VOID NTAPI DoFullInfoCommand (VOID)
 
VOID NTAPI DoPagingCommand (VOID)
 
VOID NTAPI DoSetTimeCommand (IN PCHAR InputTime)
 
VOID NTAPI DoKillCommand (IN PCHAR KillString)
 
VOID NTAPI DoLowerPriorityCommand (IN PCHAR PrioString)
 
VOID NTAPI DoRaisePriorityCommand (IN PCHAR PrioString)
 
VOID NTAPI DoLimitMemoryCommand (IN PCHAR LimitString)
 
VOID NTAPI DoCrashCommand (VOID)
 
VOID NTAPI DoMachineInformationCommand (VOID)
 
VOID NTAPI DoChannelCommand (IN PCHAR ChannelString)
 
VOID NTAPI DoCmdCommand (IN PCHAR InputString)
 
VOID NTAPI DoLockCommand (VOID)
 
VOID NTAPI DoHelpCommand (VOID)
 
VOID NTAPI DoGetNetInfo (IN BOOLEAN DoPrint)
 
VOID NTAPI DoSetIpAddressCommand (IN PCHAR IpString)
 
VOID NTAPI DoTlistCommand (VOID)
 
FORCEINLINE VOID SacInitializeLock (IN PSAC_CHANNEL_LOCK Lock)
 
FORCEINLINE VOID SacAcquireLock (IN PSAC_CHANNEL_LOCK Lock)
 
FORCEINLINE VOID SacReleaseLock (IN PSAC_CHANNEL_LOCK Lock)
 
FORCEINLINE VOID SacAssertMutexLockHeld (VOID)
 
FORCEINLINE VOID SacInitializeMutexLock (VOID)
 
FORCEINLINE VOID SacAcquireMutexLock (VOID)
 
FORCEINLINE VOID SacReleaseMutexLock (VOID)
 
FORCEINLINE ULONG ChannelGetFlags (IN PSAC_CHANNEL Channel)
 
FORCEINLINE LONG ChannelGetIndex (IN PSAC_CHANNEL Channel)
 
FORCEINLINE BOOLEAN ChannelHasNewIBufferData (IN PSAC_CHANNEL Channel)
 

Variables

ULONG SACDebug
 
PSAC_MESSAGE_ENTRY GlobalMessageTable
 
KMUTEX CurrentChannelLock
 
LONG CurrentChannelRefCount
 
PCHAR SerialPortBuffer
 
LONG SerialPortConsumerIndex
 
LONG SerialPortProducerIndex
 
PCHAR Utf8ConversionBuffer
 
BOOLEAN GlobalPagingNeeded
 
BOOLEAN GlobalDoThreads
 
ULONG Utf8ConversionBufferSize
 
BOOLEAN CommandConsoleLaunchingEnabled
 

Macro Definition Documentation

◆ ALLOC_BLOCK_TAG

#define ALLOC_BLOCK_TAG   'ApcR'

Definition at line 138 of file sacdrv.h.

◆ CHANNEL_BLOCK_TAG

#define CHANNEL_BLOCK_TAG   'CpcR'

Definition at line 143 of file sacdrv.h.

◆ ChannelClearEvent

#define ChannelClearEvent (   Channel,
  x 
)
Value:
{ \
ASSERT(Channel->x); \
ASSERT(Channel->x##ObjectBody); \
ASSERT(Channel->x##WaitObjectBody); \
if (Channel->x##WaitObjectBody) \
{ \
KeClearEvent(Channel->x##WaitObjectBody); \
} \
else \
{ \
} \
}
Status
Definition: gdiplustypes.h:25
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Definition at line 114 of file sacdrv.h.

◆ ChannelInitializeEvent

#define ChannelInitializeEvent (   Channel,
  Attributes,
  x 
)
Value:
{ \
PVOID Object, WaitObject; \
if (Attributes->x) \
{ \
if (!VerifyEventWaitable(Attributes->x, &Object, &WaitObject)) \
{ \
goto FailChannel; \
} \
Channel->x = Attributes->x; \
Channel->x##ObjectBody = Object; \
Channel->x##WaitObjectBody = WaitObject; \
} \
}
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
BOOLEAN NTAPI VerifyEventWaitable(IN HANDLE Handle, OUT PVOID *WaitObject, OUT PVOID *ActualWaitObject)
Definition: util.c:1172
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Definition at line 70 of file sacdrv.h.

◆ ChannelLockAttributes

#define ChannelLockAttributes (   x)    SacAcquireLock(&x->ChannelAttributeLock);

Definition at line 1336 of file sacdrv.h.

◆ ChannelLockCreates

#define ChannelLockCreates ( )    SacAcquireLock(&ChannelCreateLock);

Definition at line 1330 of file sacdrv.h.

◆ ChannelLockIBuffer

#define ChannelLockIBuffer (   x)    SacAcquireLock(&x->ChannelIBufferLock);

Definition at line 1334 of file sacdrv.h.

◆ ChannelLockOBuffer

#define ChannelLockOBuffer (   x)    SacAcquireLock(&x->ChannelOBufferLock);

Definition at line 1332 of file sacdrv.h.

◆ ChannelSetEvent

#define ChannelSetEvent (   Channel,
  x 
)
Value:
{ \
ASSERT(Channel->x); \
ASSERT(Channel->x##ObjectBody); \
ASSERT(Channel->x##WaitObjectBody); \
if (Channel->x##WaitObjectBody) \
{ \
KeSetEvent(Channel->x##WaitObjectBody, EVENT_INCREMENT, FALSE); \
} \
else \
{ \
} \
}
#define FALSE
Definition: types.h:117
#define EVENT_INCREMENT
Definition: iotypes.h:597

Definition at line 99 of file sacdrv.h.

◆ ChannelSlotLock

#define ChannelSlotLock (   x)    SacAcquireLock(&ChannelSlotLock[x]);

Definition at line 1338 of file sacdrv.h.

◆ ChannelSlotUnlock

#define ChannelSlotUnlock (   x)    SacReleaseLock(&ChannelSlotLock[x]);

Definition at line 1339 of file sacdrv.h.

◆ ChannelUninitializeEvent

#define ChannelUninitializeEvent (   Channel,
  x,
  f 
)
Value:
{ \
ASSERT(ChannelGetFlags(Channel) & (f)); \
ASSERT(Channel->x##ObjectBody); \
ASSERT(Channel->x##WaitObjectBody); \
if (Channel->x##ObjectBody) \
{ \
ObDereferenceObject(Channel->x##ObjectBody); \
Channel->Flags &= ~(f); \
Channel->x = NULL; \
Channel->x##ObjectBody = NULL; \
Channel->x##WaitObjectBody = NULL; \
} \
}
#define NULL
Definition: types.h:112
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
FORCEINLINE ULONG ChannelGetFlags(IN PSAC_CHANNEL Channel)
Definition: sacdrv.h:1346

Definition at line 85 of file sacdrv.h.

◆ ChannelUnlockAttributes

#define ChannelUnlockAttributes (   x)    SacReleaseLock(&x->ChannelAttributeLock);

Definition at line 1337 of file sacdrv.h.

◆ ChannelUnlockCreates

#define ChannelUnlockCreates ( )    SacReleaseLock(&ChannelCreateLock);

Definition at line 1331 of file sacdrv.h.

◆ ChannelUnlockIBuffer

#define ChannelUnlockIBuffer (   x)    SacReleaseLock(&x->ChannelIBufferLock);

Definition at line 1335 of file sacdrv.h.

◆ ChannelUnlockOBuffer

#define ChannelUnlockOBuffer (   x)    SacReleaseLock(&x->ChannelOBufferLock);

Definition at line 1333 of file sacdrv.h.

◆ CHECK_ALLOCATION

#define CHECK_ALLOCATION (   x)     CHECK_PARAMETER_WITH_STATUS(x, STATUS_NO_MEMORY)

Definition at line 64 of file sacdrv.h.

◆ CHECK_PARAMETER

Definition at line 54 of file sacdrv.h.

◆ CHECK_PARAMETER1

Definition at line 56 of file sacdrv.h.

◆ CHECK_PARAMETER2

Definition at line 58 of file sacdrv.h.

◆ CHECK_PARAMETER3

Definition at line 60 of file sacdrv.h.

◆ CHECK_PARAMETER4

Definition at line 62 of file sacdrv.h.

◆ CHECK_PARAMETER_WITH_STATUS

#define CHECK_PARAMETER_WITH_STATUS (   Condition,
  Status 
)
Value:
{ \
{ \
return Status; \
} \
}
IN ULONG IN UCHAR Condition
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3287

Definition at line 47 of file sacdrv.h.

◆ FREE_POOL_TAG

#define FREE_POOL_TAG   'FpcR'

Definition at line 141 of file sacdrv.h.

◆ GENERIC_TAG

#define GENERIC_TAG   '?pcR'

Definition at line 137 of file sacdrv.h.

◆ GLOBAL_BLOCK_TAG

#define GLOBAL_BLOCK_TAG   'GpcR'

Definition at line 142 of file sacdrv.h.

◆ GLOBAL_MEMORY_SIGNATURE

#define GLOBAL_MEMORY_SIGNATURE   'DAEH'

Definition at line 145 of file sacdrv.h.

◆ INITIAL_BLOCK_TAG

#define INITIAL_BLOCK_TAG   'IpcR'

Definition at line 139 of file sacdrv.h.

◆ LOCAL_MEMORY_SIGNATURE

#define LOCAL_MEMORY_SIGNATURE   'SSEL'

Definition at line 144 of file sacdrv.h.

◆ MAX_UTF8_ENCODE_BLOCK_LENGTH

#define MAX_UTF8_ENCODE_BLOCK_LENGTH   (Utf8ConversionBufferSize / 3 - 1)

Definition at line 160 of file sacdrv.h.

◆ SAC_CELL_FLAG_BLINK

#define SAC_CELL_FLAG_BLINK   1

Definition at line 179 of file sacdrv.h.

◆ SAC_CELL_FLAG_BOLD

#define SAC_CELL_FLAG_BOLD   2

Definition at line 180 of file sacdrv.h.

◆ SAC_CELL_FLAG_INVERTED

#define SAC_CELL_FLAG_INVERTED   4

Definition at line 181 of file sacdrv.h.

◆ SAC_CHANNEL_DESCRIPTION_SIZE

#define SAC_CHANNEL_DESCRIPTION_SIZE   256

Definition at line 153 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_APPLICATION

#define SAC_CHANNEL_FLAG_APPLICATION   0x20

Definition at line 174 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_CLOSE_EVENT

#define SAC_CHANNEL_FLAG_CLOSE_EVENT   0x2

Definition at line 170 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT

#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT   0x4

Definition at line 171 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_INTERNAL

#define SAC_CHANNEL_FLAG_INTERNAL   0x1

Definition at line 169 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_LOCK_EVENT

#define SAC_CHANNEL_FLAG_LOCK_EVENT   0x8

Definition at line 172 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_REDRAW_EVENT

#define SAC_CHANNEL_FLAG_REDRAW_EVENT   0x10

Definition at line 173 of file sacdrv.h.

◆ SAC_CHANNEL_NAME_SIZE

#define SAC_CHANNEL_NAME_SIZE   64

Definition at line 152 of file sacdrv.h.

◆ SAC_DBG

#define SAC_DBG (   x,
  ... 
)
Value:
if (SACDebug & x) \
{ \
DbgPrint("SAC %s: ", __FUNCTION__); \
DbgPrint(__VA_ARGS__); \
}
#define __FUNCTION__
Definition: types.h:112
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
ULONG SACDebug
Definition: data.c:15

Definition at line 37 of file sacdrv.h.

◆ SAC_DBG_ENTRY_EXIT

#define SAC_DBG_ENTRY_EXIT   0x01

Definition at line 32 of file sacdrv.h.

◆ SAC_DBG_INIT

#define SAC_DBG_INIT   0x04

Definition at line 34 of file sacdrv.h.

◆ SAC_DBG_MACHINE

#define SAC_DBG_MACHINE   0x2000

Definition at line 36 of file sacdrv.h.

◆ SAC_DBG_MM

#define SAC_DBG_MM   0x1000

Definition at line 35 of file sacdrv.h.

◆ SAC_DBG_UTIL

#define SAC_DBG_UTIL   0x02

Definition at line 33 of file sacdrv.h.

◆ SAC_MAX_CHANNELS

#define SAC_MAX_CHANNELS   10

Definition at line 154 of file sacdrv.h.

◆ SAC_MAX_MESSAGES

#define SAC_MAX_MESSAGES   200

Definition at line 156 of file sacdrv.h.

◆ SAC_MEMORY_LIST_SIZE

#define SAC_MEMORY_LIST_SIZE   (1 * 1024 * 1024)

Definition at line 150 of file sacdrv.h.

◆ SAC_OBUFFER_SIZE

#define SAC_OBUFFER_SIZE   (2 * 1024)

Definition at line 151 of file sacdrv.h.

◆ SAC_RAW_IBUFFER_SIZE

#define SAC_RAW_IBUFFER_SIZE   0x2000

Definition at line 164 of file sacdrv.h.

◆ SAC_RAW_OBUFFER_SIZE

#define SAC_RAW_OBUFFER_SIZE   0x2000

Definition at line 163 of file sacdrv.h.

◆ SAC_SERIAL_PORT_BUFFER_SIZE

#define SAC_SERIAL_PORT_BUFFER_SIZE   1024

Definition at line 155 of file sacdrv.h.

◆ SAC_VTUTF8_COL_HEIGHT

#define SAC_VTUTF8_COL_HEIGHT   25

Definition at line 158 of file sacdrv.h.

◆ SAC_VTUTF8_COL_WIDTH

#define SAC_VTUTF8_COL_WIDTH   80

Definition at line 157 of file sacdrv.h.

◆ SAC_VTUTF8_IBUFFER_SIZE

#define SAC_VTUTF8_IBUFFER_SIZE   0x2000

Definition at line 162 of file sacdrv.h.

◆ SAC_VTUTF8_OBUFFER_SIZE

#define SAC_VTUTF8_OBUFFER_SIZE   0x2D00

Definition at line 161 of file sacdrv.h.

◆ SAC_VTUTF8_ROW_HEIGHT

#define SAC_VTUTF8_ROW_HEIGHT   24

Definition at line 159 of file sacdrv.h.

◆ SacAllocatePool

#define SacAllocatePool (   Length,
  Tag 
)     MyAllocatePool(Length, Tag, __FILE__, __LINE__)

Definition at line 24 of file sacdrv.h.

◆ SacFreePool

#define SacFreePool (   Pointer)     MyFreePool((PVOID*)(&Pointer))

Definition at line 26 of file sacdrv.h.

◆ SECURITY_BLOCK_TAG

#define SECURITY_BLOCK_TAG   'SpcR'

Definition at line 140 of file sacdrv.h.

◆ VT_220_BACKTAB

#define VT_220_BACKTAB   L"[0Z"

Definition at line 1510 of file sacdrv.h.

◆ VT_ANSI_BACKTAB_CHAR

#define VT_ANSI_BACKTAB_CHAR   L'Z'

Definition at line 1509 of file sacdrv.h.

◆ VT_ANSI_COMMAND

#define VT_ANSI_COMMAND   L'['

Definition at line 1485 of file sacdrv.h.

◆ VT_ANSI_CUP_CURSOR_CHAR

#define VT_ANSI_CUP_CURSOR_CHAR   L'H'

Definition at line 1515 of file sacdrv.h.

◆ VT_ANSI_CURSOR_DOWN

#define VT_ANSI_CURSOR_DOWN   L"[B"

Definition at line 1491 of file sacdrv.h.

◆ VT_ANSI_CURSOR_DOWN_CHAR

#define VT_ANSI_CURSOR_DOWN_CHAR   L'B'

Definition at line 1490 of file sacdrv.h.

◆ VT_ANSI_CURSOR_LEFT

#define VT_ANSI_CURSOR_LEFT   L"[D"

Definition at line 1497 of file sacdrv.h.

◆ VT_ANSI_CURSOR_LEFT_CHAR

#define VT_ANSI_CURSOR_LEFT_CHAR   L'D'

Definition at line 1496 of file sacdrv.h.

◆ VT_ANSI_CURSOR_RIGHT

#define VT_ANSI_CURSOR_RIGHT   L"[C"

Definition at line 1494 of file sacdrv.h.

◆ VT_ANSI_CURSOR_RIGHT_CHAR

#define VT_ANSI_CURSOR_RIGHT_CHAR   L'C'

Definition at line 1493 of file sacdrv.h.

◆ VT_ANSI_CURSOR_UP

#define VT_ANSI_CURSOR_UP   L"[A"

Definition at line 1488 of file sacdrv.h.

◆ VT_ANSI_CURSOR_UP_CHAR

#define VT_ANSI_CURSOR_UP_CHAR   L'A'

Definition at line 1487 of file sacdrv.h.

◆ VT_ANSI_ERASE_DOWN_SCREEN

#define VT_ANSI_ERASE_DOWN_SCREEN   L"[J"

Definition at line 1505 of file sacdrv.h.

◆ VT_ANSI_ERASE_END_LINE

#define VT_ANSI_ERASE_END_LINE   L"[K"

Definition at line 1500 of file sacdrv.h.

◆ VT_ANSI_ERASE_ENTIRE_LINE

#define VT_ANSI_ERASE_ENTIRE_LINE   L"[2K"

Definition at line 1502 of file sacdrv.h.

◆ VT_ANSI_ERASE_ENTIRE_SCREEN

#define VT_ANSI_ERASE_ENTIRE_SCREEN   L"[2J"

Definition at line 1507 of file sacdrv.h.

◆ VT_ANSI_ERASE_LINE_CHAR

#define VT_ANSI_ERASE_LINE_CHAR   L'K'

Definition at line 1499 of file sacdrv.h.

◆ VT_ANSI_ERASE_SCREEN_CHAR

#define VT_ANSI_ERASE_SCREEN_CHAR   L'J'

Definition at line 1504 of file sacdrv.h.

◆ VT_ANSI_ERASE_START_LINE

#define VT_ANSI_ERASE_START_LINE   L"[1K"

Definition at line 1501 of file sacdrv.h.

◆ VT_ANSI_ERASE_UP_SCREEN

#define VT_ANSI_ERASE_UP_SCREEN   L"[1J"

Definition at line 1506 of file sacdrv.h.

◆ VT_ANSI_ESCAPE

#define VT_ANSI_ESCAPE   L'\x1B'

Definition at line 1484 of file sacdrv.h.

◆ VT_ANSI_HVP_CURSOR_CHAR

#define VT_ANSI_HVP_CURSOR_CHAR   L'f'

Definition at line 1514 of file sacdrv.h.

◆ VT_ANSI_SCROLL_CHAR

#define VT_ANSI_SCROLL_CHAR   L'r'

Definition at line 1516 of file sacdrv.h.

◆ VT_ANSI_SEPARATOR_CHAR

#define VT_ANSI_SEPARATOR_CHAR   L';'

Definition at line 1513 of file sacdrv.h.

◆ VT_ANSI_SET_ATTRIBUTE_CHAR

#define VT_ANSI_SET_ATTRIBUTE_CHAR   L'm'

Definition at line 1512 of file sacdrv.h.

Typedef Documentation

◆ PSAC_CELL_DATA

◆ PSAC_CHANNEL

◆ PSAC_CHANNEL_ATTRIBUTES

◆ PSAC_CHANNEL_CREATE

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_CREATE) (IN struct _SAC_CHANNEL *Channel)

Definition at line 343 of file sacdrv.h.

◆ PSAC_CHANNEL_DESTROY

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_DESTROY) (IN struct _SAC_CHANNEL *Channel)

Definition at line 349 of file sacdrv.h.

◆ PSAC_CHANNEL_IBUFFER_FULL

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_IBUFFER_FULL) (IN struct _SAC_CHANNEL *Channel, OUT PBOOLEAN BufferStatus)

Definition at line 395 of file sacdrv.h.

◆ PSAC_CHANNEL_IBUFFER_LENGTH

typedef ULONG(NTAPI * PSAC_CHANNEL_IBUFFER_LENGTH) (IN struct _SAC_CHANNEL *Channel)

Definition at line 402 of file sacdrv.h.

◆ PSAC_CHANNEL_ID

◆ PSAC_CHANNEL_IREAD

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_IREAD) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize, IN PULONG ReturnBufferSize)

Definition at line 386 of file sacdrv.h.

◆ PSAC_CHANNEL_IREAD_LAST

typedef WCHAR(NTAPI * PSAC_CHANNEL_IREAD_LAST) (IN struct _SAC_CHANNEL *Channel)

Definition at line 408 of file sacdrv.h.

◆ PSAC_CHANNEL_IWRITE

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_IWRITE) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize)

Definition at line 414 of file sacdrv.h.

◆ PSAC_CHANNEL_LOCK

◆ PSAC_CHANNEL_OECHO

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_OECHO) (IN struct _SAC_CHANNEL *Channel, IN PCHAR String, IN ULONG Length)

Definition at line 364 of file sacdrv.h.

◆ PSAC_CHANNEL_OFLUSH

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_OFLUSH) (IN struct _SAC_CHANNEL *Channel)

Definition at line 372 of file sacdrv.h.

◆ PSAC_CHANNEL_OREAD

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_OREAD) (IN struct _SAC_CHANNEL *Channel, IN PCHAR Buffer, IN ULONG BufferSize, OUT PULONG ByteCount)

Definition at line 355 of file sacdrv.h.

◆ PSAC_CHANNEL_OWRITE

typedef NTSTATUS(NTAPI * PSAC_CHANNEL_OWRITE) (IN struct _SAC_CHANNEL *Channel, IN PCHAR String, IN ULONG Length)

Definition at line 378 of file sacdrv.h.

◆ PSAC_CHANNEL_STATUS

◆ PSAC_DEVICE_EXTENSION

◆ PSAC_MACHINE_INFO

◆ PSAC_MEMORY_ENTRY

◆ PSAC_MEMORY_LIST

◆ PSAC_MESSAGE_ENTRY

◆ PSAC_STATIC_ESCAPE_STRING

◆ PSAC_VTUTF8_SCREEN

◆ SAC_ANSI_COMMANDS

◆ SAC_ANSI_DISPATCH

◆ SAC_CELL_DATA

◆ SAC_CHANNEL

◆ SAC_CHANNEL_ATTRIBUTES

◆ SAC_CHANNEL_ID

◆ SAC_CHANNEL_LOCK

◆ SAC_CHANNEL_STATUS

◆ SAC_CHANNEL_TYPE

◆ SAC_DEVICE_EXTENSION

◆ SAC_MACHINE_INFO

◆ SAC_MEMORY_ENTRY

◆ SAC_MEMORY_LIST

◆ SAC_MESSAGE_ENTRY

◆ SAC_POST_COMMANDS

◆ SAC_STATIC_ESCAPE_STRING

◆ SAC_VTUTF8_SCREEN

◆ VT_ANSI_ATTRIBUTES

Enumeration Type Documentation

◆ _SAC_ANSI_COMMANDS

Enumerator
SacCursorUp 
SacCursorDown 
SacCursorRight 
SacCursorLeft 
SacFontNormal 
SacFontBlink 
SacFontBlinkOff 
SacFontBold 
SacFontBoldOff 
SacFontInverse 
SacFontInverseOff 
SacBackTab 
SacEraseEndOfLine 
SacEraseStartOfLine 
SacEraseLine 
SacEraseEndOfScreen 
SacEraseStartOfScreen 
SacEraseScreen 
SacSetCursorPosition 
SacSetScrollRegion 
SacSetColors 
SacSetBackgroundColor 
SacSetFontColor 
SacSetColorsAndAttributes 

Definition at line 214 of file sacdrv.h.

215{
enum _SAC_ANSI_COMMANDS SAC_ANSI_COMMANDS
@ SacFontBoldOff
Definition: sacdrv.h:224
@ SacCursorLeft
Definition: sacdrv.h:219
@ SacFontBold
Definition: sacdrv.h:223
@ SacEraseScreen
Definition: sacdrv.h:233
@ SacFontInverse
Definition: sacdrv.h:225
@ SacSetBackgroundColor
Definition: sacdrv.h:237
@ SacEraseLine
Definition: sacdrv.h:230
@ SacSetColorsAndAttributes
Definition: sacdrv.h:239
@ SacFontBlinkOff
Definition: sacdrv.h:222
@ SacCursorUp
Definition: sacdrv.h:216
@ SacFontNormal
Definition: sacdrv.h:220
@ SacCursorRight
Definition: sacdrv.h:218
@ SacSetCursorPosition
Definition: sacdrv.h:234
@ SacFontInverseOff
Definition: sacdrv.h:226
@ SacEraseEndOfLine
Definition: sacdrv.h:228
@ SacFontBlink
Definition: sacdrv.h:221
@ SacEraseEndOfScreen
Definition: sacdrv.h:231
@ SacEraseStartOfLine
Definition: sacdrv.h:229
@ SacEraseStartOfScreen
Definition: sacdrv.h:232
@ SacSetFontColor
Definition: sacdrv.h:238
@ SacCursorDown
Definition: sacdrv.h:217
@ SacBackTab
Definition: sacdrv.h:227
@ SacSetScrollRegion
Definition: sacdrv.h:235
@ SacSetColors
Definition: sacdrv.h:236

◆ _SAC_ANSI_DISPATCH

Enumerator
SacAnsiClearScreen 
SacAnsiClearEndOfScreen 
SacAnsiClearEndOfLine 
SacAnsiSetColors 
SacAnsiSetPosition 
SacAnsiClearAttributes 
SacAnsiSetInverseAttribute 
SacAnsiClearInverseAttribute 
SacAnsiSetBlinkAttribute 
SacAnsiClearBlinkAttribute 
SacAnsiSetBoldAttribute 
SacAnsiClearBoldAttribute 

Definition at line 245 of file sacdrv.h.

246{
enum _SAC_ANSI_DISPATCH SAC_ANSI_DISPATCH
@ SacAnsiSetColors
Definition: sacdrv.h:250
@ SacAnsiClearEndOfLine
Definition: sacdrv.h:249
@ SacAnsiClearBlinkAttribute
Definition: sacdrv.h:256
@ SacAnsiSetInverseAttribute
Definition: sacdrv.h:253
@ SacAnsiSetBoldAttribute
Definition: sacdrv.h:257
@ SacAnsiClearInverseAttribute
Definition: sacdrv.h:254
@ SacAnsiClearBoldAttribute
Definition: sacdrv.h:258
@ SacAnsiClearAttributes
Definition: sacdrv.h:252
@ SacAnsiClearScreen
Definition: sacdrv.h:247
@ SacAnsiSetBlinkAttribute
Definition: sacdrv.h:255
@ SacAnsiSetPosition
Definition: sacdrv.h:251
@ SacAnsiClearEndOfScreen
Definition: sacdrv.h:248

◆ _SAC_CHANNEL_STATUS

Enumerator
Inactive 
Active 

Definition at line 285 of file sacdrv.h.

286{
287 Inactive,
288 Active
enum _SAC_CHANNEL_STATUS * PSAC_CHANNEL_STATUS
enum _SAC_CHANNEL_STATUS SAC_CHANNEL_STATUS
@ Inactive
Definition: sacdrv.h:287
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:561

◆ _SAC_CHANNEL_TYPE

Enumerator
VtUtf8 
Cmd 
Raw 

Definition at line 275 of file sacdrv.h.

276{
277 VtUtf8,
278 Cmd,
279 Raw
enum _SAC_CHANNEL_TYPE SAC_CHANNEL_TYPE
@ Cmd
Definition: sacdrv.h:278
@ Raw
Definition: sacdrv.h:279
@ VtUtf8
Definition: sacdrv.h:277

◆ _SAC_POST_COMMANDS

Enumerator
Nothing 
Shutdown 
Close 
Restart 

Definition at line 264 of file sacdrv.h.

265{
266 Nothing,
267 Shutdown,
268 Close,
269 Restart
enum _SAC_POST_COMMANDS SAC_POST_COMMANDS
@ Nothing
Definition: sacdrv.h:266
@ Restart
Definition: sacdrv.h:269
@ Shutdown
Definition: sacdrv.h:267
@ Close
Definition: sacdrv.h:268

◆ _VT_ANSI_ATTRIBUTES

Enumerator
Normal 
Bold 
Faint 
Italic 
Underline 
SlowBlink 
FastBlink 
Inverse 
Conceal 
Strikethrough 
PrimaryFont 
AlternateFont1 
AlternateFont2 
AlternateFont3 
Alternatefont4 
AlternateFont5 
AlternateFont6 
AlternateFont7 
AlternateFont8 
AlternateFont9 
Fraktur 
DoubleUnderline 
BoldOff 
ItalicOff 
UnderlineOff 
BlinkOff 
Reserved 
InverseOff 
ConcealOff 
StrikethroughOff 
SetColorStart 
SetColorBlack 
SetColorRed 
SetColorGreen 
SetColorYellow 
SetColorBlue 
SetcolorMAgent 
SetColorCyan 
SetColorWhite 
SetColorMax 
SetColor256 
SeTextColorDefault 
SetBackColorStart 
SetBackColorBlack 
SetBackColorRed 
SetBackColorGreen 
SetBackColorYellow 
SetBackColorBlue 
SetBackcolorMAgent 
SetBackColorCyan 
SetBackColorWhite 
SetBackColorMax 
SetBackColor256 
SetBackColorDefault 
Reserved1 
Framed 
Encircled 
Overlined 
FramedOff 
OverlinedOff 
Reserved2 
Reserved3 
Reserved4 
Reserved5 

Definition at line 1373 of file sacdrv.h.

1374{
1375 //
1376 // Attribute modifiers (mostly supported)
1377 //
1378 Normal,
1379 Bold,
1380 Faint,
1381 Italic,
1382 Underline,
1383 SlowBlink,
1384 FastBlink,
1385 Inverse,
1386 Conceal,
1388
1389 //
1390 // Font selectors (not supported)
1391 //
1402
1403 //
1404 // Additional attributes (not supported)
1405 //
1406 Fraktur,
1408
1409 //
1410 // Attribute Un-modifiers (mostly supported)
1411 //
1412 BoldOff,
1413 ItalicOff,
1415 BlinkOff,
1416 Reserved,
1417 InverseOff,
1418 ConcealOff,
1420
1421 //
1422 // Standard Text Color
1423 //
1434
1435 //
1436 // Extended Text Color (not supported)
1437 //
1440
1441 //
1442 // Standard Background Color
1443 //
1454
1455 //
1456 // Extended Background Color (not supported)
1457 //
1460
1461 //
1462 // Extra Attributes (not supported)
1463 //
1464 Reserved1,
1465 Framed,
1466 Encircled,
1467 Overlined,
1468 FramedOff,
1470 Reserved2,
1471 Reserved3,
1472 Reserved4,
1473 Reserved5
1474
1475 //
1476 // Ideograms (not supported)
1477 //
@ ItalicOff
Definition: sacdrv.h:1413
@ AlternateFont2
Definition: sacdrv.h:1394
@ Reserved3
Definition: sacdrv.h:1471
@ Inverse
Definition: sacdrv.h:1385
@ AlternateFont7
Definition: sacdrv.h:1399
@ SetBackColorCyan
Definition: sacdrv.h:1451
@ SetColorBlue
Definition: sacdrv.h:1429
@ SetBackColorBlack
Definition: sacdrv.h:1445
@ SetBackColor256
Definition: sacdrv.h:1458
@ AlternateFont9
Definition: sacdrv.h:1401
@ SetBackColorStart
Definition: sacdrv.h:1444
@ SetBackColorGreen
Definition: sacdrv.h:1447
@ BoldOff
Definition: sacdrv.h:1412
@ SetcolorMAgent
Definition: sacdrv.h:1430
@ OverlinedOff
Definition: sacdrv.h:1469
@ SetBackColorWhite
Definition: sacdrv.h:1452
@ AlternateFont3
Definition: sacdrv.h:1395
@ Normal
Definition: sacdrv.h:1378
@ Strikethrough
Definition: sacdrv.h:1387
@ SetColorWhite
Definition: sacdrv.h:1432
@ Reserved
Definition: sacdrv.h:1416
@ SlowBlink
Definition: sacdrv.h:1383
@ Reserved4
Definition: sacdrv.h:1472
@ SetColorBlack
Definition: sacdrv.h:1425
@ SetBackColorMax
Definition: sacdrv.h:1453
@ AlternateFont5
Definition: sacdrv.h:1397
@ InverseOff
Definition: sacdrv.h:1417
@ Encircled
Definition: sacdrv.h:1466
@ ConcealOff
Definition: sacdrv.h:1418
@ Reserved2
Definition: sacdrv.h:1470
@ SetColor256
Definition: sacdrv.h:1438
@ AlternateFont1
Definition: sacdrv.h:1393
@ SetBackColorYellow
Definition: sacdrv.h:1448
@ AlternateFont6
Definition: sacdrv.h:1398
@ DoubleUnderline
Definition: sacdrv.h:1407
@ Bold
Definition: sacdrv.h:1379
@ SetBackColorBlue
Definition: sacdrv.h:1449
@ SeTextColorDefault
Definition: sacdrv.h:1439
@ Underline
Definition: sacdrv.h:1382
@ AlternateFont8
Definition: sacdrv.h:1400
@ Alternatefont4
Definition: sacdrv.h:1396
@ SetColorYellow
Definition: sacdrv.h:1428
@ SetBackColorDefault
Definition: sacdrv.h:1459
@ Italic
Definition: sacdrv.h:1381
@ SetBackcolorMAgent
Definition: sacdrv.h:1450
@ PrimaryFont
Definition: sacdrv.h:1392
@ SetColorGreen
Definition: sacdrv.h:1427
@ SetColorRed
Definition: sacdrv.h:1426
@ Faint
Definition: sacdrv.h:1380
@ Reserved5
Definition: sacdrv.h:1473
@ Overlined
Definition: sacdrv.h:1467
@ FastBlink
Definition: sacdrv.h:1384
@ Fraktur
Definition: sacdrv.h:1406
@ UnderlineOff
Definition: sacdrv.h:1414
@ Conceal
Definition: sacdrv.h:1386
@ FramedOff
Definition: sacdrv.h:1468
@ SetColorStart
Definition: sacdrv.h:1424
@ SetColorMax
Definition: sacdrv.h:1433
@ Framed
Definition: sacdrv.h:1465
@ StrikethroughOff
Definition: sacdrv.h:1419
@ SetColorCyan
Definition: sacdrv.h:1431
@ SetBackColorRed
Definition: sacdrv.h:1446
@ BlinkOff
Definition: sacdrv.h:1415
@ Reserved1
Definition: sacdrv.h:1464
enum _VT_ANSI_ATTRIBUTES VT_ANSI_ATTRIBUTES

Function Documentation

◆ C_ASSERT()

C_ASSERT ( sizeof(SAC_CELL_DATA = =6)

◆ ChanMgrCloseChannel()

NTSTATUS NTAPI ChanMgrCloseChannel ( IN PSAC_CHANNEL  Channel)

Definition at line 593 of file chanmgr.c.

594{
596 CHECK_PARAMETER(Channel);
597
598 /* Check if the channel is active */
599 if (ChannelIsActive(Channel))
600 {
601 /* Yep, close it */
602 Status = ChannelClose(Channel);
603 }
604 else
605 {
606 /* Nothing to do */
608 }
609
610 /* Handle the channel close */
611 ConMgrHandleEvent(TRUE, Channel, &Status);
612 return Status;
613}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ChannelClose(IN PSAC_CHANNEL Channel)
Definition: channel.c:558
BOOLEAN NTAPI ChannelIsActive(IN PSAC_CHANNEL Channel)
Definition: channel.c:250
NTSTATUS NTAPI ConMgrHandleEvent(IN ULONG EventCode, IN PSAC_CHANNEL Channel, OUT PVOID Data)
Definition: conmgr.c:888
#define TRUE
Definition: types.h:120
#define STATUS_ALREADY_DISCONNECTED
Definition: ntstatus.h:216
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54

Referenced by ChanMgrCloseChannelsWithFileObject(), and ConMgrWorkerProcessEvents().

◆ ChanMgrCreateChannel()

NTSTATUS NTAPI ChanMgrCreateChannel ( OUT PSAC_CHANNEL Channel,
IN PSAC_CHANNEL_ATTRIBUTES  Attributes 
)

Definition at line 345 of file chanmgr.c.

347{
349 PSAC_CHANNEL NewChannel;
350 SAC_CHANNEL_ID ChanId;
351 ULONG i;
352 CHECK_PARAMETER(Channel);
354
355 /* No other channel create attempts can happen */
357
358 /* Is the channel manager initialized? */
360 {
361 /* Nope, bail out */
363 goto ReturnStatus;
364 }
365
366 /* Reap any zombie channels */
368 if (!NT_SUCCESS(Status))
369 {
370 /* Bail out on error */
372 goto ReturnStatus;
373 }
374
375 /* Check if we already have a channel with this name */
376 if (!ChanMgrIsUniqueName(Attributes->NameBuffer))
377 {
378 /* We do, fail */
380 goto ReturnStatus;
381 }
382
383 /* Allocate this channel */
384 NewChannel = SacAllocatePool(sizeof(SAC_CHANNEL), CHANNEL_BLOCK_TAG);
386 RtlZeroMemory(NewChannel, sizeof(SAC_CHANNEL));
387
388 /* Loop channel slots */
389 for (i = 0; i < SAC_MAX_CHANNELS; i++)
390 {
391 /* Find a free spot for it */
392 if (ChannelReaped[i])
393 {
394 /* Free slot found, attempt to use it */
397 if (ChannelArray[i] == NewChannel) break;
398 }
399 }
400
401 /* Did we not find a single free slot? */
402 if (i == SAC_MAX_CHANNELS)
403 {
404 /* Bail out */
405 goto ReturnStatus;
406 }
407
408 /* Create an ID for this channel */
409 RtlZeroMemory(&ChanId, sizeof(ChanId));
411 if (!NT_SUCCESS(Status))
412 {
413 /* Bail out if we couldn't */
414 SAC_DBG(SAC_DBG_INIT, "SAC Create Channel :: Failed to get GUID\n");
415 goto ReturnStatus;
416 }
417
418 /* Now create the channel proper */
419 Status = ChannelCreate(NewChannel, Attributes, ChanId);
420 if (NT_SUCCESS(Status))
421 {
422 /* Set the channel index */
423 _InterlockedExchange(&NewChannel->Index, i);
424
425 /* Add the initial reference to the channel */
427
428 /* Return it to the caller */
429 *Channel = NewChannel;
430
431 /* This slot is now occupied */
432 ASSERT(ChannelReaped[i] == 1);
434 }
435 else
436 {
437 /* We couldn't create it, free the buffer */
438 SacFreePool(NewChannel);
439 }
440
441ReturnStatus:
442 /* Return whatever the operation status was */
444 return Status;
445}
PSAC_CHANNEL ChannelArray[SAC_MAX_CHANNELS]
Definition: chanmgr.c:17
BOOLEAN NTAPI ChanMgrIsUniqueName(IN PWCHAR ChannelName)
Definition: chanmgr.c:282
FORCEINLINE VOID ChannelReferenceToOneByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:109
#define CHANNEL_SLOT_IS_IN_USE(x)
Definition: chanmgr.c:26
NTSTATUS NTAPI ChanMgrReapChannels(VOID)
Definition: chanmgr.c:309
LONG ChannelReaped[SAC_MAX_CHANNELS]
Definition: chanmgr.c:19
BOOLEAN ChannelCreateEnabled
Definition: chanmgr.c:16
NTSTATUS NTAPI ChannelCreate(IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes, IN SAC_CHANNEL_ID ChannelId)
Definition: channel.c:457
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
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 InterlockedCompareExchangePointer
Definition: interlocked.h:129
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
#define ASSERT(a)
Definition: mode.c:44
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:380
#define STATUS_DUPLICATE_NAME
Definition: ntstatus.h:425
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
#define CHECK_PARAMETER_WITH_STATUS(Condition, Status)
Definition: sacdrv.h:47
#define ChannelLockCreates()
Definition: sacdrv.h:1330
#define SAC_MAX_CHANNELS
Definition: sacdrv.h:154
#define ChannelUnlockCreates()
Definition: sacdrv.h:1331
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define CHANNEL_BLOCK_TAG
Definition: sacdrv.h:143
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
GUID ChannelGuid
Definition: sacdrv.h:296
LONG Index
Definition: sacdrv.h:426
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59

Referenced by ConMgrInitialize().

◆ ChanMgrGetByHandle()

NTSTATUS NTAPI ChanMgrGetByHandle ( IN SAC_CHANNEL_ID  ChannelId,
OUT PSAC_CHANNEL TargetChannel 
)

Definition at line 202 of file chanmgr.c.

204{
206 ULONG i;
207 PSAC_CHANNEL Channel;
208 CHECK_PARAMETER2(TargetChannel);
209
210 /* Assume failure */
211 *TargetChannel = NULL;
213
214 /* Loop through all channels */
215 for (i = 0; i < SAC_MAX_CHANNELS; i++)
216 {
217 /* Reference this one and check if it's valid */
219 {
220 /* All good, grab it */
221 Channel = ChannelFromIndex(i);
222 ASSERT(Channel != NULL);
223
224 /* Check if the channel ID matches */
225 if (ChannelIsEqual(Channel, &ChannelId))
226 {
227 /* We found it, return it (with a reference held) */
228 *TargetChannel = Channel;
229 return STATUS_SUCCESS;
230 }
231
232 /* Not the one we want, dereference this one and keep going */
234 }
235 }
236
237 /* No channels with this ID were found */
238 return Status;
239}
FORCEINLINE LONG ChannelReferenceByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:60
FORCEINLINE VOID ChannelDereferenceByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:83
FORCEINLINE PSAC_CHANNEL ChannelFromIndex(IN ULONG Index)
Definition: chanmgr.c:30
BOOLEAN NTAPI ChannelIsEqual(IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ID ChannelId)
Definition: channel.c:25
#define STATUS_NOT_FOUND
Definition: shellext.h:72

Referenced by ChanMgrGetByHandleAndFileObject(), ConMgrInitialize(), and ConMgrResetCurrentChannel().

◆ ChanMgrGetNextActiveChannel()

NTSTATUS NTAPI ChanMgrGetNextActiveChannel ( IN PSAC_CHANNEL  CurrentChannel,
IN PULONG  TargetIndex,
OUT PSAC_CHANNEL TargetChannel 
)

Definition at line 521 of file chanmgr.c.

524{
526 ULONG i;
527 LONG ChannelIndex, StartIndex;
528 PSAC_CHANNEL FoundChannel;
529 BOOLEAN ChannelFound;
531 CHECK_PARAMETER2(TargetIndex);
532 CHECK_PARAMETER3(TargetChannel);
533
534 /* Get the current channel index */
536 if (!NT_SUCCESS(Status)) return Status;
537
538 /* Assume failure */
539 ChannelFound = FALSE;
540
541 /* Loop through all the possible active channels */
542 StartIndex = (ChannelIndex + 1) % SAC_MAX_CHANNELS;
543 for (i = StartIndex; i != StartIndex; i = (i + 1) % SAC_MAX_CHANNELS)
544 {
545 /* Get the channel and see if it exists*/
546 Status = ChanMgrGetByIndex(i, &FoundChannel);
548 {
549 /* Bail out if we failed for some reason */
550 if (!NT_SUCCESS(Status)) return Status;
551
552 /* It exists -- is it active? Or, does it have output data? */
553 if ((ChannelIsActive(FoundChannel)) ||
554 (!(ChannelIsActive(FoundChannel)) &&
555 (FoundChannel->ChannelHasNewOBufferData)))
556 {
557 /* It's active or has output data, return with it */
558 ChannelFound = TRUE;
559 break;
560 }
561
562 /* Drop the reference on this channel and try the next one */
563 Status = ChanMgrReleaseChannel(FoundChannel);
564 if (!NT_SUCCESS(Status)) return Status;
565 }
566 }
567
568 /* Check if we successfully found a channel */
569 if ((NT_SUCCESS(Status)) && (ChannelFound))
570 {
571 /* Return it and its indexed. Remember we still hold the reference */
572 *TargetIndex = i;
573 *TargetChannel = FoundChannel;
574 }
575
576 /* All done */
577 return Status;
578}
unsigned char BOOLEAN
NTSTATUS NTAPI ChanMgrGetByIndex(IN LONG TargetIndex, IN PSAC_CHANNEL *TargetChannel)
Definition: chanmgr.c:496
NTSTATUS NTAPI ChanMgrGetChannelIndex(IN PSAC_CHANNEL Channel, IN PLONG ChannelIndex)
Definition: chanmgr.c:483
NTSTATUS NTAPI ChanMgrReleaseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:243
PSAC_CHANNEL CurrentChannel
Definition: conmgr.c:26
long LONG
Definition: pedump.c:60
#define CHECK_PARAMETER3(x)
Definition: sacdrv.h:60
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
LONG ChannelHasNewOBufferData
Definition: sacdrv.h:459

Referenced by ConMgrAdvanceCurrentChannel().

◆ ChanMgrInitialize()

NTSTATUS NTAPI ChanMgrInitialize ( VOID  )

Definition at line 118 of file chanmgr.c.

119{
120 ULONG i;
121
122 /* Initialize the channel lock */
125
126 /* Loop through the channel arrays */
127 for (i = 0; i < SAC_MAX_CHANNELS; i++)
128 {
129 /* Clear and initialize their locks */
132
133 /* Clear their statuses and reference counts */
136 }
137
138 /* All good */
139 return STATUS_SUCCESS;
140}
SAC_CHANNEL_LOCK ChannelSlotLock[SAC_MAX_CHANNELS]
Definition: chanmgr.c:20
SAC_CHANNEL_LOCK ChannelCreateLock
Definition: chanmgr.c:15
LONG ChannelRefCount[SAC_MAX_CHANNELS]
Definition: chanmgr.c:18
FORCEINLINE VOID SacInitializeLock(IN PSAC_CHANNEL_LOCK Lock)
Definition: sacdrv.h:1252

Referenced by InitializeGlobalData().

◆ ChanMgrReleaseChannel()

NTSTATUS NTAPI ChanMgrReleaseChannel ( IN PSAC_CHANNEL  Channel)

Definition at line 243 of file chanmgr.c.

244{
245 LONG Index;
246 ULONG RefCount;
247 PSAC_CHANNEL ThisChannel;
248 CHECK_PARAMETER(Channel);
249
250 /* Get the index of the channel */
251 Index = ChannelGetIndex(Channel);
252
253 /* Drop a reference -- there should still be at least the keepalive left */
256 ASSERT(RefCount > 0);
257
258 /* Do we only have the keep-alive left, and the channel is dead? */
259 if ((RefCount == 1) && !(ChannelIsActive(Channel)))
260 {
261 /* Check if the ??? flag is set, or if there's no output data */
262 ThisChannel = ChannelFromIndex(Index);
263 if (!(ThisChannel->Flags & 1))
264 {
265 /* Nope, we can wipe the references and get rid of it */
267 }
268 else if (!ThisChannel->ChannelHasNewOBufferData)
269 {
270 /* No data, we can wipe the references and get rid of it */
272 }
273 }
274
275 /* We're done, we can unlock the slot now */
277 return STATUS_SUCCESS;
278}
FORCEINLINE VOID ChannelDereferenceToZeroByIndex(IN LONG Index)
Definition: chanmgr.c:92
FORCEINLINE LONG ChannelDereferenceByIndex(IN LONG Index)
Definition: chanmgr.c:72
#define ChannelSlotUnlock(x)
Definition: sacdrv.h:1339
FORCEINLINE LONG ChannelGetIndex(IN PSAC_CHANNEL Channel)
Definition: sacdrv.h:1353
ULONG Flags
Definition: sacdrv.h:445
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by ChanMgrCloseChannelsWithFileObject(), ChanMgrGetByHandleAndFileObject(), ChanMgrGetChannelCount(), ChanMgrGetNextActiveChannel(), ChanMgrIsUniqueName(), ConMgrSetCurrentChannel(), ConMgrShutdown(), and ConMgrWorkerProcessEvents().

◆ ChanMgrShutdown()

NTSTATUS NTAPI ChanMgrShutdown ( VOID  )

Definition at line 144 of file chanmgr.c.

145{
146 /* FIXME: TODO */
148}
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by FreeGlobalData().

◆ ChannelClearRedrawEvent()

NTSTATUS NTAPI ChannelClearRedrawEvent ( IN PSAC_CHANNEL  Channel)

Definition at line 198 of file channel.c.

199{
201
202 /* Clear the event */
203 ChannelClearEvent(Channel, RedrawEvent);
204 return Status;
205}
#define ChannelClearEvent(Channel, x)
Definition: sacdrv.h:114

Referenced by ConMgrSetCurrentChannel().

◆ ChannelClose()

NTSTATUS NTAPI ChannelClose ( IN PSAC_CHANNEL  Channel)

Definition at line 558 of file channel.c.

559{
561 CHECK_PARAMETER(Channel);
562
563 /* Set the channel inactive */
564 ChannelSetStatus(Channel, Inactive);
565
566 /* Set the close event */
567 if (Channel->Flags & SAC_CHANNEL_FLAG_CLOSE_EVENT)
568 {
569 ChannelSetEvent(Channel, CloseEvent);
570 }
571
572 /* Close all the handles */
574 return Status;
575}
NTSTATUS NTAPI ChannelDereferenceHandles(IN PSAC_CHANNEL Channel)
Definition: channel.c:35
NTSTATUS NTAPI ChannelSetStatus(IN PSAC_CHANNEL Channel, IN SAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:236
#define SAC_CHANNEL_FLAG_CLOSE_EVENT
Definition: sacdrv.h:170
#define ChannelSetEvent(Channel, x)
Definition: sacdrv.h:99

Referenced by ChanMgrCloseChannel(), and ConMgrShutdown().

◆ ChannelCreate()

NTSTATUS NTAPI ChannelCreate ( IN PSAC_CHANNEL  Channel,
IN PSAC_CHANNEL_ATTRIBUTES  Attributes,
IN SAC_CHANNEL_ID  ChannelId 
)

Definition at line 457 of file channel.c.

460{
462 CHECK_PARAMETER1(Channel);
464
465 /* If a close event is being passed in, it must exist, and vice-versa */
467 {
468 CHECK_PARAMETER(Attributes->CloseEvent != NULL);
469 }
470 else
471 {
472 CHECK_PARAMETER(Attributes->CloseEvent == NULL);
473 }
474
475 /* If a new data event is being passed in, it must exist, and vice-versa */
477 {
478 CHECK_PARAMETER(Attributes->HasNewDataEvent != NULL);
479 }
480 else
481 {
482 CHECK_PARAMETER(Attributes->HasNewDataEvent == NULL);
483 }
484
485 /* If a lock event is being passed in, it must exist, and vice-versa */
487 {
488 CHECK_PARAMETER(Attributes->LockEvent != NULL);
489 }
490 else
491 {
492 CHECK_PARAMETER(Attributes->LockEvent == NULL);
493 }
494
495 /* If a redraw event is being passed in, it must exist, and vice-versa */
497 {
498 CHECK_PARAMETER(Attributes->RedrawEvent != NULL);
499 }
500 else
501 {
502 CHECK_PARAMETER(Attributes->RedrawEvent == NULL);
503 }
504
505 /* Initialize the channel structure */
506 RtlZeroMemory(Channel, sizeof(SAC_CHANNEL));
507 Channel->ChannelId = ChannelId;
508 Channel->ChannelType = Attributes->ChannelType;
509 Channel->Flags = Attributes->Flag;
511 {
512 Channel->ApplicationType = Attributes->ChannelId;
513 }
514
515 /* Initialize all the locks and events */
516 SacInitializeLock(&Channel->ChannelAttributeLock);
517 SacInitializeLock(&Channel->ChannelOBufferLock);
518 SacInitializeLock(&Channel->ChannelIBufferLock);
519 ChannelInitializeEvent(Channel, Attributes, CloseEvent);
520 ChannelInitializeEvent(Channel, Attributes, HasNewDataEvent);
521 ChannelInitializeEvent(Channel, Attributes, LockEvent);
522 ChannelInitializeEvent(Channel, Attributes, RedrawEvent);
523
524 /* Set the name and description */
525 ChannelSetName(Channel, Attributes->NameBuffer);
526 ChannelSetDescription(Channel, Attributes->DescriptionBuffer);
527
528 /* Initialize the function table for the type of channel this is */
530 if (!NT_SUCCESS(Status))
531 {
532 /* This is critical */
533 SAC_DBG(SAC_DBG_INIT, "SAC Create Channel :: Failed to initialize vtable\n");
534 goto FailChannel;
535 }
536
537 /* Now call the channel specific type constructor */
538 Status = Channel->ChannelCreate(Channel);
539 if (!NT_SUCCESS(Status))
540 {
541 /* This is critical */
542 SAC_DBG(SAC_DBG_INIT, "SAC Create Channel :: Failed channel specific initialization\n");
543 goto FailChannel;
544 }
545
546 /* Finally, mark the channel as active */
547 ChannelSetStatus(Channel, Active);
548 return STATUS_SUCCESS;
549
550FailChannel:
551 /* Destroy the channel and return the failure code */
552 Channel->ChannelDestroy(Channel);
553 return Status;
554}
NTSTATUS NTAPI ChannelSetName(IN PSAC_CHANNEL Channel, IN PWCHAR Name)
Definition: channel.c:322
NTSTATUS NTAPI ChannelSetDescription(IN PSAC_CHANNEL Channel, IN PWCHAR Description)
Definition: channel.c:368
NTSTATUS NTAPI ChannelInitializeVTable(IN PSAC_CHANNEL Channel)
Definition: channel.c:405
#define SAC_CHANNEL_FLAG_LOCK_EVENT
Definition: sacdrv.h:172
#define SAC_CHANNEL_FLAG_REDRAW_EVENT
Definition: sacdrv.h:173
#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT
Definition: sacdrv.h:171
#define ChannelInitializeEvent(Channel, Attributes, x)
Definition: sacdrv.h:70
#define SAC_CHANNEL_FLAG_APPLICATION
Definition: sacdrv.h:174

Referenced by ChanMgrCreateChannel().

◆ ChannelDestroy()

NTSTATUS NTAPI ChannelDestroy ( IN PSAC_CHANNEL  Channel)

Definition at line 77 of file channel.c.

78{
79 CHECK_PARAMETER(Channel);
80
81 /* Same thing as dereferencing all the handles */
82 return ChannelDereferenceHandles(Channel);
83}

Referenced by RawChannelDestroy(), and VTUTF8ChannelDestroy().

◆ ChannelGetFlags()

FORCEINLINE ULONG ChannelGetFlags ( IN PSAC_CHANNEL  Channel)

Definition at line 1346 of file sacdrv.h.

1347{
1348 return Channel->Flags;
1349}

◆ ChannelGetIndex()

FORCEINLINE LONG ChannelGetIndex ( IN PSAC_CHANNEL  Channel)

Definition at line 1353 of file sacdrv.h.

1354{
1355 /* Return the index of the channel */
1356 return Channel->Index;
1357}

Referenced by ChanMgrGetChannelIndex(), and ChanMgrReleaseChannel().

◆ ChannelGetName()

NTSTATUS NTAPI ChannelGetName ( IN PSAC_CHANNEL  Channel,
OUT PWCHAR Name 
)

Definition at line 297 of file channel.c.

299{
300 CHECK_PARAMETER1(Channel);
302
303 /* Allocate space to hold the name */
304 *Name = SacAllocatePool(sizeof(Channel->NameBuffer), GLOBAL_BLOCK_TAG);
306
307 /* Lock the attributes while we copy the name */
308 ChannelLockAttributes(Channel);
309
310 /* Copy the name and null-terminate it */
311 ASSERT(((wcslen(Channel->NameBuffer) + 1) * sizeof(WCHAR)) <= ((SAC_CHANNEL_NAME_SIZE + 1) * sizeof(WCHAR)));
312 wcsncpy(*Name, Channel->NameBuffer, RTL_NUMBER_OF(Channel->NameBuffer)); // bug
314
315 /* Release the lock and return */
317 return STATUS_SUCCESS;
318}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
#define CHECK_ALLOCATION(x)
Definition: sacdrv.h:64
#define ChannelLockAttributes(x)
Definition: sacdrv.h:1336
#define SAC_CHANNEL_NAME_SIZE
Definition: sacdrv.h:152
#define ChannelUnlockAttributes(x)
Definition: sacdrv.h:1337
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:142
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ChanMgrGetChannelByName().

◆ ChannelHasNewIBufferData()

FORCEINLINE BOOLEAN ChannelHasNewIBufferData ( IN PSAC_CHANNEL  Channel)

Definition at line 1361 of file sacdrv.h.

1362{
1363 /* Return if there's any new data in the input buffer */
1364 return Channel->ChannelHasNewIBufferData;
1365}

Referenced by ChanMgrReapChannels(), RawChannelIRead(), and VTUTF8ChannelIRead().

◆ ChannelHasRedrawEvent()

NTSTATUS NTAPI ChannelHasRedrawEvent ( IN PSAC_CHANNEL  Channel,
OUT PBOOLEAN  Present 
)

Definition at line 209 of file channel.c.

211{
212 CHECK_PARAMETER1(Channel);
213 CHECK_PARAMETER2(Present);
214
215 /* Return if the flag is set */
216 *Present = Channel->Flags & SAC_CHANNEL_FLAG_REDRAW_EVENT;
217 return STATUS_SUCCESS;
218}

Referenced by ConMgrDisplayCurrentChannel(), and ConMgrSetCurrentChannel().

◆ ChannelIBufferLength()

ULONG NTAPI ChannelIBufferLength ( IN PSAC_CHANNEL  Channel)

Definition at line 163 of file channel.c.

164{
166
167 /* Get the input buffer length while holding the lock */
168 ChannelLockOBuffer(Channel);
169 Length = Channel->ChannelInputBufferLength(Channel);
170 ChannelUnlockOBuffer(Channel);
171 return Length;
172}
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define ChannelLockOBuffer(x)
Definition: sacdrv.h:1332
#define ChannelUnlockOBuffer(x)
Definition: sacdrv.h:1333

Referenced by ConMgrSerialPortConsumer().

◆ ChannelIRead()

NTSTATUS NTAPI ChannelIRead ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize,
IN OUT PULONG  ResultBufferSize 
)

Definition at line 131 of file channel.c.

135{
137
138 /* Read the input buffer while holding the lock */
139 ChannelLockIBuffer(Channel);
140 Status = Channel->ChannelInputRead(Channel,
141 Buffer,
143 ResultBufferSize);
144 ChannelUnlockIBuffer(Channel);
145 return Status;
146}
Definition: bufpool.h:45
#define ChannelLockIBuffer(x)
Definition: sacdrv.h:1334
#define ChannelUnlockIBuffer(x)
Definition: sacdrv.h:1335
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by ConMgrSerialPortConsumer().

◆ ChannelIReadLast()

WCHAR NTAPI ChannelIReadLast ( IN PSAC_CHANNEL  Channel)

Definition at line 150 of file channel.c.

151{
152 WCHAR LastChar;
153
154 /* Read the last character while holding the lock */
155 ChannelLockIBuffer(Channel);
156 LastChar = Channel->ChannelInputReadLast(Channel);
157 ChannelUnlockIBuffer(Channel);
158 return LastChar;
159}

Referenced by ConMgrSerialPortConsumer().

◆ ChannelIsActive()

BOOLEAN NTAPI ChannelIsActive ( IN PSAC_CHANNEL  Channel)

Definition at line 250 of file channel.c.

251{
252 SAC_CHANNEL_STATUS ChannelStatus;
254
255 /* Get the status */
256 if (!NT_SUCCESS(ChannelGetStatus(Channel, &ChannelStatus)))
257 {
258 /* We couldn't even do that, assume it's inactive */
259 IsActive = FALSE;
260 }
261 else
262 {
263 /* Check if the status shows activity */
264 IsActive = (ChannelStatus == Active);
265 }
266
267 /* Return the state */
268 return IsActive;
269}
_In_ BOOLEAN IsActive
Definition: cdrom.h:1427
NTSTATUS NTAPI ChannelGetStatus(IN PSAC_CHANNEL Channel, OUT PSAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:222

Referenced by ChanMgrCloseChannel(), ChanMgrGetChannelCount(), ChanMgrGetNextActiveChannel(), ChanMgrReleaseChannel(), and ChannelDereferenceToZeroByIndex().

◆ ChannelIsEqual()

BOOLEAN NTAPI ChannelIsEqual ( IN PSAC_CHANNEL  Channel,
IN PSAC_CHANNEL_ID  ChannelId 
)

Definition at line 25 of file channel.c.

27{
28 /* Check if the GUIDs match */
29 return IsEqualGUIDAligned(&Channel->ChannelId.ChannelGuid,
30 &ChannelId->ChannelGuid);
31}
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by ChanMgrGetByHandle(), and ConMgrIsWriteEnabled().

◆ ChannelIWrite()

NTSTATUS NTAPI ChannelIWrite ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize 
)

Definition at line 116 of file channel.c.

119{
121
122 /* Write into the input buffer while holding the lock */
123 ChannelLockIBuffer(Channel);
124 Status = Channel->ChannelInputWrite(Channel, Buffer, BufferSize);
125 ChannelUnlockIBuffer(Channel);
126 return Status;
127}

Referenced by ConMgrSerialPortConsumer().

◆ ChannelOFlush()

NTSTATUS NTAPI ChannelOFlush ( IN PSAC_CHANNEL  Channel)

Definition at line 103 of file channel.c.

104{
106
107 /* While holding the output lock, flush to the output buffer */
108 ChannelLockOBuffer(Channel);
109 Status = Channel->ChannelOutputFlush(Channel);
110 ChannelUnlockOBuffer(Channel);
111 return Status;
112}

Referenced by ConMgrDisplayCurrentChannel().

◆ ChannelOWrite()

NTSTATUS NTAPI ChannelOWrite ( IN PSAC_CHANNEL  Channel,
IN PCHAR  Buffer,
IN ULONG  BufferSize 
)

Definition at line 87 of file channel.c.

90{
93
94 /* While holding the output lock, write to the output buffer */
95 ChannelLockOBuffer(Channel);
96 Status = Channel->ChannelOutputWrite(Channel, Buffer, BufferSize);
97 ChannelUnlockOBuffer(Channel);
98 return Status;
99}
#define SAC_OBUFFER_SIZE
Definition: sacdrv.h:151

Referenced by SacPutString().

◆ ChannelSetRedrawEvent()

NTSTATUS NTAPI ChannelSetRedrawEvent ( IN PSAC_CHANNEL  Channel)

Definition at line 176 of file channel.c.

177{
179
180 /* Set the event */
181 ChannelSetEvent(Channel, RedrawEvent);
182 return Status;
183}

Referenced by ConMgrDisplayCurrentChannel().

◆ ConMgrFlushData()

NTSTATUS NTAPI ConMgrFlushData ( IN PSAC_CHANNEL  Channel)

Definition at line 139 of file conmgr.c.

140{
141 /* Nothing to do */
142 return STATUS_SUCCESS;
143}

Referenced by RawChannelOEcho(), RawChannelOFlush(), VTUTF8ChannelAnsiDispatch(), VTUTF8ChannelOEcho(), and VTUTF8ChannelOFlush().

◆ ConMgrHandleEvent()

NTSTATUS NTAPI ConMgrHandleEvent ( IN ULONG  EventCode,
IN PSAC_CHANNEL  Channel,
OUT PVOID  Data 
)

Definition at line 888 of file conmgr.c.

891{
892 ASSERT(FALSE);
894}

Referenced by ChanMgrCloseChannel().

◆ ConMgrInitialize()

NTSTATUS NTAPI ConMgrInitialize ( VOID  )

Definition at line 163 of file conmgr.c.

164{
165 PWCHAR pcwch;
166 PSAC_CHANNEL FoundChannel;
167 SAC_CHANNEL_ATTRIBUTES SacChannelAttributes;
169
170 /* Initialize the connection manager lock */
173
174 /* Setup the attributes for the raw SAC channel */
175 RtlZeroMemory(&SacChannelAttributes, sizeof(SacChannelAttributes));
176 SacChannelAttributes.ChannelType = VtUtf8;
177
178 /* Get the right name for it */
179 pcwch = GetMessage(SAC_CHANNEL_NAME);
180 ASSERT(pcwch);
181 wcsncpy(SacChannelAttributes.NameBuffer, pcwch, SAC_CHANNEL_NAME_SIZE);
182 SacChannelAttributes.NameBuffer[SAC_CHANNEL_NAME_SIZE] = ANSI_NULL;
183
184 /* Get the right description for it */
185 pcwch = GetMessage(SAC_CHANNEL_DESCRIPTION);
186 ASSERT(pcwch);
187 wcsncpy(SacChannelAttributes.DescriptionBuffer, pcwch, SAC_CHANNEL_DESCRIPTION_SIZE);
189
190 /* Set all the right flags */
192 SacChannelAttributes.CloseEvent = NULL;
193 SacChannelAttributes.HasNewDataEvent = NULL;
194 SacChannelAttributes.LockEvent = NULL;
195 SacChannelAttributes.RedrawEvent = NULL;
196 SacChannelAttributes.ChannelId = PRIMARY_SAC_CHANNEL_APPLICATION_GUID;
197
198 /* Now create it */
199 Status = ChanMgrCreateChannel(&SacChannel, &SacChannelAttributes);
200 if (NT_SUCCESS(Status))
201 {
202 /* Try to get it back */
204 if (NT_SUCCESS(Status))
205 {
206 /* Set it as the current and SAC channel */
207 SacChannel = CurrentChannel = FoundChannel;
208
209 /* Disable writes for now and clear the display */
210 _InterlockedExchange(&FoundChannel->WriteEnabled, FALSE);
212 if (!NT_SUCCESS(Status))
213 {
214 SAC_DBG(SAC_DBG_INIT, "SAC ConMgrInitialize: Failed dispatch\n");
215 }
216
217 /* Display the initial prompt */
218 SacPutSimpleMessage(SAC_NEWLINE);
219 SacPutSimpleMessage(SAC_INIT_STATUS);
220 SacPutSimpleMessage(SAC_NEWLINE);
221 SacPutSimpleMessage(SAC_PROMPT);
222
223 /* Display the current channel */
225 }
226 }
227
228 /* Release the channel lock */
230 return STATUS_SUCCESS;
231}
NTSTATUS NTAPI ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes)
Definition: chanmgr.c:345
NTSTATUS NTAPI ChanMgrGetByHandle(IN SAC_CHANNEL_ID ChannelId, OUT PSAC_CHANNEL *TargetChannel)
Definition: chanmgr.c:202
PSAC_CHANNEL SacChannel
Definition: conmgr.c:27
NTSTATUS NTAPI ConMgrDisplayCurrentChannel(VOID)
Definition: conmgr.c:81
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57
@ HeadlessCmdClearDisplay
Definition: hdl.h:132
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 ANSI_NULL
#define SAC_CHANNEL_DESCRIPTION_SIZE
Definition: sacdrv.h:153
FORCEINLINE VOID SacAcquireMutexLock(VOID)
Definition: sacdrv.h:1308
FORCEINLINE VOID SacReleaseMutexLock(VOID)
Definition: sacdrv.h:1320
#define SAC_CHANNEL_FLAG_INTERNAL
Definition: sacdrv.h:169
FORCEINLINE VOID SacInitializeMutexLock(VOID)
Definition: sacdrv.h:1297
SAC_CHANNEL_TYPE ChannelType
Definition: sacdrv.h:478
WCHAR DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE+1]
Definition: sacdrv.h:480
WCHAR NameBuffer[SAC_CHANNEL_NAME_SIZE+1]
Definition: sacdrv.h:479
SAC_CHANNEL_ID ChannelId
Definition: sacdrv.h:427
LONG WriteEnabled
Definition: sacdrv.h:447
uint16_t * PWCHAR
Definition: typedefs.h:56
#define GetMessage
Definition: winuser.h:5780

Referenced by InitializeDeviceData().

◆ ConMgrIsWriteEnabled()

BOOLEAN NTAPI ConMgrIsWriteEnabled ( IN PSAC_CHANNEL  Channel)

Definition at line 155 of file conmgr.c.

156{
157 /* If the current channel is active, allow writes */
158 return ChannelIsEqual(Channel, &CurrentChannel->ChannelId);
159}

Referenced by ConMgrChannelClose(), RawChannelOWrite(), and VTUTF8ChannelOWrite().

◆ ConMgrShutdown()

NTSTATUS NTAPI ConMgrShutdown ( VOID  )

Definition at line 372 of file conmgr.c.

373{
375
376 /* Check if we have a SAC channel */
377 if (SacChannel)
378 {
379 /* Close it */
381 if (!NT_SUCCESS(Status))
382 {
383 SAC_DBG(SAC_DBG_INIT, "SAC ConMgrShutdown: failed closing SAC channel.\n");
384 }
385
386 /* No longer have one */
388 }
389
390 /* Check if we have a current channel */
391 if (CurrentChannel)
392 {
393 /* Release it */
395 if (!NT_SUCCESS(Status))
396 {
397 SAC_DBG(SAC_DBG_INIT, "SAC ConMgrShutdown: failed releasing current channel\n");
398 }
399
400 /* No longer have one */
402 }
403
404 /* All done */
405 return STATUS_SUCCESS;
406}

Referenced by FreeGlobalData().

◆ ConMgrSimpleEventMessage()

BOOLEAN NTAPI ConMgrSimpleEventMessage ( IN ULONG  MessageIndex,
IN BOOLEAN  LockHeld 
)

Definition at line 252 of file conmgr.c.

254{
255 PWCHAR MessageBuffer;
257
258 /* Get the message to send out */
259 MessageBuffer = GetMessage(MessageIndex);
260 if (MessageBuffer)
261 {
262 /* Send it */
263 ConMgrEventMessage(MessageBuffer, LockHeld);
264 Result = TRUE;
265 }
266 else
267 {
268 /* It doesn't exist, fail */
269 Result = FALSE;
270 }
271
272 /* Return if the message was sent or not */
273 return Result;
274}
VOID NTAPI ConMgrEventMessage(IN PWCHAR EventMessage, IN BOOLEAN LockHeld)
Definition: conmgr.c:235
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426

Referenced by DoRebootCommand().

◆ ConMgrWorkerProcessEvents()

VOID NTAPI ConMgrWorkerProcessEvents ( IN PSAC_DEVICE_EXTENSION  DeviceExtension)

Definition at line 835 of file conmgr.c.

836{
837 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC WorkerProcessEvents: Entering.\n");
838
839 /* Enter the main loop */
840 while (TRUE)
841 {
842 /* Wait for something to do */
843 KeWaitForSingleObject(&DeviceExtension->Event,
844 Executive,
846 FALSE,
847 NULL);
848
849 /* Consume data off the serial port */
852 {
853 case Restart:
854 /* A reboot was sent, do it */
856 break;
857
858 case Close:
859 /* A close was sent, do it */
862 break;
863
864 case Shutdown:
865 /* A shutdown was sent, do it */
867 break;
868 }
869
870 /* Clear the serial port consumer state */
873 }
874}
NTSTATUS NTAPI ChanMgrCloseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:593
VOID NTAPI DoRebootCommand(IN BOOLEAN Reboot)
Definition: concmd.c:355
ULONG ExecutePostConsumerCommand
Definition: conmgr.c:29
PSAC_CHANNEL ExecutePostConsumerCommandData
Definition: conmgr.c:30
VOID NTAPI ConMgrSerialPortConsumer(VOID)
Definition: conmgr.c:574
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
#define KernelMode
Definition: asm.h:34
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
@ Executive
Definition: ketypes.h:403

Referenced by WorkerProcessEvents().

◆ ConMgrWriteData()

NTSTATUS NTAPI ConMgrWriteData ( IN PSAC_CHANNEL  Channel,
IN PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 111 of file conmgr.c.

114{
115 ULONG i;
118
119 /* Loop up to 32 times */
120 for (i = 0; i < 32; i++)
121 {
122 /* Attempt sending the data */
124 if (Status != STATUS_UNSUCCESSFUL) break;
125
126 /* Sending the data on the port failed, wait a second... */
127 Interval.HighPart = -1;
128 Interval.LowPart = -100000;
130 }
131
132 /* After 32 attempts it should really have worked... */
134 return Status;
135}
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
@ HeadlessCmdPutData
Definition: hdl.h:150
DWORD Interval
Definition: netstat.c:33
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771

Referenced by RawChannelOEcho(), RawChannelOFlush(), VTUTF8ChannelAnsiDispatch(), VTUTF8ChannelOEcho(), and VTUTF8ChannelOFlush().

◆ Dispatch()

NTSTATUS NTAPI Dispatch ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 53 of file dispatch.c.

55{
57}

◆ DispatchDeviceControl()

NTSTATUS NTAPI DispatchDeviceControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 21 of file dispatch.c.

23{
25}

Referenced by DriverEntry().

◆ DispatchShutdownControl()

NTSTATUS NTAPI DispatchShutdownControl ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 29 of file dispatch.c.

31{
33}

Referenced by DriverEntry().

◆ DoChannelCommand()

VOID NTAPI DoChannelCommand ( IN PCHAR  ChannelString)

Definition at line 484 of file concmd.c.

485{
486 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
487}

Referenced by ConMgrProcessInputLine().

◆ DoCmdCommand()

VOID NTAPI DoCmdCommand ( IN PCHAR  InputString)

Definition at line 491 of file concmd.c.

492{
493 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
494}

Referenced by ConMgrProcessInputLine().

◆ DoCrashCommand()

VOID NTAPI DoCrashCommand ( VOID  )

Definition at line 466 of file concmd.c.

467{
468 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoCrashCommand: Entering.\n");
469
470 /* Crash the machine */
471 KeBugCheckEx(MANUALLY_INITIATED_CRASH, 0, 0, 0, 0);
472 __debugbreak();
473}
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by ConMgrProcessInputLine().

◆ DoFullInfoCommand()

VOID NTAPI DoFullInfoCommand ( VOID  )

Definition at line 409 of file concmd.c.

410{
411 /* Flip the flag */
413
414 /* Print out the new state */
416}
BOOLEAN GlobalDoThreads
Definition: conmgr.c:35

Referenced by ConMgrProcessInputLine().

◆ DoGetNetInfo()

VOID NTAPI DoGetNetInfo ( IN BOOLEAN  DoPrint)

Definition at line 557 of file concmd.c.

558{
559 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
560}

◆ DoHelpCommand()

VOID NTAPI DoHelpCommand ( VOID  )

Definition at line 529 of file concmd.c.

530{
531 ULONG Count = 0;
532
533 /* Print out all the help messages */
534 if (!PrintHelpMessage(112, &Count)) return;
535 if (!PrintHelpMessage(12, &Count)) return;
536 if (!PrintHelpMessage(13, &Count)) return;
537 if (!PrintHelpMessage(14, &Count)) return;
538 if (!PrintHelpMessage(15, &Count)) return;
539 if (!PrintHelpMessage(16, &Count)) return;
540 if (!PrintHelpMessage(31, &Count)) return;
541 if (!PrintHelpMessage(18, &Count)) return;
542 if (!PrintHelpMessage(19, &Count)) return;
543 if (!PrintHelpMessage(32, &Count)) return;
544 if (!PrintHelpMessage(20, &Count)) return;
545 if (!PrintHelpMessage(21, &Count)) return;
546 if (!PrintHelpMessage(22, &Count)) return;
547 if (!PrintHelpMessage(23, &Count)) return;
548 if (!PrintHelpMessage(24, &Count)) return;
549 if (!PrintHelpMessage(25, &Count)) return;
550 if (!PrintHelpMessage(27, &Count)) return;
551 if (!PrintHelpMessage(28, &Count)) return;
552 if (!PrintHelpMessage(29, &Count)) return;
553}
FORCEINLINE BOOLEAN PrintHelpMessage(IN ULONG MessageId, IN OUT PULONG Count)
Definition: concmd.c:505
int Count
Definition: noreturn.cpp:7

Referenced by ConMgrProcessInputLine().

◆ DoKillCommand()

VOID NTAPI DoKillCommand ( IN PCHAR  KillString)

Definition at line 438 of file concmd.c.

439{
440 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
441}

Referenced by ConMgrProcessInputLine().

◆ DoLimitMemoryCommand()

VOID NTAPI DoLimitMemoryCommand ( IN PCHAR  LimitString)

Definition at line 459 of file concmd.c.

460{
461 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
462}

Referenced by ConMgrProcessInputLine().

◆ DoLockCommand()

VOID NTAPI DoLockCommand ( VOID  )

Definition at line 498 of file concmd.c.

499{
500 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
501}

Referenced by ConMgrProcessInputLine().

◆ DoLowerPriorityCommand()

VOID NTAPI DoLowerPriorityCommand ( IN PCHAR  PrioString)

Definition at line 445 of file concmd.c.

446{
447 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
448}

Referenced by ConMgrProcessInputLine().

◆ DoMachineInformationCommand()

VOID NTAPI DoMachineInformationCommand ( VOID  )

Definition at line 477 of file concmd.c.

478{
479 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
480}

Referenced by ConMgrProcessInputLine().

◆ DoPagingCommand()

VOID NTAPI DoPagingCommand ( VOID  )

Definition at line 420 of file concmd.c.

421{
422 /* Flip the flag */
424
425 /* Print out the new state */
427}
BOOLEAN GlobalPagingNeeded
Definition: conmgr.c:35

Referenced by ConMgrProcessInputLine().

◆ DoRaisePriorityCommand()

VOID NTAPI DoRaisePriorityCommand ( IN PCHAR  PrioString)

Definition at line 452 of file concmd.c.

453{
454 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
455}

Referenced by ConMgrProcessInputLine().

◆ DoRebootCommand()

VOID NTAPI DoRebootCommand ( IN BOOLEAN  Reboot)

Definition at line 355 of file concmd.c.

356{
357 LARGE_INTEGER Timeout, TickCount;
360 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoRebootCommand: Entering.\n");
361
362 /* Get the current time now, and setup a timeout in 1 second */
363 KeQueryTickCount(&TickCount);
364 Timeout.QuadPart = TickCount.QuadPart / (10000000 / KeQueryTimeIncrement());
365
366 /* Check if the timeout is small enough */
367 if (Timeout.QuadPart < 60 )
368 {
369 /* Show the prompt */
371 SAC_RESTART_PROMPT : SAC_SHUTDOWN_PROMPT,
372 TRUE);
373
374 /* Do the wait */
376 Timeout.QuadPart = -10000000 * (60 - Timeout.LowPart);
378 }
379
380 /* Do a shutdown or a reboot, based on the request */
382
383 /* Check if anyone in the command channel already allocated this */
384 if (!GlobalBuffer)
385 {
386 /* Allocate it */
388 if (!GlobalBuffer)
389 {
390 /* We need the global buffer, bail out without it*/
391 SacPutSimpleMessage(SAC_OUT_OF_MEMORY_PROMPT);
392 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoRebootCommand: Exiting (1).\n");
393 return;
394 }
395
396 /* Set the size of the buffer */
398 }
399
400 /* We came back from a reboot, this doesn't make sense, tell the user */
401 SacPutSimpleMessage(Reboot ? SAC_RESTART_FAIL_PROMPT : SAC_SHUTDOWN_FAIL_PROMPT);
402 swprintf(GlobalBuffer, GetMessage(SAC_FAIL_PROMPT), Status);
404 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoRebootCommand: Exiting.\n");
405}
@ Reboot
Definition: bl.h:891
PVOID GlobalBuffer
Definition: concmd.c:17
ULONG GlobalBufferSize
Definition: concmd.c:18
BOOLEAN NTAPI ConMgrSimpleEventMessage(IN ULONG MessageIndex, IN BOOLEAN LockHeld)
Definition: conmgr.c:252
VOID NTAPI SacPutString(IN PWCHAR String)
Definition: conmgr.c:41
#define swprintf
Definition: precomp.h:40
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define PAGE_SIZE
Definition: env_spec_w32.h:49
@ ShutdownReboot
Definition: extypes.h:177
@ ShutdownPowerOff
Definition: extypes.h:178
@ SynchronizationEvent
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
static ULONG Timeout
Definition: ping.c:61
#define KeQueryTickCount(CurrentCount)
Definition: ke.h:43
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by ConMgrWorkerProcessEvents().

◆ DoSetIpAddressCommand()

VOID NTAPI DoSetIpAddressCommand ( IN PCHAR  IpString)

Definition at line 564 of file concmd.c.

565{
566 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
567}

Referenced by ConMgrProcessInputLine().

◆ DoSetTimeCommand()

VOID NTAPI DoSetTimeCommand ( IN PCHAR  InputTime)

Definition at line 431 of file concmd.c.

432{
433 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
434}

Referenced by ConMgrProcessInputLine().

◆ DoTlistCommand()

VOID NTAPI DoTlistCommand ( VOID  )

Definition at line 571 of file concmd.c.

572{
574 PVOID NewGlobalBuffer;
575 ULONG Size;
576 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Entering.\n");
577
578 /* Check if a global buffer already exists */
579 if (!GlobalBuffer)
580 {
581 /* It doesn't, allocate one */
583 if (GlobalBuffer)
584 {
585 /* Remember its current size */
586 GlobalBufferSize = 4096;
587 }
588 else
589 {
590 /* Out of memory, bail out */
592 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Exiting.\n");
593 return;
594 }
595 }
596
597 /* Loop as long as the buffer is too small */
598 while (TRUE)
599 {
600 /* Get the process list */
602 if ((Status != STATUS_NO_MEMORY) &&
604 {
605 /* It fits! Bail out */
606 break;
607 }
608
609 /* We need a new bigger buffer */
610 NewGlobalBuffer = SacAllocatePool(GlobalBufferSize + 4096,
612 if (!NewGlobalBuffer)
613 {
614 /* Out of memory, bail out */
616 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Exiting.\n");
617 return;
618 }
619
620 /* Free the old one, update state */
622 GlobalBufferSize += 4096;
623 GlobalBuffer = NewGlobalBuffer;
624 }
625
626 /* Did we get here because we have the whole list? */
627 if (!NT_SUCCESS(Status))
628 {
629 /* Nope, print out a failure message */
633 }
634 else
635 {
636 /* Yep, print out the list */
638 }
639
640 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC DoTlistCommand: Exiting.\n");
641}
VOID NTAPI PrintTListInfo(IN PSAC_SYSTEM_INFORMATION SacInfo)
Definition: concmd.c:312
NTSTATUS NTAPI GetTListInfo(IN PSAC_SYSTEM_INFORMATION SacInfo, IN ULONG InputSize, OUT PULONG TotalSize)
Definition: concmd.c:76
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by ConMgrProcessInputLine().

◆ FreeDeviceData()

VOID NTAPI FreeDeviceData ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 147 of file data.c.

148{
149 PSAC_DEVICE_EXTENSION DeviceExtension;
152 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Entering.\n");
153
154 /* Get the device extension and see how far we had gotten */
155 DeviceExtension = (PSAC_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
156 if (!(GlobalDataInitialized) || !(DeviceExtension->Initialized))
157 {
158 goto Exit;
159 }
160
161 /* Attempt to rundown while holding the lock */
162 KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
163 while (DeviceExtension->RundownInProgress)
164 {
165 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Waiting....\n");
166
167 /* Initiate and wait for rundown */
169 KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
170 Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
171 Executive,
173 FALSE,
174 NULL);
176
177 /* Re-acquire the lock and check if rundown is done */
178 KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
179 }
180
181 /* Now set the rundown flag while we cancel the timer */
182 DeviceExtension->RundownInProgress = TRUE;
183 KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
184
185 /* Cancel it */
186 KeCancelTimer(&DeviceExtension->Timer);
187
188 /* Reacquire the lock*/
189 KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
190 DeviceExtension->RundownInProgress = FALSE;
191
192 /* Now do the last rundown attempt, we should be the only ones here */
194 KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
195 KeSetEvent(&DeviceExtension->Event, DeviceExtension->PriorityBoost, 0);
196 Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
197 Executive,
199 FALSE,
200 NULL);
202
203 /* We no longer care about shutdown */
205
206 /* We are now fully uninitialized */
207 KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
208 DeviceExtension->Initialized = FALSE;
209 KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
210Exit:
211 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Exiting.\n");
212}
BOOLEAN GlobalDataInitialized
Definition: data.c:17
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
if(dx< 0)
Definition: linetemp.h:194
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1725
struct _SAC_DEVICE_EXTENSION * PSAC_DEVICE_EXTENSION
static void Exit(void)
Definition: sock.c:1330
BOOLEAN Initialized
Definition: sacdrv.h:509
KSPIN_LOCK Lock
Definition: sacdrv.h:515
BOOLEAN RundownInProgress
Definition: sacdrv.h:512
KPRIORITY PriorityBoost
Definition: sacdrv.h:513
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:792

Referenced by UnloadHandler().

◆ FreeGlobalData()

VOID NTAPI FreeGlobalData ( VOID  )

Definition at line 100 of file data.c.

101{
103 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeGlobalData: Entering.\n");
104
105 /* Only free if we allocated */
107 {
108 /* Close the SAC event if we had created one */
109 if (SACEvent)
110 {
112 SACEvent = NULL;
113 }
114
115 /* Destroy the cached messages */
117
118 /* Delete the Win32 symbolic link */
119 RtlInitUnicodeString(&SymbolicLink, L"\\DosDevices\\SAC");
121
122 /* Tear down connections */
124
125 /* Tear down channels */
127
128 /* Free the serial port buffer */
130
131 /* Free cached machine information */
133
134 /* Cleanup the custom heap allocator */
136
137 /* We're back to a virgin state */
139 }
140
141 /* All done */
142 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeGlobalData: Exiting.\n");
143}
NTSTATUS NTAPI ChanMgrShutdown(VOID)
Definition: chanmgr.c:144
NTSTATUS NTAPI ConMgrShutdown(VOID)
Definition: conmgr.c:372
static const WCHAR SymbolicLink[]
Definition: interface.c:31
HANDLE SACEventHandle
Definition: data.c:22
PKEVENT SACEvent
Definition: data.c:21
VOID NTAPI FreeMemoryManagement(VOID)
Definition: memory.c:62
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define L(x)
Definition: ntvdm.h:50
VOID NTAPI FreeMachineInformation(VOID)
Definition: util.c:1156
PCHAR SerialPortBuffer
Definition: util.c:35
NTSTATUS NTAPI TearDownGlobalMessageTable(VOID)
Definition: util.c:379

Referenced by DriverEntry(), and UnloadHandler().

◆ FreeMachineInformation()

◆ FreeMemoryManagement()

VOID NTAPI FreeMemoryManagement ( VOID  )

Definition at line 62 of file memory.c.

63{
66 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
67
68 /* Acquire the memory lock while freeing the list(s) */
70 while (GlobalMemoryList)
71 {
73
74 /* While outside of the lock, save the next list and free this one */
76 Next = GlobalMemoryList->Next;
78
79 /* Reacquire the lock and see if there was another list to free */
81 GlobalMemoryList = Next;
82 }
83
84 /* All done */
86 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting\n");
87}
KSPIN_LOCK MemoryLock
Definition: memory.c:16
PSAC_MEMORY_LIST GlobalMemoryList
Definition: memory.c:17
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define GLOBAL_MEMORY_SIGNATURE
Definition: sacdrv.h:145
ULONG Signature
Definition: sacdrv.h:199
struct _SAC_MEMORY_LIST * Next
Definition: sacdrv.h:202

Referenced by FreeGlobalData().

◆ GetCommandConsoleLaunchingPermission()

NTSTATUS NTAPI GetCommandConsoleLaunchingPermission ( OUT PBOOLEAN  Permission)

Definition at line 981 of file util.c.

982{
985
986 /* Assume success and read the key */
987 *Permission = TRUE;
988 Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacdrv",
989 L"DisableCmdSessions",
990 &Dummy);
992 {
993 /* The default is success */
995 }
996 else
997 {
998 /* Only if the key is present and set, do we disable permission */
999 if (NT_SUCCESS(Status)) *Permission = FALSE;
1000 }
1001
1002 /* Return status */
1003 return Status;
1004}
NTSTATUS NTAPI GetRegistryValueBuffer(IN PCWSTR KeyName, IN PWCHAR ValueName, IN PKEY_VALUE_PARTIAL_INFORMATION *Buffer)
Definition: util.c:392
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

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}
ULONG GlobalMessageTableCount
Definition: util.c:32
PSAC_MESSAGE_ENTRY GlobalMessageTable
Definition: util.c:31
Definition: sacdrv.h:206
ULONG Index
Definition: sacdrv.h:207
PWCHAR Buffer
Definition: sacdrv.h:208

◆ GetMessageLineCount()

ULONG NTAPI GetMessageLineCount ( IN ULONG  MessageIndex)

Definition at line 1233 of file util.c.

1234{
1235 ULONG LineCount = 0;
1236 PWCHAR Buffer;
1237
1238 /* Get the message buffer */
1239 Buffer = GetMessage(MessageIndex);
1240 if (Buffer)
1241 {
1242 /* Scan it looking for new lines, and increment the count each time */
1243 while (*Buffer) if (*Buffer++ == L'\n') ++LineCount;
1244 }
1245
1246 /* Return the line count */
1247 return LineCount;
1248}

Referenced by PrintHelpMessage().

◆ ImposeSacCmdServiceStartTypePolicy()

NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy ( VOID  )

Definition at line 1008 of file util.c.

1009{
1012 PULONG Data;
1013
1014 /* Read the service start type*/
1015 Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1016 L"Start",
1017 &Buffer);
1018 if (!NT_SUCCESS(Status)) return Status;
1019
1020 /* If there's no start type, fail, as this is unusual */
1021 if (!Buffer) return STATUS_UNSUCCESSFUL;
1022
1023 /* Read the value */
1026 if (!NT_SUCCESS(Status)) return Status;
1027
1028 /* Check what the current start type is */
1029 switch (*Data)
1030 {
1031 /* It's boot, system, or disabled */
1032 case 1:
1033 case 2:
1034 case 4:
1035 /* Leave it as is */
1036 return Status;
1037
1038 case 3:
1039
1040 /* It's set to automatic, set it to system instead */
1041 *Data = 2;
1042 Status = SetRegistryValue(L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\sacsvr",
1043 L"Start",
1044 REG_DWORD,
1045 Data,
1046 sizeof(ULONG));
1047 if (!NT_SUCCESS(Status))
1048 {
1049 SAC_DBG(SAC_DBG_INIT, "SAC ImposeSacCmdServiceStartTypePolicy: Failed SetRegistryValue: %X\n", Status);
1050 }
1051 break;
1052
1053 default:
1054 ASSERT(FALSE);
1055 }
1056
1057 return Status;
1058}
NTSTATUS NTAPI CopyRegistryValueData(IN PVOID *Buffer, IN PKEY_VALUE_PARTIAL_INFORMATION PartialInfo)
Definition: util.c:514
NTSTATUS NTAPI SetRegistryValue(IN PCWSTR KeyName, IN PWCHAR ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: util.c:465
#define REG_DWORD
Definition: sdbapi.c:596
uint32_t * PULONG
Definition: typedefs.h:59

Referenced by InitializeGlobalData().

◆ InitializeCmdEventInfo()

VOID NTAPI InitializeCmdEventInfo ( VOID  )

Definition at line 1062 of file util.c.

1063{
1064 /* Check if we were already initialized */
1066 {
1067 /* Full state expected */
1071
1072 /* Dereference each wait object in turn */
1074 {
1076 }
1077
1079 {
1081 }
1082
1084 {
1086 }
1087 }
1088
1089 /* Claer everything */
1097
1098 /* Reset state */
1100}
PKEVENT RequestSacCmdFailureEventWaitObjectBody
Definition: util.c:27
PVOID RequestSacCmdSuccessEventObjectBody
Definition: util.c:24
PFILE_OBJECT ServiceProcessFileObject
Definition: util.c:28
PVOID RequestSacCmdEventObjectBody
Definition: util.c:22
PVOID RequestSacCmdFailureEventObjectBody
Definition: util.c:26
PKEVENT RequestSacCmdSuccessEventWaitObjectBody
Definition: util.c:25
BOOLEAN HaveUserModeServiceCmdEventInfo
Definition: util.c:29
PKEVENT RequestSacCmdEventWaitObjectBody
Definition: util.c:23
#define ObDereferenceObject
Definition: obfuncs.h:203

Referenced by InitializeGlobalData().

◆ InitializeDeviceData()

BOOLEAN NTAPI InitializeDeviceData ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 216 of file data.c.

217{
218 PSAC_DEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
219 BOOLEAN EnableData;
220 ULONG PriorityValue;
224 PAGED_CODE();
225 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering.\n");
226
227 /* If we already did this, bail out */
228 if (DeviceExtension->Initialized) goto SuccessExit;
229
230 /* Setup the DO flags */
231 DeviceObject->Flags |= DO_DIRECT_IO;
232 DeviceObject->StackSize = 16;
233
234 /* Setup the device extension */
235 DeviceExtension->DeviceObject = DeviceObject;
236 DeviceExtension->PriorityBoost = IO_SERIAL_INCREMENT;
237 DeviceExtension->PriorityFail = 0;
238 DeviceExtension->RundownInProgress = 0;
239
240 /* Initialize locks, events, timers, DPCs, etc... */
241 KeInitializeTimer(&DeviceExtension->Timer);
242 KeInitializeDpc(&DeviceExtension->Dpc, TimerDpcRoutine, DeviceExtension);
243 KeInitializeSpinLock(&DeviceExtension->Lock);
245 InitializeListHead(&DeviceExtension->List);
246
247 /* Attempt to enable HDL support */
248 EnableData = TRUE;
250 &EnableData,
251 sizeof(EnableData),
252 NULL,
253 NULL);
254 if (!NT_SUCCESS(Status))
255 {
256 /* Bail out if we couldn't even get this far */
257 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (1) with status FALSE\n");
258 return FALSE;
259 }
260
261 /* Remember which process we started in */
262 DeviceExtension->Process = IoGetCurrentProcess();
263
264 /* Protect the device against non-admins */
266 if (!NT_SUCCESS(Status))
267 {
268 /* Write down why we failed */
269 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (2) with status FALSE\n");
270
271 /* Disable the HDL terminal on failure */
272 EnableData = FALSE;
274 &EnableData,
275 sizeof(EnableData),
276 NULL,
277 NULL);
278 if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
279
280 /* Bail out */
281 return FALSE;
282 }
283
284 /* Create the worker thread */
287 NULL,
288 NULL,
289 NULL,
291 DeviceExtension);
292 if (!NT_SUCCESS(Status))
293 {
294 /* Write down why we failed */
295 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (3) with status FALSE\n");
296
297 /* Disable the HDL terminal on failure */
298 EnableData = FALSE;
300 &EnableData,
301 sizeof(EnableData),
302 NULL,
303 NULL);
304 if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
305
306 /* Bail out */
307 return FALSE;
308 }
309
310 /* Set the priority of our thread to highest */
311 PriorityValue = HIGH_PRIORITY;
314 &PriorityValue,
315 sizeof(PriorityValue));
316 if (!NT_SUCCESS(Status))
317 {
318 /* For debugging, write down why we failed */
319 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (6) with status FALSE\n");
320 DeviceExtension->PriorityFail = TRUE;
321
322 /* Initialize rundown and wait for the thread to do it */
324 KeSetEvent(&DeviceExtension->Event, DeviceExtension->PriorityBoost, FALSE);
325 Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
326 Executive,
328 FALSE,
329 NULL);
331
332 /* Disable the HDL terminal on failure */
333 EnableData = FALSE;
335 &EnableData,
336 sizeof(EnableData),
337 NULL,
338 NULL);
339 if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
340
341 /* Bail out */
342 return FALSE;
343 }
344
345 /* The first "packet" is the machine information in XML... */
347 if (NT_SUCCESS(Status))
348 {
349 /* Go ahead and send it */
350 UTF8EncodeAndSend(L"<?xml version=\"1.0\"?>\r\n");
352
353 /* Free the temporary buffer */
355 }
356
357 /* Finally, initialize the I/O Manager */
359 if (!NT_SUCCESS(Status)) return FALSE;
360
361 /* Set the timer. Once this is done, the device is initialized */
362 DueTime.QuadPart = -4000;
363 KeSetTimerEx(&DeviceExtension->Timer, DueTime, 4, &DeviceExtension->Dpc);
364 DeviceExtension->Initialized = TRUE;
365
366SuccessExit:
367 /* Success path -- everything worked */
368 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with status TRUE\n");
369 return TRUE;
370}
#define PAGED_CODE()
NTSTATUS NTAPI ConMgrInitialize(VOID)
Definition: conmgr.c:163
@ ThreadPriority
Definition: compat.h:937
static const WCHAR Message[]
Definition: register.c:74
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
NTSTATUS NTAPI CreateDeviceSecurityDescriptor(IN PDEVICE_OBJECT *DeviceObject)
Definition: data.c:52
VOID NTAPI WorkerThreadStartUp(IN PVOID Context)
Definition: data.c:36
VOID NTAPI TimerDpcRoutine(IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dispatch.c:61
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
@ HeadlessCmdEnableTerminal
Definition: hdl.h:129
#define HIGH_PRIORITY
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
PEPROCESS NTAPI IoGetCurrentProcess(VOID)
Definition: util.c:139
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
NTSTATUS NTAPI UTF8EncodeAndSend(IN PWCHAR String)
Definition: util.c:165
NTSTATUS NTAPI TranslateMachineInformationXML(IN PWCHAR *Buffer, IN PWCHAR ExtraData)
Definition: util.c:541
BOOLEAN PriorityFail
Definition: sacdrv.h:511
LIST_ENTRY List
Definition: sacdrv.h:522
HANDLE WorkerThreadHandle
Definition: sacdrv.h:518
PEPROCESS Process
Definition: sacdrv.h:514
PDEVICE_OBJECT DeviceObject
Definition: sacdrv.h:508
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
#define IO_SERIAL_INCREMENT
Definition: iotypes.h:607

Referenced by DriverEntry().

◆ InitializeGlobalData()

BOOLEAN NTAPI InitializeGlobalData ( IN PUNICODE_STRING  RegistryPath,
IN PDRIVER_OBJECT  DriverObject 
)

Definition at line 374 of file data.c.

376{
378 UNICODE_STRING LinkName;
380 UNICODE_STRING EventName;
381 PAGED_CODE();
382 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering.\n");
383
384 /* If we already did this, bail out */
385 if (GlobalDataInitialized) goto SuccessExit;
386
387 /* Setup the symbolic link for Win32 support */
388 RtlInitUnicodeString(&LinkName, L"\\DosDevices\\SAC");
389 RtlInitUnicodeString(&DeviceName, L"\\Device\\SAC");
391 if (!NT_SUCCESS(Status)) return FALSE;
392
393 /* Initialize the internal heap manager */
395 {
396 IoDeleteSymbolicLink(&LinkName);
397 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with status FALSE\n");
398 return FALSE;
399 }
400
401 /* Preload the messages in memory */
403 if (!NT_SUCCESS(Status))
404 {
405 IoDeleteSymbolicLink(&LinkName);
406 SAC_DBG(SAC_DBG_INIT, "unable to pre-load message table: %X\n", Status);
407 return FALSE;
408 }
409
410 /* Check if the administrator enabled this */
412 if (!NT_SUCCESS(Status))
413 {
414 /* Is it enabled? */
416 {
417 /* Set the service start type to the correct value */
419 if (!NT_SUCCESS(Status))
420 {
421 SAC_DBG(SAC_DBG_INIT, "failed ImposeSacCmdServiceStartTypePolicy: %X\n", Status);
422 }
423 }
424
425 /* We're going to keep going with the default */
426 SAC_DBG(SAC_DBG_INIT, "failed GetCommandConsoleLaunchingPermission: %X\n", Status);
427 }
428
429 /* Allocate the UTF-8 Conversion Buffer */
432 {
433 /* Handle failure case */
435 IoDeleteSymbolicLink(&LinkName);
436 SAC_DBG(SAC_DBG_INIT, "unable to allocate memory for UTF8 translation\n");
437 return FALSE;
438 }
439
440 /* Initialize the channel manager */
442 if (!NT_SUCCESS(Status))
443 {
444 /* Handle failure case */
447 IoDeleteSymbolicLink(&LinkName);
448 SAC_DBG(SAC_DBG_INIT, "Failed to create SAC Channel\n");
449 return FALSE;
450 }
451
452 /* Allocate the serial port buffer */
454 if (!SerialPortBuffer)
455 {
456 /* Handle failure case */
459 IoDeleteSymbolicLink(&LinkName);
460 SAC_DBG(SAC_DBG_INIT, "Failed to allocate Serial Port Buffer\n");
461 return FALSE;
462 }
463
464 /* Zero it out */
466
467 /* Initialize command events. After this, driver data is good to go */
471 ProcessingType = 0;
472 IoctlSubmitted = 0;
473
474 /* Create the SAC event */
475 RtlInitUnicodeString(&EventName, L"\\SACEvent");
477 if (!SACEvent)
478 {
479 /* Handle failure case */
482 IoDeleteSymbolicLink(&LinkName);
483 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with event NULL\n");
484 return FALSE;
485 }
486
487 /* Cache machine information */
489
490 /* Register it */
492 if (!NT_SUCCESS(Status))
493 {
494 /* Handle failure case */
497 IoDeleteSymbolicLink(&LinkName);
498 SAC_DBG(SAC_DBG_INIT, "Failed to register blue screen machine info\n");
499 return FALSE;
500 }
501
502SuccessExit:
503 /* Success path -- everything worked */
504 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with status TRUE\n");
505 return TRUE;
506}
NTSTATUS NTAPI ChanMgrInitialize(VOID)
Definition: chanmgr.c:118
BOOLEAN IoctlSubmitted
Definition: data.c:19
ULONG ProcessingType
Definition: data.c:20
BOOLEAN CommandConsoleLaunchingEnabled
Definition: data.c:16
KMUTEX SACCMDEventInfoMutex
Definition: data.c:18
BOOLEAN NTAPI InitializeMemoryManagement(VOID)
Definition: memory.c:23
PKEVENT NTAPI IoCreateSynchronizationEvent(IN PUNICODE_STRING EventName, IN PHANDLE EventHandle)
Definition: ioevent.c:82
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
Definition: mutex.c:67
NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy(VOID)
Definition: util.c:1008
ULONG Utf8ConversionBufferSize
Definition: util.c:18
NTSTATUS NTAPI PreloadGlobalMessageTable(IN PVOID ImageBase)
Definition: util.c:280
NTSTATUS NTAPI RegisterBlueScreenMachineInformation(VOID)
Definition: util.c:1104
NTSTATUS NTAPI GetCommandConsoleLaunchingPermission(OUT PBOOLEAN Permission)
Definition: util.c:981
#define SAC_SERIAL_PORT_BUFFER_SIZE
Definition: sacdrv.h:155
VOID NTAPI InitializeMachineInformation(VOID)
Definition: util.c:692
VOID NTAPI InitializeCmdEventInfo(VOID)
Definition: util.c:1062
PCHAR Utf8ConversionBuffer
Definition: util.c:17
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213

Referenced by DriverEntry().

◆ InitializeMachineInformation()

VOID NTAPI InitializeMachineInformation ( VOID  )

Definition at line 692 of file util.c.

693{
695 PWCHAR GuidString, MajorVersion, ServicePack, BuildNumber, MessageBuffer;
696 PWCHAR ProductType;
697 ULONG SuiteTypeMessage;
698 BOOLEAN SetupInProgress = FALSE;
699 GUID SystemGuid;
700 SIZE_T RealSize, Size, OutputSize;
702 RTL_OSVERSIONINFOEXW VersionInformation;
703 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Entering.\n");
704
705 /* Don't do anything if we already queried this */
707 {
708 SAC_DBG(SAC_DBG_MACHINE, "SAC Initialize Machine Information:: MachineInformationBuffer already initialized.\n");
709 return;
710 }
711
712 /* Allocate the machine information */
716 {
717 goto Fail;
718 }
719
720 /* Zero it out for now */
722
723 /* Query OS version */
724 RtlZeroMemory(&VersionInformation, sizeof(VersionInformation));
725 VersionInformation.dwOSVersionInfoSize = sizeof(VersionInformation);
726 Status = RtlGetVersion((PRTL_OSVERSIONINFOW)&VersionInformation);
727 if (!NT_SUCCESS(Status))
728 {
729 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (2).\n");
730 goto Fail;
731 }
732
733 /* Check if setup is in progress */
734 Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\Setup",
735 L"SystemSetupInProgress",
736 &PartialInfo);
737 if (NT_SUCCESS(Status))
738 {
739 /* The key is there, is the value set? */
740 if (*(PULONG)PartialInfo->Data) SetupInProgress = TRUE;
741 SacFreePool(PartialInfo);
742 if (SetupInProgress)
743 {
744 /* Yes, so we'll use a special hostname to identify this */
745 MessageBuffer = GetMessage(SAC_UNINITIALIZED_MSG);
746 Size = wcslen(MessageBuffer);
747 ASSERT(Size > 0);
748 RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
749
750 /* Make room for it and copy it in there */
754 {
755 wcscpy(MachineInformation->MachineName, MessageBuffer);
756 }
757 }
758 }
759
760 /* If we are not in setup mode, or if we failed to check... */
761 if (!SetupInProgress)
762 {
763 /* Query the computer name */
764 Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
765 L"CurrentControlSet\\Control\\"
766 L"ComputerName\\ComputerName",
767 L"ComputerName",
768 &PartialInfo);
769 if (!NT_SUCCESS(Status))
770 {
771 /* It's not critical, but we won't have it */
772 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get machine name.\n");
773 }
774 else
775 {
776 /* We have the name, copy it from the registry */
779 PartialInfo);
780 SacFreePool(PartialInfo);
781 if (!NT_SUCCESS(Status))
782 {
783 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (20).\n");
784 goto Fail;
785 }
786 }
787 }
788
789 /* Next step, try to get the machine GUID */
790 RtlZeroMemory(&SystemGuid, sizeof(SystemGuid));
791 OutputSize = sizeof(SystemGuid);
793 NULL,
794 0,
795 &SystemGuid,
796 &OutputSize);
797 if (!NT_SUCCESS(Status))
798 {
799 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Failed to get Machine GUID.\n");
800 }
801 else
802 {
803 /* We have it -- make room for it */
805 if (!GuidString)
806 {
807 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (31).\n");
808 goto Fail;
809 }
810
811 /* Build the string with the GUID in it, and save the ppointer to it */
813 L"%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
814 SystemGuid.Data1,
815 SystemGuid.Data2,
816 SystemGuid.Data3,
817 SystemGuid.Data4[0],
818 SystemGuid.Data4[1],
819 SystemGuid.Data4[2],
820 SystemGuid.Data4[3],
821 SystemGuid.Data4[4],
822 SystemGuid.Data4[5],
823 SystemGuid.Data4[6],
824 SystemGuid.Data4[7]);
826 }
827
828 /* Next, query the processor architecture */
829 Status = GetRegistryValueBuffer(L"\\Registry\\Machine\\System\\"
830 L"CurrentControlSet\\Control\\"
831 L"Session Manager\\Environment",
832 L"PROCESSOR_ARCHITECTURE",
833 &PartialInfo);
834 if (!NT_SUCCESS(Status))
835 {
836 /* It's not critical, but we won't have it */
837 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
838 }
839 else
840 {
841 /* We have it! Copy the value from the registry */
843 ProcessorArchitecture,
844 PartialInfo);
845 SacFreePool(PartialInfo);
846 if (!NT_SUCCESS(Status))
847 {
848 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (30).\n");
849 goto Fail;
850 }
851 }
852
853 /* Now allocate a buffer for the OS version number */
855 if (!MajorVersion)
856 {
857 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (50).\n");
858 goto Fail;
859 }
860
861 /* Build the buffer and set a pointer to it */
863 L"%d.%d",
864 VersionInformation.dwMajorVersion,
865 VersionInformation.dwMinorVersion);
867
868 /* Now allocate a buffer for the OS build number */
870 if (!BuildNumber)
871 {
872 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC InitializeMachineInformation: Exiting (60).\n");
873 goto Fail;
874 }
875
876 /* Build the buffer and set a pointer to it */
877 swprintf(BuildNumber, L"%d", VersionInformation.dwBuildNumber);
879
880 /* Now check what kind of SKU this is */
882 {
883 SuiteTypeMessage = SAC_DATACENTER_SUITE_MSG;
884 }
885 else if (ExVerifySuite(EmbeddedNT))
886 {
887 SuiteTypeMessage = SAC_EMBEDDED_SUITE_MSG;
888 }
889 else if (ExVerifySuite(Enterprise))
890 {
891 SuiteTypeMessage = SAC_ENTERPRISE_SUITE_MSG;
892 }
893 else
894 {
895 /* Unknown or perhaps a client SKU */
896 SuiteTypeMessage = SAC_NO_SUITE_MSG;
897 }
898
899 /* Get the string that corresponds to the SKU type */
900 MessageBuffer = GetMessage(SuiteTypeMessage);
901 if (!MessageBuffer)
902 {
903 /* We won't have it, but this isn't critical */
904 SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed to get product type.\n");
905 }
906 else
907 {
908 /* Calculate the size we need to hold the string */
909 Size = wcslen(MessageBuffer);
910 ASSERT(Size > 0);
911 RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
912
913 /* Allocate a buffer for it */
914 ProductType = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
915 if (!ProductType)
916 {
917 SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed product type memory allocation.\n");
918 goto Fail;
919 }
920
921 /* Copy the string and set the pointer */
922 RtlCopyMemory(ProductType, MessageBuffer, RealSize);
923 MachineInformation->ProductType = ProductType;
924 }
925
926 /* Check if this is a SP version or RTM version */
927 if (VersionInformation.wServicePackMajor)
928 {
929 /* This is a service pack, allocate a buffer for the version */
930 ServicePack = SacAllocatePool(0x18, GLOBAL_BLOCK_TAG);
931 if (ServicePack)
932 {
933 /* Build the buffer and set a pointer to it */
934 swprintf(ServicePack,
935 L"%d.%d",
936 VersionInformation.wServicePackMajor,
937 VersionInformation.wServicePackMinor);
938 MachineInformation->ServicePack = ServicePack;
939
940 /* We've collected all the machine info and are done! */
941 return;
942 }
943
944 /* This is the failure path */
945 SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
946 }
947 else
948 {
949 /* Get a generic string that indicates there's no service pack */
950 MessageBuffer = GetMessage(SAC_NO_DATA_MSG);
951 Size = wcslen(MessageBuffer);
952 ASSERT(Size > 0);
953 RealSize = Size * sizeof(WCHAR) + sizeof(UNICODE_NULL);
954
955 /* Allocate memory for the "no service pack" string */
956 ServicePack = SacAllocatePool(RealSize, GLOBAL_BLOCK_TAG);
957 if (ServicePack)
958 {
959 /* Copy the buffer and set a pointer to it */
960 RtlCopyMemory(ServicePack, MessageBuffer, RealSize);
961 MachineInformation->ServicePack = ServicePack;
962
963 /* We've collected all the machine info and are done! */
964 return;
965 }
966
967 SAC_DBG(SAC_DBG_INIT, "SAC InitializeMachineInformation: Failed service pack memory allocation.\n");
968 }
969
970Fail:
971 /* In the failure path, always cleanup the machine information buffer */
973 {
975 }
976 SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC Initialize Machine Information : Exiting with error.\n");
977}
NTSTATUS NTAPI RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
Definition: version.c:158
int Fail
Definition: ehthrow.cxx:24
ULONG BuildNumber
Definition: ros_glue.cpp:6
ULONG MajorVersion
Definition: ros_glue.cpp:4
@ HeadlessCmdQueryGUID
Definition: hdl.h:149
static PWSTR GuidString
Definition: apphelp.c:93
BOOLEAN NTAPI ExVerifySuite(SUITE_TYPE SuiteType)
Definition: sysinfo.c:377
#define SAC_DBG_MACHINE
Definition: sacdrv.h:36
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_In_ DWORD _Out_ PDWORD _In_opt_ PCSTR MachineName
Definition: setupapi.h:1293
ULONG dwMajorVersion
Definition: rtltypes.h:270
ULONG dwMinorVersion
Definition: rtltypes.h:271
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:269
USHORT wServicePackMinor
Definition: rtltypes.h:276
ULONG dwBuildNumber
Definition: rtltypes.h:272
USHORT wServicePackMajor
Definition: rtltypes.h:275
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
@ DataCenter
Definition: extypes.h:27
@ Enterprise
Definition: extypes.h:21
@ EmbeddedNT
Definition: extypes.h:26

Referenced by InitializeGlobalData().

◆ InitializeMemoryManagement()

BOOLEAN NTAPI InitializeMemoryManagement ( VOID  )

Definition at line 23 of file memory.c.

24{
26 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering\n");
27
28 /* Allocate a nonpaged heap for us to use */
34 {
35 /* Initialize a lock for it */
37
38 /* Initialize the head of the list */
43
44 /* Initialize the first free entry */
46 Entry->Signature = LOCAL_MEMORY_SIGNATURE;
47 Entry->Tag = FREE_POOL_TAG;
49
50 /* All done */
51 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with TRUE.\n");
52 return TRUE;
53 }
54
55 /* No pool available to manage our heap */
56 SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting with FALSE. No pool.\n");
57 return FALSE;
58}
#define NonPagedPool
Definition: env_spec_w32.h:307
PVOID NTAPI ExAllocatePoolWithTagPriority(IN POOL_TYPE PoolType, IN SIZE_T NumberOfBytes, IN ULONG Tag, IN EX_POOL_PRIORITY Priority)
Definition: expool.c:2960
struct _SAC_MEMORY_LIST SAC_MEMORY_LIST
#define SAC_MEMORY_LIST_SIZE
Definition: sacdrv.h:150
struct _SAC_MEMORY_ENTRY SAC_MEMORY_ENTRY
#define FREE_POOL_TAG
Definition: sacdrv.h:141
#define LOCAL_MEMORY_SIGNATURE
Definition: sacdrv.h:144
struct _SAC_MEMORY_ENTRY * PSAC_MEMORY_ENTRY
#define INITIAL_BLOCK_TAG
Definition: sacdrv.h:139
base of all file and directory entries
Definition: entries.h:83
Definition: sacdrv.h:192
PSAC_MEMORY_ENTRY LocalDescriptor
Definition: sacdrv.h:200