Author: gadamopoulos Date: Sat Jan 8 13:26:33 2011 New Revision: 50325
URL: http://svn.reactos.org/svn/reactos?rev=50325&view=rev Log: [winent] - Remove a hack for stock objects from RosGdiSelectBitmap. To handle stock objects properly, map their handles instead [win32k] - Add NtGdiGetStockObject and remove some difference to trunk.
From now on if a function is the same with trunk it will use the NtGdi prefix
Modified: branches/arwinss/reactos/base/system/winlogon/winlogon.c branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c branches/arwinss/reactos/subsystems/win32/win32k/gre/pen.c branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db
Modified: branches/arwinss/reactos/base/system/winlogon/winlogon.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/base/system/winl... ============================================================================== --- branches/arwinss/reactos/base/system/winlogon/winlogon.c [iso-8859-1] (original) +++ branches/arwinss/reactos/base/system/winlogon/winlogon.c [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -197,6 +197,41 @@ CloseHandle(ProcessInformation.hProcess);
return res; +} + +static VOID +WaitForLsass(VOID) +{ + HANDLE hEvent; + DWORD dwError; + + hEvent = CreateEventW(NULL, + TRUE, + FALSE, + L"LSA_RPC_SERVER_ACTIVE"); + if (hEvent == NULL) + { + dwError = GetLastError(); + TRACE("WL: Failed to create the notication event (Error %lu)\n", dwError); + + if (dwError == ERROR_ALREADY_EXISTS) + { + hEvent = OpenEventW(SYNCHRONIZE, + FALSE, + L"LSA_RPC_SERVER_ACTIVE"); + if (hEvent == NULL) + { + ERR("WL: Could not open the notification event (Error %lu)\n", GetLastError()); + return; + } + } + } + + TRACE("WL: Wait for the LSA server!\n"); + WaitForSingleObject(hEvent, INFINITE); + TRACE("WL: LSA server running!\n"); + + CloseHandle(hEvent); }
BOOL @@ -348,6 +383,9 @@
DisplayStatusMessage(WLSession, WLSession->WinlogonDesktop, IDS_REACTOSISSTARTINGUP);
+ /* Wait for the LSA server */ + WaitForLsass(); + #if 0 /* Connect to NetLogon service (lsass.exe) */ /* Real winlogon uses "Winlogon" */
Modified: branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winent... ============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/gdidrv.c [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -14,9 +14,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(rosgdidrv);
/* GLOBALS ****************************************************************/ -HANDLE hStockBitmap; static struct list handle_mapping_list = LIST_INIT( handle_mapping_list ); static CRITICAL_SECTION handle_mapping_cs; +static BOOL StockObjectsInitialized = FALSE;
typedef struct _HMAPPING { @@ -65,6 +65,22 @@ { PHMAPPING mapping;
+ /* Map stock objects if not mapped yet */ + if(!StockObjectsInitialized) + { + HGDIOBJ hKernel, hUser; + + hKernel = NtGdiGetStockObject(DEFAULT_BITMAP); + hUser = GetStockObject( STOCK_LAST+1 ); + + /* Make sure that both kernel mode and user mode objects are initialized */ + if(hKernel && hUser) + { + AddHandleMapping(NtGdiGetStockObject(DEFAULT_BITMAP), GetStockObject( STOCK_LAST+1 )); + StockObjectsInitialized = TRUE; + } + } + mapping = FindHandleMapping(hUser);
return mapping ? mapping->hKernel : NULL; @@ -129,11 +145,7 @@
/* Get DC type */ dcType = GetObjectType(hdc); - - /* Save stock bitmap's handle */ - if (dcType == OBJ_MEMDC && !hStockBitmap) - hStockBitmap = GetCurrentObject( hdc, OBJ_BITMAP ); - + /* Call the win32 kernel */ bRet = RosGdiCreateDC(&hKernelDC, driver, device, output, initData, dcType);
@@ -273,16 +285,13 @@
HBITMAP CDECL RosDrv_SelectBitmap( NTDRV_PDEVICE *physDev, HBITMAP hbitmap ) { - BOOL bRes, bStock = FALSE; + BOOL bRes;
/* Check if it's a stock bitmap */ - if (hbitmap == hStockBitmap) - bStock = TRUE; - else - hbitmap = (HBITMAP)MapUserHandle(hbitmap); + hbitmap = (HBITMAP)MapUserHandle(hbitmap);
/* Select the bitmap into the DC */ - bRes = RosGdiSelectBitmap(physDev->hKernelDC, hbitmap, bStock); + bRes = RosGdiSelectBitmap(physDev->hKernelDC, hbitmap);
/* If there was an error, return 0 */ if (!bRes) return 0;
Modified: branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos/... ============================================================================== --- branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h [iso-8859-1] (original) +++ branches/arwinss/reactos/include/reactos/wine/ntrosgdi.h [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -87,12 +87,13 @@ INT widthSrc, INT heightSrc, DWORD rop );
/* dc.c */ +HGDIOBJ APIENTRY NtGdiGetStockObject(INT Object); BOOL APIENTRY RosGdiCreateDC( HDC *pdev, LPCWSTR driver, LPCWSTR device, LPCWSTR output, const DEVMODEW* initData, ULONG dcType ); BOOL APIENTRY RosGdiDeleteDC( HDC physDev ); BOOL APIENTRY RosGdiGetDCOrgEx( HDC physDev, LPPOINT lpp ); BOOL APIENTRY RosGdiPaintRgn( HDC physDev, HRGN hrgn ); -BOOL APIENTRY RosGdiSelectBitmap( HDC physDev, HBITMAP hbitmap, BOOL stock ); +BOOL APIENTRY RosGdiSelectBitmap( HDC physDev, HBITMAP hbitmap ); VOID APIENTRY RosGdiSelectBrush( HDC physDev, LOGBRUSH *pLogBrush ); HFONT APIENTRY RosGdiSelectFont( HDC physDev, HFONT hfont, HANDLE gdiFont ); VOID APIENTRY RosGdiSelectPen( HDC physDev, LOGPEN *pLogPen, EXTLOGPEN *pExtLogPen );
Modified: branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/eng/engpal.c [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -465,11 +465,7 @@ dc = DC_LockDc(hDC); if (!dc) return 0;
-#if 0 systemPalette = NtGdiGetStockObject(DEFAULT_PALETTE); -#else - systemPalette = hStockPalette; -#endif palGDI = PALETTE_LockPalette(dc->dclevel.hpal);
if (palGDI == NULL)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gdi/dc.c [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -21,9 +21,16 @@ BOOL FASTCALL IntCreatePrimarySurface();
/* GLOBALS *******************************************************************/ -HGDIOBJ hStockBmp; -HGDIOBJ hStockPalette; -HGDIOBJ hNullPen; +HGDIOBJ StockObjects[NB_STOCK_OBJECTS]; + +static LOGPEN WhitePen = + { PS_SOLID, { 0, 0 }, RGB(255,255,255) }; + +static LOGPEN BlackPen = + { PS_SOLID, { 0, 0 }, RGB(0,0,0) }; + +static LOGPEN NullPen = + { PS_NULL, { 0, 0 }, 0 };
/* PUBLIC FUNCTIONS **********************************************************/
@@ -87,13 +94,13 @@ EBRUSHOBJ_vInit(&pNewDC->eboFill, pNewDC->dclevel.pbrFill, pNewDC);
/* Set the default palette */ - pNewDC->dclevel.hpal = hStockPalette; + pNewDC->dclevel.hpal = StockObjects[DEFAULT_PALETTE]; pNewDC->dclevel.ppal = PALETTE_ShareLockPalette(pNewDC->dclevel.hpal);
if (dcType == OBJ_MEMDC) { DPRINT("Creating a memory DC %x\n", hNewDC); - pNewDC->dclevel.pSurface = SURFACE_ShareLockSurface(hStockBmp); + pNewDC->dclevel.pSurface = SURFACE_ShareLockSurface(StockObjects[DEFAULT_BITMAP]);
/* Set DC rectangles */ pNewDC->rcVport.left = 0; pNewDC->rcVport.top = 0; @@ -117,7 +124,7 @@ pNewDC->pWindow = NULL;
/* Set default palette */ - pNewDC->dclevel.hpal = hStockPalette; + pNewDC->dclevel.hpal = StockObjects[DEFAULT_PALETTE];
/* Give handle to the caller */ *pdev = hNewDC; @@ -152,19 +159,13 @@ return FALSE; }
-BOOL APIENTRY RosGdiSelectBitmap( HDC physDev, HBITMAP hbitmap, BOOL bStock ) +BOOL APIENTRY RosGdiSelectBitmap( HDC physDev, HBITMAP hbitmap ) { PDC pDC; PSURFACE pSurface;
DPRINT("Selecting %x bitmap to hdc %x\n", hbitmap, physDev); - - if (bStock) - { - /* Selecting stock bitmap */ - hbitmap = hStockBmp; - } - + pSurface = SURFACE_ShareLockSurface(hbitmap); if(pSurface== NULL) { @@ -684,12 +685,39 @@
VOID CreateStockObjects() { - hStockBmp = IntGdiCreateBitmap(1, 1, 1, 1, NULL); - hStockPalette = (HGDIOBJ)PALETTE_Init(); - hNullPen = IntCreateStockPen(PS_NULL, 0, BS_SOLID, 0); - - GDIOBJ_ConvertToStockObj(&hStockBmp); - GDIOBJ_ConvertToStockObj(&hStockPalette); - GDIOBJ_ConvertToStockObj(&hNullPen); -} + UINT Object; + + memset(StockObjects, 0, sizeof(StockObjects)); + + /* Create GDI Stock Objects from the logical structures we've defined */ + + StockObjects[DEFAULT_BITMAP] = IntGdiCreateBitmap(1, 1, 1, 1, NULL); + StockObjects[DEFAULT_PALETTE] = (HGDIOBJ)PALETTE_Init(); + StockObjects[WHITE_PEN] = IntCreateStockPen(WhitePen.lopnStyle, WhitePen.lopnWidth.x, BS_SOLID, WhitePen.lopnColor); + StockObjects[BLACK_PEN] = IntCreateStockPen(BlackPen.lopnStyle, BlackPen.lopnWidth.x, BS_SOLID, BlackPen.lopnColor); + StockObjects[DC_PEN] = IntCreateStockPen(BlackPen.lopnStyle, BlackPen.lopnWidth.x, BS_SOLID, BlackPen.lopnColor); + StockObjects[NULL_PEN] = IntCreateStockPen(NullPen.lopnStyle, NullPen.lopnWidth.x, BS_SOLID, NullPen.lopnColor); + + for (Object = 0; Object < NB_STOCK_OBJECTS; Object++) + { + if (NULL != StockObjects[Object]) + { + GDIOBJ_ConvertToStockObj(&StockObjects[Object]); + } + } +} + +/*! + * Return stock object. + * \param Object - stock object id. + * \return Handle to the object. +*/ +HGDIOBJ APIENTRY +NtGdiGetStockObject(INT Object) +{ + DPRINT("NtGdiGetStockObject index %d\n", Object); + + return ((Object < 0) || (NB_STOCK_OBJECTS <= Object)) ? NULL : StockObjects[Object]; +} + /* EOF */
Modified: branches/arwinss/reactos/subsystems/win32/win32k/gre/pen.c URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/gre/pen.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/gre/pen.c [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -73,11 +73,7 @@
if ( (dwPenStyle & PS_STYLE_MASK) == PS_NULL) { -#if 0 return StockObjects[NULL_PEN]; -#else - return hNullPen; -#endif }
if (bOldStylePen)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/gre.h [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -120,12 +120,6 @@ INT FASTCALL BitsPerFormat(ULONG Format);
-/* bitmap.c */ -extern HGDIOBJ hStockBmp; -extern HGDIOBJ hStockPalette; -extern HGDIOBJ hNullPen; -VOID CreateStockObjects(); - /* device.c */ LONG FASTCALL GreChangeDisplaySettings(PUNICODE_STRING pDeviceName, LPDEVMODEW DevMode, DWORD dwflags,
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/win32kp.h [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -91,3 +91,5 @@ VOID UserCleanup(VOID); VOID UserInitialize(VOID);
+extern HGDIOBJ StockObjects[]; +VOID CreateStockObjects();
Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win32... ============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sat Jan 8 13:26:33 2011 @@ -1,4 +1,5 @@ wine_server_call 1 +NtGdiGetStockObject 1 RosGdiAlphaBlend 11 RosGdiBitBlt 9 RosGdiCreateBitmap 3 @@ -17,7 +18,7 @@ RosGdiDeleteDC 1 RosGdiGetDCOrgEx 2 RosGdiPaintRgn 2 -RosGdiSelectBitmap 3 +RosGdiSelectBitmap 2 RosGdiSelectBrush 2 RosGdiSelectFont 3 RosGdiSelectPen 3