ReactOS  0.4.14-dev-608-gd495a4f
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 137 of file sacdrv.h.

◆ CHANNEL_BLOCK_TAG

#define CHANNEL_BLOCK_TAG   'CpcR'

Definition at line 142 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); \
Status = STATUS_SUCCESS; \
} \
else \
{ \
Status = STATUS_UNSUCCESSFUL; \
} \
}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
return STATUS_SUCCESS
Definition: btrfs.c:2938

Definition at line 113 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; \
} \
}
BOOLEAN NTAPI VerifyEventWaitable(IN HANDLE Handle, OUT PVOID *WaitObject, OUT PVOID *ActualWaitObject)
Definition: util.c:1169
static IUnknown Object
Definition: main.c:512
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348

Definition at line 70 of file sacdrv.h.

◆ ChannelLockAttributes

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

Definition at line 1335 of file sacdrv.h.

◆ ChannelLockCreates

#define ChannelLockCreates ( )    SacAcquireLock(&ChannelCreateLock);

Definition at line 1329 of file sacdrv.h.

◆ ChannelLockIBuffer

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

Definition at line 1333 of file sacdrv.h.

◆ ChannelLockOBuffer

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

Definition at line 1331 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); \
Status = STATUS_SUCCESS; \
} \
else \
{ \
Status = STATUS_UNSUCCESSFUL; \
} \
}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define EVENT_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2938

Definition at line 98 of file sacdrv.h.

◆ ChannelSlotLock

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

Definition at line 1337 of file sacdrv.h.

◆ ChannelSlotUnlock

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

Definition at line 1338 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; \
} \
}
FORCEINLINE ULONG ChannelGetFlags(IN PSAC_CHANNEL Channel)
Definition: sacdrv.h:1345
smooth NULL
Definition: ftsmooth.c:416
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83

Definition at line 84 of file sacdrv.h.

◆ ChannelUnlockAttributes

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

Definition at line 1336 of file sacdrv.h.

◆ ChannelUnlockCreates

#define ChannelUnlockCreates ( )    SacReleaseLock(&ChannelCreateLock);

Definition at line 1330 of file sacdrv.h.

◆ ChannelUnlockIBuffer

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

Definition at line 1334 of file sacdrv.h.

◆ ChannelUnlockOBuffer

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

Definition at line 1332 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; \
} \
}
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
IN ULONG IN UCHAR Condition
Status
Definition: gdiplustypes.h:24

Definition at line 47 of file sacdrv.h.

◆ FREE_POOL_TAG

#define FREE_POOL_TAG   'FpcR'

Definition at line 140 of file sacdrv.h.

◆ GENERIC_TAG

#define GENERIC_TAG   '?pcR'

Definition at line 136 of file sacdrv.h.

◆ GLOBAL_BLOCK_TAG

#define GLOBAL_BLOCK_TAG   'GpcR'

Definition at line 141 of file sacdrv.h.

◆ GLOBAL_MEMORY_SIGNATURE

#define GLOBAL_MEMORY_SIGNATURE   'DAEH'

Definition at line 144 of file sacdrv.h.

◆ INITIAL_BLOCK_TAG

#define INITIAL_BLOCK_TAG   'IpcR'

Definition at line 138 of file sacdrv.h.

◆ LOCAL_MEMORY_SIGNATURE

#define LOCAL_MEMORY_SIGNATURE   'SSEL'

Definition at line 143 of file sacdrv.h.

◆ MAX_UTF8_ENCODE_BLOCK_LENGTH

#define MAX_UTF8_ENCODE_BLOCK_LENGTH   (Utf8ConversionBufferSize / 3 - 1)

Definition at line 159 of file sacdrv.h.

◆ SAC_CELL_FLAG_BLINK

#define SAC_CELL_FLAG_BLINK   1

Definition at line 178 of file sacdrv.h.

◆ SAC_CELL_FLAG_BOLD

#define SAC_CELL_FLAG_BOLD   2

Definition at line 179 of file sacdrv.h.

◆ SAC_CELL_FLAG_INVERTED

#define SAC_CELL_FLAG_INVERTED   4

Definition at line 180 of file sacdrv.h.

◆ SAC_CHANNEL_DESCRIPTION_SIZE

#define SAC_CHANNEL_DESCRIPTION_SIZE   256

Definition at line 152 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_APPLICATION

#define SAC_CHANNEL_FLAG_APPLICATION   0x20

Definition at line 173 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_CLOSE_EVENT

#define SAC_CHANNEL_FLAG_CLOSE_EVENT   0x2

Definition at line 169 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT

#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT   0x4

Definition at line 170 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_INTERNAL

#define SAC_CHANNEL_FLAG_INTERNAL   0x1

Definition at line 168 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_LOCK_EVENT

#define SAC_CHANNEL_FLAG_LOCK_EVENT   0x8

Definition at line 171 of file sacdrv.h.

◆ SAC_CHANNEL_FLAG_REDRAW_EVENT

#define SAC_CHANNEL_FLAG_REDRAW_EVENT   0x10

Definition at line 172 of file sacdrv.h.

◆ SAC_CHANNEL_NAME_SIZE

#define SAC_CHANNEL_NAME_SIZE   64

Definition at line 151 of file sacdrv.h.

◆ SAC_DBG

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

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 153 of file sacdrv.h.

◆ SAC_MAX_MESSAGES

#define SAC_MAX_MESSAGES   200

Definition at line 155 of file sacdrv.h.

◆ SAC_MEMORY_LIST_SIZE

#define SAC_MEMORY_LIST_SIZE   (1 * 1024 * 1024)

Definition at line 149 of file sacdrv.h.

◆ SAC_OBUFFER_SIZE

#define SAC_OBUFFER_SIZE   (2 * 1024)

Definition at line 150 of file sacdrv.h.

◆ SAC_RAW_IBUFFER_SIZE

#define SAC_RAW_IBUFFER_SIZE   0x2000

Definition at line 163 of file sacdrv.h.

◆ SAC_RAW_OBUFFER_SIZE

#define SAC_RAW_OBUFFER_SIZE   0x2000

Definition at line 162 of file sacdrv.h.

◆ SAC_SERIAL_PORT_BUFFER_SIZE

#define SAC_SERIAL_PORT_BUFFER_SIZE   1024

Definition at line 154 of file sacdrv.h.

◆ SAC_VTUTF8_COL_HEIGHT

#define SAC_VTUTF8_COL_HEIGHT   25

Definition at line 157 of file sacdrv.h.

◆ SAC_VTUTF8_COL_WIDTH

#define SAC_VTUTF8_COL_WIDTH   80

Definition at line 156 of file sacdrv.h.

◆ SAC_VTUTF8_IBUFFER_SIZE

#define SAC_VTUTF8_IBUFFER_SIZE   0x2000

Definition at line 161 of file sacdrv.h.

◆ SAC_VTUTF8_OBUFFER_SIZE

#define SAC_VTUTF8_OBUFFER_SIZE   0x2D00

Definition at line 160 of file sacdrv.h.

◆ SAC_VTUTF8_ROW_HEIGHT

#define SAC_VTUTF8_ROW_HEIGHT   24

Definition at line 158 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 139 of file sacdrv.h.

◆ VT_220_BACKTAB

#define VT_220_BACKTAB   L"[0Z"

Definition at line 1509 of file sacdrv.h.

◆ VT_ANSI_BACKTAB_CHAR

#define VT_ANSI_BACKTAB_CHAR   L'Z'

Definition at line 1508 of file sacdrv.h.

◆ VT_ANSI_COMMAND

#define VT_ANSI_COMMAND   L'['

Definition at line 1484 of file sacdrv.h.

◆ VT_ANSI_CUP_CURSOR_CHAR

#define VT_ANSI_CUP_CURSOR_CHAR   L'H'

Definition at line 1514 of file sacdrv.h.

◆ VT_ANSI_CURSOR_DOWN

#define VT_ANSI_CURSOR_DOWN   L"[B"

Definition at line 1490 of file sacdrv.h.

◆ VT_ANSI_CURSOR_DOWN_CHAR

#define VT_ANSI_CURSOR_DOWN_CHAR   L'B'

Definition at line 1489 of file sacdrv.h.

◆ VT_ANSI_CURSOR_LEFT

#define VT_ANSI_CURSOR_LEFT   L"[D"

Definition at line 1496 of file sacdrv.h.

◆ VT_ANSI_CURSOR_LEFT_CHAR

#define VT_ANSI_CURSOR_LEFT_CHAR   L'D'

Definition at line 1495 of file sacdrv.h.

◆ VT_ANSI_CURSOR_RIGHT

#define VT_ANSI_CURSOR_RIGHT   L"[C"

Definition at line 1493 of file sacdrv.h.

◆ VT_ANSI_CURSOR_RIGHT_CHAR

#define VT_ANSI_CURSOR_RIGHT_CHAR   L'C'

Definition at line 1492 of file sacdrv.h.

◆ VT_ANSI_CURSOR_UP

#define VT_ANSI_CURSOR_UP   L"[A"

Definition at line 1487 of file sacdrv.h.

◆ VT_ANSI_CURSOR_UP_CHAR

#define VT_ANSI_CURSOR_UP_CHAR   L'A'

Definition at line 1486 of file sacdrv.h.

◆ VT_ANSI_ERASE_DOWN_SCREEN

#define VT_ANSI_ERASE_DOWN_SCREEN   L"[J"

Definition at line 1504 of file sacdrv.h.

◆ VT_ANSI_ERASE_END_LINE

#define VT_ANSI_ERASE_END_LINE   L"[K"

Definition at line 1499 of file sacdrv.h.

◆ VT_ANSI_ERASE_ENTIRE_LINE

#define VT_ANSI_ERASE_ENTIRE_LINE   L"[2K"

Definition at line 1501 of file sacdrv.h.

◆ VT_ANSI_ERASE_ENTIRE_SCREEN

#define VT_ANSI_ERASE_ENTIRE_SCREEN   L"[2J"

Definition at line 1506 of file sacdrv.h.

◆ VT_ANSI_ERASE_LINE_CHAR

#define VT_ANSI_ERASE_LINE_CHAR   L'K'

Definition at line 1498 of file sacdrv.h.

◆ VT_ANSI_ERASE_SCREEN_CHAR

#define VT_ANSI_ERASE_SCREEN_CHAR   L'J'

Definition at line 1503 of file sacdrv.h.

◆ VT_ANSI_ERASE_START_LINE

#define VT_ANSI_ERASE_START_LINE   L"[1K"

Definition at line 1500 of file sacdrv.h.

◆ VT_ANSI_ERASE_UP_SCREEN

#define VT_ANSI_ERASE_UP_SCREEN   L"[1J"

Definition at line 1505 of file sacdrv.h.

◆ VT_ANSI_ESCAPE

#define VT_ANSI_ESCAPE   L'\x1B'

Definition at line 1483 of file sacdrv.h.

◆ VT_ANSI_HVP_CURSOR_CHAR

#define VT_ANSI_HVP_CURSOR_CHAR   L'f'

Definition at line 1513 of file sacdrv.h.

◆ VT_ANSI_SCROLL_CHAR

#define VT_ANSI_SCROLL_CHAR   L'r'

Definition at line 1515 of file sacdrv.h.

◆ VT_ANSI_SEPARATOR_CHAR

#define VT_ANSI_SEPARATOR_CHAR   L';'

Definition at line 1512 of file sacdrv.h.

◆ VT_ANSI_SET_ATTRIBUTE_CHAR

#define VT_ANSI_SET_ATTRIBUTE_CHAR   L'm'

Definition at line 1511 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 213 of file sacdrv.h.

214 {
215  SacCursorUp,
220  SacFontBlink,
222  SacFontBold,
226  SacBackTab,
229  SacEraseLine,
235  SacSetColors,
enum _SAC_ANSI_COMMANDS SAC_ANSI_COMMANDS

◆ _SAC_ANSI_DISPATCH

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

Definition at line 244 of file sacdrv.h.

◆ _SAC_CHANNEL_STATUS

Enumerator
Inactive 
Active 

Definition at line 284 of file sacdrv.h.

285 {
286  Inactive,
287  Active
enum _SAC_CHANNEL_STATUS * PSAC_CHANNEL_STATUS
Definition: sacdrv.h:287
enum _SAC_CHANNEL_STATUS SAC_CHANNEL_STATUS

◆ _SAC_CHANNEL_TYPE

Enumerator
VtUtf8 
Cmd 
Raw 

Definition at line 274 of file sacdrv.h.

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

◆ _SAC_POST_COMMANDS

Enumerator
Nothing 
Shutdown 
Close 
Restart 

Definition at line 263 of file sacdrv.h.

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

◆ _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 1372 of file sacdrv.h.

1373 {
1374  //
1375  // Attribute modifiers (mostly supported)
1376  //
1377  Normal,
1378  Bold,
1379  Faint,
1380  Italic,
1381  Underline,
1382  SlowBlink,
1383  FastBlink,
1384  Inverse,
1385  Conceal,
1386  Strikethrough,
1387 
1388  //
1389  // Font selectors (not supported)
1390  //
1391  PrimaryFont,
1401 
1402  //
1403  // Additional attributes (not supported)
1404  //
1405  Fraktur,
1407 
1408  //
1409  // Attribute Un-modifiers (mostly supported)
1410  //
1411  BoldOff,
1412  ItalicOff,
1413  UnderlineOff,
1414  BlinkOff,
1415  Reserved,
1416  InverseOff,
1417  ConcealOff,
1419 
1420  //
1421  // Standard Text Color
1422  //
1423  SetColorStart,
1425  SetColorRed,
1426  SetColorGreen,
1428  SetColorBlue,
1430  SetColorCyan,
1431  SetColorWhite,
1433 
1434  //
1435  // Extended Text Color (not supported)
1436  //
1437  SetColor256,
1439 
1440  //
1441  // Standard Background Color
1442  //
1453 
1454  //
1455  // Extended Background Color (not supported)
1456  //
1459 
1460  //
1461  // Extra Attributes (not supported)
1462  //
1463  Reserved1,
1464  Framed,
1465  Encircled,
1466  Overlined,
1467  FramedOff,
1468  OverlinedOff,
1469  Reserved2,
1470  Reserved3,
1471  Reserved4,
1472  Reserved5
1473 
1474  //
1475  // Ideograms (not supported)
1476  //
enum _VT_ANSI_ATTRIBUTES VT_ANSI_ATTRIBUTES
Definition: sacdrv.h:1378
Definition: sacdrv.h:1379

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 }
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:204
LONG NTSTATUS
Definition: precomp.h:26
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
NTSTATUS NTAPI ChannelClose(IN PSAC_CHANNEL Channel)
Definition: channel.c:558
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI ChannelIsActive(IN PSAC_CHANNEL Channel)
Definition: channel.c:250

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);
385  CHECK_PARAMETER_WITH_STATUS(NewChannel, STATUS_NO_MEMORY); // bug
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));
410  Status = ExUuidCreate(&ChanId.ChannelGuid);
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 
441 ReturnStatus:
442  /* Return whatever the operation status was */
444  return Status;
445 }
NTSTATUS NTAPI ChanMgrReapChannels(VOID)
Definition: chanmgr.c:309
LONG Index
Definition: sacdrv.h:425
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
LONG NTSTATUS
Definition: precomp.h:26
LONG ChannelReaped[SAC_MAX_CHANNELS]
Definition: chanmgr.c:19
#define STATUS_DUPLICATE_NAME
Definition: ntstatus.h:411
BOOLEAN ChannelCreateEnabled
Definition: chanmgr.c:16
#define CHANNEL_SLOT_IS_IN_USE(x)
Definition: chanmgr.c:26
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
PSAC_CHANNEL ChannelArray[SAC_MAX_CHANNELS]
Definition: chanmgr.c:17
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
NTKERNELAPI NTSTATUS ExUuidCreate(OUT UUID *Uuid)
Definition: uuid.c:385
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
FORCEINLINE VOID ChannelReferenceToOneByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:109
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GUID ChannelGuid
Definition: sacdrv.h:295
BOOLEAN NTAPI ChanMgrIsUniqueName(IN PWCHAR ChannelName)
Definition: chanmgr.c:282
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI ChannelCreate(IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes, IN SAC_CHANNEL_ID ChannelId)
Definition: channel.c:457
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define ChannelLockCreates()
Definition: sacdrv.h:1329
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define CHECK_PARAMETER_WITH_STATUS(Condition, Status)
Definition: sacdrv.h:47
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
#define ChannelUnlockCreates()
Definition: sacdrv.h:1330
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define CHANNEL_BLOCK_TAG
Definition: sacdrv.h:142
#define SAC_MAX_CHANNELS
Definition: sacdrv.h:153

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 }
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI ChannelIsEqual(IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ID ChannelId)
Definition: channel.c:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PSAC_CHANNEL ChannelFromIndex(IN ULONG Index)
Definition: chanmgr.c:30
#define STATUS_NOT_FOUND
Definition: shellext.h:72
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
FORCEINLINE LONG ChannelReferenceByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:60
FORCEINLINE VOID ChannelDereferenceByIndexWithLock(IN LONG Index)
Definition: chanmgr.c:83
Status
Definition: gdiplustypes.h:24
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define SAC_MAX_CHANNELS
Definition: sacdrv.h:153

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 */
535  Status = ChanMgrGetChannelIndex(CurrentChannel, &ChannelIndex);
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);
547  if (Status != STATUS_NOT_FOUND)
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 }
#define TRUE
Definition: types.h:120
PSAC_CHANNEL CurrentChannel
Definition: conmgr.c:26
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ChanMgrGetByIndex(IN LONG TargetIndex, IN PSAC_CHANNEL *TargetChannel)
Definition: chanmgr.c:496
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
long LONG
Definition: pedump.c:60
unsigned char BOOLEAN
LONG ChannelHasNewOBufferData
Definition: sacdrv.h:458
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
Status
Definition: gdiplustypes.h:24
#define CHECK_PARAMETER3(x)
Definition: sacdrv.h:60
BOOLEAN NTAPI ChannelIsActive(IN PSAC_CHANNEL Channel)
Definition: channel.c:250
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
NTSTATUS NTAPI ChanMgrGetChannelIndex(IN PSAC_CHANNEL Channel, IN PLONG ChannelIndex)
Definition: chanmgr.c:483
unsigned int ULONG
Definition: retypes.h:1
#define SAC_MAX_CHANNELS
Definition: sacdrv.h:153
NTSTATUS NTAPI ChanMgrReleaseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:243

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 */
130  ChannelArray[i] = NULL;
132 
133  /* Clear their statuses and reference counts */
136  }
137 
138  /* All good */
139  return STATUS_SUCCESS;
140 }
#define TRUE
Definition: types.h:120
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
LONG ChannelReaped[SAC_MAX_CHANNELS]
Definition: chanmgr.c:19
BOOLEAN ChannelCreateEnabled
Definition: chanmgr.c:16
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
PSAC_CHANNEL ChannelArray[SAC_MAX_CHANNELS]
Definition: chanmgr.c:17
FORCEINLINE VOID SacInitializeLock(IN PSAC_CHANNEL_LOCK Lock)
Definition: sacdrv.h:1251
smooth NULL
Definition: ftsmooth.c:416
LONG ChannelRefCount[SAC_MAX_CHANNELS]
Definition: chanmgr.c:18
SAC_CHANNEL_LOCK ChannelSlotLock[SAC_MAX_CHANNELS]
Definition: chanmgr.c:20
SAC_CHANNEL_LOCK ChannelCreateLock
Definition: chanmgr.c:15
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define SAC_MAX_CHANNELS
Definition: sacdrv.h:153

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 */
255  RefCount = ChannelDereferenceByIndex(Index);
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 }
#define ChannelSlotUnlock(x)
Definition: sacdrv.h:1338
FORCEINLINE VOID ChannelDereferenceToZeroByIndex(IN LONG Index)
Definition: chanmgr.c:92
long LONG
Definition: pedump.c:60
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
FORCEINLINE PSAC_CHANNEL ChannelFromIndex(IN ULONG Index)
Definition: chanmgr.c:30
LONG ChannelHasNewOBufferData
Definition: sacdrv.h:458
FORCEINLINE LONG ChannelDereferenceByIndex(IN LONG Index)
Definition: chanmgr.c:72
FORCEINLINE LONG ChannelGetIndex(IN PSAC_CHANNEL Channel)
Definition: sacdrv.h:1352
static const UCHAR Index[8]
Definition: usbohci.c:18
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: sacdrv.h:444
SAC_CHANNEL_LOCK ChannelSlotLock[SAC_MAX_CHANNELS]
Definition: chanmgr.c:20
BOOLEAN NTAPI ChannelIsActive(IN PSAC_CHANNEL Channel)
Definition: channel.c:250
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938

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 */
147  return STATUS_NOT_IMPLEMENTED;
148 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

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 }
LONG NTSTATUS
Definition: precomp.h:26
#define ChannelClearEvent(Channel, x)
Definition: sacdrv.h:113
Status
Definition: gdiplustypes.h:24

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 }
LONG NTSTATUS
Definition: precomp.h:26
#define SAC_CHANNEL_FLAG_CLOSE_EVENT
Definition: sacdrv.h:169
NTSTATUS NTAPI ChannelSetStatus(IN PSAC_CHANNEL Channel, IN SAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:236
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
#define ChannelSetEvent(Channel, x)
Definition: sacdrv.h:98
NTSTATUS NTAPI ChannelDereferenceHandles(IN PSAC_CHANNEL Channel)
Definition: channel.c:35
Status
Definition: gdiplustypes.h:24

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 */
529  Status = ChannelInitializeVTable(Channel);
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 
550 FailChannel:
551  /* Destroy the channel and return the failure code */
552  Channel->ChannelDestroy(Channel);
553  return Status;
554 }
NTSTATUS NTAPI ChannelInitializeVTable(IN PSAC_CHANNEL Channel)
Definition: channel.c:405
LONG NTSTATUS
Definition: precomp.h:26
#define SAC_CHANNEL_FLAG_CLOSE_EVENT
Definition: sacdrv.h:169
NTSTATUS NTAPI ChannelSetDescription(IN PSAC_CHANNEL Channel, IN PWCHAR Description)
Definition: channel.c:368
FORCEINLINE VOID SacInitializeLock(IN PSAC_CHANNEL_LOCK Lock)
Definition: sacdrv.h:1251
NTSTATUS NTAPI ChannelSetStatus(IN PSAC_CHANNEL Channel, IN SAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:236
smooth NULL
Definition: ftsmooth.c:416
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
Definition: sacdrv.h:287
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SAC_CHANNEL_FLAG_HAS_NEW_DATA_EVENT
Definition: sacdrv.h:170
#define SAC_CHANNEL_FLAG_APPLICATION
Definition: sacdrv.h:173
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI ChannelSetName(IN PSAC_CHANNEL Channel, IN PWCHAR Name)
Definition: channel.c:322
#define ChannelInitializeEvent(Channel, Attributes, x)
Definition: sacdrv.h:70
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define SAC_CHANNEL_FLAG_REDRAW_EVENT
Definition: sacdrv.h:172
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define SAC_CHANNEL_FLAG_LOCK_EVENT
Definition: sacdrv.h:171

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 }
#define CHECK_PARAMETER(x)
Definition: sacdrv.h:54
NTSTATUS NTAPI ChannelDereferenceHandles(IN PSAC_CHANNEL Channel)
Definition: channel.c:35

Referenced by RawChannelDestroy(), and VTUTF8ChannelDestroy().

◆ ChannelGetFlags()

FORCEINLINE ULONG ChannelGetFlags ( IN PSAC_CHANNEL  Channel)

Definition at line 1345 of file sacdrv.h.

1346 {
1347  return Channel->Flags;
1348 }

◆ ChannelGetIndex()

FORCEINLINE LONG ChannelGetIndex ( IN PSAC_CHANNEL  Channel)

Definition at line 1352 of file sacdrv.h.

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

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 */
316  ChannelUnlockAttributes(Channel);
317  return STATUS_SUCCESS;
318 }
#define CHECK_ALLOCATION(x)
Definition: sacdrv.h:64
#define ChannelUnlockAttributes(x)
Definition: sacdrv.h:1336
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
#define UNICODE_NULL
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ChannelLockAttributes(x)
Definition: sacdrv.h:1335
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define SAC_CHANNEL_NAME_SIZE
Definition: sacdrv.h:151
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ChanMgrGetChannelByName().

◆ ChannelHasNewIBufferData()

FORCEINLINE BOOLEAN ChannelHasNewIBufferData ( IN PSAC_CHANNEL  Channel)

Definition at line 1360 of file sacdrv.h.

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

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 }
#define CHECK_PARAMETER1(x)
Definition: sacdrv.h:56
#define SAC_CHANNEL_FLAG_REDRAW_EVENT
Definition: sacdrv.h:172
#define CHECK_PARAMETER2(x)
Definition: sacdrv.h:58
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ConMgrDisplayCurrentChannel(), and ConMgrSetCurrentChannel().

◆ ChannelIBufferLength()

ULONG NTAPI ChannelIBufferLength ( IN PSAC_CHANNEL  Channel)

Definition at line 163 of file channel.c.

164 {
165  ULONG Length;
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:101
#define ChannelLockOBuffer(x)
Definition: sacdrv.h:1331
unsigned int ULONG
Definition: retypes.h:1
#define ChannelUnlockOBuffer(x)
Definition: sacdrv.h:1332

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,
142  BufferSize,
143  ResultBufferSize);
144  ChannelUnlockIBuffer(Channel);
145  return Status;
146 }
#define ChannelLockIBuffer(x)
Definition: sacdrv.h:1333
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define BufferSize
Definition: classpnp.h:419
#define ChannelUnlockIBuffer(x)
Definition: sacdrv.h:1334
Status
Definition: gdiplustypes.h:24

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 }
#define ChannelLockIBuffer(x)
Definition: sacdrv.h:1333
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ChannelUnlockIBuffer(x)
Definition: sacdrv.h:1334

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;
253  BOOLEAN IsActive;
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 }
NTSTATUS NTAPI ChannelGetStatus(IN PSAC_CHANNEL Channel, OUT PSAC_CHANNEL_STATUS ChannelStatus)
Definition: channel.c:222
unsigned char BOOLEAN
Definition: sacdrv.h:287
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
enum _SAC_CHANNEL_STATUS SAC_CHANNEL_STATUS

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:233

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 }
#define ChannelLockIBuffer(x)
Definition: sacdrv.h:1333
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define BufferSize
Definition: classpnp.h:419
#define ChannelUnlockIBuffer(x)
Definition: sacdrv.h:1334
Status
Definition: gdiplustypes.h:24

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 }
LONG NTSTATUS
Definition: precomp.h:26
#define ChannelLockOBuffer(x)
Definition: sacdrv.h:1331
Status
Definition: gdiplustypes.h:24
#define ChannelUnlockOBuffer(x)
Definition: sacdrv.h:1332

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 }
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define BufferSize
Definition: classpnp.h:419
#define ChannelLockOBuffer(x)
Definition: sacdrv.h:1331
Status
Definition: gdiplustypes.h:24
#define CHECK_PARAMETER3(x)
Definition: sacdrv.h:60
#define SAC_OBUFFER_SIZE
Definition: sacdrv.h:150
#define ChannelUnlockOBuffer(x)
Definition: sacdrv.h:1332

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 }
LONG NTSTATUS
Definition: precomp.h:26
#define ChannelSetEvent(Channel, x)
Definition: sacdrv.h:98
Status
Definition: gdiplustypes.h:24

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 }
return STATUS_SUCCESS
Definition: btrfs.c:2938

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);
893  return STATUS_NOT_IMPLEMENTED;
894 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

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 */
203  Status = ChanMgrGetByHandle(SacChannel->ChannelId, &FoundChannel);
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 }
#define SAC_CHANNEL_FLAG_INTERNAL
Definition: sacdrv.h:168
PSAC_CHANNEL SacChannel
Definition: conmgr.c:27
Definition: sacdrv.h:276
WCHAR DescriptionBuffer[SAC_CHANNEL_DESCRIPTION_SIZE+1]
Definition: sacdrv.h:479
PSAC_CHANNEL CurrentChannel
Definition: conmgr.c:26
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
#define SAC_CHANNEL_DESCRIPTION_SIZE
Definition: sacdrv.h:152
WCHAR NameBuffer[SAC_CHANNEL_NAME_SIZE+1]
Definition: sacdrv.h:478
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
SAC_CHANNEL_TYPE ChannelType
Definition: sacdrv.h:477
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ChanMgrCreateChannel(OUT PSAC_CHANNEL *Channel, IN PSAC_CHANNEL_ATTRIBUTES Attributes)
Definition: chanmgr.c:345
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FORCEINLINE VOID SacReleaseMutexLock(VOID)
Definition: sacdrv.h:1319
#define SAC_CHANNEL_FLAG_APPLICATION
Definition: sacdrv.h:173
FORCEINLINE VOID SacAcquireMutexLock(VOID)
Definition: sacdrv.h:1307
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
#define GetMessage
Definition: winuser.h:5765
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI ChanMgrGetByHandle(IN SAC_CHANNEL_ID ChannelId, OUT PSAC_CHANNEL *TargetChannel)
Definition: chanmgr.c:202
return STATUS_SUCCESS
Definition: btrfs.c:2938
FORCEINLINE VOID SacInitializeMutexLock(VOID)
Definition: sacdrv.h:1296
#define SAC_CHANNEL_NAME_SIZE
Definition: sacdrv.h:151
NTSTATUS NTAPI ConMgrDisplayCurrentChannel(VOID)
Definition: conmgr.c:81
LONG WriteEnabled
Definition: sacdrv.h:446
SAC_CHANNEL_ID ChannelId
Definition: sacdrv.h:426

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 }
PSAC_CHANNEL CurrentChannel
Definition: conmgr.c:26
BOOLEAN NTAPI ChannelIsEqual(IN PSAC_CHANNEL Channel, IN PSAC_CHANNEL_ID ChannelId)
Definition: channel.c:25
SAC_CHANNEL_ID ChannelId
Definition: sacdrv.h:426

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 */
387  SacChannel = NULL;
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 }
PSAC_CHANNEL SacChannel
Definition: conmgr.c:27
PSAC_CHANNEL CurrentChannel
Definition: conmgr.c:26
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ChannelClose(IN PSAC_CHANNEL Channel)
Definition: channel.c:558
#define SAC_DBG_INIT
Definition: sacdrv.h:34
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2938
NTSTATUS NTAPI ChanMgrReleaseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:243

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;
256  BOOLEAN Result;
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 }
#define TRUE
Definition: types.h:120
uint16_t * PWCHAR
Definition: typedefs.h:54
unsigned char BOOLEAN
_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
VOID NTAPI ConMgrEventMessage(IN PWCHAR EventMessage, IN BOOLEAN LockHeld)
Definition: conmgr.c:235
#define GetMessage
Definition: winuser.h:5765

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,
845  KernelMode,
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 }
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
smooth NULL
Definition: ftsmooth.c:416
ULONG ExecutePostConsumerCommand
Definition: conmgr.c:29
PSAC_CHANNEL ExecutePostConsumerCommandData
Definition: conmgr.c:30
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
VOID NTAPI ConMgrSerialPortConsumer(VOID)
Definition: conmgr.c:574
Definition: sacdrv.h:267
VOID NTAPI DoRebootCommand(IN BOOLEAN Reboot)
Definition: concmd.c:355
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
NTSTATUS NTAPI ChanMgrCloseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:593
NTSTATUS NTAPI ChanMgrReleaseChannel(IN PSAC_CHANNEL Channel)
Definition: chanmgr.c:243

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 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI HeadlessDispatch(IN HEADLESS_CMD Command, IN PVOID InputBuffer, IN SIZE_T InputBufferSize, OUT PVOID OutputBuffer, OUT PSIZE_T OutputBufferSize)
Definition: hdlsterm.c:570
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG BufferLength
Definition: usbdlib.h:225
NTSTATUS NTAPI KeDelayExecutionThread(IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Interval OPTIONAL)
Definition: wait.c:283
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
DWORD Interval
Definition: netstat.c:33
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1

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 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

◆ DispatchDeviceControl()

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

Definition at line 21 of file dispatch.c.

23 {
25 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

Referenced by DriverEntry().

◆ DispatchShutdownControl()

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

Definition at line 29 of file dispatch.c.

31 {
33 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
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:107

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
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

◆ 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 }
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
FORCEINLINE BOOLEAN PrintHelpMessage(IN ULONG MessageId, IN OUT PULONG Count)
Definition: concmd.c:505
unsigned int ULONG
Definition: retypes.h:1

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

Referenced by ConMgrProcessInputLine().

◆ DoRebootCommand()

VOID NTAPI DoRebootCommand ( IN BOOLEAN  Reboot)

Definition at line 355 of file concmd.c.

356 {
357  LARGE_INTEGER Timeout, TickCount;
359  KEVENT Event;
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 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
ULONG GlobalBufferSize
Definition: concmd.c:18
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
Definition: bl.h:892
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
PVOID GlobalBuffer
Definition: concmd.c:17
VOID NTAPI SacPutString(IN PWCHAR String)
Definition: conmgr.c:41
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
NTSTATUS NTAPI NtShutdownSystem(IN SHUTDOWN_ACTION Action)
Definition: shutdown.c:43
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57
static ULONG Timeout
Definition: ping.c:61
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define GetMessage
Definition: winuser.h:5765
BOOLEAN NTAPI ConMgrSimpleEventMessage(IN ULONG MessageIndex, IN BOOLEAN LockHeld)
Definition: conmgr.c:252
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
LONGLONG QuadPart
Definition: typedefs.h:112

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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 }
#define TRUE
Definition: types.h:120
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONG NTSTATUS
Definition: precomp.h:26
ULONG GlobalBufferSize
Definition: concmd.c:18
#define GLOBAL_BLOCK_TAG
Definition: sacdrv.h:141
#define SacAllocatePool(Length, Tag)
Definition: sacdrv.h:24
PVOID GlobalBuffer
Definition: concmd.c:17
VOID NTAPI SacPutString(IN PWCHAR String)
Definition: conmgr.c:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI PrintTListInfo(IN PSAC_SYSTEM_INFORMATION SacInfo)
Definition: concmd.c:312
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NTSTATUS NTAPI GetTListInfo(IN PSAC_SYSTEM_INFORMATION SacInfo, IN ULONG InputSize, OUT PULONG TotalSize)
Definition: concmd.c:76
Status
Definition: gdiplustypes.h:24
BOOLEAN NTAPI SacPutSimpleMessage(IN ULONG MessageIndex)
Definition: conmgr.c:57
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define GetMessage
Definition: winuser.h:5765
unsigned int ULONG
Definition: retypes.h:1
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32

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;
151  KIRQL OldIrql;
152  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Entering.\n");
153 
154  /* Get the device extension and see how far we had gotten */
156  if ((GlobalDataInitialized) && (DeviceExtension->Initialized))
157  {
158  /* Attempt to rundown while holding the lock */
159  KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
160  while (DeviceExtension->RundownInProgress)
161  {
162  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Waiting....\n");
163 
164  /* Initiate and wait for rundown */
165  KeInitializeEvent(&DeviceExtension->RundownEvent, SynchronizationEvent, 0);
166  KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
167  Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
168  Executive,
169  KernelMode,
170  FALSE,
171  NULL);
173 
174  /* Re-acquire the lock and check if rundown is done */
175  KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
176  }
177  }
178 
179  /* Now set the rundown flag while we cancel the timer */
180  DeviceExtension->RundownInProgress = TRUE;
181  KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
182 
183  /* Cancel it */
184  KeCancelTimer(&DeviceExtension->Timer);
185 
186  /* Reacquire the lock*/
187  KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
188  DeviceExtension->RundownInProgress = FALSE;
189 
190  /* Now do the last rundown attempt, we should be the only ones here */
191  KeInitializeEvent(&DeviceExtension->RundownEvent, SynchronizationEvent, 0);
192  KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
193  KeSetEvent(&DeviceExtension->Event, DeviceExtension->PriorityBoost, 0);
194  Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
195  Executive,
196  KernelMode,
197  FALSE,
198  NULL);
200 
201  /* We no longer care about shutdown */
203 
204  /* We are now fully uninitialized */
205  KeAcquireSpinLock(&DeviceExtension->Lock, &OldIrql);
206  DeviceExtension->Initialized = FALSE;
207  KeReleaseSpinLock(&DeviceExtension->Lock, OldIrql);
208  SAC_DBG(SAC_DBG_ENTRY_EXIT, "SAC FreeDeviceData: Exiting.\n");
209 }
#define TRUE
Definition: types.h:120
struct _SAC_DEVICE_EXTENSION * PSAC_DEVICE_EXTENSION
LONG NTSTATUS
Definition: precomp.h:26
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
KPRIORITY PriorityBoost
Definition: sacdrv.h:512
BOOLEAN NTAPI KeCancelTimer(IN OUT PKTIMER Timer)
Definition: timerobj.c:206
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK Lock
Definition: sacdrv.h:514
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1725
BOOLEAN Initialized
Definition: sacdrv.h:508
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
Status
Definition: gdiplustypes.h:24
BOOLEAN RundownInProgress
Definition: sacdrv.h:511
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
BOOLEAN GlobalDataInitialized
Definition: data.c:17
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
return STATUS_SUCCESS
Definition: btrfs.c:2938

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 */
123  ConMgrShutdown();
124 
125  /* Tear down channels */
126  ChanMgrShutdown();
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 }
VOID NTAPI FreeMachineInformation(VOID)
Definition: util.c:1153
PCHAR SerialPortBuffer
Definition: util.c:35
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTATUS NTAPI ConMgrShutdown(VOID)
Definition: conmgr.c:372
NTSTATUS NTAPI ChanMgrShutdown(VOID)
Definition: chanmgr.c:144
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI TearDownGlobalMessageTable(VOID)
Definition: util.c:379
VOID NTAPI FreeMemoryManagement(VOID)
Definition: memory.c:62
#define SacFreePool(Pointer)
Definition: sacdrv.h:26
static const WCHAR L[]
Definition: oid.c:1250
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
BOOLEAN GlobalDataInitialized
Definition: data.c:17
PKEVENT SACEvent
Definition: data.c:21
HANDLE SACEventHandle
Definition: data.c:22
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
static const WCHAR SymbolicLink[]
Definition: interface.c:31

Referenced by DriverEntry(), and UnloadHandler().

◆ FreeMachineInformation()

VOID NTAPI FreeMachineInformation ( VOID  )

Definition at line 1153 of file util.c.

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

Referenced by FreeGlobalData().

◆ FreeMemoryManagement()

VOID NTAPI FreeMemoryManagement ( VOID  )

Definition at line 62 of file memory.c.

63 {
64  PSAC_MEMORY_LIST Next;
65  KIRQL OldIrql;
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 }
UCHAR KIRQL
Definition: env_spec_w32.h:591
struct _SAC_MEMORY_LIST * Next
Definition: sacdrv.h:201
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define SAC_DBG(x,...)
Definition: sacdrv.h:37
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
ULONG Signature
Definition: sacdrv.h:198
PSAC_MEMORY_LIST GlobalMemoryList
Definition: memory.c:17
#define SAC_DBG_ENTRY_EXIT
Definition: sacdrv.h:32
KSPIN_LOCK MemoryLock
Definition: memory.c:16
#define GLOBAL_MEMORY_SIGNATURE
Definition: sacdrv.h:144
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by FreeGlobalData().

◆ GetCommandConsoleLaunchingPermission()

NTSTATUS NTAPI GetCommandConsoleLaunchingPermission ( OUT PBOOLEAN  Permission)

Definition at line 978 of file util.c.

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

Referenced by InitializeGlobalData().

◆ GetMessage()

PWCHAR NTAPI GetMessage ( IN ULONG  MessageIndex)

Definition at line 139 of file util.c.

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

Referenced by GetMessageLineCount(), and InitializeMachineInformation().

◆ GetMessageLineCount()

ULONG NTAPI GetMessageLineCount ( IN ULONG  MessageIndex)

Definition at line 1230 of file util.c.

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

Referenced by PrintHelpMessage().

◆ ImposeSacCmdServiceStartTypePolicy()

NTSTATUS NTAPI ImposeSacCmdServiceStartTypePolicy ( VOID  )

Definition at line 1005 of file util.c.

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

Referenced by InitializeGlobalData().

◆ InitializeCmdEventInfo()

VOID NTAPI InitializeCmdEventInfo ( VOID  )

Definition at line 1059 of file util.c.

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

Referenced by InitializeGlobalData().

◆ InitializeDeviceData()

BOOLEAN NTAPI InitializeDeviceData ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 213 of file data.c.

214 {
216  BOOLEAN EnableData;
217  ULONG PriorityValue;
220  PWCHAR Message;
221  PAGED_CODE();
222  SAC_DBG(SAC_DBG_ENTRY_EXIT, "Entering.\n");
223 
224  /* If we already did this, bail out */
225  if (DeviceExtension->Initialized) goto SuccessExit;
226 
227  /* Setup the DO flags */
229  DeviceObject->StackSize = 16;
230 
231  /* Setup the device extension */
232  DeviceExtension->DeviceObject = DeviceObject;
233  DeviceExtension->PriorityBoost = IO_SERIAL_INCREMENT;
234  DeviceExtension->PriorityFail = 0;
235  DeviceExtension->RundownInProgress = 0;
236 
237  /* Initialize locks, events, timers, DPCs, etc... */
238  KeInitializeTimer(&DeviceExtension->Timer);
239  KeInitializeDpc(&DeviceExtension->Dpc, TimerDpcRoutine, DeviceExtension);
240  KeInitializeSpinLock(&DeviceExtension->Lock);
241  KeInitializeEvent(&DeviceExtension->Event, SynchronizationEvent, FALSE);
242  InitializeListHead(&DeviceExtension->List);
243 
244  /* Attempt to enable HDL support */
245  EnableData = TRUE;
247  &EnableData,
248  sizeof(EnableData),
249  NULL,
250  0);
251  if (!NT_SUCCESS(Status))
252  {
253  /* Bail out if we couldn't even get this far */
254  SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (1) with status FALSE\n");
255  return FALSE;
256  }
257 
258  /* Remember which process we started in */
259  DeviceExtension->Process = IoGetCurrentProcess();
260 
261  /* Protect the device against non-admins */
263  if (!NT_SUCCESS(Status))
264  {
265  /* Write down why we failed */
266  SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (2) with status FALSE\n");
267 
268  /* Disable the HDL terminal on failure */
269  EnableData = FALSE;
271  &EnableData,
272  sizeof(EnableData),
273  NULL,
274  NULL);
275  if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
276 
277  /* Bail out */
278  return FALSE;
279  }
280 
281  /* Create the worker thread */
282  Status = PsCreateSystemThread(&DeviceExtension->WorkerThreadHandle,
284  NULL,
285  NULL,
286  NULL,
288  DeviceExtension);
289  if (!NT_SUCCESS(Status))
290  {
291  /* Write down why we failed */
292  SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (3) with status FALSE\n");
293 
294  /* Disable the HDL terminal on failure */
295  EnableData = FALSE;
297  &EnableData,
298  sizeof(EnableData),
299  NULL,
300  NULL);
301  if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
302 
303  /* Bail out */
304  return FALSE;
305  }
306 
307  /* Set the priority of our thread to highest */
308  PriorityValue = HIGH_PRIORITY;
311  &PriorityValue,
312  sizeof(PriorityValue));
313  if (!NT_SUCCESS(Status))
314  {
315  /* For debugging, write down why we failed */
316  SAC_DBG(SAC_DBG_ENTRY_EXIT, "Exiting (6) with status FALSE\n");
317  DeviceExtension->PriorityFail = TRUE;
318 
319  /* Initialize rundown and wait for the thread to do it */
321  KeSetEvent(&DeviceExtension->Event, DeviceExtension->PriorityBoost, FALSE);
322  Status = KeWaitForSingleObject(&DeviceExtension->RundownEvent,
323  Executive,
324  KernelMode,
325  FALSE,
326  NULL);
328 
329  /* Disable the HDL terminal on failure */
330  EnableData = FALSE;
332  &EnableData,
333  sizeof(EnableData),
334  NULL,
335  0);
336  if (!NT_SUCCESS(Status)) SAC_DBG(SAC_DBG_INIT, "Failed dispatch\n");
337 
338  /* Bail out */
339  return FALSE;
340  }
341 
342  /* The first "packet" is the machine information in XML... */
344  if (NT_SUCCESS(Status))
345  {
346  /* Go ahead and send it */
347  UTF8EncodeAndSend(L"<?xml version=\"1.0\"?>\r\n");
349 
350  /* Free the temporary buffer */
351  SacFreePool(