[FORMATTING] Standardize win32csr to 4-space indents. Based on a patch by Adam Kachwalla [Bug 5380]. No code changes.

svn path=/trunk/; revision=47457
This commit is contained in:
Jeffrey Morlan 2010-05-30 20:00:17 +00:00
parent dfc4dcb9b5
commit d27f068a19
10 changed files with 3838 additions and 3837 deletions

View file

@ -5,7 +5,7 @@
* PURPOSE: CSRSS alias support functions
* COPYRIGHT: Christoph Wittich
* Johannes Anderwald
*
*
*/
@ -17,10 +17,10 @@
typedef struct tagALIAS_ENTRY
{
LPCWSTR lpSource;
LPCWSTR lpTarget;
struct tagALIAS_ENTRY * Next;
}ALIAS_ENTRY, *PALIAS_ENTRY;
LPCWSTR lpSource;
LPCWSTR lpTarget;
struct tagALIAS_ENTRY * Next;
} ALIAS_ENTRY, *PALIAS_ENTRY;
typedef struct tagALIAS_HEADER
@ -29,7 +29,7 @@ typedef struct tagALIAS_HEADER
PALIAS_ENTRY Data;
struct tagALIAS_HEADER * Next;
}ALIAS_HEADER, *PALIAS_HEADER;
} ALIAS_HEADER, *PALIAS_HEADER;
/* Ensure that a buffer is contained within the process's shared memory section. */
static BOOL
@ -37,10 +37,10 @@ ValidateBuffer(PCSRSS_PROCESS_DATA ProcessData, PVOID Buffer, ULONG Size)
{
ULONG Offset = (BYTE *)Buffer - (BYTE *)ProcessData->CsrSectionViewBase;
if (Offset >= ProcessData->CsrSectionViewSize
|| Size > (ProcessData->CsrSectionViewSize - Offset))
|| Size > (ProcessData->CsrSectionViewSize - Offset))
{
DPRINT1("Invalid buffer %p %d; not within %p %d\n",
Buffer, Size, ProcessData->CsrSectionViewBase, ProcessData->CsrSectionViewSize);
Buffer, Size, ProcessData->CsrSectionViewBase, ProcessData->CsrSectionViewSize);
return FALSE;
}
return TRUE;
@ -67,38 +67,38 @@ IntFindAliasHeader(PALIAS_HEADER RootHeader, LPCWSTR lpExeName)
PALIAS_HEADER
IntCreateAliasHeader(LPCWSTR lpExeName)
{
PALIAS_HEADER Entry;
UINT dwLength = wcslen(lpExeName) + 1;
PALIAS_HEADER Entry;
UINT dwLength = wcslen(lpExeName) + 1;
Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) * dwLength);
if (!Entry)
return Entry;
Entry->lpExeName = (LPCWSTR)(Entry + 1);
wcscpy((WCHAR*)Entry->lpExeName, lpExeName);
Entry->Data = NULL;
Entry->Next = NULL;
return Entry;
Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_HEADER) + sizeof(WCHAR) * dwLength);
if (!Entry)
return Entry;
Entry->lpExeName = (LPCWSTR)(Entry + 1);
wcscpy((WCHAR*)Entry->lpExeName, lpExeName);
Entry->Data = NULL;
Entry->Next = NULL;
return Entry;
}
VOID
IntInsertAliasHeader(PALIAS_HEADER * RootHeader, PALIAS_HEADER NewHeader)
{
PALIAS_HEADER CurrentHeader;
PALIAS_HEADER *LastLink = RootHeader;
PALIAS_HEADER CurrentHeader;
PALIAS_HEADER *LastLink = RootHeader;
while ((CurrentHeader = *LastLink) != NULL)
{
INT Diff = _wcsicmp(NewHeader->lpExeName, CurrentHeader->lpExeName);
if (Diff < 0)
{
break;
}
LastLink = &CurrentHeader->Next;
}
while ((CurrentHeader = *LastLink) != NULL)
{
INT Diff = _wcsicmp(NewHeader->lpExeName, CurrentHeader->lpExeName);
if (Diff < 0)
{
break;
}
LastLink = &CurrentHeader->Next;
}
*LastLink = NewHeader;
NewHeader->Next = CurrentHeader;
*LastLink = NewHeader;
NewHeader->Next = CurrentHeader;
}
PALIAS_ENTRY
@ -130,60 +130,60 @@ IntGetAliasEntry(PALIAS_HEADER Header, LPCWSTR lpSrcName)
VOID
IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry)
{
PALIAS_ENTRY CurrentEntry;
PALIAS_ENTRY *LastLink = &Header->Data;
PALIAS_ENTRY CurrentEntry;
PALIAS_ENTRY *LastLink = &Header->Data;
while ((CurrentEntry = *LastLink) != NULL)
{
INT Diff = _wcsicmp(NewEntry->lpSource, CurrentEntry->lpSource);
if (Diff < 0)
while ((CurrentEntry = *LastLink) != NULL)
{
break;
INT Diff = _wcsicmp(NewEntry->lpSource, CurrentEntry->lpSource);
if (Diff < 0)
{
break;
}
LastLink = &CurrentEntry->Next;
}
LastLink = &CurrentEntry->Next;
}
*LastLink = NewEntry;
NewEntry->Next = CurrentEntry;
*LastLink = NewEntry;
NewEntry->Next = CurrentEntry;
}
PALIAS_ENTRY
IntCreateAliasEntry(LPCWSTR lpSource, LPCWSTR lpTarget)
{
UINT dwSource;
UINT dwTarget;
PALIAS_ENTRY Entry;
UINT dwSource;
UINT dwTarget;
PALIAS_ENTRY Entry;
dwSource = wcslen(lpSource) + 1;
dwTarget = wcslen(lpTarget) + 1;
dwSource = wcslen(lpSource) + 1;
dwTarget = wcslen(lpTarget) + 1;
Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) * (dwSource + dwTarget));
if (!Entry)
return Entry;
Entry = RtlAllocateHeap(Win32CsrApiHeap, 0, sizeof(ALIAS_ENTRY) + sizeof(WCHAR) * (dwSource + dwTarget));
if (!Entry)
return Entry;
Entry->lpSource = (LPCWSTR)(Entry + 1);
wcscpy((LPWSTR)Entry->lpSource, lpSource);
Entry->lpTarget = Entry->lpSource + dwSource;
wcscpy((LPWSTR)Entry->lpTarget, lpTarget);
Entry->Next = NULL;
Entry->lpSource = (LPCWSTR)(Entry + 1);
wcscpy((LPWSTR)Entry->lpSource, lpSource);
Entry->lpTarget = Entry->lpSource + dwSource;
wcscpy((LPWSTR)Entry->lpTarget, lpTarget);
Entry->Next = NULL;
return Entry;
return Entry;
}
UINT
IntGetConsoleAliasesExesLength(PALIAS_HEADER RootHeader)
{
UINT length = 0;
UINT length = 0;
while(RootHeader)
{
length += (wcslen(RootHeader->lpExeName) + 1) * sizeof(WCHAR);
RootHeader = RootHeader->Next;
}
if (length)
length += sizeof(WCHAR); // last entry entry is terminated with 2 zero bytes
while(RootHeader)
{
length += (wcslen(RootHeader->lpExeName) + 1) * sizeof(WCHAR);
RootHeader = RootHeader->Next;
}
if (length)
length += sizeof(WCHAR); // last entry entry is terminated with 2 zero bytes
return length;
return length;
}
UINT
@ -215,22 +215,22 @@ IntGetConsoleAliasesExes(PALIAS_HEADER RootHeader, LPWSTR TargetBuffer, UINT Tar
UINT
IntGetAllConsoleAliasesLength(PALIAS_HEADER Header)
{
UINT Length = 0;
PALIAS_ENTRY CurEntry = Header->Data;
UINT Length = 0;
PALIAS_ENTRY CurEntry = Header->Data;
while(CurEntry)
{
Length += wcslen(CurEntry->lpSource);
Length += wcslen(CurEntry->lpTarget);
Length += 2; // zero byte and '='
CurEntry = CurEntry->Next;
}
while(CurEntry)
{
Length += wcslen(CurEntry->lpSource);
Length += wcslen(CurEntry->lpTarget);
Length += 2; // zero byte and '='
CurEntry = CurEntry->Next;
}
if (Length)
{
return (Length+1) * sizeof(WCHAR);
}
return 0;
if (Length)
{
return (Length+1) * sizeof(WCHAR);
}
return 0;
}
UINT
IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBufferLength)
@ -316,7 +316,7 @@ CSR_API(CsrAddConsoleAlias)
{
return STATUS_INVALID_PARAMETER;
}
Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (!NT_SUCCESS(Request->Status))
{
@ -379,11 +379,11 @@ CSR_API(CsrGetConsoleAlias)
lpTarget = Request->Data.GetConsoleAlias.TargetBuffer;
DPRINT("CsrGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p TargetBufferLength %u\n",
lpExeName, lpSource, lpTarget, Request->Data.GetConsoleAlias.TargetBufferLength);
if (Request->Data.GetConsoleAlias.ExeLength == 0 || lpTarget == NULL ||
Request->Data.GetConsoleAlias.TargetBufferLength == 0 || Request->Data.GetConsoleAlias.SourceLength == 0)
DPRINT("CsrGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p TargetBufferLength %u\n",
lpExeName, lpSource, lpTarget, Request->Data.GetConsoleAlias.TargetBufferLength);
if (Request->Data.GetConsoleAlias.ExeLength == 0 || lpTarget == NULL ||
Request->Data.GetConsoleAlias.TargetBufferLength == 0 || Request->Data.GetConsoleAlias.SourceLength == 0)
{
return STATUS_INVALID_PARAMETER;
}
@ -465,7 +465,7 @@ CSR_API(CsrGetAllConsoleAliases)
return STATUS_ACCESS_VIOLATION;
}
BytesWritten = IntGetAllConsoleAliases(Header,
BytesWritten = IntGetAllConsoleAliases(Header,
Request->Data.GetAllConsoleAlias.AliasBuffer,
Request->Data.GetAllConsoleAlias.AliasBufferLength);
@ -509,7 +509,7 @@ CSR_API(CsrGetConsoleAliasesExes)
PCSRSS_CONSOLE Console;
UINT BytesWritten;
UINT ExesLength;
DPRINT("CsrGetConsoleAliasesExes entered\n");
Request->Status = ConioConsoleFromProcessData(ProcessData, &Console);
@ -519,7 +519,7 @@ CSR_API(CsrGetConsoleAliasesExes)
}
ExesLength = IntGetConsoleAliasesExesLength(Console->Aliases);
if (ExesLength > Request->Data.GetConsoleAliasesExes.Length)
{
ConioUnlockConsole(Console);
@ -531,7 +531,7 @@ CSR_API(CsrGetConsoleAliasesExes)
ConioUnlockConsole(Console);
return STATUS_INVALID_PARAMETER;
}
if (!ValidateBuffer(ProcessData,
Request->Data.GetConsoleAliasesExes.ExeNames,
Request->Data.GetConsoleAliasesExes.Length))
@ -540,7 +540,7 @@ CSR_API(CsrGetConsoleAliasesExes)
return STATUS_ACCESS_VIOLATION;
}
BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
BytesWritten = IntGetConsoleAliasesExes(Console->Aliases,
Request->Data.GetConsoleAliasesExes.ExeNames,
Request->Data.GetConsoleAliasesExes.Length);

View file

@ -19,7 +19,7 @@ typedef struct APPSWITCH_ITEM
BOOL bFocus;
struct APPSWITCH_ITEM * Next;
WCHAR szText[1];
}APPSWITCH_ITEM, *PAPPSWITCH_ITEM;
} APPSWITCH_ITEM, *PAPPSWITCH_ITEM;
static PAPPSWITCH_ITEM pRoot = NULL;
static DWORD NumOfWindows = 0;
@ -30,7 +30,7 @@ UINT WINAPI PrivateExtractIconExW(LPCWSTR,int,HICON*,HICON*,UINT);
BOOL
CALLBACK
CALLBACK
EnumWindowEnumProc(
HWND hwnd,
LPARAM lParam
@ -51,21 +51,21 @@ EnumWindowEnumProc(
hIcon = (HICON)SendMessage(hwnd, WM_GETICON, ICON_BIG, 0);
if (!hIcon)
{
GetWindowThreadProcessId(hwnd, &dwPid);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, dwPid);
if (hProcess)
{
if (GetModuleFileNameExW(hProcess, NULL, szFileName, MAX_PATH))
{
szFileName[MAX_PATH-1] = L'\0';
PrivateExtractIconExW(szFileName, 0, &hIcon, NULL, 1);
}
}
GetWindowThreadProcessId(hwnd, &dwPid);
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_READ, FALSE, dwPid);
if (hProcess)
{
if (GetModuleFileNameExW(hProcess, NULL, szFileName, MAX_PATH))
{
szFileName[MAX_PATH-1] = L'\0';
PrivateExtractIconExW(szFileName, 0, &hIcon, NULL, 1);
}
}
}
else
{
/* icons from WM_GETICON need to be copied */
hIcon = CopyIcon(hIcon);
/* icons from WM_GETICON need to be copied */
hIcon = CopyIcon(hIcon);
}
/* get the text length */
Length = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
@ -88,9 +88,9 @@ EnumWindowEnumProc(
if (!pRoot)
{
/* first item */
pRoot = pItem;
return TRUE;
/* first item */
pRoot = pItem;
return TRUE;
}
/* enumerate the last item */
@ -107,16 +107,16 @@ EnumWindowEnumProc(
VOID
EnumerateAppWindows(HDESK hDesk, HWND hwndDlg)
{
/* initialize defaults */
pRoot = NULL;
NumOfWindows = 0;
hAppWindowDlg = hwndDlg;
/* enumerate all windows */
EnumDesktopWindows(hDesk, EnumWindowEnumProc, (LPARAM)NULL);
if (NumOfWindows > 7)
{
/* FIXME resize window */
}
/* initialize defaults */
pRoot = NULL;
NumOfWindows = 0;
hAppWindowDlg = hwndDlg;
/* enumerate all windows */
EnumDesktopWindows(hDesk, EnumWindowEnumProc, (LPARAM)NULL);
if (NumOfWindows > 7)
{
/* FIXME resize window */
}
}
VOID
@ -126,7 +126,7 @@ MarkNextEntryAsActive()
pItem = pRoot;
if (!pRoot)
return;
return;
while(pItem)
{
@ -153,82 +153,82 @@ KeyboardHookProc(
LPARAM lParam
)
{
PKBDLLHOOKSTRUCT hk = (PKBDLLHOOKSTRUCT) lParam;
PKBDLLHOOKSTRUCT hk = (PKBDLLHOOKSTRUCT) lParam;
if (wParam == WM_SYSKEYUP)
{
/* is tab key pressed */
if (hk->vkCode == VK_TAB)
{
if (hAppWindowDlg == NULL)
{
/* FIXME
* launch window
*/
DPRINT1("launch alt-tab window\n");
}
else
{
MarkNextEntryAsActive();
}
}
}
return CallNextHookEx(hhk, nCode, wParam, lParam);
if (wParam == WM_SYSKEYUP)
{
/* is tab key pressed */
if (hk->vkCode == VK_TAB)
{
if (hAppWindowDlg == NULL)
{
/* FIXME
* launch window
*/
DPRINT1("launch alt-tab window\n");
}
else
{
MarkNextEntryAsActive();
}
}
}
return CallNextHookEx(hhk, nCode, wParam, lParam);
}
VOID
PaintAppWindows(HWND hwndDlg, HDC hDc)
{
DWORD dwIndex, X, Y;
PAPPSWITCH_ITEM pCurItem;
RECT Rect;
DWORD XSize, YSize, XMax;
HBRUSH hBrush;
DWORD dwIndex, X, Y;
PAPPSWITCH_ITEM pCurItem;
RECT Rect;
DWORD XSize, YSize, XMax;
HBRUSH hBrush;
X = 10;
Y = 10;
XSize = GetSystemMetrics(SM_CXICON);
YSize = GetSystemMetrics(SM_CYICON);
XMax = (XSize+(XSize/2)) * 7 + X;
pCurItem = pRoot;
X = 10;
Y = 10;
XSize = GetSystemMetrics(SM_CXICON);
YSize = GetSystemMetrics(SM_CYICON);
XMax = (XSize+(XSize/2)) * 7 + X;
pCurItem = pRoot;
for (dwIndex = 0; dwIndex < NumOfWindows; dwIndex++)
{
if (X >= XMax)
{
X = 10;
Y += YSize + (YSize/2);
}
if (pCurItem->bFocus)
{
for (dwIndex = 0; dwIndex < NumOfWindows; dwIndex++)
{
if (X >= XMax)
{
X = 10;
Y += YSize + (YSize/2);
}
if (pCurItem->bFocus)
{
hBrush = CreateSolidBrush(RGB(30, 30, 255));
SetRect(&Rect, X-5, Y-5, X + XSize + 5, Y + YSize + 5);
FillRect(hDc, &Rect, hBrush);
DeleteObject((HGDIOBJ)hBrush);
SendDlgItemMessageW(hwndDlg, IDC_STATIC_CUR_APP, WM_SETTEXT, 0, (LPARAM)pCurItem->szText);
}
}
DrawIcon(hDc, X, Y, pCurItem->hIcon);
pCurItem = pCurItem->Next;
X += XSize +(XSize/2);
}
DrawIcon(hDc, X, Y, pCurItem->hIcon);
pCurItem = pCurItem->Next;
X += XSize +(XSize/2);
}
}
VOID
DestroyAppWindows()
{
PAPPSWITCH_ITEM pCurItem, pNextItem;
PAPPSWITCH_ITEM pCurItem, pNextItem;
pCurItem = pRoot;
while(pCurItem)
{
pNextItem = pCurItem->Next;
DestroyIcon(pCurItem->hIcon);
HeapFree(Win32CsrApiHeap, 0, pCurItem);
pCurItem = pNextItem;
}
pRoot = NULL;
hAppWindowDlg = NULL;
NumOfWindows = 0;
pCurItem = pRoot;
while(pCurItem)
{
pNextItem = pCurItem->Next;
DestroyIcon(pCurItem->hIcon);
HeapFree(Win32CsrApiHeap, 0, pCurItem);
pCurItem = pNextItem;
}
pRoot = NULL;
hAppWindowDlg = NULL;
NumOfWindows = 0;
}
INT_PTR

File diff suppressed because it is too large Load diff

View file

@ -49,71 +49,71 @@ DtbgWindowProc(HWND Wnd,
switch (Msg)
{
case WM_ERASEBKGND:
PaintDesktop((HDC)wParam);
return 1;
case WM_ERASEBKGND:
PaintDesktop((HDC)wParam);
return 1;
case WM_PAINT:
if (BeginPaint(Wnd, &PS))
EndPaint(Wnd, &PS);
return 0;
case WM_PAINT:
if (BeginPaint(Wnd, &PS))
EndPaint(Wnd, &PS);
return 0;
case WM_SETCURSOR:
return (LRESULT)SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW));
case WM_SETCURSOR:
return (LRESULT)SetCursor(LoadCursorW(0, (LPCWSTR)IDC_ARROW));
case WM_NCCREATE:
return (LRESULT)TRUE;
case WM_NCCREATE:
return (LRESULT)TRUE;
case WM_CREATE:
case WM_CLOSE:
return 0;
case WM_CREATE:
case WM_CLOSE:
return 0;
case WM_NOTIFY:
case WM_NOTIFY:
{
PPRIVATE_NOTIFY_DESKTOP nmh = (PPRIVATE_NOTIFY_DESKTOP)lParam;
/* Use WM_NOTIFY for private messages since
* it can't be sent between processes!
*/
switch (nmh->hdr.code)
{
PPRIVATE_NOTIFY_DESKTOP nmh = (PPRIVATE_NOTIFY_DESKTOP)lParam;
case PM_SHOW_DESKTOP:
{
LRESULT Result;
/* Use WM_NOTIFY for private messages since
* it can't be sent between processes!
*/
switch (nmh->hdr.code)
{
case PM_SHOW_DESKTOP:
{
LRESULT Result;
Result = !SetWindowPos(Wnd, NULL, 0, 0,
nmh->ShowDesktop.Width,
nmh->ShowDesktop.Height,
SWP_NOACTIVATE | SWP_NOZORDER |
SWP_SHOWWINDOW);
Result = !SetWindowPos(Wnd, NULL, 0, 0,
nmh->ShowDesktop.Width,
nmh->ShowDesktop.Height,
SWP_NOACTIVATE | SWP_NOZORDER |
SWP_SHOWWINDOW);
UpdateWindow(Wnd);
VisibleDesktopWindow = Wnd;
return Result;
}
UpdateWindow(Wnd);
VisibleDesktopWindow = Wnd;
return Result;
}
case PM_HIDE_DESKTOP:
{
LRESULT Result;
case PM_HIDE_DESKTOP:
{
LRESULT Result;
Result = !SetWindowPos(Wnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOZORDER |
SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
Result = !SetWindowPos(Wnd, NULL, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOZORDER |
SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
UpdateWindow(Wnd);
VisibleDesktopWindow = NULL;
return Result;
}
default:
DPRINT("Unknown notification code 0x%x sent to the desktop window!\n",
nmh->hdr.code);
return 0;
}
UpdateWindow(Wnd);
VisibleDesktopWindow = NULL;
return Result;
}
default:
return DefWindowProcW(Wnd, Msg, wParam, lParam);
DPRINT("Unknown notification code 0x%x sent to the desktop window!\n",
nmh->hdr.code);
return 0;
}
}
default:
return DefWindowProcW(Wnd, Msg, wParam, lParam);
}
return 0;
@ -309,7 +309,7 @@ FASTCALL
DtbgIsDesktopVisible(VOID)
{
if (VisibleDesktopWindow != NULL &&
!IsWindowVisible(VisibleDesktopWindow))
!IsWindowVisible(VisibleDesktopWindow))
{
VisibleDesktopWindow = NULL;
}

View file

@ -23,7 +23,7 @@ HINSTANCE Win32CsrDllHandle = NULL;
static CSRSS_EXPORTED_FUNCS CsrExports;
static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
{
{
CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetHandle),
CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetHandle),
CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle),
@ -83,37 +83,37 @@ static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize),
CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo),
{ 0, 0, NULL }
};
};
/* FUNCTIONS *****************************************************************/
BOOL WINAPI
DllMain(HANDLE hDll,
DWORD dwReason,
LPVOID lpReserved)
DWORD dwReason,
LPVOID lpReserved)
{
if (DLL_PROCESS_ATTACH == dwReason)
if (DLL_PROCESS_ATTACH == dwReason)
{
Win32CsrDllHandle = hDll;
InitializeAppSwitchHook();
Win32CsrDllHandle = hDll;
InitializeAppSwitchHook();
}
return TRUE;
return TRUE;
}
NTSTATUS FASTCALL
Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
PVOID Context)
{
return (CsrExports.CsrEnumProcessesProc)(EnumProc, Context);
return (CsrExports.CsrEnumProcessesProc)(EnumProc, Context);
}
static BOOL WINAPI
Win32CsrInitComplete(void)
{
PrivateCsrssInitialized();
PrivateCsrssInitialized();
return TRUE;
return TRUE;
}
BOOL WINAPI
@ -122,22 +122,22 @@ Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
PCSRSS_EXPORTED_FUNCS Exports,
HANDLE CsrssApiHeap)
{
NTSTATUS Status;
CsrExports = *Exports;
Win32CsrApiHeap = CsrssApiHeap;
NTSTATUS Status;
CsrExports = *Exports;
Win32CsrApiHeap = CsrssApiHeap;
Status = NtUserInitialize(0 ,NULL, NULL);
Status = NtUserInitialize(0, NULL, NULL);
PrivateCsrssManualGuiCheck(0);
CsrInitConsoleSupport();
PrivateCsrssManualGuiCheck(0);
CsrInitConsoleSupport();
*ApiDefinitions = Win32CsrApiDefinitions;
ServerProcs->InitCompleteProc = Win32CsrInitComplete;
ServerProcs->HardErrorProc = Win32CsrHardError;
ServerProcs->ProcessInheritProc = Win32CsrDuplicateHandleTable;
ServerProcs->ProcessDeletedProc = Win32CsrReleaseConsole;
*ApiDefinitions = Win32CsrApiDefinitions;
ServerProcs->InitCompleteProc = Win32CsrInitComplete;
ServerProcs->HardErrorProc = Win32CsrHardError;
ServerProcs->ProcessInheritProc = Win32CsrDuplicateHandleTable;
ServerProcs->ProcessDeletedProc = Win32CsrReleaseConsole;
return TRUE;
return TRUE;
}
/* EOF */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -101,7 +101,7 @@ Win32CsrLockObject(PCSRSS_PROCESS_DATA ProcessData,
{
ULONG_PTR h = (ULONG_PTR)Handle >> 2;
DPRINT("CsrGetObject, Object: %x, %x, %x\n",
DPRINT("CsrGetObject, Object: %x, %x, %x\n",
Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
@ -271,7 +271,7 @@ CSR_API(CsrGetHandle)
PCSRSS_CONSOLE Console = ProcessData->Console;
Object_t *Object;
EnterCriticalSection(&Console->Lock);
if (Request->Type == GET_OUTPUT_HANDLE)
Object = &Console->ActiveBuffer->Header;
@ -366,7 +366,7 @@ CSR_API(CsrDuplicateHandle)
return STATUS_INVALID_PARAMETER;
}
}
Request->Status = Win32CsrInsertObject(ProcessData,
&Request->Data.DuplicateHandleRequest.Handle,
Entry->Object,

View file

@ -84,8 +84,8 @@ CsrpGetClientFileName(
ClientFileNameU->MaximumLength = ModuleData.BaseDllName.MaximumLength;
ClientFileNameU->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
ClientFileNameU->MaximumLength);
HEAP_ZERO_MEMORY,
ClientFileNameU->MaximumLength);
Status = NtReadVirtualMemory(hProcess,
ModuleData.BaseDllName.Buffer,
@ -123,9 +123,9 @@ CsrpCaptureStringParameters(
UnicodeStringParameterMask = HardErrorMessage->UnicodeStringParameterMask;
/* Read all strings from client space */
for (nParam = 0;
nParam < HardErrorMessage->NumberOfParameters;
nParam++, UnicodeStringParameterMask >>= 1)
for (nParam = 0;
nParam < HardErrorMessage->NumberOfParameters;
nParam++, UnicodeStringParameterMask >>= 1)
{
Parameters[nParam] = 0;
@ -194,9 +194,9 @@ CsrpFreeStringParameters(
UnicodeStringParameterMask = HardErrorMessage->UnicodeStringParameterMask;
/* Loop all parameters */
for (nParam = 0;
nParam < HardErrorMessage->NumberOfParameters;
nParam++, UnicodeStringParameterMask >>= 1)
for (nParam = 0;
nParam < HardErrorMessage->NumberOfParameters;
nParam++, UnicodeStringParameterMask >>= 1)
{
/* Check if the current parameter is a string */
if (UnicodeStringParameterMask & 0x01)
@ -292,8 +292,8 @@ CsrpFormatMessages(
/* Allocate a buffer for the caption */
CaptionStringU->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
CaptionStringU->MaximumLength);
HEAP_ZERO_MEMORY,
CaptionStringU->MaximumLength);
/* Append the file name, seperator and the caption text */
CaptionStringU->Length = 0;
@ -383,13 +383,13 @@ CsrpFormatMessages(
{
/* Print the string into the buffer */
StringCbPrintfW(TextStringU->Buffer,
TextStringU->MaximumLength,
FormatString,
Parameters[0],
Parameters[1],
Parameters[2],
Parameters[3],
Parameters[4]);
TextStringU->MaximumLength,
FormatString,
Parameters[0],
Parameters[1],
Parameters[2],
Parameters[3],
Parameters[4]);
Status = STATUS_SUCCESS;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
@ -424,30 +424,30 @@ CsrpMessageBox(
/* Set the message box type */
switch (ValidResponseOptions)
{
case OptionAbortRetryIgnore:
Type = MB_ABORTRETRYIGNORE;
break;
case OptionOk:
Type = MB_OK;
break;
case OptionOkCancel:
Type = MB_OKCANCEL;
break;
case OptionRetryCancel:
Type = MB_RETRYCANCEL;
break;
case OptionYesNo:
Type = MB_YESNO;
break;
case OptionYesNoCancel:
Type = MB_YESNOCANCEL;
break;
case OptionShutdownSystem:
Type = MB_RETRYCANCEL; // FIXME???
break;
case OptionAbortRetryIgnore:
Type = MB_ABORTRETRYIGNORE;
break;
case OptionOk:
Type = MB_OK;
break;
case OptionOkCancel:
Type = MB_OKCANCEL;
break;
case OptionRetryCancel:
Type = MB_RETRYCANCEL;
break;
case OptionYesNo:
Type = MB_YESNO;
break;
case OptionYesNoCancel:
Type = MB_YESNOCANCEL;
break;
case OptionShutdownSystem:
Type = MB_RETRYCANCEL; // FIXME???
break;
/* Anything else is invalid */
default:
return ResponseNotHandled;
default:
return ResponseNotHandled;
}
/* Set severity */
@ -457,7 +457,7 @@ CsrpMessageBox(
Type |= MB_SYSTEMMODAL | MB_SETFOREGROUND;
DPRINT("Text = '%S', Caption = '%S', Severity = %d, Type = 0x%lx\n",
DPRINT("Text = '%S', Caption = '%S', Severity = %d, Type = 0x%lx\n",
Text, Caption, Severity, Type);
/* Display a message box */
@ -466,15 +466,15 @@ CsrpMessageBox(
/* Return response value */
switch (MessageBoxResponse)
{
case IDOK: return ResponseOk;
case IDCANCEL: return ResponseCancel;
case IDYES: return ResponseYes;
case IDNO: return ResponseNo;
case IDABORT: return ResponseAbort;
case IDIGNORE: return ResponseIgnore;
case IDRETRY: return ResponseRetry;
case IDTRYAGAIN: return ResponseTryAgain;
case IDCONTINUE: return ResponseContinue;
case IDOK: return ResponseOk;
case IDCANCEL: return ResponseCancel;
case IDYES: return ResponseYes;
case IDNO: return ResponseNo;
case IDABORT: return ResponseAbort;
case IDIGNORE: return ResponseIgnore;
case IDRETRY: return ResponseRetry;
case IDTRYAGAIN: return ResponseTryAgain;
case IDCONTINUE: return ResponseContinue;
}
return ResponseNotHandled;
@ -537,7 +537,7 @@ Win32CsrHardError(
if (!NT_SUCCESS(Status))
{
return FALSE;
return FALSE;
}
/* Display the message box */

View file

@ -20,15 +20,15 @@ static BOOL ConsInitialized = FALSE;
static LRESULT CALLBACK
TuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_ACTIVATE)
if (msg == WM_ACTIVATE)
{
if (LOWORD(wParam) != WA_INACTIVE)
if (LOWORD(wParam) != WA_INACTIVE)
{
SetFocus(hWnd);
ConioDrawConsole(ActiveConsole);
SetFocus(hWnd);
ConioDrawConsole(ActiveConsole);
}
}
return DefWindowProcW(hWnd, msg, wParam, lParam);
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
static BOOL FASTCALL
@ -63,19 +63,19 @@ cleanup:
static BOOL FASTCALL
TuiInit(DWORD OemCP)
{
CONSOLE_SCREEN_BUFFER_INFO ScrInfo;
DWORD BytesReturned;
WNDCLASSEXW wc;
USHORT TextAttribute = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
CONSOLE_SCREEN_BUFFER_INFO ScrInfo;
DWORD BytesReturned;
WNDCLASSEXW wc;
USHORT TextAttribute = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
TuiStartService(L"Blue");
TuiStartService(L"Blue");
ConsoleDeviceHandle = CreateFileW(L"\\\\.\\BlueScreen", FILE_ALL_ACCESS, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE == ConsoleDeviceHandle)
ConsoleDeviceHandle = CreateFileW(L"\\\\.\\BlueScreen", FILE_ALL_ACCESS, 0, NULL,
OPEN_EXISTING, 0, NULL);
if (INVALID_HANDLE_VALUE == ConsoleDeviceHandle)
{
DPRINT1("Failed to open BlueScreen.\n");
return FALSE;
DPRINT1("Failed to open BlueScreen.\n");
return FALSE;
}
if (!DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_LOADFONT,
@ -93,163 +93,163 @@ TuiInit(DWORD OemCP)
DPRINT1("Failed to set text attribute\n");
}
ActiveConsole = NULL;
InitializeCriticalSection(&ActiveConsoleLock);
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO,
NULL, 0, &ScrInfo, sizeof(ScrInfo), &BytesReturned, NULL))
ActiveConsole = NULL;
InitializeCriticalSection(&ActiveConsoleLock);
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO,
NULL, 0, &ScrInfo, sizeof(ScrInfo), &BytesReturned, NULL))
{
DPRINT1("Failed to get console info\n");
return FALSE;
DPRINT1("Failed to get console info\n");
return FALSE;
}
PhysicalConsoleSize = ScrInfo.dwSize;
PhysicalConsoleSize = ScrInfo.dwSize;
RtlZeroMemory(&wc, sizeof(WNDCLASSEXW));
wc.cbSize = sizeof(WNDCLASSEXW);
wc.lpszClassName = L"TuiConsoleWindowClass";
wc.lpfnWndProc = TuiConsoleWndProc;
wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL);
if (RegisterClassExW(&wc) == 0)
RtlZeroMemory(&wc, sizeof(WNDCLASSEXW));
wc.cbSize = sizeof(WNDCLASSEXW);
wc.lpszClassName = L"TuiConsoleWindowClass";
wc.lpfnWndProc = TuiConsoleWndProc;
wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL);
if (RegisterClassExW(&wc) == 0)
{
DPRINT1("Failed to register console wndproc\n");
return FALSE;
DPRINT1("Failed to register console wndproc\n");
return FALSE;
}
return TRUE;
return TRUE;
}
static VOID WINAPI
TuiInitScreenBuffer(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buffer)
{
Buffer->DefaultAttrib = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
Buffer->DefaultAttrib = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED;
}
static void FASTCALL
TuiCopyRect(char *Dest, PCSRSS_SCREEN_BUFFER Buff, SMALL_RECT *Region)
{
UINT SrcDelta, DestDelta;
LONG i;
PBYTE Src, SrcEnd;
UINT SrcDelta, DestDelta;
LONG i;
PBYTE Src, SrcEnd;
Src = ConioCoordToPointer(Buff, Region->Left, Region->Top);
SrcDelta = Buff->MaxX * 2;
SrcEnd = Buff->Buffer + Buff->MaxY * Buff->MaxX * 2;
DestDelta = ConioRectWidth(Region) * 2;
for (i = Region->Top; i <= Region->Bottom; i++)
Src = ConioCoordToPointer(Buff, Region->Left, Region->Top);
SrcDelta = Buff->MaxX * 2;
SrcEnd = Buff->Buffer + Buff->MaxY * Buff->MaxX * 2;
DestDelta = ConioRectWidth(Region) * 2;
for (i = Region->Top; i <= Region->Bottom; i++)
{
memcpy(Dest, Src, DestDelta);
Src += SrcDelta;
if (SrcEnd <= Src)
memcpy(Dest, Src, DestDelta);
Src += SrcDelta;
if (SrcEnd <= Src)
{
Src -= Buff->MaxY * Buff->MaxX * 2;
Src -= Buff->MaxY * Buff->MaxX * 2;
}
Dest += DestDelta;
Dest += DestDelta;
}
}
static VOID WINAPI
TuiDrawRegion(PCSRSS_CONSOLE Console, SMALL_RECT *Region)
{
DWORD BytesReturned;
PCSRSS_SCREEN_BUFFER Buff = Console->ActiveBuffer;
PCONSOLE_DRAW ConsoleDraw;
UINT ConsoleDrawSize;
DWORD BytesReturned;
PCSRSS_SCREEN_BUFFER Buff = Console->ActiveBuffer;
PCONSOLE_DRAW ConsoleDraw;
UINT ConsoleDrawSize;
if (ActiveConsole != Console)
if (ActiveConsole != Console)
{
return;
return;
}
ConsoleDrawSize = sizeof(CONSOLE_DRAW) +
(ConioRectWidth(Region) * ConioRectHeight(Region)) * 2;
ConsoleDraw = HeapAlloc(Win32CsrApiHeap, 0, ConsoleDrawSize);
if (NULL == ConsoleDraw)
ConsoleDrawSize = sizeof(CONSOLE_DRAW) +
(ConioRectWidth(Region) * ConioRectHeight(Region)) * 2;
ConsoleDraw = HeapAlloc(Win32CsrApiHeap, 0, ConsoleDrawSize);
if (NULL == ConsoleDraw)
{
DPRINT1("HeapAlloc failed\n");
return;
DPRINT1("HeapAlloc failed\n");
return;
}
ConsoleDraw->X = Region->Left;
ConsoleDraw->Y = Region->Top;
ConsoleDraw->SizeX = ConioRectWidth(Region);
ConsoleDraw->SizeY = ConioRectHeight(Region);
ConsoleDraw->CursorX = Buff->CurrentX;
ConsoleDraw->CursorY = Buff->CurrentY;
ConsoleDraw->X = Region->Left;
ConsoleDraw->Y = Region->Top;
ConsoleDraw->SizeX = ConioRectWidth(Region);
ConsoleDraw->SizeY = ConioRectHeight(Region);
ConsoleDraw->CursorX = Buff->CurrentX;
ConsoleDraw->CursorY = Buff->CurrentY;
TuiCopyRect((char *) (ConsoleDraw + 1), Buff, Region);
TuiCopyRect((char *) (ConsoleDraw + 1), Buff, Region);
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_DRAW,
NULL, 0, ConsoleDraw, ConsoleDrawSize, &BytesReturned, NULL))
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_DRAW,
NULL, 0, ConsoleDraw, ConsoleDrawSize, &BytesReturned, NULL))
{
DPRINT1("Failed to draw console\n");
HeapFree(Win32CsrApiHeap, 0, ConsoleDraw);
return;
DPRINT1("Failed to draw console\n");
HeapFree(Win32CsrApiHeap, 0, ConsoleDraw);
return;
}
HeapFree(Win32CsrApiHeap, 0, ConsoleDraw);
HeapFree(Win32CsrApiHeap, 0, ConsoleDraw);
}
static VOID WINAPI
TuiWriteStream(PCSRSS_CONSOLE Console, SMALL_RECT *Region, LONG CursorStartX, LONG CursorStartY,
UINT ScrolledLines, CHAR *Buffer, UINT Length)
{
DWORD BytesWritten;
PCSRSS_SCREEN_BUFFER Buff = Console->ActiveBuffer;
DWORD BytesWritten;
PCSRSS_SCREEN_BUFFER Buff = Console->ActiveBuffer;
if (ActiveConsole->ActiveBuffer != Buff)
if (ActiveConsole->ActiveBuffer != Buff)
{
return;
return;
}
if (! WriteFile(ConsoleDeviceHandle, Buffer, Length, &BytesWritten, NULL))
if (! WriteFile(ConsoleDeviceHandle, Buffer, Length, &BytesWritten, NULL))
{
DPRINT1("Error writing to BlueScreen\n");
DPRINT1("Error writing to BlueScreen\n");
}
}
static BOOL WINAPI
TuiSetCursorInfo(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buff)
{
DWORD BytesReturned;
DWORD BytesReturned;
if (ActiveConsole->ActiveBuffer != Buff)
if (ActiveConsole->ActiveBuffer != Buff)
{
return TRUE;
return TRUE;
}
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_CURSOR_INFO,
&Buff->CursorInfo, sizeof(Buff->CursorInfo), NULL, 0,
&BytesReturned, NULL))
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_CURSOR_INFO,
&Buff->CursorInfo, sizeof(Buff->CursorInfo), NULL, 0,
&BytesReturned, NULL))
{
DPRINT1( "Failed to set cursor info\n" );
return FALSE;
DPRINT1( "Failed to set cursor info\n" );
return FALSE;
}
return TRUE;
return TRUE;
}
static BOOL WINAPI
TuiSetScreenInfo(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buff, UINT OldCursorX, UINT OldCursorY)
{
CONSOLE_SCREEN_BUFFER_INFO Info;
DWORD BytesReturned;
CONSOLE_SCREEN_BUFFER_INFO Info;
DWORD BytesReturned;
if (ActiveConsole->ActiveBuffer != Buff)
if (ActiveConsole->ActiveBuffer != Buff)
{
return TRUE;
return TRUE;
}
Info.dwCursorPosition.X = Buff->CurrentX;
Info.dwCursorPosition.Y = Buff->CurrentY;
Info.wAttributes = Buff->DefaultAttrib;
Info.dwCursorPosition.X = Buff->CurrentX;
Info.dwCursorPosition.Y = Buff->CurrentY;
Info.wAttributes = Buff->DefaultAttrib;
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO,
&Info, sizeof(CONSOLE_SCREEN_BUFFER_INFO), NULL, 0,
&BytesReturned, NULL))
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO,
&Info, sizeof(CONSOLE_SCREEN_BUFFER_INFO), NULL, 0,
&BytesReturned, NULL))
{
DPRINT1( "Failed to set cursor position\n" );
return FALSE;
DPRINT1( "Failed to set cursor position\n" );
return FALSE;
}
return TRUE;
return TRUE;
}
static BOOL WINAPI
@ -261,32 +261,32 @@ TuiUpdateScreenInfo(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER Buff)
static BOOL WINAPI
TuiChangeTitle(PCSRSS_CONSOLE Console)
{
return TRUE;
return TRUE;
}
static VOID WINAPI
TuiCleanupConsole(PCSRSS_CONSOLE Console)
{
DestroyWindow(Console->hWindow);
DestroyWindow(Console->hWindow);
EnterCriticalSection(&ActiveConsoleLock);
EnterCriticalSection(&ActiveConsoleLock);
/* Switch to next console */
if (ActiveConsole == Console)
/* Switch to next console */
if (ActiveConsole == Console)
{
ActiveConsole = Console->Next != Console ? Console->Next : NULL;
ActiveConsole = Console->Next != Console ? Console->Next : NULL;
}
if (Console->Next != Console)
if (Console->Next != Console)
{
Console->Prev->Next = Console->Next;
Console->Next->Prev = Console->Prev;
Console->Prev->Next = Console->Next;
Console->Next->Prev = Console->Prev;
}
LeaveCriticalSection(&ActiveConsoleLock);
LeaveCriticalSection(&ActiveConsoleLock);
if (NULL != ActiveConsole)
if (NULL != ActiveConsole)
{
ConioDrawConsole(ActiveConsole);
ConioDrawConsole(ActiveConsole);
}
}
@ -306,179 +306,179 @@ TuiResizeBuffer(PCSRSS_CONSOLE Console, PCSRSS_SCREEN_BUFFER ScreenBuffer, COORD
DWORD WINAPI
TuiConsoleThread (PVOID Data)
{
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) Data;
HWND NewWindow;
MSG msg;
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) Data;
HWND NewWindow;
MSG msg;
NewWindow = CreateWindowW(L"TuiConsoleWindowClass",
Console->Title.Buffer,
0,
-32000, -32000, 0, 0,
NULL, NULL,
(HINSTANCE) GetModuleHandleW(NULL),
(PVOID) Console);
Console->hWindow = NewWindow;
if (NULL == NewWindow)
NewWindow = CreateWindowW(L"TuiConsoleWindowClass",
Console->Title.Buffer,
0,
-32000, -32000, 0, 0,
NULL, NULL,
(HINSTANCE) GetModuleHandleW(NULL),
(PVOID) Console);
Console->hWindow = NewWindow;
if (NULL == NewWindow)
{
DPRINT1("CSR: Unable to create console window\n");
return 1;
DPRINT1("CSR: Unable to create console window\n");
return 1;
}
SetForegroundWindow(Console->hWindow);
SetForegroundWindow(Console->hWindow);
while (TRUE)
while (TRUE)
{
GetMessageW(&msg, 0, 0, 0);
DispatchMessage(&msg);
TranslateMessage(&msg);
GetMessageW(&msg, 0, 0, 0);
DispatchMessage(&msg);
TranslateMessage(&msg);
if (msg.message == WM_CHAR || msg.message == WM_SYSCHAR ||
msg.message == WM_KEYDOWN || msg.message == WM_KEYUP ||
msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP)
if (msg.message == WM_CHAR || msg.message == WM_SYSCHAR ||
msg.message == WM_KEYDOWN || msg.message == WM_KEYUP ||
msg.message == WM_SYSKEYDOWN || msg.message == WM_SYSKEYUP)
{
ConioProcessKey(&msg, Console, TRUE);
ConioProcessKey(&msg, Console, TRUE);
}
}
return 0;
return 0;
}
static CSRSS_CONSOLE_VTBL TuiVtbl =
{
TuiInitScreenBuffer,
TuiWriteStream,
TuiDrawRegion,
TuiSetCursorInfo,
TuiSetScreenInfo,
TuiUpdateScreenInfo,
TuiChangeTitle,
TuiCleanupConsole,
TuiChangeIcon,
TuiResizeBuffer,
TuiInitScreenBuffer,
TuiWriteStream,
TuiDrawRegion,
TuiSetCursorInfo,
TuiSetScreenInfo,
TuiUpdateScreenInfo,
TuiChangeTitle,
TuiCleanupConsole,
TuiChangeIcon,
TuiResizeBuffer,
};
NTSTATUS FASTCALL
TuiInitConsole(PCSRSS_CONSOLE Console)
{
HANDLE ThreadHandle;
HANDLE ThreadHandle;
if (! ConsInitialized)
if (! ConsInitialized)
{
ConsInitialized = TRUE;
if (! TuiInit(Console->CodePage))
ConsInitialized = TRUE;
if (! TuiInit(Console->CodePage))
{
ConsInitialized = FALSE;
return STATUS_UNSUCCESSFUL;
ConsInitialized = FALSE;
return STATUS_UNSUCCESSFUL;
}
}
Console->Vtbl = &TuiVtbl;
Console->hWindow = NULL;
Console->Size = PhysicalConsoleSize;
Console->ActiveBuffer->MaxX = PhysicalConsoleSize.X;
Console->ActiveBuffer->MaxY = PhysicalConsoleSize.Y;
Console->Vtbl = &TuiVtbl;
Console->hWindow = NULL;
Console->Size = PhysicalConsoleSize;
Console->ActiveBuffer->MaxX = PhysicalConsoleSize.X;
Console->ActiveBuffer->MaxY = PhysicalConsoleSize.Y;
ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) TuiConsoleThread,
Console, 0, NULL);
if (NULL == ThreadHandle)
ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) TuiConsoleThread,
Console, 0, NULL);
if (NULL == ThreadHandle)
{
DPRINT1("CSR: Unable to create console thread\n");
return STATUS_UNSUCCESSFUL;
DPRINT1("CSR: Unable to create console thread\n");
return STATUS_UNSUCCESSFUL;
}
CloseHandle(ThreadHandle);
CloseHandle(ThreadHandle);
EnterCriticalSection(&ActiveConsoleLock);
if (NULL != ActiveConsole)
EnterCriticalSection(&ActiveConsoleLock);
if (NULL != ActiveConsole)
{
Console->Prev = ActiveConsole;
Console->Next = ActiveConsole->Next;
ActiveConsole->Next->Prev = Console;
ActiveConsole->Next = Console;
Console->Prev = ActiveConsole;
Console->Next = ActiveConsole->Next;
ActiveConsole->Next->Prev = Console;
ActiveConsole->Next = Console;
}
else
else
{
Console->Prev = Console;
Console->Next = Console;
Console->Prev = Console;
Console->Next = Console;
}
ActiveConsole = Console;
LeaveCriticalSection(&ActiveConsoleLock);
ActiveConsole = Console;
LeaveCriticalSection(&ActiveConsoleLock);
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}
PCSRSS_CONSOLE FASTCALL
TuiGetFocusConsole(VOID)
{
return ActiveConsole;
return ActiveConsole;
}
BOOL FASTCALL
TuiSwapConsole(int Next)
{
static PCSRSS_CONSOLE SwapConsole = NULL; /* console we are thinking about swapping with */
DWORD BytesReturned;
ANSI_STRING Title;
void * Buffer;
COORD *pos;
static PCSRSS_CONSOLE SwapConsole = NULL; /* console we are thinking about swapping with */
DWORD BytesReturned;
ANSI_STRING Title;
void * Buffer;
COORD *pos;
if (0 != Next)
if (0 != Next)
{
/* alt-tab, swap consoles */
/* move SwapConsole to next console, and print its title */
EnterCriticalSection(&ActiveConsoleLock);
if (! SwapConsole)
/* alt-tab, swap consoles */
/* move SwapConsole to next console, and print its title */
EnterCriticalSection(&ActiveConsoleLock);
if (! SwapConsole)
{
SwapConsole = ActiveConsole;
SwapConsole = ActiveConsole;
}
SwapConsole = (0 < Next ? SwapConsole->Next : SwapConsole->Prev);
Title.MaximumLength = RtlUnicodeStringToAnsiSize(&SwapConsole->Title);
Title.Length = 0;
Buffer = HeapAlloc(Win32CsrApiHeap,
0,
sizeof(COORD) + Title.MaximumLength);
pos = (COORD *)Buffer;
Title.Buffer = (PVOID)((ULONG_PTR)Buffer + sizeof( COORD ));
SwapConsole = (0 < Next ? SwapConsole->Next : SwapConsole->Prev);
Title.MaximumLength = RtlUnicodeStringToAnsiSize(&SwapConsole->Title);
Title.Length = 0;
Buffer = HeapAlloc(Win32CsrApiHeap,
0,
sizeof(COORD) + Title.MaximumLength);
pos = (COORD *)Buffer;
Title.Buffer = (PVOID)((ULONG_PTR)Buffer + sizeof( COORD ));
RtlUnicodeStringToAnsiString(&Title, &SwapConsole->Title, FALSE);
pos->Y = PhysicalConsoleSize.Y / 2;
pos->X = (PhysicalConsoleSize.X - Title.Length) / 2;
/* redraw the console to clear off old title */
ConioDrawConsole(ActiveConsole);
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
NULL, 0, Buffer, sizeof(COORD) + Title.Length,
&BytesReturned, NULL))
RtlUnicodeStringToAnsiString(&Title, &SwapConsole->Title, FALSE);
pos->Y = PhysicalConsoleSize.Y / 2;
pos->X = (PhysicalConsoleSize.X - Title.Length) / 2;
/* redraw the console to clear off old title */
ConioDrawConsole(ActiveConsole);
if (! DeviceIoControl(ConsoleDeviceHandle, IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
NULL, 0, Buffer, sizeof(COORD) + Title.Length,
&BytesReturned, NULL))
{
DPRINT1( "Error writing to console\n" );
DPRINT1( "Error writing to console\n" );
}
HeapFree(Win32CsrApiHeap, 0, Buffer);
LeaveCriticalSection(&ActiveConsoleLock);
HeapFree(Win32CsrApiHeap, 0, Buffer);
LeaveCriticalSection(&ActiveConsoleLock);
return TRUE;
return TRUE;
}
else if (NULL != SwapConsole)
else if (NULL != SwapConsole)
{
EnterCriticalSection(&ActiveConsoleLock);
if (SwapConsole != ActiveConsole)
EnterCriticalSection(&ActiveConsoleLock);
if (SwapConsole != ActiveConsole)
{
/* first remove swapconsole from the list */
SwapConsole->Prev->Next = SwapConsole->Next;
SwapConsole->Next->Prev = SwapConsole->Prev;
/* now insert before activeconsole */
SwapConsole->Next = ActiveConsole;
SwapConsole->Prev = ActiveConsole->Prev;
ActiveConsole->Prev->Next = SwapConsole;
ActiveConsole->Prev = SwapConsole;
/* first remove swapconsole from the list */
SwapConsole->Prev->Next = SwapConsole->Next;
SwapConsole->Next->Prev = SwapConsole->Prev;
/* now insert before activeconsole */
SwapConsole->Next = ActiveConsole;
SwapConsole->Prev = ActiveConsole->Prev;
ActiveConsole->Prev->Next = SwapConsole;
ActiveConsole->Prev = SwapConsole;
}
ActiveConsole = SwapConsole;
SwapConsole = NULL;
ConioDrawConsole(ActiveConsole);
LeaveCriticalSection(&ActiveConsoleLock);
return TRUE;
ActiveConsole = SwapConsole;
SwapConsole = NULL;
ConioDrawConsole(ActiveConsole);
LeaveCriticalSection(&ActiveConsoleLock);
return TRUE;
}
else
else
{
return FALSE;
return FALSE;
}
}