#define NDEBUG
#include <debug.h>
-typedef struct tagHISTORY_BUFFER
+typedef struct _HISTORY_BUFFER
{
LIST_ENTRY ListEntry;
UINT Position;
/* FUNCTIONS *****************************************************************/
static PHISTORY_BUFFER
-HistoryCurrentBuffer(PCSRSS_CONSOLE Console)
+HistoryCurrentBuffer(PCONSOLE Console)
{
/* TODO: use actual EXE name sent from process that called ReadConsole */
UNICODE_STRING ExeName = { 14, 14, L"cmd.exe" };
}
static VOID
-HistoryAddEntry(PCSRSS_CONSOLE Console)
+HistoryAddEntry(PCONSOLE Console)
{
UNICODE_STRING NewEntry;
PHISTORY_BUFFER Hist;
}
static VOID
-HistoryGetCurrentEntry(PCSRSS_CONSOLE Console, PUNICODE_STRING Entry)
+HistoryGetCurrentEntry(PCONSOLE Console, PUNICODE_STRING Entry)
{
PHISTORY_BUFFER Hist;
if (!(Hist = HistoryCurrentBuffer(Console)) || Hist->NumEntries == 0)
}
static PHISTORY_BUFFER
-HistoryFindBuffer(PCSRSS_CONSOLE Console, PUNICODE_STRING ExeName)
+HistoryFindBuffer(PCONSOLE Console, PUNICODE_STRING ExeName)
{
PLIST_ENTRY Entry = Console->HistoryBuffers.Flink;
while (Entry != &Console->HistoryBuffers)
CSR_API(SrvGetConsoleCommandHistoryLength)
{
- PCSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLength;
+ PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLengthRequest;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCSRSS_CONSOLE Console;
+ PCONSOLE Console;
NTSTATUS Status;
PHISTORY_BUFFER Hist;
ULONG Length = 0;
INT i;
if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&GetCommandHistoryLength->ExeName.Buffer,
- GetCommandHistoryLength->ExeName.Length,
+ (PVOID*)&GetCommandHistoryLengthRequest->ExeName.Buffer,
+ GetCommandHistoryLengthRequest->ExeName.Length,
sizeof(BYTE)))
{
return STATUS_INVALID_PARAMETER;
}
-/*
- if (!Win32CsrValidateBuffer(ProcessData->Process,
- GetCommandHistoryLength->ExeName.Buffer,
- GetCommandHistoryLength->ExeName.Length, 1))
- {
- return STATUS_ACCESS_VIOLATION;
- }
-*/
Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
- Hist = HistoryFindBuffer(Console, &GetCommandHistoryLength->ExeName);
+ Hist = HistoryFindBuffer(Console, &GetCommandHistoryLengthRequest->ExeName);
if (Hist)
{
for (i = 0; i < Hist->NumEntries; i++)
Length += Hist->Entries[i].Length + sizeof(WCHAR);
}
- GetCommandHistoryLength->Length = Length;
+ GetCommandHistoryLengthRequest->Length = Length;
ConioUnlockConsole(Console);
}
return Status;
CSR_API(SrvGetConsoleCommandHistory)
{
- PCSRSS_GET_COMMAND_HISTORY GetCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistory;
+ PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryRequest;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCSRSS_CONSOLE Console;
+ PCONSOLE Console;
NTSTATUS Status;
PHISTORY_BUFFER Hist;
- PBYTE Buffer = (PBYTE)GetCommandHistory->History;
- ULONG BufferSize = GetCommandHistory->Length;
+ PBYTE Buffer = (PBYTE)GetCommandHistoryRequest->History;
+ ULONG BufferSize = GetCommandHistoryRequest->Length;
INT i;
if ( !CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&GetCommandHistory->History,
- GetCommandHistory->Length,
+ (PVOID*)&GetCommandHistoryRequest->History,
+ GetCommandHistoryRequest->Length,
sizeof(BYTE)) ||
!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&GetCommandHistory->ExeName.Buffer,
- GetCommandHistory->ExeName.Length,
+ (PVOID*)&GetCommandHistoryRequest->ExeName.Buffer,
+ GetCommandHistoryRequest->ExeName.Length,
sizeof(BYTE)) )
{
return STATUS_INVALID_PARAMETER;
}
-/*
- if (!Win32CsrValidateBuffer(ProcessData->Process, Buffer, BufferSize, 1) ||
- !Win32CsrValidateBuffer(ProcessData->Process,
- GetCommandHistory->ExeName.Buffer,
- GetCommandHistory->ExeName.Length, 1))
- {
- return STATUS_ACCESS_VIOLATION;
- }
-*/
Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
- Hist = HistoryFindBuffer(Console, &GetCommandHistory->ExeName);
+ Hist = HistoryFindBuffer(Console, &GetCommandHistoryRequest->ExeName);
if (Hist)
{
for (i = 0; i < Hist->NumEntries; i++)
Buffer += sizeof(WCHAR);
}
}
- GetCommandHistory->Length = Buffer - (PBYTE)GetCommandHistory->History;
+ GetCommandHistoryRequest->Length = Buffer - (PBYTE)GetCommandHistoryRequest->History;
ConioUnlockConsole(Console);
}
return Status;
CSR_API(SrvExpungeConsoleCommandHistory)
{
- PCSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistory;
+ PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistoryRequest;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCSRSS_CONSOLE Console;
+ PCONSOLE Console;
PHISTORY_BUFFER Hist;
NTSTATUS Status;
if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&ExpungeCommandHistory->ExeName.Buffer,
- ExpungeCommandHistory->ExeName.Length,
+ (PVOID*)&ExpungeCommandHistoryRequest->ExeName.Buffer,
+ ExpungeCommandHistoryRequest->ExeName.Length,
sizeof(BYTE)))
{
return STATUS_INVALID_PARAMETER;
}
-/*
- if (!Win32CsrValidateBuffer(ProcessData->Process,
- ExpungeCommandHistory->ExeName.Buffer,
- ExpungeCommandHistory->ExeName.Length, 1))
- {
- return STATUS_ACCESS_VIOLATION;
- }
-*/
Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
- Hist = HistoryFindBuffer(Console, &ExpungeCommandHistory->ExeName);
+ Hist = HistoryFindBuffer(Console, &ExpungeCommandHistoryRequest->ExeName);
HistoryDeleteBuffer(Hist);
ConioUnlockConsole(Console);
}
CSR_API(SrvSetConsoleNumberOfCommands)
{
- PCSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommands;
+ PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommandsRequest;
PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCSRSS_CONSOLE Console;
+ PCONSOLE Console;
PHISTORY_BUFFER Hist;
NTSTATUS Status;
- UINT MaxEntries = SetHistoryNumberCommands->NumCommands;
+ UINT MaxEntries = SetHistoryNumberCommandsRequest->NumCommands;
PUNICODE_STRING OldEntryList, NewEntryList;
if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&SetHistoryNumberCommands->ExeName.Buffer,
- SetHistoryNumberCommands->ExeName.Length,
+ (PVOID*)&SetHistoryNumberCommandsRequest->ExeName.Buffer,
+ SetHistoryNumberCommandsRequest->ExeName.Length,
sizeof(BYTE)))
{
return STATUS_INVALID_PARAMETER;
}
-/*
- if (!Win32CsrValidateBuffer(ProcessData->Process,
- SetHistoryNumberCommands->ExeName.Buffer,
- SetHistoryNumberCommands->ExeName.Length, 1))
- {
- return STATUS_ACCESS_VIOLATION;
- }
-*/
Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
- Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommands->ExeName);
+ Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommandsRequest->ExeName);
if (Hist)
{
OldEntryList = Hist->Entries;
CSR_API(SrvGetConsoleHistory)
{
- PCSRSS_HISTORY_INFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
- PCSRSS_CONSOLE Console;
+ PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
+ PCONSOLE Console;
NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (NT_SUCCESS(Status))
{
CSR_API(SrvSetConsoleHistory)
{
- PCSRSS_HISTORY_INFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
- PCSRSS_CONSOLE Console;
+ PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
+ PCONSOLE Console;
NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console);
if (NT_SUCCESS(Status))
{
}
static VOID
-LineInputSetPos(PCSRSS_CONSOLE Console, UINT Pos)
+LineInputSetPos(PCONSOLE Console, UINT Pos)
{
if (Pos != Console->LinePos && Console->Mode & ENABLE_ECHO_INPUT)
{
- PCSRSS_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
+ PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
UINT OldCursorX = Buffer->CurrentX;
UINT OldCursorY = Buffer->CurrentY;
INT XY = OldCursorY * Buffer->MaxX + OldCursorX;
}
static VOID
-LineInputEdit(PCSRSS_CONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Insertion)
+LineInputEdit(PCONSOLE Console, UINT NumToDelete, UINT NumToInsert, WCHAR *Insertion)
{
UINT Pos = Console->LinePos;
UINT NewSize = Console->LineSize - NumToDelete + NumToInsert;
}
static VOID
-LineInputRecallHistory(PCSRSS_CONSOLE Console, INT Offset)
+LineInputRecallHistory(PCONSOLE Console, INT Offset)
{
PHISTORY_BUFFER Hist;
}
VOID FASTCALL
-LineInputKeyDown(PCSRSS_CONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
+LineInputKeyDown(PCONSOLE Console, KEY_EVENT_RECORD *KeyEvent)
{
UINT Pos = Console->LinePos;
PHISTORY_BUFFER Hist;