https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1f78e8ec47a34869d37f05...
commit 1f78e8ec47a34869d37f05d03d6fca16707e70fc Author: James Tabor james.tabor@reactos.org AuthorDate: Tue Sep 24 17:40:18 2019 -0500 Commit: James Tabor james.tabor@reactos.org CommitDate: Tue Sep 24 17:40:18 2019 -0500
[Win32SS] Support Module Versioning.
Set the appropriate flags supporting versions of software modules. Fix arguments for getting desktop DC. --- win32ss/user/ntuser/desktop.c | 8 ++++---- win32ss/user/ntuser/menu.c | 2 +- win32ss/user/ntuser/window.c | 25 ++++++++++++++++++++----- win32ss/user/ntuser/window.h | 9 +++++++-- win32ss/user/user32/windows/window.c | 34 ++++++++++++++++++++++++++++++++-- 5 files changed, 64 insertions(+), 14 deletions(-)
diff --git a/win32ss/user/ntuser/desktop.c b/win32ss/user/ntuser/desktop.c index f1aec1b5af7..365a4e5a9a4 100644 --- a/win32ss/user/ntuser/desktop.c +++ b/win32ss/user/ntuser/desktop.c @@ -1533,7 +1533,7 @@ VOID NTAPI DesktopThreadMain(VOID) }
HDC FASTCALL -UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd) +UserGetDesktopDC(ULONG DcType, BOOL bAltDc, BOOL ValidatehWnd) { PWND DesktopObject = 0; HDC DesktopHDC = 0; @@ -1549,7 +1549,7 @@ UserGetDesktopDC(ULONG DcType, BOOL EmptyDC, BOOL ValidatehWnd) else { PMONITOR pMonitor = UserGetPrimaryMonitor(); - DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, EmptyDC); + DesktopHDC = IntGdiCreateDisplayDC(pMonitor->hDev, DcType, bAltDc); }
UserLeave(); @@ -2403,7 +2403,7 @@ IntCreateDesktop( Cs.lpszClass = (LPCWSTR) &ClassName;
/* 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) { ERR("Failed to create desktop window for the new desktop\n"); @@ -2433,7 +2433,7 @@ IntCreateDesktop( Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Cs.lpszName = (LPCWSTR)&WindowName; 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) { ERR("Failed to create message window for the new desktop\n"); diff --git a/win32ss/user/ntuser/menu.c b/win32ss/user/ntuser/menu.c index b7c550bec3a..17e31d6d13d 100644 --- a/win32ss/user/ntuser/menu.c +++ b/win32ss/user/ntuser/menu.c @@ -2807,7 +2807,7 @@ static BOOL MENU_InitPopup( PWND pWndOwner, PMENU menu, UINT flags ) Cs.hwndParent = UserHMGetHandle(pWndOwner);
/* 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;
diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c index a557c4d3387..c34dcea55f0 100644 --- a/win32ss/user/ntuser/window.c +++ b/win32ss/user/ntuser/window.c @@ -1615,7 +1615,8 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, - PDESKTOP pdeskCreated) + PDESKTOP pdeskCreated, + DWORD dwVer ) { PWND pWnd = NULL; HWND hWnd; @@ -1695,7 +1696,19 @@ PWND FASTCALL IntCreateWindow(CREATESTRUCTW* Cs, pWnd->spwndOwner = OwnerWindow; pWnd->fnid = 0; 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->hModule = Cs->hInstance; pWnd->style = Cs->style & ~WS_VISIBLE; @@ -1956,7 +1969,8 @@ PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW* Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, - PVOID acbiBuffer) + PVOID acbiBuffer, + DWORD dwVer ) { ULONG style; PWND Window = NULL, ParentWindow = NULL, OwnerWindow; @@ -2073,7 +2087,8 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, ParentWindow, OwnerWindow, acbiBuffer, - NULL); + NULL, + dwVer ); if(!Window) { ERR("IntCreateWindow failed!\n"); @@ -2598,7 +2613,7 @@ NtUserCreateWindowEx( UserEnterExclusive();
/* Call the internal function */ - pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer); + pwnd = co_UserCreateWindowEx(&Cs, &ustrClsVersion, plstrWindowName, acbiBuffer, dwFlags);
if(!pwnd) { diff --git a/win32ss/user/ntuser/window.h b/win32ss/user/ntuser/window.h index 24b60214223..f2cd877b289 100644 --- a/win32ss/user/ntuser/window.h +++ b/win32ss/user/ntuser/window.h @@ -52,17 +52,22 @@ VOID FASTCALL IntGetWindowBorderMeasures(PWND WindowObject, UINT *cx, UINT *cy); BOOL FASTCALL IntShowOwnedPopups( PWND owner, BOOL fShow ); LRESULT FASTCALL IntDefWindowProc( PWND Window, UINT Msg, WPARAM wParam, LPARAM lParam, BOOL Ansi); 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, PLARGE_STRING WindowName, PCLS Class, PWND ParentWindow, PWND OwnerWindow, PVOID acbiBuffer, - PDESKTOP pdeskCreated); + PDESKTOP pdeskCreated, + DWORD dwVer ); PWND FASTCALL co_UserCreateWindowEx(CREATESTRUCTW* Cs, PUNICODE_STRING ClassName, PLARGE_STRING WindowName, - PVOID acbiBuffer); + PVOID acbiBuffer, + DWORD dwVer ); BOOL FASTCALL IntEnableWindow(HWND,BOOL); BOOL FASTCALL IntIsWindowVisible(PWND); DWORD FASTCALL GetNCHitEx(PWND,POINT); diff --git a/win32ss/user/user32/windows/window.c b/win32ss/user/user32/windows/window.c index ccf0670bc16..e94d9a1b250 100644 --- a/win32ss/user/user32/windows/window.c +++ b/win32ss/user/user32/windows/window.c @@ -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 User32CreateWindowEx(DWORD dwExStyle, LPCSTR lpClassName, @@ -177,11 +203,15 @@ User32CreateWindowEx(DWORD dwExStyle, LPCWSTR lpszClsVersion; LPCWSTR lpLibFileName = NULL; HANDLE pCtx = NULL; + DWORD dwFlagsVer;
#if 0 DbgPrint("[window] User32CreateWindowEx style %d, exstyle %d, parent %d\n", dwStyle, dwExStyle, hWndParent); #endif
+ dwFlagsVer = RtlGetExpWinVer( hInstance ? hInstance : GetModuleHandleW(NULL) ); + TRACE("Module Version %x\n",dwFlagsVer); + if (!RegisterDefaultClasses) { TRACE("RegisterSystemControls\n"); @@ -299,8 +329,8 @@ User32CreateWindowEx(DWORD dwExStyle, hMenu, hInstance, lpParam, - dwFlags, - NULL); + dwFlagsVer, + pCtx ); if (Handle) break; if (!lpLibFileName) break; if (!ClassFound)