00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "precomp.h"
00022
#pragma hdrstop
00023
#pragma hdrstop
00024
00025
#if !defined(BUILD_WOW6432)
00026
00027
BOOL
00028 WINAPI
00029 GetConsoleMode(
00030 IN HANDLE hConsoleHandle,
00031 OUT LPDWORD lpMode
00032 )
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069 {
00070
00071
CONSOLE_API_MSG m;
00072
PCONSOLE_MODE_MSG a = &m.
u.GetConsoleMode;
00073
00074 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00075 a->
Handle = hConsoleHandle;
00076
CsrClientCallServer( (PCSR_API_MSG)&m,
00077
NULL,
00078 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00079
ConsolepGetMode
00080 ),
00081
sizeof( *a )
00082 );
00083
if (
NT_SUCCESS( m.ReturnValue )) {
00084
try {
00085 *lpMode = a->Mode;
00086 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00087
SET_LAST_ERROR (ERROR_INVALID_ACCESS);
00088
return FALSE;
00089 }
00090
return TRUE;
00091 }
else {
00092
SET_LAST_NT_ERROR (m.ReturnValue);
00093
return FALSE;
00094 }
00095
00096 }
00097
00098
DWORD
00099 WINAPI
00100 GetNumberOfConsoleFonts(
00101 VOID
00102 )
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 {
00120
00121
CONSOLE_API_MSG m;
00122
PCONSOLE_GETNUMBEROFFONTS_MSG a = &m.
u.GetNumberOfConsoleFonts;
00123
00124 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00125
CsrClientCallServer( (PCSR_API_MSG)&m,
00126
NULL,
00127 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00128
ConsolepGetNumberOfFonts
00129 ),
00130
sizeof( *a )
00131 );
00132
if (
NT_SUCCESS( m.ReturnValue )) {
00133
return a->NumberOfFonts;
00134 }
else {
00135
SET_LAST_NT_ERROR (m.ReturnValue);
00136
return FALSE;
00137 }
00138
00139 }
00140
00141
00142
BOOL
00143 WINAPI
00144 GetNumberOfConsoleInputEvents(
00145 IN HANDLE hConsoleInput,
00146 OUT LPDWORD lpNumberOfEvents
00147 )
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 {
00167
00168
CONSOLE_API_MSG m;
00169
PCONSOLE_GETNUMBEROFINPUTEVENTS_MSG a = &m.
u.GetNumberOfConsoleInputEvents;
00170
00171 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00172 a->
InputHandle = hConsoleInput;
00173
CsrClientCallServer( (PCSR_API_MSG)&m,
00174
NULL,
00175 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00176
ConsolepGetNumberOfInputEvents
00177 ),
00178
sizeof( *a )
00179 );
00180
if (
NT_SUCCESS( m.ReturnValue )) {
00181
try {
00182 *lpNumberOfEvents = a->ReadyEvents;
00183 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00184
SET_LAST_ERROR (ERROR_INVALID_ACCESS);
00185
return FALSE;
00186 }
00187
return TRUE;
00188 }
00189
else {
00190
SET_LAST_NT_ERROR (m.ReturnValue);
00191
return FALSE;
00192 }
00193
00194 }
00195
00196 COORD
00197 WINAPI
00198 GetLargestConsoleWindowSize(
00199 IN HANDLE hConsoleOutput
00200 )
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 {
00220
00221
CONSOLE_API_MSG m;
00222
PCONSOLE_GETLARGESTWINDOWSIZE_MSG a = &m.
u.GetLargestConsoleWindowSize;
00223
00224 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00225 a->
OutputHandle = hConsoleOutput;
00226
CsrClientCallServer( (PCSR_API_MSG)&m,
00227
NULL,
00228 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00229
ConsolepGetLargestWindowSize
00230 ),
00231
sizeof( *a )
00232 );
00233
if (
NT_SUCCESS( m.ReturnValue )) {
00234
return a->Size;
00235 }
else {
00236 COORD Dummy;
00237 Dummy.X = Dummy.Y = 0;
00238
SET_LAST_NT_ERROR (m.ReturnValue);
00239
return Dummy;
00240 }
00241
00242 }
00243
00244
00245
BOOL
00246 WINAPI
00247 GetConsoleScreenBufferInfo(
00248 IN HANDLE hConsoleOutput,
00249 OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
00250 )
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 {
00271
00272
CONSOLE_API_MSG m;
00273
PCONSOLE_GETSCREENBUFFERINFO_MSG a = &m.
u.GetConsoleScreenBufferInfo;
00274
00275 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00276 a->
OutputHandle = hConsoleOutput;
00277
CsrClientCallServer( (PCSR_API_MSG)&m,
00278
NULL,
00279 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00280
ConsolepGetScreenBufferInfo
00281 ),
00282
sizeof( *a )
00283 );
00284
if (
NT_SUCCESS( m.ReturnValue )) {
00285
try {
00286 lpConsoleScreenBufferInfo->dwSize = a->Size;
00287 lpConsoleScreenBufferInfo->dwCursorPosition = a->CursorPosition;
00288 lpConsoleScreenBufferInfo->wAttributes = a->Attributes;
00289 lpConsoleScreenBufferInfo->srWindow.Left = a->ScrollPosition.X;
00290 lpConsoleScreenBufferInfo->srWindow.Top = a->ScrollPosition.Y;
00291 lpConsoleScreenBufferInfo->srWindow.Right = lpConsoleScreenBufferInfo->srWindow.Left + a->CurrentWindowSize.X-1;
00292 lpConsoleScreenBufferInfo->srWindow.Bottom = lpConsoleScreenBufferInfo->srWindow.Top + a->CurrentWindowSize.Y-1;
00293 lpConsoleScreenBufferInfo->dwMaximumWindowSize = a->MaximumWindowSize;
00294 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00295
SET_LAST_ERROR (ERROR_INVALID_ACCESS);
00296
return FALSE;
00297 }
00298
return TRUE;
00299 }
else {
00300
SET_LAST_NT_ERROR (m.ReturnValue);
00301
return FALSE;
00302 }
00303
00304 }
00305
00306
BOOL
00307 WINAPI
00308 GetConsoleCursorInfo(
00309 IN HANDLE hConsoleOutput,
00310 OUT PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
00311 )
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331 {
00332
00333
CONSOLE_API_MSG m;
00334
PCONSOLE_GETCURSORINFO_MSG a = &m.
u.GetConsoleCursorInfo;
00335
00336 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00337 a->
OutputHandle = hConsoleOutput;
00338
CsrClientCallServer( (PCSR_API_MSG)&m,
00339
NULL,
00340 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00341
ConsolepGetCursorInfo
00342 ),
00343
sizeof( *a )
00344 );
00345
if (
NT_SUCCESS( m.ReturnValue )) {
00346
try {
00347 lpConsoleCursorInfo->dwSize = a->CursorSize;
00348 lpConsoleCursorInfo->bVisible = a->Visible;
00349 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00350
SET_LAST_ERROR (ERROR_INVALID_ACCESS);
00351
return FALSE;
00352 }
00353
return TRUE;
00354 }
else {
00355
SET_LAST_NT_ERROR (m.ReturnValue);
00356
return FALSE;
00357 }
00358
00359 }
00360
00361
BOOL
00362 WINAPI
00363 GetNumberOfConsoleMouseButtons(
00364 OUT LPDWORD lpNumberOfMouseButtons
00365 )
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 {
00385
00386
CONSOLE_API_MSG m;
00387
PCONSOLE_GETMOUSEINFO_MSG a = &m.
u.GetConsoleMouseInfo;
00388
00389 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00390
CsrClientCallServer( (PCSR_API_MSG)&m,
00391
NULL,
00392 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00393
ConsolepGetMouseInfo
00394 ),
00395
sizeof( *a )
00396 );
00397
if (
NT_SUCCESS( m.ReturnValue )) {
00398
try {
00399 *lpNumberOfMouseButtons = a->NumButtons;
00400 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00401
SET_LAST_ERROR (ERROR_INVALID_ACCESS);
00402
return FALSE;
00403 }
00404
return TRUE;
00405 }
else {
00406
SET_LAST_NT_ERROR (m.ReturnValue);
00407
return FALSE;
00408 }
00409
00410 }
00411
00412
DWORD
00413 WINAPI
00414 GetConsoleFontInfo(
00415 IN HANDLE hConsoleOutput,
00416 IN BOOL bMaximumWindow,
00417 IN DWORD nLength,
00418 OUT PCONSOLE_FONT_INFO lpConsoleFontInfo
00419 )
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 {
00446
00447
CONSOLE_API_MSG m;
00448
PCONSOLE_GETFONTINFO_MSG a = &m.
u.GetConsoleFontInfo;
00449 PCSR_CAPTURE_HEADER CaptureBuffer;
00450
00451 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00452 a->
OutputHandle = hConsoleOutput;
00453 a->
MaximumWindow = (BOOLEAN) bMaximumWindow;
00454 a->
NumFonts = nLength;
00455
00456 CaptureBuffer =
CsrAllocateCaptureBuffer( 1,
00457 nLength *
sizeof(CONSOLE_FONT_INFO)
00458 );
00459
if (CaptureBuffer ==
NULL) {
00460
SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
00461
return FALSE;
00462 }
00463
CsrCaptureMessageBuffer( CaptureBuffer,
00464
NULL,
00465 nLength *
sizeof(CONSOLE_FONT_INFO),
00466 (PVOID *) &a->
BufPtr
00467 );
00468
00469
CsrClientCallServer( (PCSR_API_MSG)&m,
00470 CaptureBuffer,
00471 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00472
ConsolepGetFontInfo
00473 ),
00474
sizeof( *a )
00475 );
00476
if (
NT_SUCCESS( m.ReturnValue )) {
00477
try {
00478 RtlCopyMemory( lpConsoleFontInfo, a->BufPtr, a->NumFonts *
sizeof(CONSOLE_FONT_INFO));
00479 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00480
CsrFreeCaptureBuffer( CaptureBuffer );
00481
SET_LAST_ERROR(ERROR_INVALID_ACCESS);
00482
return 0;
00483 }
00484 }
00485
else {
00486
SET_LAST_NT_ERROR (m.ReturnValue);
00487 }
00488
CsrFreeCaptureBuffer( CaptureBuffer );
00489
return a->NumFonts;
00490
00491 }
00492
00493 COORD
00494 WINAPI
00495 GetConsoleFontSize(
00496 IN HANDLE hConsoleOutput,
00497 IN DWORD nFont
00498 )
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518 {
00519
00520
CONSOLE_API_MSG m;
00521
PCONSOLE_GETFONTSIZE_MSG a = &m.
u.GetConsoleFontSize;
00522 COORD Dummy;
00523
00524 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00525 a->
OutputHandle = hConsoleOutput;
00526 a->
FontIndex = nFont;
00527
CsrClientCallServer( (PCSR_API_MSG)&m,
00528
NULL,
00529 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00530
ConsolepGetFontSize
00531 ),
00532
sizeof( *a )
00533 );
00534
if (
NT_SUCCESS( m.ReturnValue )) {
00535
return a->FontSize;
00536 }
else {
00537
SET_LAST_NT_ERROR (m.ReturnValue);
00538 Dummy.X = Dummy.Y = 0;
00539
return Dummy;
00540 }
00541
00542 }
00543
00544
BOOL
00545 WINAPI
00546 GetCurrentConsoleFont(
00547 IN HANDLE hConsoleOutput,
00548 IN BOOL bMaximumWindow,
00549 OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont
00550 )
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574 {
00575
00576
CONSOLE_API_MSG m;
00577
PCONSOLE_GETCURRENTFONT_MSG a = &m.
u.GetCurrentConsoleFont;
00578
00579 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00580 a->
OutputHandle = hConsoleOutput;
00581 a->
MaximumWindow = (BOOLEAN) bMaximumWindow;
00582 a->
OutputHandle = hConsoleOutput;
00583
CsrClientCallServer( (PCSR_API_MSG)&m,
00584
NULL,
00585 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00586
ConsolepGetCurrentFont
00587 ),
00588
sizeof( *a )
00589 );
00590
if (
NT_SUCCESS( m.ReturnValue )) {
00591
try {
00592 lpConsoleCurrentFont->dwFontSize = a->FontSize;
00593 lpConsoleCurrentFont->nFont = a->FontIndex;
00594 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00595
SET_LAST_ERROR(ERROR_INVALID_ACCESS);
00596
return FALSE;
00597 }
00598
return TRUE;
00599 }
else {
00600
SET_LAST_NT_ERROR (m.ReturnValue);
00601
return FALSE;
00602 }
00603
00604 }
00605
00606
BOOL
00607 WINAPI
00608 SetConsoleMode(
00609 IN HANDLE hConsoleHandle,
00610 IN DWORD dwMode
00611 )
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648 {
00649
00650
CONSOLE_API_MSG m;
00651
PCONSOLE_MODE_MSG a = &m.
u.SetConsoleMode;
00652
00653 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00654 a->
Handle = hConsoleHandle;
00655 a->
Mode = dwMode;
00656
CsrClientCallServer( (PCSR_API_MSG)&m,
00657
NULL,
00658 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00659
ConsolepSetMode
00660 ),
00661
sizeof( *a )
00662 );
00663
if (
NT_SUCCESS( m.ReturnValue )) {
00664
return TRUE;
00665 }
else {
00666
SET_LAST_NT_ERROR (m.ReturnValue);
00667
return FALSE;
00668 }
00669
00670 }
00671
00672
BOOL
00673 WINAPI
00674 GenerateConsoleCtrlEvent(
00675 IN DWORD dwCtrlEvent,
00676 IN DWORD dwProcessGroupId
00677 )
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700 {
00701
00702
CONSOLE_API_MSG m;
00703
PCONSOLE_CTRLEVENT_MSG a = &m.
u.GenerateConsoleCtrlEvent;
00704
00705
00706
00707
00708
00709
if ((dwCtrlEvent != CTRL_C_EVENT) && (dwCtrlEvent != CTRL_BREAK_EVENT)) {
00710
SET_LAST_ERROR (ERROR_INVALID_PARAMETER);
00711
return(
FALSE);
00712 }
00713
00714
00715 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00716 a->
CtrlEvent = dwCtrlEvent;
00717 a->
ProcessGroupId = dwProcessGroupId;
00718
CsrClientCallServer( (PCSR_API_MSG)&m,
00719
NULL,
00720 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00721
ConsolepGenerateCtrlEvent
00722 ),
00723
sizeof( *a )
00724 );
00725
if (
NT_SUCCESS( m.ReturnValue )) {
00726
return TRUE;
00727 }
else {
00728
SET_LAST_NT_ERROR (m.ReturnValue);
00729
return FALSE;
00730 }
00731
00732 }
00733
00734
BOOL
00735 WINAPI
00736 SetConsoleActiveScreenBuffer(
00737 IN HANDLE hConsoleOutput
00738 )
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756 {
00757
00758
CONSOLE_API_MSG m;
00759
PCONSOLE_SETACTIVESCREENBUFFER_MSG a = &m.
u.SetConsoleActiveScreenBuffer;
00760
00761 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00762 a->
OutputHandle = hConsoleOutput;
00763
CsrClientCallServer( (PCSR_API_MSG)&m,
00764
NULL,
00765 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00766
ConsolepSetActiveScreenBuffer
00767 ),
00768
sizeof( *a )
00769 );
00770
if (
NT_SUCCESS( m.ReturnValue )) {
00771
return TRUE;
00772 }
else {
00773
SET_LAST_NT_ERROR (m.ReturnValue);
00774
return FALSE;
00775 }
00776
00777 }
00778
00779
00780
BOOL
00781 WINAPI
00782 FlushConsoleInputBuffer(
00783 IN HANDLE hConsoleInput
00784 )
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 {
00802
00803
CONSOLE_API_MSG m;
00804
PCONSOLE_FLUSHINPUTBUFFER_MSG a = &m.
u.FlushConsoleInputBuffer;
00805
00806 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00807 a->
InputHandle = hConsoleInput;
00808
CsrClientCallServer( (PCSR_API_MSG)&m,
00809
NULL,
00810 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00811
ConsolepFlushInputBuffer
00812 ),
00813
sizeof( *a )
00814 );
00815
if (
NT_SUCCESS( m.ReturnValue )) {
00816
return TRUE;
00817 }
else {
00818
SET_LAST_NT_ERROR (m.ReturnValue);
00819
return FALSE;
00820 }
00821
00822 }
00823
00824
00825
BOOL
00826 WINAPI
00827 SetConsoleScreenBufferSize(
00828 IN HANDLE hConsoleOutput,
00829 IN COORD dwSize
00830 )
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849 {
00850
00851
CONSOLE_API_MSG m;
00852
PCONSOLE_SETSCREENBUFFERSIZE_MSG a = &m.
u.SetConsoleScreenBufferSize;
00853
00854 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00855 a->
OutputHandle = hConsoleOutput;
00856 a->
Size = dwSize;
00857
CsrClientCallServer( (PCSR_API_MSG)&m,
00858
NULL,
00859 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00860
ConsolepSetScreenBufferSize
00861 ),
00862
sizeof( *a )
00863 );
00864
if (
NT_SUCCESS( m.ReturnValue )) {
00865
return TRUE;
00866 }
else {
00867
SET_LAST_NT_ERROR (m.ReturnValue);
00868
return FALSE;
00869 }
00870
00871
00872 }
00873
00874
BOOL
00875 WINAPI
00876 SetConsoleCursorPosition(
00877 IN HANDLE hConsoleOutput,
00878 IN COORD dwCursorPosition
00879 )
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898 {
00899
00900
CONSOLE_API_MSG m;
00901
PCONSOLE_SETCURSORPOSITION_MSG a = &m.
u.SetConsoleCursorPosition;
00902
00903 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00904 a->
OutputHandle = hConsoleOutput;
00905 a->
CursorPosition = dwCursorPosition;
00906
CsrClientCallServer( (PCSR_API_MSG)&m,
00907
NULL,
00908 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00909
ConsolepSetCursorPosition
00910 ),
00911
sizeof( *a )
00912 );
00913
if (
NT_SUCCESS( m.ReturnValue )) {
00914
return TRUE;
00915 }
else {
00916
SET_LAST_NT_ERROR (m.ReturnValue);
00917
return FALSE;
00918 }
00919
00920
00921 }
00922
00923
BOOL
00924 WINAPI
00925 SetConsoleCursorInfo(
00926 IN HANDLE hConsoleOutput,
00927 IN CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo
00928 )
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948 {
00949
00950
CONSOLE_API_MSG m;
00951
PCONSOLE_SETCURSORINFO_MSG a = &m.
u.SetConsoleCursorInfo;
00952
00953 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
00954 a->
OutputHandle = hConsoleOutput;
00955
try {
00956 a->
CursorSize = lpConsoleCursorInfo->dwSize;
00957 a->
Visible = (BOOLEAN) lpConsoleCursorInfo->bVisible;
00958 } except(
EXCEPTION_EXECUTE_HANDLER ) {
00959
SET_LAST_ERROR(ERROR_INVALID_ACCESS);
00960
return FALSE;
00961 }
00962
CsrClientCallServer( (PCSR_API_MSG)&m,
00963
NULL,
00964 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00965
ConsolepSetCursorInfo
00966 ),
00967
sizeof( *a )
00968 );
00969
if (
NT_SUCCESS( m.ReturnValue )) {
00970
return TRUE;
00971 }
else {
00972
SET_LAST_NT_ERROR (m.ReturnValue);
00973
return FALSE;
00974 }
00975
00976 }
00977
00978
BOOL
00979 WINAPI
00980 SetConsoleWindowInfo(
00981 IN HANDLE hConsoleOutput,
00982 IN BOOL bAbsolute,
00983 IN CONST SMALL_RECT *lpConsoleWindow
00984 )
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004 {
01005
01006
CONSOLE_API_MSG m;
01007
PCONSOLE_SETWINDOWINFO_MSG a = &m.
u.SetConsoleWindowInfo;
01008
01009 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01010 a->
OutputHandle = hConsoleOutput;
01011 a->
Absolute = bAbsolute;
01012
try {
01013 a->
Window = *lpConsoleWindow;
01014 } except(
EXCEPTION_EXECUTE_HANDLER ) {
01015
SET_LAST_ERROR(ERROR_INVALID_ACCESS);
01016
return FALSE;
01017 }
01018
CsrClientCallServer( (PCSR_API_MSG)&m,
01019
NULL,
01020 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01021
ConsolepSetWindowInfo
01022 ),
01023
sizeof( *a )
01024 );
01025
if (
NT_SUCCESS( m.ReturnValue )) {
01026
return TRUE;
01027 }
else {
01028
SET_LAST_NT_ERROR (m.ReturnValue);
01029
return FALSE;
01030 }
01031
01032 }
01033
01034
BOOL
01035
APIENTRY
01036 ScrollConsoleScreenBufferInternal(
01037 IN HANDLE hConsoleOutput,
01038 IN CONST SMALL_RECT *lpScrollRectangle,
01039 IN CONST SMALL_RECT *lpClipRectangle,
01040 IN COORD dwDestinationOrigin,
01041 IN CONST CHAR_INFO *lpFill,
01042 IN BOOLEAN Unicode
01043 )
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
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 }
01108
01109
#endif
01110
01111
#if !defined(BUILD_WOW64)
01112
01113
BOOL
01114
APIENTRY
01115 ScrollConsoleScreenBufferA(
01116 HANDLE hConsoleOutput,
01117 CONST SMALL_RECT *lpScrollRectangle,
01118 CONST SMALL_RECT *lpClipRectangle,
01119 COORD dwDestinationOrigin,
01120 CONST CHAR_INFO *lpFill
01121 )
01122 {
01123
return ScrollConsoleScreenBufferInternal(hConsoleOutput,
01124 lpScrollRectangle,
01125 lpClipRectangle,
01126 dwDestinationOrigin,
01127 lpFill,
01128
FALSE);
01129 }
01130
01131
BOOL
01132
APIENTRY
01133 ScrollConsoleScreenBufferW(
01134 HANDLE hConsoleOutput,
01135 CONST SMALL_RECT *lpScrollRectangle,
01136 CONST SMALL_RECT *lpClipRectangle,
01137 COORD dwDestinationOrigin,
01138 CONST CHAR_INFO *lpFill
01139 )
01140 {
01141
return ScrollConsoleScreenBufferInternal(hConsoleOutput,
01142 lpScrollRectangle,
01143 lpClipRectangle,
01144 dwDestinationOrigin,
01145 lpFill,
01146
TRUE);
01147 }
01148
01149
#endif
01150
01151
#if !defined(BUILD_WOW6432)
01152
01153
BOOL
01154 WINAPI
01155 SetConsoleTextAttribute(
01156 IN HANDLE hConsoleOutput,
01157 IN WORD wAttributes
01158 )
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177 {
01178
01179
CONSOLE_API_MSG m;
01180
PCONSOLE_SETTEXTATTRIBUTE_MSG a = &m.
u.SetConsoleTextAttribute;
01181
01182 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01183 a->
OutputHandle = hConsoleOutput;
01184 a->
Attributes = wAttributes;
01185
CsrClientCallServer( (PCSR_API_MSG)&m,
01186
NULL,
01187 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01188
ConsolepSetTextAttribute
01189 ),
01190
sizeof( *a )
01191 );
01192
if (
NT_SUCCESS( m.ReturnValue )) {
01193
return TRUE;
01194 }
else {
01195
SET_LAST_NT_ERROR (m.ReturnValue);
01196
return FALSE;
01197 }
01198
01199 }
01200
01201
BOOL
01202 WINAPI
01203 SetConsoleFont(
01204 IN HANDLE hConsoleOutput,
01205 IN DWORD nFont
01206 )
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 {
01226
01227
CONSOLE_API_MSG m;
01228
PCONSOLE_SETFONT_MSG a = &m.
u.SetConsoleFont;
01229
01230 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01231 a->
OutputHandle = hConsoleOutput;
01232 a->
FontIndex = nFont;
01233
CsrClientCallServer( (PCSR_API_MSG)&m,
01234
NULL,
01235 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01236
ConsolepSetFont
01237 ),
01238
sizeof( *a )
01239 );
01240
if (
NT_SUCCESS( m.ReturnValue )) {
01241
return TRUE;
01242 }
else {
01243
SET_LAST_NT_ERROR (m.ReturnValue);
01244
return FALSE;
01245 }
01246
01247 }
01248
01249
BOOL
01250 WINAPI
01251 SetConsoleIcon(
01252 IN HICON hIcon
01253 )
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270 {
01271
01272
CONSOLE_API_MSG m;
01273
PCONSOLE_SETICON_MSG a = &m.
u.SetConsoleIcon;
01274
01275 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01276 a->
hIcon = hIcon;
01277
CsrClientCallServer( (PCSR_API_MSG)&m,
01278
NULL,
01279 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01280
ConsolepSetIcon
01281 ),
01282
sizeof( *a )
01283 );
01284
if (
NT_SUCCESS( m.ReturnValue )) {
01285
return TRUE;
01286 }
else {
01287
SET_LAST_NT_ERROR (m.ReturnValue);
01288
return FALSE;
01289 }
01290
01291 }
01292
01293
#endif
01294
01295
#if !defined(BUILD_WOW64)
01296
01297
BOOL
01298
APIENTRY
01299 SetConsoleMaximumWindowSize(
01300 HANDLE hConsoleOutput,
01301 COORD dwWindowSize
01302 )
01303 {
01304 UNREFERENCED_PARAMETER(hConsoleOutput);
01305 UNREFERENCED_PARAMETER(dwWindowSize);
01306
01307
return TRUE;
01308 }
01309
01310
#endif
01311
01312
#if !defined(BUILD_WOW6432)
01313
01314
UINT
01315 WINAPI
01316 GetConsoleCP( VOID )
01317
01318
01331 {
01332
01333
CONSOLE_API_MSG m;
01334
PCONSOLE_GETCP_MSG a = &m.
u.GetConsoleCP;
01335
01336 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01337 a->
Output =
FALSE;
01338
CsrClientCallServer( (PCSR_API_MSG)&m,
01339
NULL,
01340 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01341
ConsolepGetCP
01342 ),
01343
sizeof( *a )
01344 );
01345
if (
NT_SUCCESS( m.ReturnValue )) {
01346
return a->wCodePageID;
01347 }
else {
01348
SET_LAST_NT_ERROR (m.ReturnValue);
01349
return FALSE;
01350 }
01351
01352 }
01353
01354
BOOL
01355 WINAPI
01356 SetConsoleCP(
01357 IN UINT wCodePageID
01358 )
01359
01360
01376 {
01377
01378
CONSOLE_API_MSG m;
01379
PCONSOLE_SETCP_MSG a = &m.
u.SetConsoleCP;
01380
NTSTATUS Status;
01381
01382 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01383 a->
Output =
FALSE;
01384 a->
wCodePageID = wCodePageID;
01385
#if defined(FE_SB)
01386
Status =
NtCreateEvent(&(a->hEvent),
01387 EVENT_ALL_ACCESS,
01388
NULL,
01389 SynchronizationEvent,
01390 (BOOLEAN)
FALSE
01391 );
01392
if (!
NT_SUCCESS(
Status)) {
01393
SET_LAST_NT_ERROR(
Status);
01394
return FALSE;
01395 }
01396
#endif
01397
CsrClientCallServer( (PCSR_API_MSG)&m,
01398
NULL,
01399 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01400
ConsolepSetCP
01401 ),
01402
sizeof( *a )
01403 );
01404
if (
NT_SUCCESS( m.ReturnValue )) {
01405
#if defined(FE_SB)
01406
NTSTATUS Status;
01407
01408
Status =
NtWaitForSingleObject(a->hEvent,
FALSE,
NULL);
01409
NtClose(a->hEvent);
01410
if (
Status != 0) {
01411
SET_LAST_NT_ERROR(
Status);
01412
return FALSE;
01413 }
01414
#endif
01415
return TRUE;
01416 }
else {
01417
#if defined(FE_SB)
01418
NtClose(a->hEvent);
01419
#endif
01420
SET_LAST_NT_ERROR (m.ReturnValue);
01421
return FALSE;
01422 }
01423
01424 }
01425
01426
01427
UINT
01428 WINAPI
01429 GetConsoleOutputCP( VOID )
01430
01431
01444 {
01445
01446
CONSOLE_API_MSG m;
01447
PCONSOLE_GETCP_MSG a = &m.
u.GetConsoleCP;
01448
01449 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01450 a->
Output =
TRUE;
01451
CsrClientCallServer( (PCSR_API_MSG)&m,
01452
NULL,
01453 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01454
ConsolepGetCP
01455 ),
01456
sizeof( *a )
01457 );
01458
if (
NT_SUCCESS( m.ReturnValue )) {
01459
return a->wCodePageID;
01460 }
else {
01461
SET_LAST_NT_ERROR (m.ReturnValue);
01462
return FALSE;
01463 }
01464
01465 }
01466
01467
NTSTATUS
01468
APIENTRY
01469 SetConsoleOutputCPInternal(
01470 IN UINT wCodePageID
01471 )
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 }
01493
01494
#endif
01495
01496
01497
#if !defined(BUILD_WOW64)
01498
01499
BOOL
01500 WINAPI
01501 SetConsoleOutputCP(
01502 IN UINT wCodePageID
01503 )
01504
01505
01521 {
01522
01523
NTSTATUS Status;
01524
01525
Status =
SetConsoleOutputCPInternal(wCodePageID);
01526
01527
if(
NT_SUCCESS(
Status)) {
01528
SetTEBLangID();
01529
return TRUE;
01530 }
01531
else {
01532
SET_LAST_NT_ERROR (
Status);
01533
return FALSE;
01534 }
01535 }
01536
01537
#endif
01538
01539
#if !defined(BUILD_WOW6432)
01540
01541
BOOL
01542
APIENTRY
01543 GetConsoleKeyboardLayoutNameWorker(
01544 OUT LPSTR pszLayout,
01545 IN BOOL bAnsi)
01546
01547
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 }
01590
01591
01592
#endif
01593
01594
01595
#if !defined(BUILD_WOW64)
01596
01597
BOOL
01598 GetConsoleKeyboardLayoutNameA(
01599 LPSTR pszLayout)
01600 {
01601
return GetConsoleKeyboardLayoutNameWorker(pszLayout,
TRUE);
01602 }
01603
01604
BOOL
01605 GetConsoleKeyboardLayoutNameW(
01606 LPWSTR pwszLayout)
01607 {
01608
return GetConsoleKeyboardLayoutNameWorker((LPSTR)pwszLayout,
FALSE);
01609 }
01610
01611
#endif
01612
01613
#if !defined(BUILD_WOW6432)
01614
01615 HANDLE
01616
APIENTRY
01617 GetConsoleWindow(
01618 VOID)
01619 {
01620
01621
CONSOLE_API_MSG m;
01622
PCONSOLE_GETCONSOLEWINDOW_MSG a = &m.
u.GetConsoleWindow;
01623
01624 a->
ConsoleHandle =
GET_CONSOLE_HANDLE;
01625
CsrClientCallServer( (PCSR_API_MSG)&m,
01626
NULL,
01627 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
01628
ConsolepGetConsoleWindow
01629 ),
01630
sizeof( *a )
01631 );
01632
if (
NT_SUCCESS( m.ReturnValue )) {
01633
return a->hwnd;
01634 }
else {
01635
SET_LAST_NT_ERROR (m.ReturnValue);
01636
return NULL;
01637 }
01638
01639 }
01640
01641
#endif