test: condll.h File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# condll.h File Reference

`#include <nt.h>`
`#include <ntrtl.h>`
`#include <nturtl.h>`
`#include <windows.h>`
`#include <winuserk.h>`
`#include <conroute.h>`
`#include "conapi.h"`
`#include "ntcsrdll.h"`
`#include "conmsg.h"`
`#include <string.h>`

Go to the source code of this file.

## Defines

#define | SET_CONSOLE_HANDLE(HANDLE) ((NtCurrentPeb())->ProcessParameters->ConsoleHandle = HANDLE)
#define | GET_CONSOLE_HANDLE ((NtCurrentPeb())->ProcessParameters->ConsoleHandle)
#define | SET_LAST_ERROR(ERROR) (SetLastError( ERROR ) )
#define | SET_LAST_NT_ERROR(ERROR) (SetLastError( RtlNtStatusToDosError( ERROR ) ) )
#define | VALID_ACCESSES (GENERIC_READ | GENERIC_WRITE)
#define | VALID_SHARE_ACCESSES (FILE_SHARE_READ | FILE_SHARE_WRITE)
#define | VALID_DUP_OPTIONS (DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)
#define | CONSOLE_RECT_SIZE_X(RECT) ((RECT)->Right - (RECT)->Left + 1)
#define | CONSOLE_RECT_SIZE_Y(RECT) ((RECT)->Bottom - (RECT)->Top + 1)
#define | LockDll() RtlEnterCriticalSection(&DllLock)
#define | UnlockDll() RtlLeaveCriticalSection(&DllLock)

## Functions

NTSTATUS | InitializeCtrlHandling (VOID)
USHORT | GetCurrentExeName (LPWSTR Buffer, ULONG BufferLength)
HANDLE APIENTRY | OpenConsoleWInternal (IN ULONG HandleType, IN ULONG DesiredAccess, IN BOOL InheritHandle, IN ULONG ShareMode)
| defined(BUILD_WOW64)
BOOL APIENTRY | ReadConsoleInternal (IN HANDLE hConsoleInput, OUT LPVOID lpBuffer, IN DWORD nNumberOfCharsToRead, OUT LPDWORD lpNumberOfCharsRead, IN OUT LPVOID lpReserved, IN BOOLEAN Unicode, IN USHORT ExeNameLength, IN LPWSTR ExeName)
BOOL APIENTRY | WriteConsoleInternal (IN HANDLE hConsoleOutput, IN CONST VOID *lpBuffer, IN DWORD nNumberOfCharsToWrite, OUT LPDWORD lpNumberOfCharsWritten, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
BOOL APIENTRY | RegisterConsoleIMEInternal (IN HWND hWndConsoleIME, IN DWORD dwConsoleIMEThreadId, IN DWORD DesktopLength, IN LPWSTR Desktop, OUT DWORD *dwConsoleThreadId)
BOOL APIENTRY | UnregisterConsoleIMEInternal (IN DWORD dwConsoleIMEThtreadId)
BOOL APIENTRY | GetConsoleInput (IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead, IN USHORT wFlags, IN BOOLEAN Unicode)
BOOL APIENTRY | WriteConsoleInputInternal (IN HANDLE hConsoleInput, IN CONST INPUT_RECORD *lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsWritten, IN BOOLEAN Unicode, IN BOOLEAN Append)
| defined(BUILD_WOW64)
BOOL APIENTRY | ReadConsoleOutputInternal (IN HANDLE hConsoleOutput, OUT PCHAR_INFO lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN OUT PSMALL_RECT lpReadRegion, IN BOOLEAN Unicode)
BOOL APIENTRY | WriteConsoleOutputInternal (IN HANDLE hConsoleOutput, IN CONST CHAR_INFO *lpBuffer, IN COORD dwBufferSize, IN COORD dwBufferCoord, IN PSMALL_RECT lpWriteRegion, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
BOOL APIENTRY | ReadConsoleOutputString (IN HANDLE hConsoleOutput, OUT LPVOID lpString, IN DWORD nLength, IN DWORD nSize, IN DWORD fFlags, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfElementsRead)
BOOL APIENTRY | WriteConsoleOutputString (IN HANDLE hConsoleOutput, IN CONST VOID *lpString, IN DWORD nLength, IN DWORD nSize, IN DWORD fFlags, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfElementsWritten)
| defined(BUILD_WOW64)
BOOL APIENTRY | FillConsoleOutput (IN HANDLE hConsoleOutput, IN WORD Element, IN DWORD nLength, IN DWORD fFlags, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfElementsWritten)
| defined(BUILD_WOW64)
BOOL APIENTRY | GetConsoleKeyboardLayoutNameWorker (OUT LPSTR pszLayout, IN BOOL bAnsi)
| defined(BUILD_WOW64)
BOOL APIENTRY | SetConsolePaletteInternal (IN HANDLE hConsoleOutput, IN HPALETTE hPalette, IN UINT dwUsage)
BOOL APIENTRY | ScrollConsoleScreenBufferInternal (IN HANDLE hConsoleOutput, IN CONST SMALL_RECT *lpScrollRectangle, IN CONST SMALL_RECT *lpClipRectangle, IN COORD dwDestinationOrigin, IN CONST CHAR_INFO *lpFill, IN BOOLEAN Unicode)
NTSTATUS APIENTRY | SetConsoleOutputCPInternal (IN UINT wCodePageID)
VOID APIENTRY | SetLastConsoleEventActiveInternal (VOID)
| defined(BUILD_WOW64)
BOOL APIENTRY | ConnectConsoleInternal (IN PWSTR pObjectDirectory, IN OUT PCONSOLE_API_CONNECTINFO pConnectInfo, OUT PBOOLEAN pServerProcess)
| defined(BUILD_WOW64)
BOOL APIENTRY | AllocConsoleInternal (IN LPWSTR lpTitle, IN DWORD dwTitleLength, IN LPWSTR lpDesktop, IN DWORD dwDesktopLength, IN LPWSTR lpCurDir, IN DWORD dwCurDirLength, IN LPWSTR AppName, IN DWORD dwAppNameLength, IN LPTHREAD_START_ROUTINE CtrlRoutine, IN LPTHREAD_START_ROUTINE PropRoutine, IN OUT PCONSOLE_INFO pConsoleInfo)
| defined(BUILD_WOW64)
BOOL APIENTRY | FreeConsoleInternal (VOID)
| defined(BUILD_WOW64)
BOOL WINAPI | GetConsoleLangId (OUT LANGID *lpLangId)
| defined(BUILD_WOW64)
BOOL APIENTRY | AddConsoleAliasInternal (IN LPVOID Source, IN UINT SourceLength, IN LPVOID Target, IN UINT TargetLength, IN LPVOID ExeName, IN BOOLEAN Unicode)
DWORD APIENTRY | GetConsoleAliasInternal (IN LPVOID Source, IN UINT SourceLength, OUT LPVOID TargetBuffer, IN UINT TargetBufferLength, IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleAliasesLengthInternal (IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleAliasExesLengthInternal (IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleAliasesInternal (OUT LPVOID AliasBuffer, IN DWORD AliasBufferLength, IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleAliasExesInternal (OUT LPVOID ExeNameBuffer, IN DWORD ExeNameBufferLength, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
VOID APIENTRY | ExpungeConsoleCommandHistoryInternal (IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
BOOL APIENTRY | SetConsoleNumberOfCommandsInternal (IN DWORD Number, IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleCommandHistoryLengthInternal (IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleCommandHistoryInternal (OUT LPVOID Commands, IN DWORD CommandBufferLength, IN LPVOID ExeName, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
DWORD APIENTRY | GetConsoleTitleInternal (OUT PVOID lpConsoleTitle, IN DWORD nSize, IN BOOLEAN Unicode)
BOOL APIENTRY | SetConsoleTitleInternal (IN CONST VOID *lpConsoleTitle, IN DWORD TitleLength, IN BOOLEAN Unicode)
| defined(BUILD_WOW64)
VOID | SetTEBLangID (VOID)
| defined(BUILD_WOW6432)

## Variables

CRITICAL_SECTION | DllLock

## Define Documentation

#define CONSOLE_RECT_SIZE_X | ( | RECT |  | ) | ((RECT)->Right - (RECT)->Left + 1)

| Definition at line 58 of file condll.h. Referenced by CopyRectangle(), ReadConsoleOutputInternal(), and WriteConsoleOutputInternal().

#define CONSOLE_RECT_SIZE_Y | ( | RECT |  | ) | ((RECT)->Bottom - (RECT)->Top + 1)

| Definition at line 59 of file condll.h. Referenced by CopyRectangle(), ReadConsoleOutputInternal(), and WriteConsoleOutputInternal().

#define GET_CONSOLE_HANDLE ((NtCurrentPeb())->ProcessParameters->ConsoleHandle)

| Definition at line 47 of file condll.h. Referenced by AddConsoleAliasInternal(), AllocConsole(), CloseConsoleHandle(), ConDllInitialize(), ConsoleMenuControl(), CreateConsoleScreenBuffer(), DuplicateConsoleHandle(), ExpungeConsoleCommandHistoryInternal(), FillConsoleOutput(), FlushConsoleInputBuffer(), FreeConsole(), FreeConsoleInternal(), GenerateConsoleCtrlEvent(), GetConsoleAliasesInternal(), GetConsoleAliasesLengthInternal(), GetConsoleAliasExesInternal(), GetConsoleAliasExesLengthInternal(), GetConsoleAliasInternal(), GetConsoleCommandHistoryInternal(), GetConsoleCommandHistoryLengthInternal(), GetConsoleCP(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleFontSize(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleInput(), GetConsoleKeyboardLayoutNameWorker(), GetConsoleLangId(), GetConsoleMode(), GetConsoleOutputCP(), GetConsoleScreenBufferInfo(), GetConsoleTitleInternal(), GetConsoleWindow(), GetCurrentConsoleFont(), GetLargestConsoleWindowSize(), GetNumberOfConsoleFonts(), GetNumberOfConsoleInputEvents(), GetNumberOfConsoleMouseButtons(), InvalidateConsoleDIBits(), OpenConsoleWInternal(), ReadConsoleInternal(), ReadConsoleOutputInternal(), ReadConsoleOutputString(), RegisterConsoleVDM(), ScrollConsoleScreenBufferInternal(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleIcon(), SetConsoleKeyShortcuts(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleNumberOfCommandsInternal(), SetConsoleOutputCPInternal(), SetConsolePaletteInternal(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleTitleInternal(), SetConsoleWindowInfo(), SetLastConsoleEventActiveInternal(), ShowConsoleCursor(), VDMConsoleOperation(), VerifyConsoleIoHandle(), WriteConsoleInputInternal(), WriteConsoleInternal(), WriteConsoleOutputInternal(), and WriteConsoleOutputString().

#define LockDll | (

)

RtlEnterCriticalSection(&DllLock)

| Definition at line 68 of file condll.h. Referenced by AllocConsole(), CtrlRoutine(), FreeConsole(), and SetConsoleCtrlHandler().

#define SET_CONSOLE_HANDLE | ( | HANDLE |  | ) | ((NtCurrentPeb())->ProcessParameters->ConsoleHandle = HANDLE)

| Definition at line 46 of file condll.h. Referenced by AllocConsoleInternal(), ConDllInitialize(), ConnectConsoleInternal(), FreeConsoleInternal(), and SetUpHandles().

#define SET_LAST_ERROR | ( | ERROR |  | ) | (SetLastError( ERROR ) )

| Definition at line 48 of file condll.h. Referenced by AddConsoleAliasInternal(), AllocConsoleInternal(), CreateConsoleScreenBuffer(), DuplicateConsoleHandle(), ExpungeConsoleCommandHistoryInternal(), FillConsoleOutput(), FreeConsole(), GenerateConsoleCtrlEvent(), GetConsoleAliasesInternal(), GetConsoleAliasesLengthInternal(), GetConsoleAliasExesInternal(), GetConsoleAliasInternal(), GetConsoleCommandHistoryInternal(), GetConsoleCommandHistoryLengthInternal(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleInput(), GetConsoleInputExeNameA(), GetConsoleInputExeNameW(), GetConsoleMode(), GetConsoleScreenBufferInfo(), GetConsoleTitleInternal(), GetCurrentConsoleFont(), GetNumberOfConsoleInputEvents(), GetNumberOfConsoleMouseButtons(), InvalidateConsoleDIBits(), OpenConsoleW(), ReadConsoleInternal(), ReadConsoleOutputInternal(), ReadConsoleOutputString(), RegisterConsoleVDM(), RemoveCtrlHandler(), ScrollConsoleScreenBufferInternal(), SetConsoleCursorInfo(), SetConsoleDisplayMode(), SetConsoleInputExeNameA(), SetConsoleInputExeNameW(), SetConsoleKeyShortcuts(), SetConsoleNumberOfCommandsInternal(), SetConsoleTitleA(), SetConsoleTitleW(), SetConsoleWindowInfo(), SetCtrlHandler(), VDMConsoleOperation(), WriteConsoleInputInternal(), WriteConsoleInternal(), WriteConsoleOutputInternal(), and WriteConsoleOutputString().

#define SET_LAST_NT_ERROR | ( | ERROR |  | ) | (SetLastError( RtlNtStatusToDosError( ERROR ) ) )

| Definition at line 49 of file condll.h. Referenced by AddConsoleAliasInternal(), AllocConsoleInternal(), CloseConsoleHandle(), ConnectConsoleInternal(), CreateConsoleScreenBuffer(), DuplicateConsoleHandle(), FillConsoleOutput(), FlushConsoleInputBuffer(), FreeConsoleInternal(), GenerateConsoleCtrlEvent(), GetConsoleAliasesInternal(), GetConsoleAliasesLengthInternal(), GetConsoleAliasExesInternal(), GetConsoleAliasExesLengthInternal(), GetConsoleAliasInternal(), GetConsoleCommandHistoryInternal(), GetConsoleCP(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleFontSize(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleInput(), GetConsoleKeyboardLayoutNameWorker(), GetConsoleMode(), GetConsoleOutputCP(), GetConsoleScreenBufferInfo(), GetConsoleTitleInternal(), GetConsoleWindow(), GetCurrentConsoleFont(), GetLargestConsoleWindowSize(), GetNumberOfConsoleFonts(), GetNumberOfConsoleInputEvents(), GetNumberOfConsoleMouseButtons(), InvalidateConsoleDIBits(), OpenConsoleWInternal(), ReadConsoleInternal(), ReadConsoleOutputInternal(), ReadConsoleOutputString(), RegisterConsoleVDM(), ScrollConsoleScreenBufferInternal(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleIcon(), SetConsoleKeyShortcuts(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleNumberOfCommandsInternal(), SetConsoleOutputCP(), SetConsolePalette(), SetConsolePaletteInternal(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleTitleInternal(), SetConsoleWindowInfo(), VDMConsoleOperation(), VerifyConsoleIoHandle(), WriteConsoleInputInternal(), WriteConsoleInternal(), WriteConsoleOutputInternal(), and WriteConsoleOutputString().

#define UnlockDll | (

)

RtlLeaveCriticalSection(&DllLock)

| Definition at line 69 of file condll.h. Referenced by AllocConsole(), CtrlRoutine(), FreeConsole(), and SetConsoleCtrlHandler().

#define VALID_ACCESSES (GENERIC_READ | GENERIC_WRITE)

| Definition at line 53 of file condll.h. Referenced by CreateConsoleScreenBuffer(), DuplicateConsoleHandle(), and OpenConsoleW().

#define VALID_DUP_OPTIONS (DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)

| Definition at line 56 of file condll.h. Referenced by DuplicateConsoleHandle().

#define VALID_SHARE_ACCESSES (FILE_SHARE_READ | FILE_SHARE_WRITE)

| Definition at line 54 of file condll.h. Referenced by CreateConsoleScreenBuffer(), and OpenConsoleW().

## Function Documentation

BOOL APIENTRY AddConsoleAliasInternal | ( | IN LPVOID | Source,
|  | IN UINT | SourceLength,
|  | IN LPVOID | Target,
|  | IN UINT | TargetLength,
|  | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

Definition at line 126 of file client/cmdline.c.

References CONSOLE_API_MSG, _CONSOLE_ADDALIAS_MSG::ConsoleHandle, ConsolepAddAlias, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_ADDALIAS_MSG::Exe, _CONSOLE_ADDALIAS_MSG::ExeLength, FALSE, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, PCONSOLE_ADDALIAS_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_ADDALIAS_MSG::Source, _CONSOLE_ADDALIAS_MSG::SourceLength, _CONSOLE_ADDALIAS_MSG::Target, _CONSOLE_ADDALIAS_MSG::TargetLength, TRUE, _CONSOLE_API_MSG::u, Unicode, _CONSOLE_ADDALIAS_MSG::Unicode, _CONSOLE_ADDALIAS_MSG::UnicodeExe, and USHORT.

Referenced by AddConsoleAliasA(), and AddConsoleAliasW().

    00137           :
    00138
    00139     Source - String to substitute alias string for, in input stream.
    00140
    00141     Target - String to substitute for source.  NULL to delete an existing
    00142         alias.
    00143
    00144     ExeName - Exe to set alias in.
    00145
    00146 Return Value:
    00147
    00148     TRUE - The operation was successful.
    00149
    00150     FALSE/NULL - The operation failed. Extended error status is available
    00151         using GetLastError.
    00152
    00153 --*/
    00154
    00155 {
    00156     PCSR_CAPTURE_HEADER CaptureBuffer;
    00157     CONSOLE_API_MSG m;
    00158     ULONG CapturedMsgPointers;
    00159     PCONSOLE_ADDALIAS_MSG a = &m.u.AddConsoleAliasW;
    00160
    00161     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00162     a->SourceLength = (USHORT)SourceLength;
    00163     a->Unicode = Unicode;
    00164     CapturedMsgPointers = 2;
    00165
    00166     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00167
    00168     if (Target != NULL) {
    00169         a->TargetLength = (USHORT)TargetLength;
    00170         CapturedMsgPointers += 1;
    00171     }
    00172     else {
    00173         a->Target = NULL;
    00174         a->TargetLength = 0;
    00175     }
    00176
    00177     CaptureBuffer = CsrAllocateCaptureBuffer( CapturedMsgPointers,
    00178                                               a->SourceLength + a->TargetLength + a->ExeLength
    00179                                             );
    00180     if (CaptureBuffer == NULL) {
    00181         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00182         return FALSE;
    00183     }
    00184     CsrCaptureMessageBuffer( CaptureBuffer,
    00185                              (PCHAR) Source,
    00186                              a->SourceLength,
    00187                              (PVOID *) &a->Source
    00188                            );
    00189
    00190     CsrCaptureMessageBuffer( CaptureBuffer,
    00191                              (PCHAR) ExeName,
    00192                              a->ExeLength,
    00193                              (PVOID *) &a->Exe
    00194                            );
    00195
    00196     if (Target != NULL) {
    00197         CsrCaptureMessageBuffer( CaptureBuffer,
    00198                                  (PCHAR) Target,
    00199                                  a->TargetLength,
    00200                                  (PVOID *) &a->Target
    00201                                );
    00202     }
    00203
    00204     CsrClientCallServer( (PCSR_API_MSG)&m,
    00205                          CaptureBuffer,
    00206                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00207                                               ConsolepAddAlias
    00208                                             ),
    00209                          sizeof( *a )
    00210                        );
    00211
    00212     CsrFreeCaptureBuffer( CaptureBuffer );
    00213
    00214     if (!NT_SUCCESS( m.ReturnValue )) {
    00215         SET_LAST_NT_ERROR(m.ReturnValue);
    00216         return FALSE;
    00217     }
    00218     return TRUE;
    00219
    00220 }

BOOL APIENTRY AllocConsoleInternal | ( | IN LPWSTR | lpTitle,
|  | IN DWORD | dwTitleLength,
|  | IN LPWSTR | lpDesktop,
|  | IN DWORD | dwDesktopLength,
|  | IN LPWSTR | lpCurDir,
|  | IN DWORD | dwCurDirLength,
|  | IN LPWSTR | AppName,
|  | IN DWORD | dwAppNameLength,
|  | IN LPTHREAD_START_ROUTINE | CtrlRoutine,
|  | IN LPTHREAD_START_ROUTINE | PropRoutine,
|  | IN OUT PCONSOLE_INFO | pConsoleInfo
| ) |

defined(BUILD_WOW64)

Definition at line 656 of file dllinit.c.

References _CONSOLE_ALLOC_MSG::AppName, _CONSOLE_ALLOC_MSG::AppNameLength, BOOL, CONSOLE_INFO, _CONSOLE_ALLOC_MSG::ConsoleInfo, ConsolepAlloc, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_ALLOC_MSG::CtrlRoutine, CtrlRoutine, _CONSOLE_ALLOC_MSG::CurDir, _CONSOLE_ALLOC_MSG::CurDirLength, _CONSOLE_ALLOC_MSG::Desktop, _CONSOLE_ALLOC_MSG::DesktopLength, FALSE, INITIALIZATION_FAILED, INITIALIZATION_SUCCEEDED, NT_SUCCESS, NtClose(), NTSTATUS(), NtWaitForMultipleObjects(), NULL, NUMBER_OF_INITIALIZATION_EVENTS, _CONSOLE_ALLOC_MSG::PropRoutine, PropRoutine(), SET_CONSOLE_HANDLE, SET_LAST_ERROR, SET_LAST_NT_ERROR, Status, _CONSOLE_ALLOC_MSG::Title, _CONSOLE_ALLOC_MSG::TitleLength, TRUE, and _CONSOLE_API_MSG::u.

Referenced by AllocConsole().

    00670                    :
    00671
    00672    Marshels the parameters for the ConsolepAlloc command.
    00673
    00674 Arguments:
    00675
    00676    See the CONSOLE_ALLOC_MSG structure and AllocConsole.
    00677
    00678 Return Value:
    00679
    00680     TRUE - Success
    00681
    00682     FALSE - An error occured.
    00683
    00684 --*/
    00685 {
    00686    CONSOLE_API_MSG m;
    00687    PCONSOLE_ALLOC_MSG a = &m.u.AllocConsole;
    00688    PCSR_CAPTURE_HEADER CaptureBuffer = NULL;
    00689    BOOL Status = FALSE;
    00690    NTSTATUS St;
    00691
    00692    try {
    00693
    00694         a->CtrlRoutine = CtrlRoutine;
    00695         a->PropRoutine = PropRoutine;
    00696
    00697         // Allocate 4 extra pointer sizes to compensate for any alignment done
    00698         // by CsrCaptureMessageBuffer.
    00699
    00700         CaptureBuffer = CsrAllocateCaptureBuffer( 5,
    00701                                                   dwTitleLength + dwDesktopLength + dwCurDirLength +
    00702                                                   dwAppNameLength + sizeof( CONSOLE_INFO ) + (4 * sizeof(PVOID))
    00703                                                  );
    00704         if (CaptureBuffer == NULL) {
    00705             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00706             Status = FALSE;
    00707             leave;
    00708         }
    00709
    00710         // Allocate the CONSOLE_INFO first so that it is aligned on a pointer
    00711         // boundry.  This is necessary since NtWaitForMultipleObject expects
    00712         // its arguments aligned on a handle boundry.
    00713
    00714         CsrCaptureMessageBuffer( CaptureBuffer,
    00715                                  pConsoleInfo,
    00716                                  sizeof( CONSOLE_INFO ),
    00717                                  (PVOID *) &a->ConsoleInfo
    00718                                );
    00719
    00720         a->TitleLength = dwTitleLength;
    00721         CsrCaptureMessageBuffer( CaptureBuffer,
    00722                                  lpTitle,
    00723                                  dwTitleLength,
    00724                                  (PVOID *) &a->Title
    00725                                );
    00726
    00727         a->DesktopLength = dwDesktopLength;
    00728         CsrCaptureMessageBuffer( CaptureBuffer,
    00729                                  lpDesktop,
    00730                                  dwDesktopLength,
    00731                                  (PVOID *) &a->Desktop
    00732                                );
    00733
    00734         a->CurDirLength = dwCurDirLength;
    00735         CsrCaptureMessageBuffer( CaptureBuffer,
    00736                                  lpCurDir,
    00737                                  dwCurDirLength,
    00738                                  (PVOID *) &a->CurDir
    00739                                );
    00740
    00741         a->AppNameLength = dwAppNameLength;
    00742         CsrCaptureMessageBuffer( CaptureBuffer,
    00743                                  lpAppName,
    00744                                  dwAppNameLength,
    00745                                  (PVOID *) &a->AppName
    00746                                );
    00747
    00748         //
    00749         // Connect to the server process
    00750         //
    00751
    00752         CsrClientCallServer( (PCSR_API_MSG)&m,
    00753                              CaptureBuffer,
    00754                              CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00755                                                   ConsolepAlloc
    00756                                                 ),
    00757                              sizeof( *a )
    00758                            );
    00759         if (!NT_SUCCESS( m.ReturnValue )) {
    00760             SET_LAST_NT_ERROR (m.ReturnValue);
    00761             Status = FALSE;
    00762             leave;
    00763         }
    00764
    00765         St = NtWaitForMultipleObjects(NUMBER_OF_INITIALIZATION_EVENTS,
    00766                                       a->ConsoleInfo->InitEvents,
    00767                                       WaitAny,
    00768                                       FALSE,
    00769                                       NULL
    00770                                       );
    00771         if (!NT_SUCCESS(St)) {
    00772            SET_LAST_NT_ERROR(St);
    00773            Status = FALSE;
    00774            leave;
    00775         }
    00776
    00777         //The handles to be closed are events, so NtClose works fine.
    00778         NtClose(a->ConsoleInfo->InitEvents[INITIALIZATION_SUCCEEDED]);
    00779         NtClose(a->ConsoleInfo->InitEvents[INITIALIZATION_FAILED]);
    00780         if (St != INITIALIZATION_SUCCEEDED) {
    00781             SET_CONSOLE_HANDLE(NULL);
    00782             Status = FALSE;
    00783             leave;
    00784         }
    00785         RtlCopyMemory(pConsoleInfo, a->ConsoleInfo, sizeof(CONSOLE_INFO));
    00786         Status = TRUE;
    00787    }
    00788    finally {
    00789       if (CaptureBuffer) {
    00790          CsrFreeCaptureBuffer( CaptureBuffer );
    00791       }
    00792    }
    00793
    00794    return Status;
    00795 }

BOOL APIENTRY ConnectConsoleInternal | ( | IN PWSTR | pObjectDirectory,
|  | IN OUT PCONSOLE_API_CONNECTINFO | pConnectInfo,
|  | OUT PBOOLEAN | pServerProcess
| ) |

defined(BUILD_WOW64)

Definition at line 373 of file dllinit.c.

References CsrClientConnectToServer(), FALSE, INITIALIZATION_FAILED, INITIALIZATION_SUCCEEDED, NT_SUCCESS, NtClose(), NTSTATUS(), NtWaitForMultipleObjects(), NULL, NUMBER_OF_INITIALIZATION_EVENTS, SET_CONSOLE_HANDLE, SET_LAST_NT_ERROR, Status, and TRUE.

Referenced by ConDllInitialize().

    00379                    :
    00380
    00381     Helper function for establishing a connection with the console server.
    00382     Waits for the server to signal completion.
    00383
    00384 Arguments:
    00385
    00386     pObjectDirectory -  Supplies a null terminated string that is the same
    00387         as the value of the ObjectDirectory= argument passed to the CSRSS
    00388         program.
    00389
    00390     pConnectInfo - Supplies and recieves the connection information.
    00391
    00392     pServerProcess - Recieves TRUE if this is a server process.
    00393
    00394 Return Value:
    00395
    00396     TRUE - Success
    00397
    00398     FALSE - An error occured.
    00399
    00400 --*/
    00401 {
    00402
    00403    NTSTATUS Status;
    00404    ULONG ConnectionInformationLength;
    00405
    00406    ConnectionInformationLength = sizeof(CONSOLE_API_CONNECTINFO);
    00407
    00408    Status = CsrClientConnectToServer( pObjectDirectory,
    00409                                       CONSRV_SERVERDLL_INDEX,
    00410                                       NULL,
    00411                                       pConnectInfo,
    00412                                       &ConnectionInformationLength,
    00413                                       pServerProcess
    00414                                     );
    00415
    00416    if (!NT_SUCCESS( Status )) {
    00417        return FALSE;
    00418    }
    00419
    00420    //
    00421    // we return success although no console api can be called because
    00422    // loading shouldn't fail.  we'll fail the api calls later.
    00423    //
    00424
    00425    if (*pServerProcess) {
    00426        return TRUE;
    00427    }
    00428
    00429
    00430    //
    00431    // if this is not a console app, return success - nothing else to do.
    00432    //
    00433
    00434    if (!pConnectInfo->ConsoleApp) {
    00435        return TRUE;
    00436    }
    00437
    00438    //
    00439    // wait for initialization to complete.  we have to use the NT
    00440    // wait because the heap hasn't been initialized yet.
    00441    //
    00442
    00443    Status = NtWaitForMultipleObjects(NUMBER_OF_INITIALIZATION_EVENTS,
    00444                                         pConnectInfo->ConsoleInfo.InitEvents,
    00445                                         WaitAny,
    00446                                         FALSE,
    00447                                         NULL
    00448                                         );
    00449
    00450    if (!NT_SUCCESS(Status)) {
    00451        SET_LAST_NT_ERROR(Status);
    00452        return FALSE;
    00453    }
    00454
    00455    NtClose(pConnectInfo->ConsoleInfo.InitEvents[INITIALIZATION_SUCCEEDED]);
    00456    NtClose(pConnectInfo->ConsoleInfo.InitEvents[INITIALIZATION_FAILED]);
    00457    if (Status != INITIALIZATION_SUCCEEDED) {
    00458        SET_CONSOLE_HANDLE(NULL);
    00459        return FALSE;
    00460    }
    00461
    00462    return TRUE;
    00463 }

VOID APIENTRY ExpungeConsoleCommandHistoryInternal | ( | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 733 of file client/cmdline.c.

References _CONSOLE_EXPUNGECOMMANDHISTORY_MSG::ConsoleHandle, ConsolepExpungeCommandHistory, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_EXPUNGECOMMANDHISTORY_MSG::Exe, _CONSOLE_EXPUNGECOMMANDHISTORY_MSG::ExeLength, GET_CONSOLE_HANDLE, GetExeName(), NULL, PCONSOLE_EXPUNGECOMMANDHISTORY_MSG, SET_LAST_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_EXPUNGECOMMANDHISTORY_MSG::Unicode, Unicode, and _CONSOLE_EXPUNGECOMMANDHISTORY_MSG::UnicodeExe.

Referenced by ExpungeConsoleCommandHistoryA(), and ExpungeConsoleCommandHistoryW().

    00737 {
    00738     CONSOLE_API_MSG m;
    00739     PCONSOLE_EXPUNGECOMMANDHISTORY_MSG a = &m.u.ExpungeConsoleCommandHistoryW;
    00740     PCSR_CAPTURE_HEADER CaptureBuffer;
    00741
    00742     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00743     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00744     a->Unicode = Unicode;
    00745
    00746     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00747                                               a->ExeLength
    00748                                             );
    00749     if (CaptureBuffer == NULL) {
    00750         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00751         return;
    00752     }
    00753
    00754     CsrCaptureMessageBuffer( CaptureBuffer,
    00755                              (PCHAR) ExeName,
    00756                              a->ExeLength,
    00757                              (PVOID *) &a->Exe
    00758                            );
    00759
    00760     CsrClientCallServer( (PCSR_API_MSG)&m,
    00761                          CaptureBuffer,
    00762                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00763                                               ConsolepExpungeCommandHistory
    00764                                             ),
    00765                          sizeof( *a )
    00766                        );
    00767     CsrFreeCaptureBuffer( CaptureBuffer );
    00768
    00769 }

BOOL APIENTRY FillConsoleOutput | ( | IN HANDLE | hConsoleOutput,
|  | IN WORD | Element,
|  | IN DWORD | nLength,
|  | IN DWORD | fFlags,
|  | IN COORD | dwWriteCoord,
|  | OUT LPDWORD | lpNumberOfElementsWritten
| ) |

defined(BUILD_WOW64)

Definition at line 1448 of file iostubs.c.

References _CONSOLE_FILLCONSOLEOUTPUT_MSG::ConsoleHandle, ConsolepFillConsoleOutput, CsrClientCallServer(), _CONSOLE_FILLCONSOLEOUTPUT_MSG::Element, _CONSOLE_FILLCONSOLEOUTPUT_MSG::ElementType, EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, _CONSOLE_FILLCONSOLEOUTPUT_MSG::Length, NT_SUCCESS, NULL, _CONSOLE_FILLCONSOLEOUTPUT_MSG::OutputHandle, SET_LAST_ERROR, SET_LAST_NT_ERROR, TRUE, _CONSOLE_API_MSG::u, and _CONSOLE_FILLCONSOLEOUTPUT_MSG::WriteCoord.

Referenced by FillConsoleOutputAttribute(), FillConsoleOutputCharacterA(), and FillConsoleOutputCharacterW().

    01459           :
    01460
    01461     hConsoleOutput - Supplies an open handle to the screen buffer (CONOUT$)
    01462         that is to be written.  The handle must have been created with
    01463         GENERIC_WRITE access.
    01464
    01465     Element - The attribute or character to write.
    01466
    01467     nLength - Number of times to write the element.
    01468
    01469     fFlags - flag indicating what type of element to write.
    01470
    01471     dwWriteCoord - Screen buffer coordinates to write the element to.
    01472
    01473     lpNumberOfElementsWritten - Pointer to number of elements written.
    01474
    01475 Return Value:
    01476
    01477     TRUE - The operation was successful.
    01478
    01479     FALSE/NULL - The operation failed.
    01480         Extended error status is available using GetLastError.
    01481
    01482 --*/
    01483
    01484 {
    01485
    01486     CONSOLE_API_MSG m;
    01487     PCONSOLE_FILLCONSOLEOUTPUT_MSG a = &m.u.FillConsoleOutput;
    01488
    01489     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01490     a->OutputHandle = hConsoleOutput;
    01491     a->Length = nLength;
    01492     a->ElementType = fFlags;
    01493     a->Element = Element;
    01494     a->WriteCoord = dwWriteCoord;
    01495     CsrClientCallServer( (PCSR_API_MSG)&m,
    01496                          NULL,
    01497                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01498                                               ConsolepFillConsoleOutput
    01499                                             ),
    01500                          sizeof( *a )
    01501                        );
    01502     try {
    01503         *lpNumberOfElementsWritten = a->Length;
    01504     } except( EXCEPTION_EXECUTE_HANDLER ) {
    01505         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01506         return FALSE;
    01507     }
    01508     if (!NT_SUCCESS(m.ReturnValue)) {
    01509         SET_LAST_NT_ERROR(m.ReturnValue);
    01510         return FALSE;
    01511     }
    01512     else {
    01513         return TRUE;
    01514     }
    01515
    01516 }

BOOL APIENTRY FreeConsoleInternal | ( | VOID |  | ) |

defined(BUILD_WOW64)

Definition at line 922 of file dllinit.c.

References _CONSOLE_FREE_MSG::ConsoleHandle, ConsolepFree, CsrClientCallServer(), FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, SET_CONSOLE_HANDLE, SET_LAST_NT_ERROR, TRUE, and _CONSOLE_API_MSG::u.

Referenced by FreeConsole().

    00927                    :
    00928
    00929    Marshels the parameters for the ConsolepFree command.
    00930
    00931 Arguments:
    00932
    00933    See the CONSOLE_FREE_MSG structure and FreeConsole.
    00934
    00935 Return Value:
    00936
    00937     TRUE - Success
    00938
    00939     FALSE - An error occured.
    00940
    00941 --*/
    00942 {
    00943
    00944    CONSOLE_API_MSG m;
    00945    PCONSOLE_FREE_MSG a = &m.u.FreeConsole;
    00946
    00947    a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00948
    00949    //
    00950    // Connect to the server process
    00951    //
    00952
    00953    CsrClientCallServer( (PCSR_API_MSG)&m,
    00954                         NULL,
    00955                         CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00956                                              ConsolepFree
    00957                                            ),
    00958                         sizeof( *a )
    00959                       );
    00960
    00961    if (!NT_SUCCESS( m.ReturnValue )) {
    00962       SET_LAST_NT_ERROR (m.ReturnValue);
    00963       return FALSE;
    00964
    00965    } else {
    00966
    00967       SET_CONSOLE_HANDLE(NULL);
    00968       return TRUE;
    00969    }
    00970
    00971 }

DWORD APIENTRY GetConsoleAliasesInternal | ( | OUT LPVOID | AliasBuffer,
|  | IN DWORD | AliasBufferLength,
|  | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 550 of file client/cmdline.c.

References _CONSOLE_GETALIASES_MSG::AliasesBuffer, _CONSOLE_GETALIASES_MSG::AliasesBufferLength, _CONSOLE_GETALIASES_MSG::ConsoleHandle, ConsolepGetAliases, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, _CONSOLE_GETALIASES_MSG::Exe, _CONSOLE_GETALIASES_MSG::ExeLength, FALSE, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, PCONSOLE_GETALIASES_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_GETALIASES_MSG::Unicode, Unicode, and _CONSOLE_GETALIASES_MSG::UnicodeExe.

Referenced by GetConsoleAliasesA(), and GetConsoleAliasesW().

    00556 {
    00557     CONSOLE_API_MSG m;
    00558     PCONSOLE_GETALIASES_MSG a = &m.u.GetConsoleAliasesW;
    00559     PCSR_CAPTURE_HEADER CaptureBuffer;
    00560
    00561     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00562     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00563     a->Unicode = Unicode;
    00564     a->AliasesBufferLength = AliasBufferLength;
    00565
    00566     CaptureBuffer = CsrAllocateCaptureBuffer( 2,
    00567                                               a->ExeLength + AliasBufferLength
    00568                                             );
    00569     if (CaptureBuffer == NULL) {
    00570         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00571         return FALSE;
    00572     }
    00573
    00574     CsrCaptureMessageBuffer( CaptureBuffer,
    00575                              (PCHAR) ExeName,
    00576                              a->ExeLength,
    00577                              (PVOID *) &a->Exe
    00578                            );
    00579     CsrCaptureMessageBuffer( CaptureBuffer,
    00580                              (PCHAR) NULL,
    00581                              a->AliasesBufferLength,
    00582                              (PVOID *) &a->AliasesBuffer
    00583                            );
    00584     CsrClientCallServer( (PCSR_API_MSG)&m,
    00585                          CaptureBuffer,
    00586                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00587                                               ConsolepGetAliases
    00588                                             ),
    00589                          sizeof( *a )
    00590                        );
    00591     if (NT_SUCCESS( m.ReturnValue )) {
    00592         try {
    00593             RtlCopyMemory( AliasBuffer, a->AliasesBuffer, a->AliasesBufferLength );
    00594         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00595             CsrFreeCaptureBuffer( CaptureBuffer );
    00596             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00597             return 0;
    00598         }
    00599         CsrFreeCaptureBuffer( CaptureBuffer );
    00600         return a->AliasesBufferLength;
    00601     } else {
    00602         CsrFreeCaptureBuffer( CaptureBuffer );
    00603         SET_LAST_NT_ERROR(m.ReturnValue);
    00604         return 0;
    00605     }
    00606
    00607 }

DWORD APIENTRY GetConsoleAliasesLengthInternal | ( | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 425 of file client/cmdline.c.

References _CONSOLE_GETALIASESLENGTH_MSG::ConsoleHandle, ConsolepGetAliasesLength, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_GETALIASESLENGTH_MSG::Exe, _CONSOLE_GETALIASESLENGTH_MSG::ExeLength, FALSE, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, PCONSOLE_GETALIASESLENGTH_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_GETALIASESLENGTH_MSG::Unicode, Unicode, and _CONSOLE_GETALIASESLENGTH_MSG::UnicodeExe.

Referenced by GetConsoleAliasesLengthA(), and GetConsoleAliasesLengthW().

    00429 {
    00430     CONSOLE_API_MSG m;
    00431     PCONSOLE_GETALIASESLENGTH_MSG a = &m.u.GetConsoleAliasesLengthW;
    00432     PCSR_CAPTURE_HEADER CaptureBuffer;
    00433
    00434     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00435     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00436     a->Unicode = Unicode;
    00437
    00438     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00439                                               a->ExeLength
    00440                                             );
    00441     if (CaptureBuffer == NULL) {
    00442         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00443         return FALSE;
    00444     }
    00445
    00446     CsrCaptureMessageBuffer( CaptureBuffer,
    00447                              (PCHAR) ExeName,
    00448                              a->ExeLength,
    00449                              (PVOID *) &a->Exe
    00450                            );
    00451     CsrClientCallServer( (PCSR_API_MSG)&m,
    00452                          CaptureBuffer,
    00453                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00454                                               ConsolepGetAliasesLength
    00455                                             ),
    00456                          sizeof( *a )
    00457                        );
    00458     CsrFreeCaptureBuffer( CaptureBuffer );
    00459     if (NT_SUCCESS( m.ReturnValue )) {
    00460         return a->AliasesLength;
    00461     } else {
    00462         SET_LAST_NT_ERROR(m.ReturnValue);
    00463         return 0;
    00464     }
    00465
    00466 }

DWORD APIENTRY GetConsoleAliasExesInternal | ( | OUT LPVOID | ExeNameBuffer,
|  | IN DWORD | ExeNameBufferLength,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 647 of file client/cmdline.c.

References _CONSOLE_GETALIASEXES_MSG::AliasExesBuffer, _CONSOLE_GETALIASEXES_MSG::AliasExesBufferLength, _CONSOLE_GETALIASEXES_MSG::ConsoleHandle, ConsolepGetAliasExes, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, ExeNameBuffer, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, PCONSOLE_GETALIASEXES_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, Unicode, and _CONSOLE_GETALIASEXES_MSG::Unicode.

Referenced by GetConsoleAliasExesA(), and GetConsoleAliasExesW().

    00652 {
    00653     CONSOLE_API_MSG m;
    00654     PCONSOLE_GETALIASEXES_MSG a = &m.u.GetConsoleAliasExesW;
    00655     PCSR_CAPTURE_HEADER CaptureBuffer;
    00656
    00657     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00658     a->AliasExesBufferLength = ExeNameBufferLength;
    00659     a->Unicode = Unicode;
    00660     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00661                                               ExeNameBufferLength
    00662                                             );
    00663     if (CaptureBuffer == NULL) {
    00664         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00665         return FALSE;
    00666     }
    00667
    00668     CsrCaptureMessageBuffer( CaptureBuffer,
    00669                              (PCHAR) NULL,
    00670                              a->AliasExesBufferLength,
    00671                              (PVOID *) &a->AliasExesBuffer
    00672                            );
    00673
    00674     CsrClientCallServer( (PCSR_API_MSG)&m,
    00675                          CaptureBuffer,
    00676                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00677                                               ConsolepGetAliasExes
    00678                                             ),
    00679                          sizeof( *a )
    00680                        );
    00681     if (NT_SUCCESS( m.ReturnValue )) {
    00682         try {
    00683             RtlCopyMemory( ExeNameBuffer, a->AliasExesBuffer, a->AliasExesBufferLength );
    00684         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00685             CsrFreeCaptureBuffer( CaptureBuffer );
    00686             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00687             return 0;
    00688         }
    00689         CsrFreeCaptureBuffer( CaptureBuffer );
    00690         return a->AliasExesBufferLength;
    00691     } else {
    00692         CsrFreeCaptureBuffer( CaptureBuffer );
    00693         SET_LAST_NT_ERROR(m.ReturnValue);
    00694         return 0;
    00695     }
    00696
    00697 }

DWORD APIENTRY GetConsoleAliasExesLengthInternal | ( | IN BOOLEAN | Unicode | ) |

defined(BUILD_WOW64)

Definition at line 500 of file client/cmdline.c.

References _CONSOLE_GETALIASEXESLENGTH_MSG::ConsoleHandle, ConsolepGetAliasExesLength, CsrClientCallServer(), GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, PCONSOLE_GETALIASEXESLENGTH_MSG, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, Unicode, and _CONSOLE_GETALIASEXESLENGTH_MSG::Unicode.

Referenced by GetConsoleAliasExesLengthA(), and GetConsoleAliasExesLengthW().

    00503 {
    00504     CONSOLE_API_MSG m;
    00505     PCONSOLE_GETALIASEXESLENGTH_MSG a = &m.u.GetConsoleAliasExesLengthW;
    00506
    00507     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00508     a->Unicode = Unicode;
    00509
    00510     CsrClientCallServer( (PCSR_API_MSG)&m,
    00511                          NULL,
    00512                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00513                                               ConsolepGetAliasExesLength
    00514                                             ),
    00515                          sizeof( *a )
    00516                        );
    00517     if (NT_SUCCESS( m.ReturnValue )) {
    00518         return a->AliasExesLength;
    00519     } else {
    00520         SET_LAST_NT_ERROR(m.ReturnValue);
    00521         return 0;
    00522     }
    00523
    00524 }

DWORD APIENTRY GetConsoleAliasInternal | ( | IN LPVOID | Source,
|  | IN UINT | SourceLength,
|  | OUT LPVOID | TargetBuffer,
|  | IN UINT | TargetBufferLength,
|  | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 280 of file client/cmdline.c.

References _CONSOLE_GETALIAS_MSG::ConsoleHandle, ConsolepGetAlias, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_GETALIAS_MSG::Exe, _CONSOLE_GETALIAS_MSG::ExeLength, FALSE, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, PCONSOLE_GETALIAS_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_GETALIAS_MSG::Source, _CONSOLE_GETALIAS_MSG::SourceLength, _CONSOLE_GETALIAS_MSG::Target, _CONSOLE_GETALIAS_MSG::TargetLength, _CONSOLE_API_MSG::u, Unicode, _CONSOLE_GETALIAS_MSG::Unicode, _CONSOLE_GETALIAS_MSG::UnicodeExe, and USHORT.

Referenced by GetConsoleAliasA(), and GetConsoleAliasW().

    00291           :
    00292
    00293     Source - Name of alias to query.  NULL means query all alias names.
    00294
    00295     Target - Where to store value of alias.  If Source is NULL, then
    00296         value is one or more null terminated strings terminated by an extra
    00297         null byte.  Each null terminated string is the name of an alias.
    00298
    00299 Return Value:
    00300
    00301     Non-zero - The operation was successful, and the return value is the
    00302         number of characters stored in the Target buffer.
    00303
    00304     Zero - The operation failed. Extended error status is available
    00305         using GetLastError.
    00306
    00307 --*/
    00308
    00309 {
    00310     PCSR_CAPTURE_HEADER CaptureBuffer;
    00311     CONSOLE_API_MSG m;
    00312     ULONG CapturedMsgPointers;
    00313     PCONSOLE_GETALIAS_MSG a = &m.u.GetConsoleAliasW;
    00314
    00315     if (Source == NULL) {
    00316         SET_LAST_ERROR(ERROR_INVALID_PARAMETER);
    00317         return FALSE;
    00318     }
    00319     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00320     a->Unicode = Unicode;
    00321
    00322     CapturedMsgPointers = 3;
    00323
    00324     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00325
    00326     a->SourceLength = (USHORT) SourceLength;
    00327     a->TargetLength = (USHORT) TargetBufferLength;
    00328
    00329     CaptureBuffer = CsrAllocateCaptureBuffer( CapturedMsgPointers,
    00330                                               a->SourceLength + a->TargetLength + a->ExeLength
    00331                                             );
    00332     if (CaptureBuffer == NULL) {
    00333         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00334         return FALSE;
    00335     }
    00336
    00337     CsrCaptureMessageBuffer( CaptureBuffer,
    00338                              (PCHAR) ExeName,
    00339                              a->ExeLength,
    00340                              (PVOID *) &a->Exe
    00341                            );
    00342
    00343     CsrCaptureMessageBuffer( CaptureBuffer,
    00344                              (PCHAR) Source,
    00345                              a->SourceLength,
    00346                              (PVOID *) &a->Source
    00347                            );
    00348
    00349     CsrCaptureMessageBuffer( CaptureBuffer,
    00350                              (PCHAR) NULL,
    00351                              a->TargetLength,
    00352                              (PVOID *) &a->Target
    00353                            );
    00354
    00355     CsrClientCallServer( (PCSR_API_MSG)&m,
    00356                          CaptureBuffer,
    00357                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00358                                               ConsolepGetAlias
    00359                                             ),
    00360                          sizeof( *a )
    00361                        );
    00362
    00363     if (NT_SUCCESS( m.ReturnValue )) {
    00364         RtlCopyMemory( TargetBuffer, a->Target, a->TargetLength );
    00365     }
    00366     else {
    00367         SET_LAST_NT_ERROR(m.ReturnValue);
    00368         if (m.ReturnValue != STATUS_BUFFER_TOO_SMALL) {
    00369             a->TargetLength = 0;
    00370         }
    00371     }
    00372
    00373     CsrFreeCaptureBuffer( CaptureBuffer );
    00374
    00375     return a->TargetLength;
    00376
    00377 }

DWORD APIENTRY GetConsoleCommandHistoryInternal | ( | OUT LPVOID | Commands,
|  | IN DWORD | CommandBufferLength,
|  | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 945 of file client/cmdline.c.

References _CONSOLE_GETCOMMANDHISTORY_MSG::CommandBuffer, _CONSOLE_GETCOMMANDHISTORY_MSG::CommandBufferLength, Commands, _CONSOLE_GETCOMMANDHISTORY_MSG::ConsoleHandle, ConsolepGetCommandHistory, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, _CONSOLE_GETCOMMANDHISTORY_MSG::Exe, _CONSOLE_GETCOMMANDHISTORY_MSG::ExeLength, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, PCONSOLE_GETCOMMANDHISTORY_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_GETCOMMANDHISTORY_MSG::Unicode, Unicode, and _CONSOLE_GETCOMMANDHISTORY_MSG::UnicodeExe.

Referenced by GetConsoleCommandHistoryA(), and GetConsoleCommandHistoryW().

    00951 {
    00952     CONSOLE_API_MSG m;
    00953     PCONSOLE_GETCOMMANDHISTORY_MSG a = &m.u.GetConsoleCommandHistoryW;
    00954     PCSR_CAPTURE_HEADER CaptureBuffer;
    00955
    00956     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00957     a->CommandBufferLength = CommandBufferLength;
    00958     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00959     a->Unicode = Unicode;
    00960     CaptureBuffer = CsrAllocateCaptureBuffer( 2,
    00961                                               CommandBufferLength + a->ExeLength
    00962                                             );
    00963     if (CaptureBuffer == NULL) {
    00964         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00965         return 0;
    00966     }
    00967
    00968
    00969     CsrCaptureMessageBuffer( CaptureBuffer,
    00970                              (PCHAR) ExeName,
    00971                              a->ExeLength,
    00972                              (PVOID *) &a->Exe
    00973                            );
    00974
    00975     CsrCaptureMessageBuffer( CaptureBuffer,
    00976                              (PCHAR) NULL,
    00977                              a->CommandBufferLength,
    00978                              (PVOID *) &a->CommandBuffer
    00979                            );
    00980     CsrClientCallServer( (PCSR_API_MSG)&m,
    00981                          CaptureBuffer,
    00982                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00983                                               ConsolepGetCommandHistory
    00984                                             ),
    00985                          sizeof( *a )
    00986                        );
    00987     if (NT_SUCCESS( m.ReturnValue )) {
    00988         try {
    00989             RtlCopyMemory( Commands, a->CommandBuffer, a->CommandBufferLength );
    00990         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00991             CsrFreeCaptureBuffer( CaptureBuffer );
    00992             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00993             return 0;
    00994         }
    00995         CsrFreeCaptureBuffer( CaptureBuffer );
    00996         return a->CommandBufferLength;
    00997     } else {
    00998         CsrFreeCaptureBuffer( CaptureBuffer );
    00999         SET_LAST_NT_ERROR(m.ReturnValue);
    01000         return 0;
    01001     }
    01002
    01003 }

DWORD APIENTRY GetConsoleCommandHistoryLengthInternal | ( | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 877 of file client/cmdline.c.

References _CONSOLE_GETCOMMANDHISTORYLENGTH_MSG::ConsoleHandle, ConsolepGetCommandHistoryLength, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_GETCOMMANDHISTORYLENGTH_MSG::Exe, _CONSOLE_GETCOMMANDHISTORYLENGTH_MSG::ExeLength, GET_CONSOLE_HANDLE, GetExeName(), NULL, PCONSOLE_GETCOMMANDHISTORYLENGTH_MSG, SET_LAST_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_GETCOMMANDHISTORYLENGTH_MSG::Unicode, Unicode, and _CONSOLE_GETCOMMANDHISTORYLENGTH_MSG::UnicodeExe.

Referenced by GetConsoleCommandHistoryLengthA(), and GetConsoleCommandHistoryLengthW().

    00881 {
    00882     CONSOLE_API_MSG m;
    00883     PCONSOLE_GETCOMMANDHISTORYLENGTH_MSG a = &m.u.GetConsoleCommandHistoryLengthW;
    00884     PCSR_CAPTURE_HEADER CaptureBuffer;
    00885
    00886     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00887     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00888     a->Unicode = Unicode;
    00889     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00890                                               a->ExeLength
    00891                                             );
    00892     if (CaptureBuffer == NULL) {
    00893         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00894         return 0;
    00895     }
    00896
    00897     CsrCaptureMessageBuffer( CaptureBuffer,
    00898                              (PCHAR) ExeName,
    00899                              a->ExeLength,
    00900                              (PVOID *) &a->Exe
    00901                            );
    00902
    00903     CsrClientCallServer( (PCSR_API_MSG)&m,
    00904                          CaptureBuffer,
    00905                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00906                                               ConsolepGetCommandHistoryLength
    00907                                             ),
    00908                          sizeof( *a )
    00909                        );
    00910     CsrFreeCaptureBuffer( CaptureBuffer );
    00911     return a->CommandHistoryLength;
    00912
    00913 }

BOOL APIENTRY GetConsoleInput | ( | IN HANDLE | hConsoleInput,
|  | OUT PINPUT_RECORD | lpBuffer,
|  | IN DWORD | nLength,
|  | OUT LPDWORD | lpNumberOfEventsRead,
|  | IN USHORT | wFlags,
|  | IN BOOLEAN | Unicode
| ) |

Definition at line 29 of file iostubs.c.

References _CONSOLE_GETCONSOLEINPUT_MSG::BufPtr, CONSOLE_HANDLE, _CONSOLE_GETCONSOLEINPUT_MSG::ConsoleHandle, ConsolepGetConsoleInput, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, _CONSOLE_GETCONSOLEINPUT_MSG::Flags, GET_CONSOLE_HANDLE, INPUT_RECORD_BUFFER_SIZE, _CONSOLE_GETCONSOLEINPUT_MSG::InputHandle, NT_SUCCESS, NULL, _CONSOLE_GETCONSOLEINPUT_MSG::NumRecords, _CONSOLE_GETCONSOLEINPUT_MSG::Record, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_API_MSG::u, _CONSOLE_GETCONSOLEINPUT_MSG::Unicode, and Unicode.

Referenced by PeekConsoleInputA(), PeekConsoleInputW(), ReadConsoleInputA(), ReadConsoleInputExA(), ReadConsoleInputExW(), and ReadConsoleInputW().

    00040           :
    00041
    00042     hConsoleInput - Supplies an open handle to CONIN$ that is to be
    00043         read.  The handle must have been created with GENERIC_READ access.
    00044
    00045     lpBuffer - Supplies the address of a buffer to receive the data read
    00046         from the input buffer.
    00047
    00048     nLength - Supplies the length of lpBuffer in INPUT_RECORDs.
    00049
    00050     lpNumberOfEventsRead - Pointer to number of events read.
    00051
    00052     wFlags - Flags that control how data is read.
    00053
    00054 Return Value:
    00055
    00056     TRUE - The operation was successful.
    00057
    00058     FALSE/NULL - The operation failed.
    00059         Extended error status is available using GetLastError.
    00060
    00061 --*/
    00062
    00063 {
    00064     PCSR_CAPTURE_HEADER CaptureBuffer;
    00065     CONSOLE_API_MSG m;
    00066     PCONSOLE_GETCONSOLEINPUT_MSG a = &m.u.GetConsoleInput;
    00067
    00068     //
    00069     // If it's not a well formed handle, don't bother going to the server.
    00070     //
    00071
    00072     if (!CONSOLE_HANDLE(hConsoleInput)) {
    00073         try {
    00074             *lpNumberOfEventsRead = 0;
    00075             SET_LAST_ERROR(ERROR_INVALID_HANDLE);
    00076         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00077             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00078         }
    00079         return FALSE;
    00080     }
    00081
    00082     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00083     a->InputHandle = hConsoleInput;
    00084     a->NumRecords = nLength;
    00085     a->Flags = wFlags;
    00086     a->Unicode = Unicode;
    00087
    00088     //
    00089     // for speed in the case where we're only reading a few records, we have
    00090     // a buffer in the msg we pass to the server. this means we don't have to
    00091     // allocate a capture buffer.
    00092     //
    00093
    00094     if (nLength > INPUT_RECORD_BUFFER_SIZE) {
    00095         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00096                                                   nLength * sizeof(INPUT_RECORD)
    00097                                                 );
    00098         if (CaptureBuffer == NULL) {
    00099             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00100             return FALSE;
    00101         }
    00102         CsrCaptureMessageBuffer( CaptureBuffer,
    00103                                  NULL,
    00104                                  nLength * sizeof(INPUT_RECORD),
    00105                                  (PVOID *) &a->BufPtr
    00106                                );
    00107
    00108     } else {
    00109         a->BufPtr = a->Record;
    00110         CaptureBuffer = NULL;
    00111     }
    00112     CsrClientCallServer( (PCSR_API_MSG)&m,
    00113                          CaptureBuffer,
    00114                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00115                                               ConsolepGetConsoleInput
    00116                                             ),
    00117                          sizeof( *a )
    00118                        );
    00119
    00120     try {
    00121         if (NT_SUCCESS( m.ReturnValue )) {
    00122             *lpNumberOfEventsRead = a->NumRecords;
    00123             RtlCopyMemory(lpBuffer, a->BufPtr, a->NumRecords * sizeof(INPUT_RECORD));
    00124         }
    00125         else {
    00126             *lpNumberOfEventsRead = 0;
    00127             SET_LAST_NT_ERROR(m.ReturnValue);
    00128         }
    00129     } except( EXCEPTION_EXECUTE_HANDLER ) {
    00130         if (CaptureBuffer != NULL) {
    00131             CsrFreeCaptureBuffer( CaptureBuffer );
    00132         }
    00133         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00134         return FALSE;
    00135     }
    00136     if (CaptureBuffer != NULL) {
    00137         CsrFreeCaptureBuffer( CaptureBuffer );
    00138     }
    00139
    00140     return NT_SUCCESS(m.ReturnValue);
    00141
    00142 }

BOOL APIENTRY GetConsoleKeyboardLayoutNameWorker | ( | OUT LPSTR | pszLayout,
|  | IN BOOL | bAnsi
| ) |

defined(BUILD_WOW64)

++

Parameters:

pszLayout - address of buffer of least 9 characters bAnsi - TRUE want ANSI (8-bit) chars FALSE want Unicode (16-bit) chars

Return Value:

TRUE - success FALSE - failure

--

Definition at line 1543 of file ntcon/client/getset.c.

References _CONSOLE_GETKEYBOARDLAYOUTNAME_MSG::bAnsi, _CONSOLE_GETKEYBOARDLAYOUTNAME_MSG::ConsoleHandle, ConsolepGetKeyboardLayoutName, CsrClientCallServer(), FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, SET_LAST_NT_ERROR, TRUE, and _CONSOLE_API_MSG::u.

Referenced by GetConsoleKeyboardLayoutNameA(), and GetConsoleKeyboardLayoutNameW().

    01549           :
    01550
    01551     pszLayout  - address of buffer of least 9 characters
    01552     bAnsi      - TRUE  want ANSI (8-bit) chars
    01553                  FALSE want Unicode (16-bit) chars
    01554
    01555 Return Value:
    01556
    01557     TRUE  - success
    01558     FALSE - failure
    01559
    01560 --*/
    01561
    01562 {
    01563
    01564     CONSOLE_API_MSG m;
    01565     PCONSOLE_GETKEYBOARDLAYOUTNAME_MSG a = &m.u.GetKeyboardLayoutName;
    01566
    01567     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01568     a->bAnsi = bAnsi;
    01569
    01570     CsrClientCallServer( (PCSR_API_MSG)&m,
    01571                          NULL,
    01572                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01573                                               ConsolepGetKeyboardLayoutName
    01574                                             ),
    01575                          sizeof( *a )
    01576                        );
    01577     if (NT_SUCCESS( m.ReturnValue )) {
    01578         if (bAnsi) {
    01579            strncpy(pszLayout, a->achLayout, 9);
    01580         } else {
    01581            wcsncpy((LPWSTR)pszLayout, a->awchLayout, 9);
    01582         }
    01583         return TRUE;
    01584     } else {
    01585         SET_LAST_NT_ERROR (m.ReturnValue);
    01586         return FALSE;
    01587     }
    01588
    01589 }

BOOL WINAPI GetConsoleLangId | ( | OUT LANGID * | lpLangId | ) |

defined(BUILD_WOW64)

Definition at line 296 of file dllinit.c.

    00302           :
    00303
    00304     lpLangId - Supplies a pointer to a LANGID in which to store the Language ID.
    00305
    00306 Return Value:
    00307
    00308     TRUE - The operation was successful.
    00309
    00310     FALSE/NULL - The operation failed. Extended error status is available
    00311         using GetLastError.
    00312
    00313
    00314 --*/
    00315
    00316 {
    00317     CONSOLE_API_MSG m;
    00318     PCONSOLE_LANGID_MSG a = &m.u.GetConsoleLangId;
    00319
    00320     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00321     CsrClientCallServer( (PCSR_API_MSG)&m,
    00322                          NULL,
    00323                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00324                                               ConsolepGetLangId
    00325                                             ),
    00326                          sizeof( *a )
    00327                        );
    00328     if (NT_SUCCESS( m.ReturnValue )) {
    00329         try {
    00330             *lpLangId = a->LangId;
    00331         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00332             return FALSE;
    00333         }
    00334         return TRUE;
    00335     } else {
    00336         return FALSE;
    00337     }
    00338
    00339 }

DWORD APIENTRY GetConsoleTitleInternal | ( | OUT PVOID | lpConsoleTitle,
|  | IN DWORD | nSize,
|  | IN BOOLEAN | Unicode
| ) |

Definition at line 1070 of file client/cmdline.c.

References _CONSOLE_GETTITLE_MSG::ConsoleHandle, ConsolepGetTitle, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, PCONSOLE_GETTITLE_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_GETTITLE_MSG::Title, _CONSOLE_GETTITLE_MSG::TitleLength, _CONSOLE_API_MSG::u, Unicode, and _CONSOLE_GETTITLE_MSG::Unicode.

Referenced by GetConsoleTitleA(), and GetConsoleTitleW().

    01075 {
    01076     CONSOLE_API_MSG m;
    01077     PCONSOLE_GETTITLE_MSG a = &m.u.GetConsoleTitle;
    01078     PCSR_CAPTURE_HEADER CaptureBuffer;
    01079
    01080     if (nSize == 0) {
    01081         return 0;
    01082     }
    01083     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01084     a->TitleLength = nSize;
    01085     a->Unicode = Unicode;
    01086     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    01087                                               a->TitleLength
    01088                                             );
    01089     if (CaptureBuffer == NULL) {
    01090         return 0;
    01091     }
    01092     CsrCaptureMessageBuffer( CaptureBuffer,
    01093                              NULL,
    01094                              a->TitleLength,
    01095                              (PVOID *) &a->Title
    01096                            );
    01097     CsrClientCallServer( (PCSR_API_MSG)&m,
    01098                          CaptureBuffer,
    01099                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01100                                               ConsolepGetTitle
    01101                                             ),
    01102                          sizeof( *a )
    01103                        );
    01104     if (NT_SUCCESS( m.ReturnValue )) {
    01105         try {
    01106             RtlCopyMemory( lpConsoleTitle, a->Title, a->TitleLength);
    01107         } except( EXCEPTION_EXECUTE_HANDLER ) {
    01108             CsrFreeCaptureBuffer( CaptureBuffer );
    01109             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01110             return 0;
    01111         }
    01112     }
    01113     else {
    01114         CsrFreeCaptureBuffer( CaptureBuffer );
    01115         SET_LAST_NT_ERROR (m.ReturnValue);
    01116         return 0;
    01117     }
    01118     CsrFreeCaptureBuffer( CaptureBuffer );
    01119     return a->TitleLength;
    01120
    01121 }

USHORT GetCurrentExeName | ( | LPWSTR | Buffer,
|  | ULONG | BufferLength
| ) |

| Referenced by ReadConsoleA(), and ReadConsoleW().

NTSTATUS InitializeCtrlHandling | ( | VOID |  | ) |

Definition at line 68 of file ctrlc.c.

References AllocatedHandlerListLength, DefaultHandler(), HandlerList, HandlerListLength, INITIAL_LIST_SIZE, and SingleHandler.

Referenced by AllocConsole(), and ConDllInitialize().

    00075           :
    00076
    00077     none.
    00078
    00079 Return Value:
    00080
    00081     none.
    00082
    00083 --*/
    00084
    00085 {
    00086     AllocatedHandlerListLength = HandlerListLength = INITIAL_LIST_SIZE;
    00087     HandlerList = SingleHandler;
    00088     SingleHandler[0] = DefaultHandler;
    00089     return STATUS_SUCCESS;
    00090 }

HANDLE APIENTRY OpenConsoleWInternal | ( | IN ULONG | HandleType,
|  | IN ULONG | DesiredAccess,
|  | IN BOOL | InheritHandle,
|  | IN ULONG | ShareMode
| ) |

defined(BUILD_WOW64)

Definition at line 44 of file client/stream.c.

References _CONSOLE_OPENCONSOLE_MSG::ConsoleHandle, ConsolepOpenConsole, CsrClientCallServer(), _CONSOLE_OPENCONSOLE_MSG::DesiredAccess, GET_CONSOLE_HANDLE, _CONSOLE_OPENCONSOLE_MSG::HandleType, _CONSOLE_OPENCONSOLE_MSG::InheritHandle, INVALID_HANDLE_VALUE, NT_SUCCESS, NULL, PCONSOLE_OPENCONSOLE_MSG, SET_LAST_NT_ERROR, _CONSOLE_OPENCONSOLE_MSG::ShareMode, and _CONSOLE_API_MSG::u.

Referenced by OpenConsoleW().

    00052                    :
    00053
    00054    Marshels parameters for the ConsolepOpenConsole command.
    00055
    00056 Arguments:
    00057
    00058    See the CONSOLE_OPENCONSOLE_MSG structure and OpenConsoleW.
    00059
    00060 Return Value:
    00061
    00062     INVALID_HANDLE_VALUE - An error occured.
    00063
    00064 --*/
    00065 {
    00066
    00067     CONSOLE_API_MSG m;
    00068     PCONSOLE_OPENCONSOLE_MSG a = &m.u.OpenConsole;
    00069
    00070     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00071     a->HandleType    = HandleType;
    00072     a->DesiredAccess = DesiredAccess;
    00073     a->InheritHandle = InheritHandle;
    00074     a->ShareMode= ShareMode;
    00075     CsrClientCallServer( (PCSR_API_MSG)&m,
    00076                          NULL,
    00077                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00078                                               ConsolepOpenConsole
    00079                                             ),
    00080                          sizeof( *a )
    00081                        );
    00082     if (!NT_SUCCESS( m.ReturnValue)) {
    00083         SET_LAST_NT_ERROR(m.ReturnValue);
    00084         return (HANDLE) INVALID_HANDLE_VALUE;
    00085     }
    00086     else {
    00087         return a->Handle;
    00088     }
    00089
    00090 }

BOOL APIENTRY ReadConsoleInternal | ( | IN HANDLE | hConsoleInput,
|  | OUT LPVOID | lpBuffer,
|  | IN DWORD | nNumberOfCharsToRead,
|  | OUT LPDWORD | lpNumberOfCharsRead,
|  | IN OUT LPVOID | lpReserved,
|  | IN BOOLEAN | Unicode,
|  | IN USHORT | ExeNameLength,
|  | IN LPWSTR | ExeName
| ) |

Definition at line 191 of file client/stream.c.

References _CONSOLE_READCONSOLE_MSG::Buffer, BUFFER_SIZE, _CONSOLE_READCONSOLE_MSG::BufPtr, _CONSOLE_READCONSOLE_MSG::CaptureBufferSize, _CONSOLE_READCONSOLE_MSG::ConsoleHandle, ConsolepReadConsole, _CONSOLE_READCONSOLE_MSG::ControlKeyState, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_READCONSOLE_MSG::CtrlWakeupMask, EXCEPTION_EXECUTE_HANDLER, _CONSOLE_READCONSOLE_MSG::ExeNameLength, ExeNameLength, FALSE, GET_CONSOLE_HANDLE, _CONSOLE_READCONSOLE_MSG::InitialNumBytes, _CONSOLE_READCONSOLE_MSG::InputHandle, NT_SUCCESS, NTSTATUS(), NtYieldExecution(), NULL, _CONSOLE_READCONSOLE_MSG::NumBytes, PCONSOLE_READCONSOLE_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, Status, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_READCONSOLE_MSG::Unicode, and Unicode.

Referenced by ReadConsoleA(), and ReadConsoleW().

    00202           :
    00203
    00204     hConsoleInput - Supplies an open handle to "CONIN$" open for GENERIC_READ
    00205         or the StdIn handle.
    00206
    00207     lpBuffer - Supplies the address of a buffer to receive the data read
    00208         from the console input.
    00209
    00210     nNumberOfBytesToRead - Supplies the number of bytes to read from the
    00211         input buffer.
    00212
    00213     lpReserved - Ignore unless 4.0 application, in which case it points
    00214         to a CONSOLE_READCONSOLE_CONTROL data structure.  UNICODE only.
    00215         If !Unicode, then call fails if this parameter is non-NULL
    00216
    00217     Unicode - TRUE if call from ReadConsoleW, FALSE if ReadConsoleA
    00218
    00219
    00220 Return Value:
    00221
    00222     NON-NULL - Returns the number of bytes actually read from the input buffer.
    00223
    00224     FALSE/NULL - The operation failed.
    00225         Extended error status is available using GetLastError.
    00226 --*/
    00227
    00228 {
    00229     PCSR_CAPTURE_HEADER CaptureBuffer;
    00230     CONSOLE_API_MSG m;
    00231     PCONSOLE_READCONSOLE_MSG a = &m.u.ReadConsole;
    00232     BOOLEAN Dummy;
    00233     PCONSOLE_READCONSOLE_CONTROL pInputControl;
    00234     NTSTATUS Status;
    00235
    00236     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00237     a->InputHandle = hConsoleInput;
    00238     a->ExeNameLength = ExeNameLength;
    00239     RtlCopyMemory(a->Buffer, ExeName, ExeNameLength);
    00240     a->Unicode = Unicode;
    00241
    00242     //
    00243     // if ansi, make capture buffer large enough to hold translated
    00244     // string.  this will make server side code much simpler.
    00245     //
    00246
    00247     a->CaptureBufferSize = a->NumBytes = nNumberOfCharsToRead * sizeof(WCHAR);
    00248     if (a->CaptureBufferSize > BUFFER_SIZE) {
    00249         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00250                                                   a->CaptureBufferSize
    00251                                                 );
    00252         if (CaptureBuffer == NULL) {
    00253             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00254             return FALSE;
    00255         }
    00256         CsrCaptureMessageBuffer( CaptureBuffer,
    00257                                  NULL,
    00258                                  a->CaptureBufferSize,
    00259                                  (PVOID *) &a->BufPtr
    00260                                );
    00261
    00262     }
    00263     else {
    00264         a->BufPtr = a->Buffer;
    00265         CaptureBuffer = NULL;
    00266     }
    00267
    00268
    00269     pInputControl = (PCONSOLE_READCONSOLE_CONTROL)lpReserved;
    00270     a->InitialNumBytes = 0;
    00271     a->CtrlWakeupMask = 0;
    00272     a->ControlKeyState = 0;
    00273     Status = STATUS_SUCCESS;
    00274     try {
    00275         if (Unicode &&
    00276             ARGUMENT_PRESENT(lpReserved) &&
    00277             NtCurrentPeb()->ImageSubsystemMajorVersion >= 4 &&
    00278             pInputControl->nLength == sizeof(*pInputControl)
    00279            ) {
    00280             if ((pInputControl->nInitialChars > nNumberOfCharsToRead)) {
    00281                 Status = STATUS_INVALID_PARAMETER;
    00282             } else {
    00283                 a->InitialNumBytes = pInputControl->nInitialChars * sizeof(WCHAR);
    00284                 if (pInputControl->nInitialChars != 0) {
    00285                     RtlCopyMemory( a->BufPtr, lpBuffer, a->InitialNumBytes );
    00286                 }
    00287                 a->CtrlWakeupMask = pInputControl->dwCtrlWakeupMask;
    00288             }
    00289         } else {
    00290             pInputControl = NULL;
    00291         }
    00292     } except( EXCEPTION_EXECUTE_HANDLER ) {
    00293         Status = GetExceptionCode();
    00294     }
    00295
    00296     if (!NT_SUCCESS(Status) && pInputControl != NULL) {
    00297         if (CaptureBuffer != NULL) {
    00298             CsrFreeCaptureBuffer( CaptureBuffer );
    00299         }
    00300         SET_LAST_NT_ERROR(Status);
    00301         return FALSE;
    00302     }
    00303
    00304     CsrClientCallServer( (PCSR_API_MSG)&m,
    00305                          CaptureBuffer,
    00306                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00307                                               ConsolepReadConsole
    00308                                             ),
    00309                          sizeof( *a )
    00310                        );
    00311     if (NT_SUCCESS( m.ReturnValue )) {
    00312         try {
    00313             *lpNumberOfCharsRead = a->NumBytes;
    00314             if (Unicode) {
    00315                 *lpNumberOfCharsRead /= sizeof(WCHAR);
    00316                 if (pInputControl != NULL) {
    00317                     pInputControl->dwControlKeyState = a->ControlKeyState;
    00318                 }
    00319             }
    00320             RtlCopyMemory( lpBuffer, a->BufPtr, a->NumBytes );
    00321         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00322             if (CaptureBuffer != NULL) {
    00323                 CsrFreeCaptureBuffer( CaptureBuffer );
    00324             }
    00325             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00326             return FALSE;
    00327         }
    00328     }
    00329     if (CaptureBuffer != NULL) {
    00330         CsrFreeCaptureBuffer( CaptureBuffer );
    00331     }
    00332     if (!NT_SUCCESS( m.ReturnValue )) {
    00333         SET_LAST_NT_ERROR(m.ReturnValue);
    00334         return FALSE;
    00335     } else if (m.ReturnValue == STATUS_ALERTED) {
    00336         // ctrl-c or ctrl-break
    00337         NtYieldExecution();
    00338         SET_LAST_ERROR(ERROR_OPERATION_ABORTED);
    00339     }
    00340     return TRUE;
    00341 }

BOOL APIENTRY ReadConsoleOutputInternal | ( | IN HANDLE | hConsoleOutput,
|  | OUT PCHAR_INFO | lpBuffer,
|  | IN COORD | dwBufferSize,
|  | IN COORD | dwBufferCoord,
|  | IN OUT PSMALL_RECT | lpReadRegion,
|  | IN BOOLEAN | Unicode
| ) |

Definition at line 585 of file iostubs.c.

References _CONSOLE_READCONSOLEOUTPUT_MSG::BufPtr, _CONSOLE_READCONSOLEOUTPUT_MSG::Char, _CONSOLE_READCONSOLEOUTPUT_MSG::CharRegion, CONSOLE_RECT_SIZE_X, CONSOLE_RECT_SIZE_Y, _CONSOLE_READCONSOLEOUTPUT_MSG::ConsoleHandle, ConsolepReadConsoleOutput, CopyRectangle(), CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_READCONSOLEOUTPUT_MSG::OutputHandle, SET_LAST_ERROR, SET_LAST_NT_ERROR, SHORT, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_READCONSOLEOUTPUT_MSG::Unicode, and Unicode.

Referenced by ReadConsoleOutputA(), and ReadConsoleOutputW().

    00595           :
    00596
    00597     hConsoleOutput - Supplies an open handle to the screen buffer (CONOUT$)
    00598         that is to be read.  The handle must have been created with
    00599         GENERIC_READ access.
    00600
    00601     lpBuffer - Supplies the address of a buffer to receive the data read
    00602         from the screen buffer.  This pointer is treated as the origin of
    00603         a two dimensional array of size dwBufferSize.
    00604
    00605     dwBufferSize - size of lpBuffer
    00606
    00607     dwBufferCoord - coordinates of upper left point in buffer to receive
    00608         read data.
    00609
    00610     lpReadRegion - Supplies on input the address of a structure indicating the
    00611         rectangle within the screen buffer to read from.  The fields in
    00612         the structure are column and row coordinates.  On output, the fields
    00613         contain the actual region read.
    00614
    00615 Return Value:
    00616
    00617     TRUE - The operation was successful.
    00618
    00619     FALSE/NULL - The operation failed. Extended error status is available
    00620         using GetLastError.
    00621 --*/
    00622
    00623 {
    00624     PCSR_CAPTURE_HEADER CaptureBuffer;
    00625     CONSOLE_API_MSG m;
    00626     PCONSOLE_READCONSOLEOUTPUT_MSG a = &m.u.ReadConsoleOutput;
    00627     ULONG NumChars;
    00628     COORD SourceSize;
    00629
    00630     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00631     a->OutputHandle = hConsoleOutput;
    00632     a->Unicode = Unicode;
    00633
    00634     //
    00635     // clip region to read based on caller's buffer size
    00636     //
    00637
    00638     SourceSize.X = (SHORT)CONSOLE_RECT_SIZE_X(lpReadRegion);
    00639     if (SourceSize.X > dwBufferSize.X-dwBufferCoord.X)
    00640         SourceSize.X = dwBufferSize.X-dwBufferCoord.X;
    00641     SourceSize.Y = (SHORT)CONSOLE_RECT_SIZE_Y(lpReadRegion);
    00642     if (SourceSize.Y > dwBufferSize.Y-dwBufferCoord.Y)
    00643         SourceSize.Y = dwBufferSize.Y-dwBufferCoord.Y;
    00644
    00645     a->CharRegion.Left = lpReadRegion->Left;
    00646     a->CharRegion.Right = (SHORT)(lpReadRegion->Left + SourceSize.X - 1);
    00647     a->CharRegion.Top  = lpReadRegion->Top;
    00648     a->CharRegion.Bottom = (SHORT)(lpReadRegion->Top + SourceSize.Y - 1);
    00649
    00650     //
    00651     // for speed in the case where we're only reading one character, we have
    00652     // a buffer in the msg we pass to the server. this means we don't have to
    00653     // allocate a capture buffer.
    00654     //
    00655
    00656     NumChars = SourceSize.X * SourceSize.Y;
    00657     if (NumChars > 1) {
    00658         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00659                                                   NumChars * sizeof(CHAR_INFO)
    00660                                                 );
    00661         if (CaptureBuffer == NULL) {
    00662             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00663             return FALSE;
    00664         }
    00665         CsrCaptureMessageBuffer( CaptureBuffer,
    00666                                  NULL,
    00667                                  NumChars * sizeof(CHAR_INFO),
    00668                                  (PVOID *) &a->BufPtr
    00669                                );
    00670     }
    00671     else {
    00672         CaptureBuffer = NULL;
    00673         a->BufPtr = &a->Char;
    00674     }
    00675     CsrClientCallServer( (PCSR_API_MSG)&m,
    00676                          CaptureBuffer,
    00677                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00678                                               ConsolepReadConsoleOutput
    00679                                             ),
    00680                          sizeof( *a )
    00681                        );
    00682     if (NT_SUCCESS( m.ReturnValue )) {
    00683         try {
    00684             SMALL_RECT SourceRect;
    00685
    00686             SourceRect.Left = a->CharRegion.Left - lpReadRegion->Left;
    00687             SourceRect.Top = a->CharRegion.Top - lpReadRegion->Top;
    00688             SourceRect.Right = SourceRect.Left +
    00689                     (a->CharRegion.Right - a->CharRegion.Left);
    00690             SourceRect.Bottom =  SourceRect.Top +
    00691                     (a->CharRegion.Bottom - a->CharRegion.Top);
    00692             dwBufferCoord.X += SourceRect.Left;
    00693             dwBufferCoord.Y += SourceRect.Top;
    00694             CopyRectangle(a->BufPtr,
    00695                           SourceSize,
    00696                           &SourceRect,
    00697                           lpBuffer,
    00698                           dwBufferSize,
    00699                           dwBufferCoord
    00700                          );
    00701         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00702             if (CaptureBuffer != NULL) {
    00703                 CsrFreeCaptureBuffer( CaptureBuffer );
    00704             }
    00705             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00706             return FALSE;
    00707         }
    00708     }
    00709     if (CaptureBuffer != NULL) {
    00710         CsrFreeCaptureBuffer( CaptureBuffer );
    00711     }
    00712     *lpReadRegion = a->CharRegion;
    00713     if (!NT_SUCCESS(m.ReturnValue)) {
    00714         SET_LAST_NT_ERROR(m.ReturnValue);
    00715         return FALSE;
    00716     }
    00717     else {
    00718         return TRUE;
    00719     }
    00720
    00721 }

BOOL APIENTRY ReadConsoleOutputString | ( | IN HANDLE | hConsoleOutput,
|  | OUT LPVOID | lpString,
|  | IN DWORD | nLength,
|  | IN DWORD | nSize,
|  | IN DWORD | fFlags,
|  | IN COORD | dwReadCoord,
|  | OUT LPDWORD | lpNumberOfElementsRead
| ) |

Definition at line 974 of file iostubs.c.

References _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::BufPtr, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::ConsoleHandle, ConsolepReadConsoleOutputString, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::NumRecords, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::OutputHandle, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::ReadCoord, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::String, _CONSOLE_READCONSOLEOUTPUTSTRING_MSG::StringType, and _CONSOLE_API_MSG::u.

Referenced by ReadConsoleOutputAttribute(), ReadConsoleOutputCharacterA(), and ReadConsoleOutputCharacterW().

    00986           :
    00987
    00988     hConsoleOutput - Supplies an open handle to the screen buffer (CONOUT$)
    00989         that is to be read.  The handle must have been created with
    00990         GENERIC_READ access.
    00991
    00992     lpString - Supplies the address of a buffer to receive the character
    00993         or attribute string read from the screen buffer.
    00994
    00995     nLength - Size of lpCharacter buffer in elements.
    00996
    00997     nSize - Size of element to read.
    00998
    00999     fFlags - flag indicating what type of string to copy
    01000
    01001     dwReadCoord - Screen buffer coordinates of string to read.
    01002         read data.
    01003
    01004     lpNumberOfElementsRead - Pointer to number of events read.
    01005
    01006 Return Value:
    01007
    01008     TRUE - The operation was successful.
    01009
    01010     FALSE/NULL - The operation failed.
    01011         Extended error status is available using GetLastError.
    01012
    01013 --*/
    01014
    01015 {
    01016     PCSR_CAPTURE_HEADER CaptureBuffer;
    01017     CONSOLE_API_MSG m;
    01018     PCONSOLE_READCONSOLEOUTPUTSTRING_MSG a = &m.u.ReadConsoleOutputString;
    01019     ULONG DataLength;
    01020
    01021     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01022     a->OutputHandle = hConsoleOutput;
    01023     a->NumRecords = nLength;
    01024     a->StringType = fFlags;
    01025     a->ReadCoord = dwReadCoord;
    01026
    01027     DataLength = nLength*nSize;
    01028
    01029     //
    01030     // for speed in the case where the string is small, we have a buffer
    01031     // in the msg we pass to the server. this means we don't have to
    01032     // allocate a capture buffer.
    01033     //
    01034
    01035     if (DataLength > sizeof(a->String)) {
    01036         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    01037                                                   DataLength
    01038                                                 );
    01039         if (CaptureBuffer == NULL) {
    01040             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    01041             return FALSE;
    01042         }
    01043         CsrCaptureMessageBuffer( CaptureBuffer,
    01044                                  NULL,
    01045                                  DataLength,
    01046                                  (PVOID *) &a->BufPtr
    01047                                );
    01048
    01049     }
    01050     else {
    01051         a->BufPtr = a->String;
    01052         CaptureBuffer = NULL;
    01053     }
    01054     CsrClientCallServer( (PCSR_API_MSG)&m,
    01055                          CaptureBuffer,
    01056                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01057                                               ConsolepReadConsoleOutputString
    01058                                             ),
    01059                          sizeof( *a )
    01060                        );
    01061
    01062     try {
    01063        *lpNumberOfElementsRead = a->NumRecords;
    01064         if (NT_SUCCESS( m.ReturnValue )) {
    01065             RtlCopyMemory(lpString, a->BufPtr, a->NumRecords * nSize);
    01066         }
    01067         else {
    01068             SET_LAST_NT_ERROR(m.ReturnValue);
    01069         }
    01070     } except( EXCEPTION_EXECUTE_HANDLER ) {
    01071         if (CaptureBuffer != NULL) {
    01072             CsrFreeCaptureBuffer( CaptureBuffer );
    01073         }
    01074         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01075         return FALSE;
    01076     }
    01077     if (CaptureBuffer != NULL) {
    01078         CsrFreeCaptureBuffer( CaptureBuffer );
    01079     }
    01080     return NT_SUCCESS(m.ReturnValue);
    01081 }

BOOL APIENTRY RegisterConsoleIMEInternal | ( | IN HWND | hWndConsoleIME,
|  | IN DWORD | dwConsoleIMEThreadId,
|  | IN DWORD | DesktopLength,
|  | IN LPWSTR | Desktop,
|  | OUT DWORD * | dwConsoleThreadId
| ) |

BOOL APIENTRY ScrollConsoleScreenBufferInternal | ( | IN HANDLE | hConsoleOutput,
|  | IN CONST SMALL_RECT * | lpScrollRectangle,
|  | IN CONST SMALL_RECT * | lpClipRectangle,
|  | IN COORD | dwDestinationOrigin,
|  | IN CONST CHAR_INFO * | lpFill,
|  | IN BOOLEAN | Unicode
| ) |

Definition at line 1036 of file ntcon/client/getset.c.

References _CONSOLE_SCROLLSCREENBUFFER_MSG::Clip, _CONSOLE_SCROLLSCREENBUFFER_MSG::ClipRectangle, _CONSOLE_SCROLLSCREENBUFFER_MSG::ConsoleHandle, ConsolepScrollScreenBuffer, CsrClientCallServer(), _CONSOLE_SCROLLSCREENBUFFER_MSG::DestinationOrigin, EXCEPTION_EXECUTE_HANDLER, FALSE, _CONSOLE_SCROLLSCREENBUFFER_MSG::Fill, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_SCROLLSCREENBUFFER_MSG::OutputHandle, _CONSOLE_SCROLLSCREENBUFFER_MSG::ScrollRectangle, SET_LAST_ERROR, SET_LAST_NT_ERROR, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_SCROLLSCREENBUFFER_MSG::Unicode, and Unicode.

Referenced by ScrollConsoleScreenBufferA(), and ScrollConsoleScreenBufferW().

    01047           :
    01048
    01049     hConsoleOutput - Supplies an open handle to console output.
    01050
    01051     lpScrollRectangle - Pointer to region within screen buffer to move.
    01052
    01053     lpClipRectangle -  Pointer to region within screen buffer that may be
    01054         affected by this scroll.  This pointer may be NULL.
    01055
    01056     dwDestinationOrigin - Upper left corner of new location of ScrollRectangle
    01057         contents.
    01058
    01059     lpFill - Pointer to structure containing new contents of ScrollRectangle region.
    01060
    01061 Return Value:
    01062
    01063     TRUE - The operation was successful.
    01064
    01065     FALSE/NULL - The operation failed. Extended error status is available
    01066         using GetLastError.
    01067
    01068 --*/
    01069
    01070 {
    01071
    01072     CONSOLE_API_MSG m;
    01073     PCONSOLE_SCROLLSCREENBUFFER_MSG a = &m.u.ScrollConsoleScreenBuffer;
    01074
    01075     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01076     a->OutputHandle = hConsoleOutput;
    01077     a->Unicode = Unicode;
    01078     try {
    01079         a->ScrollRectangle = *lpScrollRectangle;
    01080         if (lpClipRectangle != NULL) {
    01081             a->Clip = TRUE;
    01082             a->ClipRectangle = *lpClipRectangle;
    01083         }
    01084         else {
    01085             a->Clip = FALSE;
    01086         }
    01087         a->Fill = *lpFill;
    01088         a->DestinationOrigin = dwDestinationOrigin;
    01089     } except( EXCEPTION_EXECUTE_HANDLER ) {
    01090         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01091         return FALSE;
    01092     }
    01093     CsrClientCallServer( (PCSR_API_MSG)&m,
    01094                          NULL,
    01095                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01096                                               ConsolepScrollScreenBuffer
    01097                                             ),
    01098                          sizeof( *a )
    01099                        );
    01100     if (NT_SUCCESS( m.ReturnValue )) {
    01101         return TRUE;
    01102     } else {
    01103         SET_LAST_NT_ERROR (m.ReturnValue);
    01104         return FALSE;
    01105     }
    01106
    01107 }

BOOL APIENTRY SetConsoleNumberOfCommandsInternal | ( | IN DWORD | Number,
|  | IN LPVOID | ExeName,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 798 of file client/cmdline.c.

References _CONSOLE_SETNUMBEROFCOMMANDS_MSG::ConsoleHandle, ConsolepSetNumberOfCommands, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), _CONSOLE_SETNUMBEROFCOMMANDS_MSG::Exe, _CONSOLE_SETNUMBEROFCOMMANDS_MSG::ExeLength, FALSE, GET_CONSOLE_HANDLE, GetExeName(), NT_SUCCESS, NULL, _CONSOLE_SETNUMBEROFCOMMANDS_MSG::NumCommands, PCONSOLE_SETNUMBEROFCOMMANDS_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_SETNUMBEROFCOMMANDS_MSG::Unicode, Unicode, and _CONSOLE_SETNUMBEROFCOMMANDS_MSG::UnicodeExe.

Referenced by SetConsoleNumberOfCommandsA(), and SetConsoleNumberOfCommandsW().

    00803 {
    00804     CONSOLE_API_MSG m;
    00805     PCONSOLE_SETNUMBEROFCOMMANDS_MSG a = &m.u.SetConsoleNumberOfCommandsW;
    00806     PCSR_CAPTURE_HEADER CaptureBuffer;
    00807
    00808     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00809     a->NumCommands = Number;
    00810     a->ExeLength = GetExeName(&ExeName,Unicode,&a->UnicodeExe);
    00811     a->Unicode = Unicode;
    00812     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00813                                               a->ExeLength
    00814                                             );
    00815     if (CaptureBuffer == NULL) {
    00816         SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00817         return FALSE;
    00818     }
    00819
    00820     CsrCaptureMessageBuffer( CaptureBuffer,
    00821                              (PCHAR) ExeName,
    00822                              a->ExeLength,
    00823                              (PVOID *) &a->Exe
    00824                            );
    00825
    00826     CsrClientCallServer( (PCSR_API_MSG)&m,
    00827                          CaptureBuffer,
    00828                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00829                                               ConsolepSetNumberOfCommands
    00830                                             ),
    00831                          sizeof( *a )
    00832                        );
    00833     CsrFreeCaptureBuffer( CaptureBuffer );
    00834     if (NT_SUCCESS( m.ReturnValue )) {
    00835         return TRUE;
    00836     } else {
    00837         SET_LAST_NT_ERROR(m.ReturnValue);
    00838         return FALSE;
    00839     }
    00840
    00841 }

NTSTATUS APIENTRY SetConsoleOutputCPInternal | ( | IN UINT | wCodePageID | ) |

Definition at line 1469 of file ntcon/client/getset.c.

References _CONSOLE_SETCP_MSG::ConsoleHandle, ConsolepSetCP, CsrClientCallServer(), GET_CONSOLE_HANDLE, NULL, _CONSOLE_SETCP_MSG::Output, TRUE, _CONSOLE_API_MSG::u, and _CONSOLE_SETCP_MSG::wCodePageID.

Referenced by SetConsoleOutputCP().

    01472 {
    01473     CONSOLE_API_MSG m;
    01474     PCONSOLE_SETCP_MSG a = &m.u.SetConsoleCP;
    01475
    01476     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01477     a->Output = TRUE;
    01478     a->wCodePageID = wCodePageID;
    01479 #if defined(FE_SB)
    01480     a->hEvent = NULL;
    01481 #endif
    01482
    01483     CsrClientCallServer( (PCSR_API_MSG)&m,
    01484                          NULL,
    01485                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01486                                               ConsolepSetCP
    01487                                             ),
    01488                          sizeof( *a )
    01489                        );
    01490
    01491     return m.ReturnValue;
    01492 }

BOOL APIENTRY SetConsolePaletteInternal | ( | IN HANDLE | hConsoleOutput,
|  | IN HPALETTE | hPalette,
|  | IN UINT | dwUsage
| ) |

Definition at line 191 of file client/private.c.

References _CONSOLE_SETPALETTE_MSG::ConsoleHandle, ConsolepSetPalette, CsrClientCallServer(), _CONSOLE_SETPALETTE_MSG::dwUsage, FALSE, GET_CONSOLE_HANDLE, _CONSOLE_SETPALETTE_MSG::hPalette, NT_SUCCESS, NTSTATUS(), NULL, _CONSOLE_SETPALETTE_MSG::OutputHandle, PCONSOLE_SETPALETTE_MSG, SET_LAST_NT_ERROR, Status, TRUE, and _CONSOLE_API_MSG::u.

Referenced by SetConsolePalette().

    00196 {
    00197
    00198     CONSOLE_API_MSG m;
    00199     PCONSOLE_SETPALETTE_MSG a = &m.u.SetConsolePalette;
    00200     NTSTATUS Status;
    00201
    00202     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00203     a->OutputHandle = hConsoleOutput;
    00204     a->hPalette = hPalette;
    00205     a->dwUsage = dwUsage;
    00206     CsrClientCallServer( (PCSR_API_MSG)&m,
    00207                          NULL,
    00208                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00209                                               ConsolepSetPalette
    00210                                             ),
    00211                          sizeof( *a )
    00212                        );
    00213     if (!NT_SUCCESS( m.ReturnValue)) {
    00214         SET_LAST_NT_ERROR(m.ReturnValue);
    00215         return FALSE;
    00216     }
    00217     else {
    00218         return TRUE;
    00219     }
    00220
    00221 }

BOOL APIENTRY SetConsoleTitleInternal | ( | IN CONST VOID * | lpConsoleTitle,
|  | IN DWORD | TitleLength,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 1170 of file client/cmdline.c.

References _CONSOLE_SETTITLE_MSG::ConsoleHandle, ConsolepSetTitle, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, PCONSOLE_SETTITLE_MSG, SET_LAST_NT_ERROR, _CONSOLE_SETTITLE_MSG::Title, _CONSOLE_SETTITLE_MSG::TitleLength, TRUE, _CONSOLE_API_MSG::u, Unicode, and _CONSOLE_SETTITLE_MSG::Unicode.

Referenced by SetConsoleTitleA(), and SetConsoleTitleW().

    01175 {
    01176     CONSOLE_API_MSG m;
    01177     PCONSOLE_SETTITLE_MSG a = &m.u.SetConsoleTitle;
    01178     PCSR_CAPTURE_HEADER CaptureBuffer;
    01179
    01180     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01181     a->TitleLength = TitleLength;
    01182     a->Unicode = Unicode;
    01183     CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    01184                                               a->TitleLength
    01185                                             );
    01186     if (CaptureBuffer == NULL) {
    01187         return FALSE;
    01188     }
    01189     CsrCaptureMessageBuffer( CaptureBuffer,
    01190                              (PCHAR) lpConsoleTitle,
    01191                              a->TitleLength,
    01192                              (PVOID *) &a->Title
    01193                            );
    01194     CsrClientCallServer( (PCSR_API_MSG)&m,
    01195                          CaptureBuffer,
    01196                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01197                                               ConsolepSetTitle
    01198                                             ),
    01199                          sizeof( *a )
    01200                        );
    01201
    01202     CsrFreeCaptureBuffer( CaptureBuffer );
    01203
    01204     if (NT_SUCCESS( m.ReturnValue )) {
    01205         return TRUE;
    01206     }
    01207     else {
    01208         SET_LAST_NT_ERROR (m.ReturnValue);
    01209         return FALSE;
    01210     }
    01211
    01212 }

VOID APIENTRY SetLastConsoleEventActiveInternal | ( | VOID |  | ) |

defined(BUILD_WOW64)

Definition at line 250 of file ctrlc.c.

References _CONSOLE_NOTIFYLASTCLOSE_MSG::ConsoleHandle, ConsolepNotifyLastClose, CsrClientCallServer(), GET_CONSOLE_HANDLE, NULL, and _CONSOLE_API_MSG::u.

Referenced by SetLastConsoleEventActive().

    00254                    :
    00255
    00256     Sends a ConsolepNotifyLastClose command to the server.
    00257
    00258 Arguments:
    00259
    00260     none.
    00261
    00262 Return Value:
    00263
    00264     None.
    00265
    00266 --*/
    00267
    00268 {
    00269     CONSOLE_API_MSG m;
    00270     PCONSOLE_NOTIFYLASTCLOSE_MSG a = &m.u.SetLastConsoleEventActive;
    00271
    00272     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00273     CsrClientCallServer( (PCSR_API_MSG)&m,
    00274                          NULL,
    00275                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00276                                               ConsolepNotifyLastClose
    00277                                             ),
    00278                          sizeof( *a )
    00279                        );
    00280 }

VOID SetTEBLangID | ( | VOID |  | ) |

defined(BUILD_WOW6432)

Definition at line 346 of file dllinit.c.

References GetConsoleLangId().

Referenced by AllocConsole(), ConDllInitialize(), and SetConsoleOutputCP().

    00359 {
    00360     LANGID LangId;
    00361
    00362     if (GetConsoleLangId(&LangId)) {
    00363         SetThreadLocale( MAKELCID(LangId, SORT_DEFAULT) );
    00364     }
    00365 }

BOOL APIENTRY UnregisterConsoleIMEInternal | ( | IN DWORD | dwConsoleIMEThtreadId | ) |

BOOL APIENTRY WriteConsoleInputInternal | ( | IN HANDLE | hConsoleInput,
|  | IN CONST INPUT_RECORD * | lpBuffer,
|  | IN DWORD | nLength,
|  | OUT LPDWORD | lpNumberOfEventsWritten,
|  | IN BOOLEAN | Unicode,
|  | IN BOOLEAN | Append
| ) |

defined(BUILD_WOW64)

Definition at line 335 of file iostubs.c.

References _CONSOLE_WRITECONSOLEINPUT_MSG::Append, _CONSOLE_WRITECONSOLEINPUT_MSG::BufPtr, _CONSOLE_WRITECONSOLEINPUT_MSG::ConsoleHandle, ConsolepWriteConsoleInput, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, INPUT_RECORD_BUFFER_SIZE, _CONSOLE_WRITECONSOLEINPUT_MSG::InputHandle, NT_SUCCESS, NULL, _CONSOLE_WRITECONSOLEINPUT_MSG::NumRecords, _CONSOLE_WRITECONSOLEINPUT_MSG::Record, SET_LAST_ERROR, SET_LAST_NT_ERROR, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_WRITECONSOLEINPUT_MSG::Unicode, and Unicode.

Referenced by WriteConsoleInputA(), WriteConsoleInputVDMA(), WriteConsoleInputVDMW(), and WriteConsoleInputW().

    00345           :
    00346
    00347     hConsoleInput - Supplies an open handle to CONIN$ that is to be
    00348         written.  The handle must have been created with GENERIC_WRITE access.
    00349
    00350     lpBuffer - Supplies the address of a buffer containing the input records
    00351         to write to the input buffer.
    00352
    00353     nLength - Supplies the length of lpBuffer in INPUT_RECORDs.
    00354
    00355     lpNumberOfEventsWritten - Pointer to number of events written.
    00356
    00357     Unicode - TRUE if characters are unicode
    00358
    00359     Append - TRUE if append to end of input stream.  if FALSE, write to the
    00360     beginning of the input stream (used by VDM).
    00361
    00362 Return Value:
    00363
    00364     TRUE - The operation was successful.
    00365
    00366     FALSE/NULL - The operation failed.
    00367         Extended error status is available using GetLastError.
    00368
    00369 --*/
    00370
    00371 {
    00372     PCSR_CAPTURE_HEADER CaptureBuffer;
    00373     CONSOLE_API_MSG m;
    00374     PCONSOLE_WRITECONSOLEINPUT_MSG a = &m.u.WriteConsoleInput;
    00375
    00376     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00377     a->InputHandle = hConsoleInput;
    00378     a->NumRecords = nLength;
    00379     a->Unicode = Unicode;
    00380     a->Append = Append;
    00381
    00382     //
    00383     // for speed in the case where we're only writing a few records, we have
    00384     // a buffer in the msg we pass to the server. this means we don't have to
    00385     // allocate a capture buffer.
    00386     //
    00387
    00388     if (nLength > INPUT_RECORD_BUFFER_SIZE) {
    00389         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00390                                                   nLength * sizeof(INPUT_RECORD)
    00391                                                 );
    00392         if (CaptureBuffer == NULL) {
    00393             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00394             return FALSE;
    00395         }
    00396         CsrCaptureMessageBuffer( CaptureBuffer,
    00397                                  (PCHAR) lpBuffer,
    00398                                  nLength * sizeof(INPUT_RECORD),
    00399                                  (PVOID *) &a->BufPtr
    00400                                );
    00401
    00402     } else {
    00403         a->BufPtr = a->Record;
    00404         CaptureBuffer = NULL;
    00405         try {
    00406             RtlCopyMemory(a->BufPtr, lpBuffer, nLength * sizeof(INPUT_RECORD));
    00407         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00408             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00409             return FALSE;
    00410         }
    00411     }
    00412     CsrClientCallServer( (PCSR_API_MSG)&m,
    00413                          CaptureBuffer,
    00414                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00415                                               ConsolepWriteConsoleInput
    00416                                             ),
    00417                          sizeof( *a )
    00418                        );
    00419     if (CaptureBuffer != NULL) {
    00420         CsrFreeCaptureBuffer( CaptureBuffer );
    00421     }
    00422     try {
    00423         *lpNumberOfEventsWritten = a->NumRecords;
    00424     } except( EXCEPTION_EXECUTE_HANDLER ) {
    00425         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00426         return FALSE;
    00427     }
    00428     if (!NT_SUCCESS(m.ReturnValue)) {
    00429         SET_LAST_NT_ERROR(m.ReturnValue);
    00430         return FALSE;
    00431     }
    00432     else {
    00433         return TRUE;
    00434     }
    00435
    00436 }

BOOL APIENTRY WriteConsoleInternal | ( | IN HANDLE | hConsoleOutput,
|  | IN CONST VOID * | lpBuffer,
|  | IN DWORD | nNumberOfCharsToWrite,
|  | OUT LPDWORD | lpNumberOfCharsWritten,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 408 of file client/stream.c.

References _CONSOLE_WRITECONSOLE_MSG::Buffer, BUFFER_SIZE, _CONSOLE_WRITECONSOLE_MSG::BufferInMessage, _CONSOLE_WRITECONSOLE_MSG::BufPtr, _CONSOLE_WRITECONSOLE_MSG::ConsoleHandle, ConsolepWriteConsole, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_WRITECONSOLE_MSG::NumBytes, _CONSOLE_WRITECONSOLE_MSG::OutputHandle, PCONSOLE_WRITECONSOLE_MSG, SET_LAST_ERROR, SET_LAST_NT_ERROR, TRUE, _CONSOLE_API_MSG::u, Unicode, and _CONSOLE_WRITECONSOLE_MSG::Unicode.

Referenced by WriteConsoleA(), and WriteConsoleW().

    00417           :
    00418
    00419     hFile - Supplies an open handle to to "CONOUT$" open for GENERIC_WRITE
    00420         or the StdOut or StdErr handle.
    00421
    00422     lpBuffer - Supplies the address of the data that is to be written to
    00423         the console output.
    00424
    00425     nNumberOfBytesToWrite - Supplies the number of bytes to write to the
    00426         console output.
    00427
    00428 Return Value:
    00429
    00430     NON-NULL - Returns the number of bytes actually written to the device.
    00431
    00432     FALSE/NULL - The operation failed.
    00433         Extended error status is available using GetLastError.
    00434 --*/
    00435
    00436 {
    00437
    00438     PCSR_CAPTURE_HEADER CaptureBuffer;
    00439     CONSOLE_API_MSG m;
    00440     PCONSOLE_WRITECONSOLE_MSG a = &m.u.WriteConsole;
    00441
    00442     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00443     a->OutputHandle = hConsoleOutput;
    00444
    00445     if (Unicode) {
    00446         a->NumBytes = nNumberOfCharsToWrite * sizeof(WCHAR);
    00447     } else {
    00448         a->NumBytes = nNumberOfCharsToWrite;
    00449     }
    00450
    00451     a->Unicode = Unicode;
    00452     if (a->NumBytes > BUFFER_SIZE) {
    00453         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00454                                                   a->NumBytes
    00455                                                 );
    00456         if (CaptureBuffer == NULL) {
    00457             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00458             return FALSE;
    00459         }
    00460         CsrCaptureMessageBuffer( CaptureBuffer,
    00461                                  (PCHAR) lpBuffer,
    00462                                  a->NumBytes,
    00463                                  (PVOID *) &a->BufPtr
    00464                                );
    00465         a->BufferInMessage = FALSE;
    00466     }
    00467     else {
    00468         a->BufPtr = a->Buffer;
    00469         try {
    00470             RtlCopyMemory( a->BufPtr, lpBuffer, a->NumBytes);
    00471         } except( EXCEPTION_EXECUTE_HANDLER ) {
    00472             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00473             return FALSE;
    00474         }
    00475         CaptureBuffer = NULL;
    00476         a->BufferInMessage = TRUE;
    00477     }
    00478     CsrClientCallServer( (PCSR_API_MSG)&m,
    00479                          CaptureBuffer,
    00480                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00481                                               ConsolepWriteConsole
    00482                                             ),
    00483                          sizeof( *a )
    00484                        );
    00485     if (CaptureBuffer != NULL) {
    00486         CsrFreeCaptureBuffer( CaptureBuffer );
    00487     }
    00488     if (!NT_SUCCESS( m.ReturnValue )) {
    00489         SET_LAST_NT_ERROR(m.ReturnValue);
    00490         return FALSE;
    00491     }
    00492     try {
    00493        *lpNumberOfCharsWritten = a->NumBytes;
    00494        if (Unicode) {
    00495            *lpNumberOfCharsWritten /= sizeof(WCHAR);
    00496        }
    00497     } except( EXCEPTION_EXECUTE_HANDLER ) {
    00498         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00499         return FALSE;
    00500     }
    00501     return TRUE;
    00502
    00503 }

BOOL APIENTRY WriteConsoleOutputInternal | ( | IN HANDLE | hConsoleOutput,
|  | IN CONST CHAR_INFO * | lpBuffer,
|  | IN COORD | dwBufferSize,
|  | IN COORD | dwBufferCoord,
|  | IN PSMALL_RECT | lpWriteRegion,
|  | IN BOOLEAN | Unicode
| ) |

defined(BUILD_WOW64)

Definition at line 771 of file iostubs.c.

References _CONSOLE_WRITECONSOLEOUTPUT_MSG::BufPtr, _CONSOLE_WRITECONSOLEOUTPUT_MSG::Char, _CONSOLE_WRITECONSOLEOUTPUT_MSG::CharRegion, CONSOLE_RECT_SIZE_X, CONSOLE_RECT_SIZE_Y, _CONSOLE_WRITECONSOLEOUTPUT_MSG::ConsoleHandle, ConsolepWriteConsoleOutput, CopyRectangle(), CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_WRITECONSOLEOUTPUT_MSG::OutputHandle, _CONSOLE_WRITECONSOLEOUTPUT_MSG::ReadVM, RtlAllocateHeap, RtlFreeHeap, SET_LAST_ERROR, SET_LAST_NT_ERROR, SHORT, TRUE, _CONSOLE_API_MSG::u, _CONSOLE_WRITECONSOLEOUTPUT_MSG::Unicode, and Unicode.

Referenced by WriteConsoleOutputA(), and WriteConsoleOutputW().

    00781           :
    00782
    00783     hConsoleOutput - Supplies an open handle to the screen buffer (CONOUT$)
    00784         that is to be written.  The handle must have been created with
    00785         GENERIC_WRITE access.
    00786
    00787     lpBuffer - Supplies the address of a buffer containing the data to write
    00788         to the screen buffer.  This buffer is treated as a two dimensional
    00789         array.
    00790
    00791     dwBufferSize - size of lpBuffer
    00792
    00793     dwBufferCoord - coordinates of upper left point in buffer to write data
    00794         from.
    00795
    00796     lpWriteRegion - Supplies on input the address of a structure indicating the
    00797         rectangle within the screen buffer to write to.  The fields in
    00798         the structure are column and row coordinates.  On output, the fields
    00799         contain the actual region written.
    00800
    00801 Return Value:
    00802
    00803     TRUE - The operation was successful.
    00804
    00805     FALSE/NULL - The operation failed. Extended error status is available
    00806         using GetLastError.
    00807 --*/
    00808
    00809 {
    00810
    00811     PCSR_CAPTURE_HEADER CaptureBuffer;
    00812     CONSOLE_API_MSG m;
    00813     PCONSOLE_WRITECONSOLEOUTPUT_MSG a = &m.u.WriteConsoleOutput;
    00814     ULONG NumChars;
    00815     COORD SourceSize;
    00816     COORD TargetPoint;
    00817
    00818     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    00819     a->OutputHandle = hConsoleOutput;
    00820     a->Unicode = Unicode;
    00821
    00822     //
    00823     // clip region to write based on caller's buffer size
    00824     //
    00825
    00826     SourceSize.X = (SHORT)CONSOLE_RECT_SIZE_X(lpWriteRegion);
    00827     if (SourceSize.X > dwBufferSize.X-dwBufferCoord.X)
    00828         SourceSize.X = dwBufferSize.X-dwBufferCoord.X;
    00829     SourceSize.Y = (SHORT)CONSOLE_RECT_SIZE_Y(lpWriteRegion);
    00830     if (SourceSize.Y > dwBufferSize.Y-dwBufferCoord.Y)
    00831         SourceSize.Y = dwBufferSize.Y-dwBufferCoord.Y;
    00832
    00833     if (SourceSize.X <= 0 ||
    00834         SourceSize.Y <= 0) {
    00835         SET_LAST_ERROR(ERROR_INVALID_PARAMETER);
    00836         return FALSE;
    00837     }
    00838
    00839     a->CharRegion.Left = lpWriteRegion->Left;
    00840     a->CharRegion.Right = (SHORT)(lpWriteRegion->Left + SourceSize.X - 1);
    00841     a->CharRegion.Top  = lpWriteRegion->Top;
    00842     a->CharRegion.Bottom = (SHORT)(lpWriteRegion->Top + SourceSize.Y - 1);
    00843
    00844     //
    00845     // for speed in the case where we're only writing one character, we have
    00846     // a buffer in the msg we pass to the server. this means we don't have to
    00847     // allocate a capture buffer.
    00848     //
    00849
    00850     NumChars = SourceSize.X * SourceSize.Y;
    00851     if (NumChars > 1) {
    00852         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    00853                                                   NumChars * sizeof(CHAR_INFO)
    00854                                                 );
    00855         if (CaptureBuffer == NULL) {
    00856             a->ReadVM=TRUE;
    00857             a->BufPtr = RtlAllocateHeap( RtlProcessHeap(), 0, NumChars * sizeof(CHAR_INFO));
    00858             if (a->BufPtr == NULL) {
    00859                 SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    00860                 return FALSE;
    00861             }
    00862         } else {
    00863             a->ReadVM=FALSE;
    00864             CsrCaptureMessageBuffer( CaptureBuffer,
    00865                                      NULL,
    00866                                      NumChars * sizeof(CHAR_INFO),
    00867                                      (PVOID *) &a->BufPtr
    00868                                    );
    00869         }
    00870     }
    00871     else {
    00872         a->ReadVM=FALSE;
    00873         CaptureBuffer = NULL;
    00874         a->BufPtr = &a->Char;
    00875     }
    00876     try {
    00877         SMALL_RECT SourceRect;
    00878
    00879         SourceRect.Left = dwBufferCoord.X;
    00880         SourceRect.Top = dwBufferCoord.Y;
    00881         SourceRect.Right = (SHORT)(dwBufferCoord.X+SourceSize.X-1);
    00882         SourceRect.Bottom = (SHORT)(dwBufferCoord.Y+SourceSize.Y-1);
    00883         TargetPoint.X = 0;
    00884         TargetPoint.Y = 0;
    00885         CopyRectangle(lpBuffer,
    00886                       dwBufferSize,
    00887                       &SourceRect,
    00888                       a->BufPtr,
    00889                       SourceSize,
    00890                       TargetPoint
    00891                      );
    00892     } except( EXCEPTION_EXECUTE_HANDLER ) {
    00893         if (CaptureBuffer != NULL) {
    00894             CsrFreeCaptureBuffer( CaptureBuffer );
    00895         } else if (a->ReadVM) {
    00896             // a->BufPtr was allocated with RtlAllocateHeap.
    00897             RtlFreeHeap( RtlProcessHeap(), 0, a->BufPtr);
    00898         }
    00899         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    00900         return FALSE;
    00901     }
    00902     CsrClientCallServer( (PCSR_API_MSG)&m,
    00903                          CaptureBuffer,
    00904                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    00905                                               ConsolepWriteConsoleOutput
    00906                                             ),
    00907                          sizeof( *a )
    00908                        );
    00909     if (CaptureBuffer != NULL) {
    00910         CsrFreeCaptureBuffer( CaptureBuffer );
    00911     } else if (a->ReadVM) {
    00912         // a->BufPtr was allocated with RtlAllocateHeap.
    00913         RtlFreeHeap(RtlProcessHeap(),0,a->BufPtr);
    00914     }
    00915     *lpWriteRegion = a->CharRegion;
    00916     if (!NT_SUCCESS(m.ReturnValue)) {
    00917         SET_LAST_NT_ERROR(m.ReturnValue);
    00918         return FALSE;
    00919     }
    00920     else {
    00921         return TRUE;
    00922     }
    00923
    00924 }

BOOL APIENTRY WriteConsoleOutputString | ( | IN HANDLE | hConsoleOutput,
|  | IN CONST VOID * | lpString,
|  | IN DWORD | nLength,
|  | IN DWORD | nSize,
|  | IN DWORD | fFlags,
|  | IN COORD | dwWriteCoord,
|  | OUT LPDWORD | lpNumberOfElementsWritten
| ) |

defined(BUILD_WOW64)

Definition at line 1212 of file iostubs.c.

References _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::BufPtr, _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::ConsoleHandle, ConsolepWriteConsoleOutputString, CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), EXCEPTION_EXECUTE_HANDLER, FALSE, GET_CONSOLE_HANDLE, NT_SUCCESS, NULL, _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::NumRecords, _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::OutputHandle, SET_LAST_ERROR, SET_LAST_NT_ERROR, _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::String, _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::StringType, TRUE, _CONSOLE_API_MSG::u, and _CONSOLE_WRITECONSOLEOUTPUTSTRING_MSG::WriteCoord.

Referenced by WriteConsoleOutputAttribute(), WriteConsoleOutputCharacterA(), and WriteConsoleOutputCharacterW().

    01224           :
    01225
    01226     hConsoleOutput - Supplies an open handle to the screen buffer (CONOUT$)
    01227         that is to be written.  The handle must have been created with
    01228         GENERIC_WRITE access.
    01229
    01230     lpString - Supplies the address of a buffer containing the character
    01231         or attribute string to write to the screen buffer.
    01232
    01233     nLength - Length of string to write, in elements.
    01234
    01235     nSize - Size of element to read.
    01236
    01237     fFlags - flag indicating what type of string to copy
    01238
    01239     dwWriteCoord - Screen buffer coordinates to write the string to.
    01240
    01241     lpNumberOfElementsWritten - Pointer to number of elements written.
    01242
    01243 Return Value:
    01244
    01245     TRUE - The operation was successful.
    01246
    01247     FALSE/NULL - The operation failed.
    01248         Extended error status is available using GetLastError.
    01249
    01250 --*/
    01251
    01252 {
    01253
    01254     PCSR_CAPTURE_HEADER CaptureBuffer;
    01255     CONSOLE_API_MSG m;
    01256     PCONSOLE_WRITECONSOLEOUTPUTSTRING_MSG a = &m.u.WriteConsoleOutputString;
    01257     ULONG DataLength;
    01258
    01259     a->ConsoleHandle = GET_CONSOLE_HANDLE;
    01260     a->OutputHandle = hConsoleOutput;
    01261     a->NumRecords = nLength;
    01262     a->StringType = fFlags;
    01263     a->WriteCoord = dwWriteCoord;
    01264
    01265     //
    01266     // for speed in the case where the string is small, we have a buffer
    01267     // in the msg we pass to the server. this means we don't have to
    01268     // allocate a capture buffer.
    01269     //
    01270
    01271     DataLength = nLength*nSize;
    01272     if (DataLength > sizeof(a->String)) {
    01273         CaptureBuffer = CsrAllocateCaptureBuffer( 1,
    01274                                                   DataLength
    01275                                                 );
    01276         if (CaptureBuffer == NULL) {
    01277             SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
    01278             return FALSE;
    01279         }
    01280         CsrCaptureMessageBuffer( CaptureBuffer,
    01281                                  (PCHAR) lpString,
    01282                                  DataLength,
    01283                                  (PVOID *) &a->BufPtr
    01284                                );
    01285     }
    01286     else {
    01287         a->BufPtr = a->String;
    01288         CaptureBuffer = NULL;
    01289
    01290         try {
    01291             RtlCopyMemory(a->BufPtr, lpString, DataLength);
    01292         } except( EXCEPTION_EXECUTE_HANDLER ) {
    01293             SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01294             return FALSE;
    01295         }
    01296     }
    01297     CsrClientCallServer( (PCSR_API_MSG)&m,
    01298                          CaptureBuffer,
    01299                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
    01300                                               ConsolepWriteConsoleOutputString
    01301                                             ),
    01302                          sizeof( *a )
    01303                        );
    01304     if (CaptureBuffer != NULL) {
    01305         CsrFreeCaptureBuffer( CaptureBuffer );
    01306     }
    01307     try {
    01308         *lpNumberOfElementsWritten = a->NumRecords;
    01309     } except( EXCEPTION_EXECUTE_HANDLER ) {
    01310         SET_LAST_ERROR(ERROR_INVALID_ACCESS);
    01311         return FALSE;
    01312     }
    01313     if (!NT_SUCCESS(m.ReturnValue)) {
    01314         SET_LAST_NT_ERROR(m.ReturnValue);
    01315         return FALSE;
    01316     }
    01317     else {
    01318         return TRUE;
    01319     }
    01320
    01321 }

## Variable Documentation

CRITICAL_SECTION DllLock

| Definition at line 67 of file condll.h. Referenced by ConDllInitialize().