Skip to content
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

Bump minimal supported Windows version to Windows Vista (0x0600). #499

Open
wants to merge 4 commits into
base: Cog
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions build.win32x86/common/Makefile.msvc.tools
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,17 @@ ifdef MSVC
MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1
endif

# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501
# Set minimum version to Windows 8 (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0602 -DWINVER=0x0602
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As suggested on the mailing list, I would just use 0x0600

See also https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=vs-2019 for the list of _WIN32_WINNT version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you feel about setting minimum supported version to 8.0? I want to do this because of the GetSystemTimePreciseAsFileTime function, which appears in 8.0 nd neatly solves the time issues in the win32 VM (use of the millisecond clock to derive greater precision than the 15ms tick in GetSystemTimeAsFileTime causes significant direct over the course of several days).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have 0x6000 (Vista) and use that function. Ping me in a week or so, when I'm back from vacation


# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h
#NOBUILTIN:= -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf
NOBUILTIN:=-D_MT
MACHINE:=x86

DEFS:= $(COGDEFS) $(MEMACCESS) $(WINVER) \
-DWIN32=1 -DUNICODE=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
-DWIN32=1 -D_WIN32=1 -DUNICODE=1 \
-DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
$(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET)

#############################################################################
Expand Down
9 changes: 5 additions & 4 deletions build.win32x86/common/Makefile.tools
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ else
COGDEFS:= $(COGDEFS) -DCOGMTVM=0 -DDEBUGVM=$(DEBUGVM)
endif

# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501
# Set minimum version to Windows 8 (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0602 -DWINVER=0x0602

# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h
NOBUILTIN:= -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf
CFLAGS:= -msse2 -ggdb2 -m32 \
-mno-rtd -mms-bitfields $(OFLAGS) $(NOBUILTIN) $(WARNINGS)

TZ:=$(shell date +%Z)
DEFS:= $(COGDEFS) $(WINVER) -DWIN32=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN \
-DNO_SERVICE -D'TZ="$(TZ)"' \
DEFS:= $(COGDEFS) $(WINVER) \
-DWIN32=1 -D_WIN32=1 \
-DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE -D'TZ="$(TZ)"' \
$(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET)

#############################################################################
Expand Down
8 changes: 3 additions & 5 deletions build.win64x64/common/Makefile.msvc.tools
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,16 @@ MEMACCESS:=-DUSE_INLINE_MEMORY_ACCESSORS=1
endif

# Set minimum version to Windows 8 (see /cygwin/usr/include/w32api/w32api.h)
#but if so, sqWin32AEC.cpp includes DeviceTopology.h & barfs
#WINVER:=-D_WIN32_WINNT=0x0801 -DWINVER=0x0801
# Set minimum version to Windows 10
WINVER:=-D_WIN64=1 -D_WIN32_WINNT=0x1001 -DWINVER=0x1001
WINVER:=-D_WIN32_WINNT=0x0602 -DWINVER=0x0602

# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h
#NOBUILTIN:= -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf
NOBUILTIN:=-D_MT
MACHINE:=x64

DEFS:= -D$(VM)VM=1 $(COGDEFS) $(MEMACCESS) $(WINVER) \
-DWIN32=1 -DUNICODE=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
-DWIN32=1 -DWIN64=1 -D_WIN32=1 -D_WIN64=1 -DUNICODE=1 \
-DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
$(NDEBUG) -DLSB_FIRST -DVM_NAME='"$(VM_NAME)"' $(XDEFS) $(CROQUET)

#############################################################################
Expand Down
7 changes: 4 additions & 3 deletions build.win64x64/common/Makefile.tools
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ ifeq ($(COMPILER_TO_USE),clang)
COGDEFS:=$(COGDEFS) -mno-stack-arg-probe
endif

# Set minimum version to WindowsXP (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0501 -DWINVER=0x0501
# Set minimum version to Windows 8 (see /cygwin/usr/include/w32api/w32api.h)
WINVER:=-D_WIN32_WINNT=0x0602 -DWINVER=0x0602

# define _MT to eliminate the inline versions of printf et al in mingw/stdio.h
NOBUILTIN:= -D_MT -fno-builtin-printf -fno-builtin-putchar -fno-builtin-fprintf
Expand All @@ -59,7 +59,8 @@ CFLAGS:= -fdeclspec -msse2 -ggdb2 -m64 \

TZ:=$(shell date +%Z)
DEFS:= -D$(VM)VM=1 $(COGDEFS) $(WINVER) \
-DWIN64=1 -DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
-DWIN32=1 -DWIN64=1 -D_WIN32=1 -D_WIN64=1 \
-DWIN32_FILE_SUPPORT -DNO_ISNAN -DNO_SERVICE \
$(NDEBUG) -DLSB_FIRST -D'VM_NAME="$(VM_NAME)"' $(XDEFS) $(CROQUET)

#############################################################################
Expand Down
41 changes: 0 additions & 41 deletions platforms/win32/vm/sqWin32.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,47 +398,6 @@ void pluginHandleEvent(MSG* msg);
int recordDragDropEvent(HWND wnd, int dragType, int x, int y, int numFiles);
#endif

/****************************************************************************/
/* few addtional definitions for those having older include files */
/****************************************************************************/
#if (WINVER < 0x0400) && !defined(_GNU_H_WINDOWS_H)
/* CreateWindowEx params since Win95/NT4 */
#define WS_EX_WINDOWEDGE 0x00000100L
#define WS_EX_CLIENTEDGE 0x00000200L
#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE)
#define WS_EX_APPWINDOW 0x00040000L
#define WS_EX_TOOLWINDOW 0x00000080L
#define WS_EX_CONTEXTHELP 0x00000400L

/* WM_USERCHANGED since Win95/NT4 */
#define WM_USERCHANGED 0x0054

/* Shell_NoifiyIcon() for the system tray on Win95/NT4 */
typedef struct _NOTIFYICONDATAA {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
CHAR szTip[64];
} NOTIFYICONDATA, *PNOTIFYICONDATA;

#define NIM_ADD 0x00000000
#define NIM_MODIFY 0x00000001
#define NIM_DELETE 0x00000002

#define NIF_MESSAGE 0x00000001
#define NIF_ICON 0x00000002
#define NIF_TIP 0x00000004

#endif /* WINVER < 0x0400 */

/* WM_MOUSEWHEEL since Win98/NT4 */
#ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020A
#endif

/******************************************************/
/* Profiling support */
/******************************************************/
Expand Down
77 changes: 4 additions & 73 deletions platforms/win32/vm/sqWin32Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,55 +38,11 @@
# endif
#endif


/************************************************************************************************************/
/* few addtional definitions for those having older include files especially #include <fileextd.h> */
/************************************************************************************************************/
#if (WINVER < 0x0600)
/*Copied from winbase.h*/
typedef struct _FILE_NAME_INFO {
DWORD FileNameLength;
WCHAR FileName[1];
} FILE_NAME_INFO, *PFILE_NAME_INFO;
typedef enum _FILE_INFO_BY_HANDLE_CLASS {
FileBasicInfo = 0,
FileStandardInfo = 1,
FileNameInfo = 2,
FileRenameInfo = 3,
FileDispositionInfo = 4,
FileAllocationInfo = 5,
FileEndOfFileInfo = 6,
FileStreamInfo = 7,
FileCompressionInfo = 8,
FileAttributeTagInfo = 9,
FileIdBothDirectoryInfo = 10, // 0xA
FileIdBothDirectoryRestartInfo = 11, // 0xB
FileIoPriorityHintInfo = 12, // 0xC
FileRemoteProtocolInfo = 13, // 0xD
FileFullDirectoryInfo = 14, // 0xE
FileFullDirectoryRestartInfo = 15, // 0xF
FileStorageInfo = 16, // 0x10
FileAlignmentInfo = 17, // 0x11
FileIdInfo = 18, // 0x12
FileIdExtdDirectoryInfo = 19, // 0x13
FileIdExtdDirectoryRestartInfo = 20, // 0x14
MaximumFileInfoByHandlesClass
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
#endif //(WINVER < 0x0600)

#if !defined(IMAGE_SIZEOF_NT_OPTIONAL_HEADER)
#include <winnt.h>
#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER sizeof(IMAGE_OPTIONAL_HEADER)
#endif

/* Windows Vista support
* AUTHOR: Korakurider (kr)
* CHANGE NOTES:
* 1) new command line option "-lowRights" was introduced
* to support IE7/protected mode.
*/
#define VISTA_SECURITY 1 /* IE7/Vista protected mode support */

# define VMOPTION(arg) "-"arg

/*** Crash debug -- Imported from Virtual Machine ***/
Expand Down Expand Up @@ -135,10 +91,8 @@ static WCHAR vmLogDirW[MAX_PATH];

WCHAR *logName = L""; /* full path and name to log file */

#ifdef VISTA_SECURITY
BOOL fLowRights = 0; /* started as low integiry process,
BOOL fLowRights = 0; /* started as low integrity process,
need to use alternate untrustedUserDirectory */
#endif /* VISTA_SECURITY */

/* Service stuff */
WCHAR serviceName[MAX_PATH+1]; /* The name of the NT service */
Expand Down Expand Up @@ -925,41 +879,20 @@ sqInt fileHandleType(HANDLE fdHandle) {
int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * MAX_PATH;
FILE_NAME_INFO *nameinfo;
WCHAR *p = NULL;

typedef BOOL(WINAPI *pfnGetFileInformationByHandleEx)(
HANDLE hFile,
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
LPVOID lpFileInformation,
DWORD dwBufferSize
);
static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL;
if (!pGetFileInformationByHandleEx) {
pGetFileInformationByHandleEx = (pfnGetFileInformationByHandleEx)
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetFileInformationByHandleEx");
if (!pGetFileInformationByHandleEx)
return -1;
}

nameinfo = malloc(size);
if (nameinfo == NULL) {
return -1;
}
nameinfo = alloca(size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not, alloca is a bit shorter, but the pairs of malloc and free seems correct here...
I'd rather consider this change as un-necessary.

/* Check the name of the pipe: '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */
if (pGetFileInformationByHandleEx(fdHandle, FileNameInfo, nameinfo, size)) {
if (GetFileInformationByHandleEx(fdHandle, FileNameInfo, nameinfo, size)) {
nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0';
p = nameinfo->FileName;
//Check that the pipe name contains msys or cygwin
if ((((wcsstr(p, L"msys-") || wcsstr(p, L"cygwin-"))) &&
(wcsstr(p, L"-pty") && wcsstr(p, L"-master")))) {
//The openned pipe is a msys xor cygwin pipe to pty
free(nameinfo);
return 4;
}
else
free(nameinfo);
return 2; //else it is just a standard pipe
}
free(nameinfo);
return -1;
}

Expand Down Expand Up @@ -1896,10 +1829,8 @@ parseVMArgument(int argc, char *argv[])
printPhaseTime(1);
return 1;
}
#ifdef VISTA_SECURITY /* IE7/Vista protected mode support */
/* started with low rights, use alternate untrustedUserDirectory */
else if (!strcmp(argv[0], VMOPTION("lowRights"))) { fLowRights = true; return 1; }
#endif /* VISTA_SECURITY */

#if (STACKVM || NewspeakVM) && !COGVM
else if (!strcmp(argv[0], VMOPTION("sendtrace")))
{ extern sqInt sendTrace; sendTrace = 1; return 1; }
Expand Down