00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
#include "precomp.h"
00021 
#pragma hdrstop
00022 
#pragma hdrstop
00023 
00024 
BOOL
00025 
APIENTRY
00026 VDMConsoleOperation(
00027     DWORD  iFunction,
00028     LPVOID lpData
00029     )
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 {
00049     
CONSOLE_API_MSG m;
00050     
PCONSOLE_VDM_MSG a = &m.
u.VDMConsoleOperation;
00051     LPRECT lpRect;
00052     LPPOINT lpPoint;
00053     PBOOL lpBool;
00054     PCSR_CAPTURE_HEADER CaptureBuffer = 
NULL;
00055 
#if defined(FE_SB)
00056 
#if defined(i386)
00057 
    LPVDM_IOCTL_PARAM lpIoctlParam;
00058 
#endif
00059 
#endif // FE_SB
00060 
00061     a->
ConsoleHandle = 
GET_CONSOLE_HANDLE;
00062     a->
iFunction = iFunction;
00063     
if (iFunction == VDM_CLIENT_TO_SCREEN ||
00064         iFunction == VDM_SCREEN_TO_CLIENT) {
00065         lpPoint = (LPPOINT)lpData;
00066         a->
Point = *lpPoint;
00067     } 
else if (iFunction == VDM_FULLSCREEN_NOPAINT) {
00068         a->
Bool = (lpData != 
NULL);
00069     }
00070 
#if defined(FE_SB)
00071 
    else if (iFunction == VDM_SET_VIDEO_MODE) {
00072         a->
Bool = (lpData != 
NULL);
00073     }
00074 
#if defined(i386)
00075 
    else if (iFunction == VDM_SAVE_RESTORE_HW_STATE) {
00076         a->
Bool = (lpData != 
NULL);
00077     }
00078     
else if (iFunction == VDM_VIDEO_IOCTL) {
00079         lpIoctlParam = (LPVDM_IOCTL_PARAM)lpData;
00080         a->VDMIoctlParam = *lpIoctlParam;
00081         
if (lpIoctlParam->lpvInBuffer != 
NULL) {
00082             
if (lpIoctlParam->lpvOutBuffer != 
NULL || lpIoctlParam->cbInBuffer == 0) {
00083                 
SET_LAST_ERROR(ERROR_INVALID_PARAMETER);
00084                 
return FALSE;
00085             }
00086             CaptureBuffer = 
CsrAllocateCaptureBuffer( 1,
00087                                                       lpIoctlParam->cbInBuffer
00088                                                     );
00089             
if (CaptureBuffer == 
NULL) {
00090                 
SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
00091                 
return FALSE;
00092             }
00093             
CsrCaptureMessageBuffer( CaptureBuffer,
00094                                      (PCHAR) lpIoctlParam->lpvInBuffer,
00095                                      lpIoctlParam->cbInBuffer,
00096                                      (PVOID *) &a->VDMIoctlParam.lpvInBuffer
00097                                    );
00098         }
00099         
if (lpIoctlParam->lpvOutBuffer != 
NULL) {
00100             
if (lpIoctlParam->cbOutBuffer == 0) {
00101                 
SET_LAST_ERROR(ERROR_INVALID_PARAMETER);
00102                 
return FALSE;
00103             }
00104             CaptureBuffer = 
CsrAllocateCaptureBuffer( 1,
00105                                                       lpIoctlParam->cbOutBuffer
00106                                                     );
00107             
if (CaptureBuffer == 
NULL) {
00108                 
SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY);
00109                 
return FALSE;
00110             }
00111             
CsrCaptureMessageBuffer( CaptureBuffer,
00112                                      (PCHAR) lpIoctlParam->lpvOutBuffer,
00113                                      lpIoctlParam->cbOutBuffer,
00114                                      (PVOID *) &a->VDMIoctlParam.lpvOutBuffer
00115                                    );
00116         }
00117     }
00118 
#endif // i386
00119 
#endif // FE_SB
00120 
    CsrClientCallServer( (PCSR_API_MSG)&m,
00121                          CaptureBuffer,
00122                          CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX,
00123                          
ConsolepVDMOperation
00124                                             ),
00125                          
sizeof( *a )
00126                        );
00127     
if (
NT_SUCCESS( m.ReturnValue )) {
00128         
switch (iFunction) {
00129             
case VDM_IS_ICONIC:
00130             
case VDM_IS_HIDDEN:
00131                 lpBool = (PBOOL)lpData;
00132                 *lpBool = a->Bool;
00133                 
break;
00134             
case VDM_CLIENT_RECT:
00135                 lpRect = (LPRECT)lpData;
00136                 *lpRect = a->Rect;
00137                 
break;
00138             
case VDM_CLIENT_TO_SCREEN:
00139             
case VDM_SCREEN_TO_CLIENT:
00140                 *lpPoint = a->Point;
00141                 
break;
00142 
#if defined(FE_SB)
00143 
#if defined(i386)
00144 
            case VDM_VIDEO_IOCTL:
00145                 
if (lpIoctlParam->lpvOutBuffer != 
NULL) {
00146                     
try {
00147                         RtlCopyMemory( lpIoctlParam->lpvOutBuffer,
00148                                        a->VDMIoctlParam.lpvOutBuffer,
00149                                        lpIoctlParam->cbOutBuffer );
00150                     } except( 
EXCEPTION_EXECUTE_HANDLER ) {
00151                         
CsrFreeCaptureBuffer( CaptureBuffer );
00152                         
SET_LAST_ERROR(ERROR_INVALID_ACCESS);
00153                         
return FALSE;
00154                     }
00155                 }
00156                 
if (CaptureBuffer != 
NULL) {
00157                     
CsrFreeCaptureBuffer( CaptureBuffer );
00158                 }
00159                 
break;
00160 
#endif // i386
00161 
#endif // FE_SB
00162 
            default:
00163                 
break;
00164         }
00165         
return TRUE;
00166     } 
else {
00167 
#if defined(FE_SB)
00168 
#if defined(i386)
00169 
        if (CaptureBuffer != 
NULL) {
00170             
CsrFreeCaptureBuffer( CaptureBuffer );
00171         }
00172 
#endif // i386
00173 
#endif // FE_SB
00174 
        SET_LAST_NT_ERROR (m.ReturnValue);
00175         
return FALSE;
00176     }
00177 }