00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include <nt.h>
00023
#include <ntrtl.h>
00024
#include <nturtl.h>
00025
00026
00027
#if !defined(SORTPP_PASS)
00028
#include <windows.h>
00029
#endif
00030
00031
#include <winuserk.h>
00032
#include <conroute.h>
00033
#include "conapi.h"
00034
00035
#include "ntcsrdll.h"
00036
#include "conmsg.h"
00037
#include <string.h>
00038
00039
#if defined(BUILD_WOW64)
00040
#define SET_CONSOLE_HANDLE(HANDLE) (Wow64SetConsoleHandle(HANDLE))
00041
#define GET_CONSOLE_HANDLE (Wow64GetConsoleHandle())
00042
#define SET_LAST_ERROR(ERROR) (Wow64SetLastError(ERROR) )
00043
#define SET_LAST_NT_ERROR(ERROR) (Wow64SetLastError(RtlNtStatusToDosError( ERROR )) )
00044
#include "ntwow64c.h"
00045
#else
00046 #define SET_CONSOLE_HANDLE(HANDLE) ((NtCurrentPeb())->ProcessParameters->ConsoleHandle = HANDLE)
00047 #define GET_CONSOLE_HANDLE ((NtCurrentPeb())->ProcessParameters->ConsoleHandle)
00048 #define SET_LAST_ERROR(ERROR) (SetLastError( ERROR ) )
00049 #define SET_LAST_NT_ERROR(ERROR) (SetLastError( RtlNtStatusToDosError( ERROR ) ) )
00050
#endif
00051
00052
00053 #define VALID_ACCESSES (GENERIC_READ | GENERIC_WRITE)
00054 #define VALID_SHARE_ACCESSES (FILE_SHARE_READ | FILE_SHARE_WRITE)
00055
00056 #define VALID_DUP_OPTIONS (DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)
00057
00058 #define CONSOLE_RECT_SIZE_X(RECT) ((RECT)->Right - (RECT)->Left + 1)
00059 #define CONSOLE_RECT_SIZE_Y(RECT) ((RECT)->Bottom - (RECT)->Top + 1)
00060
00061
00062
00063
00064
00065
00066
00067 CRITICAL_SECTION
DllLock;
00068 #define LockDll() RtlEnterCriticalSection(&DllLock)
00069 #define UnlockDll() RtlLeaveCriticalSection(&DllLock)
00070
00071
NTSTATUS
00072
InitializeCtrlHandling( VOID );
00073
00074
USHORT
00075
GetCurrentExeName(
00076 LPWSTR Buffer,
00077 ULONG BufferLength
00078 );
00079
00080 HANDLE
00081
APIENTRY
00082
OpenConsoleWInternal(
00083 IN ULONG HandleType,
00084 IN ULONG DesiredAccess,
00085 IN BOOL InheritHandle,
00086 IN ULONG ShareMode
00087 );
00088
00089
BOOL
00090
APIENTRY
00091
ReadConsoleInternal(
00092 IN HANDLE hConsoleInput,
00093 OUT LPVOID lpBuffer,
00094 IN DWORD nNumberOfCharsToRead,
00095 OUT LPDWORD lpNumberOfCharsRead,
00096 IN OUT LPVOID lpReserved,
00097 IN BOOLEAN Unicode,
00098 IN USHORT ExeNameLength,
00099 IN LPWSTR ExeName
00100 );
00101
00102
BOOL
00103
APIENTRY
00104
WriteConsoleInternal(
00105 IN HANDLE hConsoleOutput,
00106 IN CONST VOID *lpBuffer,
00107 IN DWORD nNumberOfCharsToWrite,
00108 OUT LPDWORD lpNumberOfCharsWritten,
00109 IN BOOLEAN Unicode
00110 );
00111
00112
BOOL
00113
APIENTRY
00114
RegisterConsoleIMEInternal(
00115 IN HWND hWndConsoleIME,
00116 IN DWORD dwConsoleIMEThreadId,
00117 IN DWORD DesktopLength,
00118 IN LPWSTR Desktop,
00119 OUT DWORD *dwConsoleThreadId
00120 );
00121
00122
BOOL
00123
APIENTRY
00124
UnregisterConsoleIMEInternal(
00125 IN DWORD dwConsoleIMEThtreadId
00126 );
00127
00128
BOOL
00129
APIENTRY
00130
GetConsoleInput(
00131 IN HANDLE hConsoleInput,
00132 OUT PINPUT_RECORD lpBuffer,
00133 IN DWORD nLength,
00134 OUT LPDWORD lpNumberOfEventsRead,
00135 IN USHORT wFlags,
00136 IN BOOLEAN Unicode
00137 );
00138
00139
BOOL
00140
APIENTRY
00141
WriteConsoleInputInternal(
00142 IN HANDLE hConsoleInput,
00143 IN CONST INPUT_RECORD *lpBuffer,
00144 IN DWORD nLength,
00145 OUT LPDWORD lpNumberOfEventsWritten,
00146 IN BOOLEAN Unicode,
00147 IN BOOLEAN Append
00148 );
00149
00150
BOOL
00151
APIENTRY
00152
ReadConsoleOutputInternal(
00153 IN HANDLE hConsoleOutput,
00154 OUT PCHAR_INFO lpBuffer,
00155 IN COORD dwBufferSize,
00156 IN COORD dwBufferCoord,
00157 IN OUT PSMALL_RECT lpReadRegion,
00158 IN BOOLEAN Unicode
00159 );
00160
00161
BOOL
00162
APIENTRY
00163
WriteConsoleOutputInternal(
00164 IN HANDLE hConsoleOutput,
00165 IN CONST CHAR_INFO *lpBuffer,
00166 IN COORD dwBufferSize,
00167 IN COORD dwBufferCoord,
00168 IN PSMALL_RECT lpWriteRegion,
00169 IN BOOLEAN Unicode
00170 );
00171
00172
BOOL
00173
APIENTRY
00174
ReadConsoleOutputString(
00175 IN HANDLE hConsoleOutput,
00176 OUT LPVOID lpString,
00177 IN DWORD nLength,
00178 IN DWORD nSize,
00179 IN DWORD fFlags,
00180 IN COORD dwReadCoord,
00181 OUT LPDWORD lpNumberOfElementsRead
00182 );
00183
00184
BOOL
00185
APIENTRY
00186
WriteConsoleOutputString(
00187 IN HANDLE hConsoleOutput,
00188 IN CONST VOID *lpString,
00189 IN DWORD nLength,
00190 IN DWORD nSize,
00191 IN DWORD fFlags,
00192 IN COORD dwWriteCoord,
00193 OUT LPDWORD lpNumberOfElementsWritten
00194 );
00195
00196
BOOL
00197
APIENTRY
00198
FillConsoleOutput(
00199 IN HANDLE hConsoleOutput,
00200 IN WORD Element,
00201 IN DWORD nLength,
00202 IN DWORD fFlags,
00203 IN COORD dwWriteCoord,
00204 OUT LPDWORD lpNumberOfElementsWritten
00205 );
00206
00207
BOOL
00208
APIENTRY
00209
GetConsoleKeyboardLayoutNameWorker(
00210 OUT LPSTR pszLayout,
00211 IN BOOL bAnsi);
00212
00213
BOOL
00214
APIENTRY
00215
SetConsolePaletteInternal(
00216 IN HANDLE hConsoleOutput,
00217 IN HPALETTE hPalette,
00218 IN UINT dwUsage
00219 );
00220
00221
BOOL
00222
APIENTRY
00223
ScrollConsoleScreenBufferInternal(
00224 IN HANDLE hConsoleOutput,
00225 IN CONST SMALL_RECT *lpScrollRectangle,
00226 IN CONST SMALL_RECT *lpClipRectangle,
00227 IN COORD dwDestinationOrigin,
00228 IN CONST CHAR_INFO *lpFill,
00229 IN BOOLEAN Unicode
00230 );
00231
00232
NTSTATUS
00233
APIENTRY
00234
SetConsoleOutputCPInternal(
00235 IN UINT wCodePageID
00236 );
00237
00238
VOID
00239
APIENTRY
00240
SetLastConsoleEventActiveInternal(
00241 VOID
00242 );
00243
00244
BOOL
00245
APIENTRY
00246
ConnectConsoleInternal(
00247 IN PWSTR pObjectDirectory,
00248 IN OUT
PCONSOLE_API_CONNECTINFO pConnectInfo,
00249 OUT PBOOLEAN pServerProcess
00250 );
00251
00252
00253
BOOL
00254
APIENTRY
00255
AllocConsoleInternal(
00256 IN LPWSTR lpTitle,
00257 IN DWORD dwTitleLength,
00258 IN LPWSTR lpDesktop,
00259 IN DWORD dwDesktopLength,
00260 IN LPWSTR lpCurDir,
00261 IN DWORD dwCurDirLength,
00262 IN LPWSTR AppName,
00263 IN DWORD dwAppNameLength,
00264 IN LPTHREAD_START_ROUTINE CtrlRoutine,
00265 IN LPTHREAD_START_ROUTINE PropRoutine,
00266 IN OUT
PCONSOLE_INFO pConsoleInfo
00267 );
00268
00269
BOOL
00270
APIENTRY
00271
FreeConsoleInternal(
00272 VOID
00273 );
00274
00275
BOOL
00276 WINAPI
00277
GetConsoleLangId(
00278 OUT LANGID *lpLangId
00279 );
00280
00281
BOOL
00282
APIENTRY
00283
AddConsoleAliasInternal(
00284 IN LPVOID Source,
00285 IN UINT SourceLength,
00286 IN LPVOID Target,
00287 IN UINT TargetLength,
00288 IN LPVOID ExeName,
00289 IN BOOLEAN Unicode
00290 );
00291
00292
DWORD
00293
APIENTRY
00294
GetConsoleAliasInternal(
00295 IN LPVOID Source,
00296 IN UINT SourceLength,
00297 OUT LPVOID TargetBuffer,
00298 IN UINT TargetBufferLength,
00299 IN LPVOID ExeName,
00300 IN BOOLEAN Unicode
00301 );
00302
00303
DWORD
00304
APIENTRY
00305
GetConsoleAliasesLengthInternal(
00306 IN LPVOID ExeName,
00307 IN BOOLEAN Unicode
00308 );
00309
00310
DWORD
00311
APIENTRY
00312
GetConsoleAliasExesLengthInternal(
00313 IN BOOLEAN Unicode
00314 );
00315
00316
DWORD
00317
APIENTRY
00318
GetConsoleAliasesInternal(
00319 OUT LPVOID AliasBuffer,
00320 IN DWORD AliasBufferLength,
00321 IN LPVOID ExeName,
00322 IN BOOLEAN Unicode
00323 );
00324
00325
DWORD
00326
APIENTRY
00327
GetConsoleAliasExesInternal(
00328 OUT LPVOID ExeNameBuffer,
00329 IN DWORD ExeNameBufferLength,
00330 IN BOOLEAN Unicode
00331 );
00332
00333
VOID
00334
APIENTRY
00335
ExpungeConsoleCommandHistoryInternal(
00336 IN LPVOID ExeName,
00337 IN BOOLEAN Unicode
00338 );
00339
00340
BOOL
00341
APIENTRY
00342
SetConsoleNumberOfCommandsInternal(
00343 IN DWORD Number,
00344 IN LPVOID ExeName,
00345 IN BOOLEAN Unicode
00346 );
00347
00348
DWORD
00349
APIENTRY
00350
GetConsoleCommandHistoryLengthInternal(
00351 IN LPVOID ExeName,
00352 IN BOOLEAN Unicode
00353 );
00354
00355
DWORD
00356
APIENTRY
00357
GetConsoleCommandHistoryInternal(
00358 OUT LPVOID Commands,
00359 IN DWORD CommandBufferLength,
00360 IN LPVOID ExeName,
00361 IN BOOLEAN Unicode
00362 );
00363
00364
DWORD
00365
APIENTRY
00366
GetConsoleTitleInternal(
00367 OUT PVOID lpConsoleTitle,
00368 IN DWORD nSize,
00369 IN BOOLEAN Unicode
00370 );
00371
00372
BOOL
00373
APIENTRY
00374
SetConsoleTitleInternal(
00375 IN CONST VOID *lpConsoleTitle,
00376 IN DWORD TitleLength,
00377 IN BOOLEAN Unicode
00378 );
00379
00380
VOID
00381
SetTEBLangID(
00382 VOID
00383 );