[Win32SS] Support Module Versioning.

Set the appropriate flags supporting versions of software modules.
Fix arguments for getting desktop DC.
This commit is contained in:
James Tabor 2019-09-24 17:40:18 -05:00
parent 6bf7a8edfb
commit 1f78e8ec47
5 changed files with 64 additions and 14 deletions

View file

@ -1533,7 +1533,7 @@ VOID NTAPI DesktopThreadMain(VOID)
} }
HDC FASTCALL HDC FASTCALL
UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd) UserGetDesktopDC(ULONG DcType, BOOL bAltDc, BOOL ValidatehWnd)
{ {
PWND DesktopObject = 0; PWND DesktopObject = 0;
HDC DesktopHDC = 0; HDC DesktopHDC = 0;
@ -1549,7 +1549,7 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd)
else else
{ {
PMONITOR pMonitor = UserGetPrimaryMonitor(); PMONITOR pMonitor = UserGetPrimaryMonitor();
DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC); DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, bAltDc);
} }
UserLeave(); UserLeave();
@ -2403,7 +2403,7 @@ IntCreateDesktop(
Cs.lpszClass = (LPCWSTR) &ClassName; Cs.lpszClass = (LPCWSTR) &ClassName;
/* Use IntCreateWindow instead of co_UserCreateWindowEx because the later expects a thread with a desktop */ /* Use IntCreateWindow instead of co_UserCreateWindowEx because the later expects a thread with a desktop */
pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk, WINVER);
if (pWnd == NULL) if (pWnd == NULL)
{ {
ERR("Failed to create desktop window for the new desktop\n"); ERR("Failed to create desktop window for the new desktop\n");
@ -2433,7 +2433,7 @@ IntCreateDesktop(
Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Cs.hInstance = hModClient; // hModuleWin; // Server side winproc!
Cs.lpszName = (LPCWSTR)&WindowName; Cs.lpszName = (LPCWSTR)&WindowName;
Cs.lpszClass = (LPCWSTR)&ClassName; Cs.lpszClass = (LPCWSTR)&ClassName;
pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk); pWnd = IntCreateWindow(&Cs, &WindowName, pcls, NULL, NULL, NULL, pdesk, WINVER);
if (pWnd == NULL) if (pWnd == NULL)
{ {
ERR("Failed to create message window for the new desktop\n"); ERR("Failed to create message window for the new desktop\n");

View file

@ -2807,7 +2807,7 @@ static BOOL MENU_InitPopup( PWND pWndOwner, PMENU menu, UINT flags )
Cs.hwndParent = UserHMGetHandle(pWndOwner); Cs.hwndParent = UserHMGetHandle(pWndOwner);
/* NOTE: In Windows, top menu popup is not owned. */ /* NOTE: In Windows, top menu popup is not owned. */
pWndCreated = co_UserCreateWindowEx( &Cs, &ClassName, &WindowName, NULL); pWndCreated = co_UserCreateWindowEx( &Cs, &ClassName, &WindowName, NULL, WINVER );
if( !pWndCreated ) return FALSE; if( !pWndCreated ) return FALSE;

View file

@ -1615,7 +1615,8 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
PWND ParentWindow, PWND ParentWindow,
PWND OwnerWindow, PWND OwnerWindow,
PVOID acbiBuffer, PVOID acbiBuffer,
PDESKTOP pdeskCreated) PDESKTOP pdeskCreated,
DWORD dwVer )
{ {
PWND pWnd = NULL; PWND pWnd = NULL;
HWND hWnd; HWND hWnd;
@ -1695,7 +1696,19 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
pWnd->spwndOwner = OwnerWindow; pWnd->spwndOwner = OwnerWindow;
pWnd->fnid = 0; pWnd->fnid = 0;
pWnd->spwndLastActive = pWnd; pWnd->spwndLastActive = pWnd;
pWnd->state2 |= WNDS2_WIN40COMPAT; // FIXME!!! // Ramp up compatible version sets.
if ( dwVer >= WINVER_WIN31 )
{
pWnd->state2 |= WNDS2_WIN31COMPAT;
if ( dwVer >= WINVER_WINNT4 )
{
pWnd->state2 |= WNDS2_WIN40COMPAT;
if ( dwVer >= WINVER_WIN2K )
{
pWnd->state2 |= WNDS2_WIN50COMPAT;
}
}
}
pWnd->pcls = Class; pWnd->pcls = Class;
pWnd->hModule = Cs->hInstance; pWnd->hModule = Cs->hInstance;
pWnd->style = Cs->style & ~WS_VISIBLE; pWnd->style = Cs->style & ~WS_VISIBLE;
@ -1956,7 +1969,8 @@ PWND FASTCALL
co_UserCreateWindowEx(CREATESTRUCTW* Cs, co_UserCreateWindowEx(CREATESTRUCTW* Cs,
PUNICODE_STRING ClassName, PUNICODE_STRING ClassName,
PLARGE_STRING WindowName, PLARGE_STRING WindowName,
PVOID acbiBuffer) PVOID acbiBuffer,
DWORD dwVer )
{ {
ULONG style; ULONG style;
PWND Window = NULL, ParentWindow = NULL, OwnerWindow; PWND Window = NULL, ParentWindow = NULL, OwnerWindow;
@ -2073,7 +2087,8 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
ParentWindow, ParentWindow,
OwnerWindow, OwnerWindow,
acbiBuffer, acbiBuffer,
NULL); NULL,
dwVer );
if(!Window) if(!Window)
{ {
ERR("IntCreateWindow failed!\n"); ERR("IntCreateWindow failed!\n");
@ -2598,7 +2613,7 @@ NtUserCreateWindowEx(
UserEnterExclusive(); UserEnterExclusive();
/* Call the internal function */ /* Call the internal function */
pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer); pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer, dwFlags);
if(!pwnd) if(!pwnd)
{ {

View file

@ -52,17 +52,22 @@ VOID FASTCALL IntGetWindowBorderMeasures(PWND WindowObject, UINT *cx, UINT *cy);
BOOL FASTCALL IntShowOwnedPopups( PWND owner, BOOL fShow ); BOOL FASTCALL IntShowOwnedPopups( PWND owner, BOOL fShow );
LRESULT FASTCALL IntDefWindowProc( PWND Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi); LRESULT FASTCALL IntDefWindowProc( PWND Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi);
VOID FASTCALL IntNotifyWinEvent(DWORD, PWND, LONG, LONG, DWORD); VOID FASTCALL IntNotifyWinEvent(DWORD, PWND, LONG, LONG, DWORD);
#define WINVER_WIN2K _WIN32_WINNT_WIN2K
#define WINVER_WINNT4 _WIN32_WINNT_NT4
#define WINVER_WIN31 0x30A
PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs,
PLARGE_STRING WindowName, PLARGE_STRING WindowName,
PCLS Class, PCLS Class,
PWND ParentWindow, PWND ParentWindow,
PWND OwnerWindow, PWND OwnerWindow,
PVOID acbiBuffer, PVOID acbiBuffer,
PDESKTOP pdeskCreated); PDESKTOP pdeskCreated,
DWORD dwVer );
PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW* Cs, PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW* Cs,
PUNICODE_STRING ClassName, PUNICODE_STRING ClassName,
PLARGE_STRING WindowName, PLARGE_STRING WindowName,
PVOID acbiBuffer); PVOID acbiBuffer,
DWORD dwVer );
BOOL FASTCALL IntEnableWindow(HWND,BOOL); BOOL FASTCALL IntEnableWindow(HWND,BOOL);
BOOL FASTCALL IntIsWindowVisible(PWND); BOOL FASTCALL IntIsWindowVisible(PWND);
DWORD FASTCALL GetNCHitEx(PWND,POINT); DWORD FASTCALL GetNCHitEx(PWND,POINT);

View file

@ -148,6 +148,32 @@ RtlFreeLargeString(
} }
} }
DWORD
FASTCALL
RtlGetExpWinVer( HMODULE hModule )
{
DWORD dwMajorVersion = 3; // Set default to Windows 3.10.
DWORD dwMinorVersion = 10;
PIMAGE_NT_HEADERS pinth;
if ( hModule && !((ULONG_PTR)hModule >> 16))
{
pinth = RtlImageNtHeader( hModule );
dwMajorVersion = pinth->OptionalHeader.MajorSubsystemVersion;
if ( dwMajorVersion == 1 )
{
dwMajorVersion = 3;
}
else
{
dwMinorVersion = pinth->OptionalHeader.MinorSubsystemVersion;
}
}
return MAKELONG(MAKEWORD(dwMinorVersion, dwMajorVersion), 0);
}
HWND WINAPI HWND WINAPI
User32CreateWindowEx(DWORD dwExStyle, User32CreateWindowEx(DWORD dwExStyle,
LPCSTR lpClassName, LPCSTR lpClassName,
@ -177,11 +203,15 @@ User32CreateWindowEx(DWORD dwExStyle,
LPCWSTR lpszClsVersion; LPCWSTR lpszClsVersion;
LPCWSTR lpLibFileName = NULL; LPCWSTR lpLibFileName = NULL;
HANDLE pCtx = NULL; HANDLE pCtx = NULL;
DWORD dwFlagsVer;
#if 0 #if 0
DbgPrint("[window] User32CreateWindowEx style %d, exstyle %d, parent %d\n", dwStyle, dwExStyle, hWndParent); DbgPrint("[window] User32CreateWindowEx style %d, exstyle %d, parent %d\n", dwStyle, dwExStyle, hWndParent);
#endif #endif
dwFlagsVer = RtlGetExpWinVer( hInstance ? hInstance : GetModuleHandleW(NULL) );
TRACE("Module Version %x\n",dwFlagsVer);
if (!RegisterDefaultClasses) if (!RegisterDefaultClasses)
{ {
TRACE("RegisterSystemControls\n"); TRACE("RegisterSystemControls\n");
@ -299,8 +329,8 @@ User32CreateWindowEx(DWORD dwExStyle,
hMenu, hMenu,
hInstance, hInstance,
lpParam, lpParam,
dwFlags, dwFlagsVer,
NULL); pCtx );
if (Handle) break; if (Handle) break;
if (!lpLibFileName) break; if (!lpLibFileName) break;
if (!ClassFound) if (!ClassFound)