Skip to content

[Win32] Add explicit supported OS version check and set to build 14393 #2054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ org.eclipse.swt.internal.gtk3.GTK3,../org.eclipse.swt/Eclipse SWT PI/gtk/library
org.eclipse.swt.internal.gtk4.GTK4,../org.eclipse.swt/Eclipse SWT PI/gtk/library/,\
org.eclipse.swt.internal.ole.win32.COM,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\
org.eclipse.swt.internal.win32.OS,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\
org.eclipse.swt.internal.win32.version.OsVersion,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\
org.eclipse.swt.internal.gdip.Gdip,../org.eclipse.swt/Eclipse SWT PI/win32/library/,\
org.eclipse.swt.internal.cairo.Cairo,../org.eclipse.swt/Eclipse SWT PI/cairo/library/,\
org.eclipse.swt.internal.opengl.glx.GLX,../org.eclipse.swt/Eclipse SWT OpenGL/glx/library/,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@
*******************************************************************************/
package org.eclipse.swt.internal;


public class Platform {
public static final String PLATFORM = "cocoa"; //$NON-NLS-1$

public static boolean isLoadable () {
return Library.isLoadable ();
}

public static void exitIfNotLoadable() {
if (!Library.isLoadable ()) {
System.err.println("Libraries for platform " + Platform.PLATFORM + " cannot be loaded because of incompatible environment");
System.exit(1);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
public class C extends Platform {

static {
exitIfNotLoadable();
Library.loadLibrary ("swt"); //$NON-NLS-1$
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
*******************************************************************************/
package org.eclipse.swt.internal;


public class Platform {
public static final String PLATFORM = "gtk"; //$NON-NLS-1$

public static boolean isLoadable () {
return Library.isLoadable ();
}

public static void exitIfNotLoadable() {
if (!Library.isLoadable ()) {
System.err.println("Libraries for platform " + Platform.PLATFORM + " cannot be loaded because of incompatible environment");
System.exit(1);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ SWT_OBJS = swt.obj callback.obj c.obj c_stats.obj \
os.obj os_structs.obj os_custom.obj os_stats.obj \
com_structs.obj com.obj com_stats.obj com_custom.obj

OSVERSION_PREFIX = swt-osversion
OSVERSION_LIB = $(OSVERSION_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
OSVERSION_OBJS = osversion.obj osversion_structs.obj osversion_stats.obj

GDIP_PREFIX = swt-gdip
GDIP_LIB = $(GDIP_PREFIX)-$(WS_PREFIX)-$(SWT_VERSION).dll
GDIP_LIBS = gdiplus.lib
Expand All @@ -57,7 +61,7 @@ dlllflags = -dll /WX
guilibsmt = kernel32.lib ws2_32.lib mswsock.lib advapi32.lib bufferoverflowu.lib user32.lib gdi32.lib comdlg32.lib winspool.lib
olelibsmt = ole32.lib uuid.lib oleaut32.lib $(guilibsmt)

all: make_swt make_awt make_gdip make_wgl
all: make_osversion make_swt make_awt make_gdip make_wgl

.c.obj:
cl $(CFLAGS) $*.c
Expand All @@ -74,6 +78,14 @@ make_swt: $(SWT_OBJS) swt.res
link @templrf
del templrf

make_osversion: $(OSVERSION_OBJS) swt_osversion.res
echo $(ldebug) $(dlllflags) $(guilibsmt) >templrf
echo $(OSVERSION_OBJS) >>templrf
echo swt_osversion.res >>templrf
echo -out:$(OSVERSION_LIB) >>templrf
link @templrf
del templrf

make_gdip: $(GDIP_OBJS) swt_gdip.res
echo $(ldebug) $(dlllflags) $(guilibsmt) >templrf
echo $(GDIP_LIBS) >>templrf
Expand Down Expand Up @@ -104,6 +116,9 @@ make_wgl: $(WGL_OBJS) swt_wgl.res
swt.res:
rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(SWT_LIB)\" -r -fo swt.res swt.rc

swt_osversion.res:
rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(OSVERSION_LIB)\" -r -fo swt_osversion.res swt_osversion.rc

swt_gdip.res:
rc $(RCFLAGS) -DSWT_ORG_FILENAME=\"$(GDIP_LIB)\" -r -fo swt_gdip.res swt_gdip.rc

Expand Down
40 changes: 0 additions & 40 deletions bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(AddFontResourceEx)
}
#endif

#ifndef NO_AdjustWindowRectEx
JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectEx)
(JNIEnv *env, jclass that, jobject arg0, jint arg1, jboolean arg2, jint arg3)
{
RECT _arg0, *lparg0=NULL;
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, AdjustWindowRectEx_FUNC);
if (arg0) if ((lparg0 = getRECTFields(env, arg0, &_arg0)) == NULL) goto fail;
rc = (jboolean)AdjustWindowRectEx(lparg0, arg1, arg2, arg3);
fail:
if (arg0 && lparg0) setRECTFields(env, arg0, lparg0);
OS_NATIVE_EXIT(env, that, AdjustWindowRectEx_FUNC);
return rc;
}
#endif

#ifndef NO_AdjustWindowRectExForDpi
JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectExForDpi)
(JNIEnv *env, jclass that, jobject arg0, jint arg1, jboolean arg2, jint arg3, jint arg4)
Expand All @@ -132,15 +116,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(AdjustWindowRectExForDpi)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, AdjustWindowRectExForDpi_FUNC);
if (arg0) if ((lparg0 = getRECTFields(env, arg0, &_arg0)) == NULL) goto fail;
/*
rc = (jboolean)AdjustWindowRectExForDpi(lparg0, arg1, arg2, arg3, arg4);
*/
{
OS_LOAD_FUNCTION(fp, AdjustWindowRectExForDpi)
if (fp) {
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(RECT *, jint, jboolean, jint, jint))fp)(lparg0, arg1, arg2, arg3, arg4);
}
}
fail:
if (arg0 && lparg0) setRECTFields(env, arg0, lparg0);
OS_NATIVE_EXIT(env, that, AdjustWindowRectExForDpi_FUNC);
Expand Down Expand Up @@ -3320,15 +3296,7 @@ JNIEXPORT jint JNICALL OS_NATIVE(GetSystemMetricsForDpi)
{
jint rc = 0;
OS_NATIVE_ENTER(env, that, GetSystemMetricsForDpi_FUNC);
/*
rc = (jint)GetSystemMetricsForDpi(arg0, arg1);
*/
{
OS_LOAD_FUNCTION(fp, GetSystemMetricsForDpi)
if (fp) {
rc = (jint)((jint (CALLING_CONVENTION*)(jint, jint))fp)(arg0, arg1);
}
}
OS_NATIVE_EXIT(env, that, GetSystemMetricsForDpi_FUNC);
return rc;
}
Expand Down Expand Up @@ -9329,15 +9297,7 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(SystemParametersInfoForDpi)
jboolean rc = 0;
OS_NATIVE_ENTER(env, that, SystemParametersInfoForDpi_FUNC);
if (arg2) if ((lparg2 = getNONCLIENTMETRICSFields(env, arg2, &_arg2)) == NULL) goto fail;
/*
rc = (jboolean)SystemParametersInfoForDpi(arg0, arg1, lparg2, arg3, arg4);
*/
{
OS_LOAD_FUNCTION(fp, SystemParametersInfoForDpi)
if (fp) {
rc = (jboolean)((jboolean (CALLING_CONVENTION*)(jint, jint, NONCLIENTMETRICS *, jint, jint))fp)(arg0, arg1, lparg2, arg3, arg4);
}
}
fail:
if (arg2 && lparg2) setNONCLIENTMETRICSFields(env, arg2, lparg2);
OS_NATIVE_EXIT(env, that, SystemParametersInfoForDpi_FUNC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,5 @@
#define GetDpiForWindow_LIB "user32.dll"
#define RtlGetVersion_LIB "ntdll.dll"
#define OpenThemeDataForDpi_LIB "uxtheme.dll"
#define GetSystemMetricsForDpi_LIB "user32.dll"
#define GetThreadDpiAwarenessContext_LIB "user32.dll"
#define SetThreadDpiAwarenessContext_LIB "user32.dll"
#define SystemParametersInfoForDpi_LIB "user32.dll"
#define AdjustWindowRectExForDpi_LIB "user32.dll"
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ typedef enum {
ActivateActCtx_FUNC,
ActivateKeyboardLayout_FUNC,
AddFontResourceEx_FUNC,
AdjustWindowRectEx_FUNC,
AdjustWindowRectExForDpi_FUNC,
AllowDarkModeForWindow_FUNC,
AllowSetForegroundWindow_FUNC,
Expand Down
66 changes: 66 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/osversion.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*******************************************************************************
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

/* Note: This file was auto-generated by org.eclipse.swt.tools.internal.JNIGenerator */
/* DO NOT EDIT - your changes will be lost. */

#include "swt.h"
#include "osversion_structs.h"
#include "osversion_stats.h"

#ifndef OsVersion_NATIVE
#define OsVersion_NATIVE(func) Java_org_eclipse_swt_internal_win32_version_OsVersion_##func
#endif

#ifdef _WIN32
/* Many methods don't use their 'env' and 'that' arguments */
#pragma warning (disable: 4100)
#endif

#ifndef NO_OSVERSIONINFOEX_1sizeof
JNIEXPORT jint JNICALL OsVersion_NATIVE(OSVERSIONINFOEX_1sizeof)
(JNIEnv *env, jclass that)
{
jint rc = 0;
OsVersion_NATIVE_ENTER(env, that, OSVERSIONINFOEX_1sizeof_FUNC);
rc = (jint)OSVERSIONINFOEX_sizeof();
OsVersion_NATIVE_EXIT(env, that, OSVERSIONINFOEX_1sizeof_FUNC);
return rc;
}
#endif

#ifndef NO_RtlGetVersion
JNIEXPORT jint JNICALL OsVersion_NATIVE(RtlGetVersion)
(JNIEnv *env, jclass that, jobject arg0)
{
OSVERSIONINFOEX _arg0, *lparg0=NULL;
jint rc = 0;
OsVersion_NATIVE_ENTER(env, that, RtlGetVersion_FUNC);
if (arg0) if ((lparg0 = getOSVERSIONINFOEXFields(env, arg0, &_arg0)) == NULL) goto fail;
/*
rc = (jint)RtlGetVersion(lparg0);
*/
{
OsVersion_LOAD_FUNCTION(fp, RtlGetVersion)
if (fp) {
rc = (jint)((jint (CALLING_CONVENTION*)(OSVERSIONINFOEX *))fp)(lparg0);
}
}
fail:
if (arg0 && lparg0) setOSVERSIONINFOEXFields(env, arg0, lparg0);
OsVersion_NATIVE_EXIT(env, that, RtlGetVersion_FUNC);
return rc;
}
#endif

33 changes: 33 additions & 0 deletions bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/osversion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* Copyright (c) 2025 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

#ifndef INC_osversion_H
#define INC_osversion_H

/*
* Windows headers will sometimes have warnings above level 2, just
* ignore all of them, we can't do anything about it anyway.
*/
#pragma warning(push, 2)

#include <windows.h>

/* Restore warnings */
#pragma warning(pop)

/* Optional custom definitions to exclude some types */
#include "defines.h"

#define OsVersion_LOAD_FUNCTION LOAD_FUNCTION

#include "osversion_custom.h"

#endif /* INC_osversion_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

#include "swt.h"
#include "winversion_structs.h"
#include "winversion_stats.h"

#define WinVersion_NATIVE(func) Java_org_eclipse_swt_internal_win32_version_WinVersion_##func

HINSTANCE g_hInstance = NULL;
BOOL WINAPI DllMain(HANDLE hInstDLL, DWORD dwReason, LPVOID lpvReserved)
{
/* Suppress warnings about unreferenced parameters */
(void)lpvReserved;

if (dwReason == DLL_PROCESS_ATTACH) {
if (g_hInstance == NULL) g_hInstance = hInstDLL;
}
return TRUE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright (c) 2025 Vector Informatik GmbH and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

/* Libraries for dynamic loaded functions */
#define RtlGetVersion_LIB "ntdll.dll"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

/* Note: This file was auto-generated by org.eclipse.swt.tools.internal.JNIGenerator */
/* DO NOT EDIT - your changes will be lost. */

#include "swt.h"
#include "osversion_stats.h"

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2000, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

/* Note: This file was auto-generated by org.eclipse.swt.tools.internal.JNIGenerator */
/* DO NOT EDIT - your changes will be lost. */

#ifndef OsVersion_NATIVE_ENTER
#define OsVersion_NATIVE_ENTER(env, that, func)
#endif
#ifndef OsVersion_NATIVE_EXIT
#define OsVersion_NATIVE_EXIT(env, that, func)
#endif

typedef enum {
OSVERSIONINFOEX_1sizeof_FUNC,
RtlGetVersion_FUNC,
} OsVersion_FUNCS;
Loading
Loading