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

bitmap.c File Reference

#include "precomp.h"

Go to the source code of this file.

Functions

NTSTATUS CreateConsoleBitmap (IN OUT PCONSOLE_GRAPHICS_BUFFER_INFO GraphicsInfo, IN OUT PSCREEN_INFORMATION ScreenInfo, OUT PVOID *lpBitmap, OUT HANDLE *hMutex)
ULONG SrvInvalidateBitMapRect (IN OUT PCSR_API_MSG m, IN OUT PCSR_REPLY_STATUS ReplyStatus)
NTSTATUS WriteRegionToScreenBitMap (IN PSCREEN_INFORMATION ScreenInfo, IN PSMALL_RECT Region)
VOID FreeConsoleBitmap (IN PSCREEN_INFORMATION ScreenInfo)


Function Documentation

NTSTATUS CreateConsoleBitmap IN OUT PCONSOLE_GRAPHICS_BUFFER_INFO  GraphicsInfo,
IN OUT PSCREEN_INFORMATION  ScreenInfo,
OUT PVOID *  lpBitmap,
OUT HANDLE *  hMutex
 

Definition at line 27 of file w32/ntcon/server/bitmap.c.

References ASSERT, BMP_TAG, CONSOLE_CLIENTPROCESSHANDLE, ConsoleHeapAlloc, ConsoleHeapFree, DbgPrint, FALSE, L, MAKE_TAG, MapHandle(), NT_SUCCESS, NtClose(), NtCreateMutant(), NtCreateSection(), NtMapViewOfSection(), NTSTATUS(), NtUnmapViewOfSection(), NULL, SHORT, and Status.

Referenced by CreateScreenBuffer().

00033 { 00034 NTSTATUS Status; 00035 LARGE_INTEGER MaximumSize; 00036 SIZE_T ViewSize; 00037 00038 // 00039 // adjust bitmap info 00040 // 00041 00042 00043 if (GraphicsInfo->lpBitMapInfo->bmiHeader.biHeight > 0) 00044 { 00045 #if DBG 00046 DbgPrint("*************** Negating biHeight\n"); 00047 #endif 00048 GraphicsInfo->lpBitMapInfo->bmiHeader.biHeight = 00049 -GraphicsInfo->lpBitMapInfo->bmiHeader.biHeight; 00050 } 00051 00052 if (GraphicsInfo->lpBitMapInfo->bmiHeader.biCompression != BI_RGB) 00053 { 00054 #if DBG 00055 DbgPrint("*************** setting Compression to BI_RGB)\n"); 00056 #endif 00057 GraphicsInfo->lpBitMapInfo->bmiHeader.biCompression = BI_RGB; 00058 } 00059 00060 // 00061 // allocate screeninfo buffer data and copy it 00062 // 00063 00064 ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo = (LPBITMAPINFO)ConsoleHeapAlloc(MAKE_TAG( BMP_TAG ),GraphicsInfo->dwBitMapInfoLength); 00065 if (ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo == NULL) { 00066 return STATUS_NO_MEMORY; 00067 } 00068 ScreenInfo->BufferInfo.GraphicsInfo.BitMapInfoLength = GraphicsInfo->dwBitMapInfoLength; 00069 RtlCopyMemory(ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo, 00070 GraphicsInfo->lpBitMapInfo, 00071 GraphicsInfo->dwBitMapInfoLength 00072 ); 00073 ASSERT((GraphicsInfo->lpBitMapInfo->bmiHeader.biWidth * 00074 -GraphicsInfo->lpBitMapInfo->bmiHeader.biHeight / 8 * 00075 GraphicsInfo->lpBitMapInfo->bmiHeader.biBitCount) == 00076 (LONG)GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage); 00077 00078 // 00079 // create bitmap section 00080 // 00081 00082 MaximumSize.QuadPart = GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage; 00083 Status = NtCreateSection(&ScreenInfo->BufferInfo.GraphicsInfo.hSection, 00084 SECTION_ALL_ACCESS, 00085 NULL, 00086 &MaximumSize, 00087 PAGE_READWRITE, 00088 SEC_COMMIT, 00089 NULL 00090 ); 00091 if (!NT_SUCCESS(Status)) { 00092 ConsoleHeapFree(ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo); 00093 return Status; 00094 } 00095 00096 // 00097 // map server view of section 00098 // 00099 00100 ViewSize = GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage; 00101 ScreenInfo->BufferInfo.GraphicsInfo.BitMap = 0; 00102 Status = NtMapViewOfSection(ScreenInfo->BufferInfo.GraphicsInfo.hSection, 00103 NtCurrentProcess(), 00104 &ScreenInfo->BufferInfo.GraphicsInfo.BitMap, 00105 0L, 00106 GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage, 00107 NULL, 00108 &ViewSize, 00109 ViewUnmap, 00110 0L, 00111 PAGE_READWRITE 00112 ); 00113 if (!NT_SUCCESS(Status)) { 00114 ConsoleHeapFree(ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo); 00115 NtClose(ScreenInfo->BufferInfo.GraphicsInfo.hSection); 00116 return Status; 00117 } 00118 00119 // 00120 // map client view of section 00121 // 00122 00123 ViewSize = GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage; 00124 *lpBitmap = 0; 00125 Status = NtMapViewOfSection(ScreenInfo->BufferInfo.GraphicsInfo.hSection, 00126 CONSOLE_CLIENTPROCESSHANDLE(), 00127 lpBitmap, 00128 0L, 00129 GraphicsInfo->lpBitMapInfo->bmiHeader.biSizeImage, 00130 NULL, 00131 &ViewSize, 00132 ViewUnmap, 00133 0L, 00134 PAGE_READWRITE 00135 ); 00136 if (!NT_SUCCESS(Status)) { 00137 ConsoleHeapFree(ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo); 00138 NtUnmapViewOfSection(NtCurrentProcess(),ScreenInfo->BufferInfo.GraphicsInfo.BitMap); 00139 NtClose(ScreenInfo->BufferInfo.GraphicsInfo.hSection); 00140 return Status; 00141 } 00142 ScreenInfo->BufferInfo.GraphicsInfo.ClientProcess = CONSOLE_CLIENTPROCESSHANDLE(); 00143 ScreenInfo->BufferInfo.GraphicsInfo.ClientBitMap = *lpBitmap; 00144 00145 // 00146 // create mutex to serialize access to bitmap, then map handle to mutex to client side 00147 // 00148 00149 NtCreateMutant(&ScreenInfo->BufferInfo.GraphicsInfo.hMutex, 00150 MUTANT_ALL_ACCESS, NULL, FALSE); 00151 MapHandle(CONSOLE_CLIENTPROCESSHANDLE(), 00152 ScreenInfo->BufferInfo.GraphicsInfo.hMutex, 00153 hMutex 00154 ); 00155 00156 ScreenInfo->BufferInfo.GraphicsInfo.dwUsage = GraphicsInfo->dwUsage; 00157 ScreenInfo->ScreenBufferSize.X = (WORD)GraphicsInfo->lpBitMapInfo->bmiHeader.biWidth; 00158 ScreenInfo->ScreenBufferSize.Y = (WORD)-GraphicsInfo->lpBitMapInfo->bmiHeader.biHeight; 00159 ScreenInfo->Window.Left = 0; 00160 ScreenInfo->Window.Top = 0; 00161 ScreenInfo->Window.Right = (SHORT)(ScreenInfo->Window.Left+ScreenInfo->ScreenBufferSize.X-1); 00162 ScreenInfo->Window.Bottom = (SHORT)(ScreenInfo->Window.Top+ScreenInfo->ScreenBufferSize.Y-1); 00163 return STATUS_SUCCESS; 00164 }

VOID FreeConsoleBitmap IN PSCREEN_INFORMATION  ScreenInfo  ) 
 

Definition at line 353 of file w32/ntcon/server/bitmap.c.

References ConsoleHeapFree, NtClose(), and NtUnmapViewOfSection().

Referenced by FreeScreenBuffer().

00356 { 00357 NtUnmapViewOfSection(NtCurrentProcess(), 00358 ScreenInfo->BufferInfo.GraphicsInfo.BitMap); 00359 NtUnmapViewOfSection(ScreenInfo->BufferInfo.GraphicsInfo.ClientProcess, 00360 ScreenInfo->BufferInfo.GraphicsInfo.ClientBitMap); 00361 NtClose(ScreenInfo->BufferInfo.GraphicsInfo.hSection); 00362 NtClose(ScreenInfo->BufferInfo.GraphicsInfo.hMutex); 00363 ConsoleHeapFree(ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo); 00364 }

ULONG SrvInvalidateBitMapRect IN OUT PCSR_API_MSG  m,
IN OUT PCSR_REPLY_STATUS  ReplyStatus
 

Definition at line 168 of file w32/ntcon/server/bitmap.c.

References ApiPreamble(), ASSERT, _HANDLE_DATA::Buffer, CONSOLE_GRAPHICS_OUTPUT_HANDLE, CONSOLE_IS_DBCS_ENABLED, CONSOLE_OEMFONT_DISPLAY, CONSOLE_OUTPUT_HANDLE, CONSOLE_PERPROCESSDATA, _CONSOLE_INVALIDATERECT_MSG::ConsoleHandle, _CONSOLE_INFORMATION::CP, _CONSOLE_INFORMATION::CurrentScreenBuffer, DereferenceIoHandle(), _SCREEN_INFORMATION::Flags, _CONSOLE_INFORMATION::FullScreenFlags, _HANDLE_DATA::HandleType, NT_SUCCESS, NTSTATUS(), NULL, _CONSOLE_INFORMATION::OutputCP, _CONSOLE_INVALIDATERECT_MSG::OutputHandle, PBYTE, PCONSOLE_INVALIDATERECT_MSG, _CONSOLE_INVALIDATERECT_MSG::Rect, Status, UINT, UnlockConsole(), USACP, _CONSOLE_INFORMATION::VDMBuffer, _CONSOLE_INFORMATION::VDMBufferSize, WINDOWSCP, WriteRectToScreenBuffer, and WriteToScreen.

00175 : 00176 00177 This routine is called to indicate that the application has modified a region 00178 in the bitmap. We update the region to the screen. 00179 00180 Arguments: 00181 00182 m - message containing api parameters 00183 00184 ReplyStatus - Indicates whether to reply to the dll port. 00185 00186 Return Value: 00187 00188 --*/ 00189 00190 { 00191 PCONSOLE_INVALIDATERECT_MSG a = (PCONSOLE_INVALIDATERECT_MSG)&m->u.ApiMessageData; 00192 PCONSOLE_INFORMATION Console; 00193 PHANDLE_DATA HandleData; 00194 NTSTATUS Status; 00195 UINT Codepage; 00196 00197 Status = ApiPreamble(a->ConsoleHandle, 00198 &Console 00199 ); 00200 if (!NT_SUCCESS(Status)) { 00201 return Status; 00202 } 00203 00204 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00205 a->OutputHandle, 00206 CONSOLE_OUTPUT_HANDLE | CONSOLE_GRAPHICS_OUTPUT_HANDLE, 00207 GENERIC_WRITE, 00208 &HandleData 00209 ); 00210 if (!NT_SUCCESS(Status)) { 00211 UnlockConsole(Console); 00212 return((ULONG) Status); 00213 } 00214 if (HandleData->HandleType & CONSOLE_OUTPUT_HANDLE) { 00215 //ASSERT(Console->Flags & CONSOLE_VDM_REGISTERED); 00216 //ASSERT(!(Console->FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE)); 00217 ASSERT(Console->VDMBuffer != NULL); 00218 if (Console->VDMBuffer != NULL) { 00219 //ASSERT(HandleData->Buffer.ScreenBuffer->ScreenBufferSize.X <= Console->VDMBufferSize.X); 00220 //ASSERT(HandleData->Buffer.ScreenBuffer->ScreenBufferSize.Y <= Console->VDMBufferSize.Y); 00221 if (HandleData->Buffer.ScreenBuffer->ScreenBufferSize.X <= Console->VDMBufferSize.X && 00222 HandleData->Buffer.ScreenBuffer->ScreenBufferSize.Y <= Console->VDMBufferSize.Y) { 00223 COORD TargetPoint; 00224 00225 TargetPoint.X = a->Rect.Left; 00226 TargetPoint.Y = a->Rect.Top; 00227 // VDM can sometimes get out of sync with window size 00228 //ASSERT(a->Rect.Left >= 0); 00229 //ASSERT(a->Rect.Top >= 0); 00230 //ASSERT(a->Rect.Right < HandleData->Buffer.ScreenBuffer->ScreenBufferSize.X); 00231 //ASSERT(a->Rect.Bottom < HandleData->Buffer.ScreenBuffer->ScreenBufferSize.Y); 00232 //ASSERT(a->Rect.Left <= a->Rect.Right); 00233 //ASSERT(a->Rect.Top <= a->Rect.Bottom); 00234 if ((a->Rect.Left >= 0) && 00235 (a->Rect.Top >= 0) && 00236 (a->Rect.Right < HandleData->Buffer.ScreenBuffer->ScreenBufferSize.X) && 00237 (a->Rect.Bottom < HandleData->Buffer.ScreenBuffer->ScreenBufferSize.Y) && 00238 (a->Rect.Left <= a->Rect.Right) && 00239 (a->Rect.Top <= a->Rect.Bottom) ) { 00240 00241 if ((Console->CurrentScreenBuffer->Flags & CONSOLE_OEMFONT_DISPLAY) && ((Console->FullScreenFlags & CONSOLE_FULLSCREEN) == 0)) { 00242 #if defined(FE_SB) 00243 if (CONSOLE_IS_DBCS_ENABLED() && 00244 Console->OutputCP != WINDOWSCP ) 00245 { 00246 Codepage = USACP; 00247 } 00248 else 00249 00250 #endif 00251 // we want UnicodeOem characters 00252 Codepage = WINDOWSCP; 00253 } else { 00254 #if defined(FE_SB) 00255 if (CONSOLE_IS_DBCS_ENABLED()) { 00256 Codepage = Console->OutputCP; 00257 } 00258 else 00259 #endif 00260 // we want real Unicode characters 00261 Codepage = Console->CP; 00262 } 00263 00264 WriteRectToScreenBuffer((PBYTE)Console->VDMBuffer, 00265 Console->VDMBufferSize, &a->Rect, 00266 HandleData->Buffer.ScreenBuffer, TargetPoint, 00267 Codepage); 00268 WriteToScreen(HandleData->Buffer.ScreenBuffer,&a->Rect); 00269 } else { 00270 Status = STATUS_INVALID_PARAMETER; 00271 } 00272 } else { 00273 Status = STATUS_INVALID_PARAMETER; 00274 } 00275 } else { 00276 Status = STATUS_INVALID_PARAMETER; 00277 } 00278 } else { 00279 00280 // 00281 // write data to screen 00282 // 00283 00284 WriteToScreen(HandleData->Buffer.ScreenBuffer,&a->Rect); 00285 } 00286 00287 UnlockConsole(Console); 00288 return Status; 00289 UNREFERENCED_PARAMETER(ReplyStatus); 00290 }

NTSTATUS WriteRegionToScreenBitMap IN PSCREEN_INFORMATION  ScreenInfo,
IN PSMALL_RECT  Region
 

Definition at line 293 of file w32/ntcon/server/bitmap.c.

References DWORD, FALSE, InvertSelection(), NtReleaseMutant(), NtWaitForSingleObject(), NULL, and TRUE.

Referenced by ConsoleWindowProc(), and WWSB_WriteToScreen().

00297 { 00298 DWORD NumScanLines; 00299 int Height; 00300 // 00301 // if we have a selection, turn it off. 00302 // 00303 00304 InvertSelection(ScreenInfo->Console,TRUE); 00305 00306 NtWaitForSingleObject(ScreenInfo->BufferInfo.GraphicsInfo.hMutex, 00307 FALSE, NULL); 00308 00309 // The origin of (xSrc, ySrc) passed to SetDIBitsToDevice is located 00310 // at the DIB's bottom-left corner no matter if the DIB is 00311 // a top-down or bottom-up. Thus, if the DIB is a top-down, we have 00312 // to translate ySrc accordingly: 00313 // if (height < 0) { // top-down 00314 // ySrc = abs(height) - rect.Bottom -1; 00315 // 00316 // else 00317 // ySrc = rect.Bottom; 00318 // 00319 Height = ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo->bmiHeader.biHeight; 00320 00321 NumScanLines = SetDIBitsToDevice(ScreenInfo->Console->hDC, 00322 Region->Left - ScreenInfo->Window.Left, 00323 Region->Top - ScreenInfo->Window.Top, 00324 Region->Right - Region->Left + 1, 00325 Region->Bottom - Region->Top + 1, 00326 Region->Left, 00327 Height < 0 ? -Height - Region->Bottom - 1 : Region->Bottom, 00328 0, 00329 ScreenInfo->ScreenBufferSize.Y, 00330 ScreenInfo->BufferInfo.GraphicsInfo.BitMap, 00331 ScreenInfo->BufferInfo.GraphicsInfo.lpBitMapInfo, 00332 ScreenInfo->BufferInfo.GraphicsInfo.dwUsage 00333 ); 00334 00335 NtReleaseMutant(ScreenInfo->BufferInfo.GraphicsInfo.hMutex, NULL); 00336 00337 // 00338 // if we have a selection, turn it on. 00339 // 00340 00341 InvertSelection(ScreenInfo->Console,FALSE); 00342 00343 if (NumScanLines == 0) { 00344 return STATUS_UNSUCCESSFUL; 00345 } 00346 return STATUS_SUCCESS; 00347 }


Generated on Sat May 15 19:42:57 2004 for test by doxygen 1.3.7