{"thread":{"id":"59118","subject":"[PATCH] mingw: replace deprecated GetVersion with RtlGetVersion","startedAt":"2023-01-19T17:07:33Z","lastAt":"2023-03-27T09:25:18Z","messageCount":5,"participants":["Rose via GitGitGadget","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"470713","messageId":"pull.1438.git.git.1674148045970.gitgitgadget@gmail.com","threadId":"59118","inReplyTo":null,"subject":"[PATCH] mingw: replace deprecated GetVersion with RtlGetVersion","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-19T17:07:25Z","receivedAt":"2023-01-19T17:07:33Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThe previous way is deprecated and returns\nthe wrong value in Windows 8 and up,\nreturning the manifest Windows data\nas opposed to the actual Windows data.\n\nRtlGetVersion is the correct way to get the Windows version now.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    mingw: replace deprecated GetVersion with RtlGetVersion\n    \n    GetVersion has its behavior changed in Windows 8 and above anyway, so\n    this is the right way to do it now.\n    \n    The previous way returns the wrong value in Windows 8 and up, returning\n    the manifest Windows data as opposed to the actual Windows data.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1438%2FAtariDreams%2Fmingw-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1438/AtariDreams/mingw-v1\nPull-Request: https://github.com/git/git/pull/1438\n\n compat/mingw.c | 33 +++++++++++++++++++++++++++------\n 1 file changed, 27 insertions(+), 6 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex af397e68a1d..ebd5850002a 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -3081,15 +3081,36 @@ int wmain(int argc, const wchar_t **wargv)\n \treturn exit_status;\n }\n \n+/*\n+ * For RtlGetVersion in uname\n+ */\n+\n+typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n+union winprocaddr {\n+\tFARPROC procaddr;\n+\tRtlGetVersionPtr procGetVersion;\n+};\n+\n int uname(struct utsname *buf)\n {\n-\tunsigned v = (unsigned)GetVersion();\n+\tunion winprocaddr RtlGetVersionInternal;\n+\tOSVERSIONINFOA version;\n+\n+\tRtlGetVersionInternal.procaddr =\n+\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n+\tif (!RtlGetVersionInternal.procaddr) {\n+\t\tdie_message_errno(\n+\t\t\t\"Could not get handle to RtlGetVersion in ntdll.dll\");\n+\t}\n+\n+\tversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n+\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n+\n \tmemset(buf, 0, sizeof(*buf));\n \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n-\txsnprintf(buf->release, sizeof(buf->release),\n-\t\t \"%u.%u\", v & 0xff, (v >> 8) & 0xff);\n-\t/* assuming NT variants only.. */\n-\txsnprintf(buf->version, sizeof(buf->version),\n-\t\t  \"%u\", (v >> 16) & 0x7fff);\n+\txsnprintf(buf->release, sizeof(buf->release), \"%lu.%lu\",\n+\t\t  version.dwMajorVersion, version.dwMinorVersion);\n+\txsnprintf(buf->version, sizeof(buf->version), \"%lu\",\n+\t\t  version.dwBuildNumber);\n \treturn 0;\n }\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"},{"id":"470719","messageId":"pull.1438.v2.git.git.1674149773693.gitgitgadget@gmail.com","threadId":"59118","inReplyTo":"pull.1438.git.git.1674148045970.gitgitgadget@gmail.com","subject":"[PATCH v2] mingw: replace deprecated GetVersion with RtlGetVersion","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-19T17:36:13Z","receivedAt":"2023-01-19T17:36:26Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThe previous way is deprecated and returns\nthe wrong value in Windows 8 and up,\nreturning the manifest Windows data\nas opposed to the actual Windows data.\n\nRtlGetVersion is the correct way to get the Windows version now.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    mingw: replace deprecated GetVersion with RtlGetVersion\n    \n    GetVersion has its behavior changed in Windows 8 and above anyway, so\n    this is the right way to do it now.\n    \n    The previous way returns the wrong value in Windows 8 and up, returning\n    the manifest Windows data as opposed to the actual Windows data.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1438%2FAtariDreams%2Fmingw-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1438/AtariDreams/mingw-v2\nPull-Request: https://github.com/git/git/pull/1438\n\nRange-diff vs v1:\n\n 1:  8fe920c653e ! 1:  e5457905028 mingw: replace deprecated GetVersion with RtlGetVersion\n     @@ compat/mingw.c: int wmain(int argc, const wchar_t **wargv)\n       }\n       \n      +/*\n     -+ * For RtlGetVersion in uname\n     ++ * for RtlGetVersion in uname\n      + */\n      +\n      +typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n     @@ compat/mingw.c: int wmain(int argc, const wchar_t **wargv)\n      +\tRtlGetVersionInternal.procaddr =\n      +\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n      +\tif (!RtlGetVersionInternal.procaddr) {\n     -+\t\tdie_message_errno(\n     -+\t\t\t\"Could not get handle to RtlGetVersion in ntdll.dll\");\n     ++\t\t/* if this is reached, something is seriously, seriously wrong\n     ++\t\t */\n     ++\t\tperror(\"Could not call RtlGetVersion in ntdll.dll\");\n     ++\t\tabort();\n      +\t}\n      +\n      +\tversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n\n\n compat/mingw.c | 35 +++++++++++++++++++++++++++++------\n 1 file changed, 29 insertions(+), 6 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex af397e68a1d..07d81fb8d69 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -3081,15 +3081,38 @@ int wmain(int argc, const wchar_t **wargv)\n \treturn exit_status;\n }\n \n+/*\n+ * for RtlGetVersion in uname\n+ */\n+\n+typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n+union winprocaddr {\n+\tFARPROC procaddr;\n+\tRtlGetVersionPtr procGetVersion;\n+};\n+\n int uname(struct utsname *buf)\n {\n-\tunsigned v = (unsigned)GetVersion();\n+\tunion winprocaddr RtlGetVersionInternal;\n+\tOSVERSIONINFOA version;\n+\n+\tRtlGetVersionInternal.procaddr =\n+\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n+\tif (!RtlGetVersionInternal.procaddr) {\n+\t\t/* if this is reached, something is seriously, seriously wrong\n+\t\t */\n+\t\tperror(\"Could not call RtlGetVersion in ntdll.dll\");\n+\t\tabort();\n+\t}\n+\n+\tversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n+\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n+\n \tmemset(buf, 0, sizeof(*buf));\n \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n-\txsnprintf(buf->release, sizeof(buf->release),\n-\t\t \"%u.%u\", v & 0xff, (v >> 8) & 0xff);\n-\t/* assuming NT variants only.. */\n-\txsnprintf(buf->version, sizeof(buf->version),\n-\t\t  \"%u\", (v >> 16) & 0x7fff);\n+\txsnprintf(buf->release, sizeof(buf->release), \"%lu.%lu\",\n+\t\t  version.dwMajorVersion, version.dwMinorVersion);\n+\txsnprintf(buf->version, sizeof(buf->version), \"%lu\",\n+\t\t  version.dwBuildNumber);\n \treturn 0;\n }\n\nbase-commit: a7caae2729742fc80147bca1c02ae848cb55921a\n-- \ngitgitgadget\n"},{"id":"470845","messageId":"pull.1438.v3.git.git.1674330625069.gitgitgadget@gmail.com","threadId":"59118","inReplyTo":"pull.1438.v2.git.git.1674149773693.gitgitgadget@gmail.com","subject":"[PATCH v3] mingw: replace deprecated GetVersion with RtlGetVersion","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-21T19:50:24Z","receivedAt":"2023-01-21T19:50:31Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThe previous way is deprecated and returns\nthe wrong value in Windows 8 and up,\nreturning the manifest Windows data\nas opposed to the actual Windows data.\n\nRtlGetVersion is the correct way\nto get the Windows version now.\n\nNote: ntdll does not need to be\nmanually loaded into the runtime,\nas this is the one special library\nthat is automatically loaded upon launch.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    mingw: replace deprecated GetVersion with RtlGetVersion\n    \n    GetVersion has its behavior changed in Windows 8 and above anyway, so\n    this is the right way to do it now.\n    \n    The previous way returns the wrong value in Windows 8 and up, returning\n    the manifest Windows data as opposed to the actual Windows data.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1438%2FAtariDreams%2Fmingw-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1438/AtariDreams/mingw-v3\nPull-Request: https://github.com/git/git/pull/1438\n\nRange-diff vs v2:\n\n 1:  e5457905028 ! 1:  31f778a6b34 mingw: replace deprecated GetVersion with RtlGetVersion\n     @@ Commit message\n          returning the manifest Windows data\n          as opposed to the actual Windows data.\n      \n     -    RtlGetVersion is the correct way to get the Windows version now.\n     +    RtlGetVersion is the correct way\n     +    to get the Windows version now.\n     +\n     +    Note: ntdll does not need to be\n     +    manually loaded into the runtime,\n     +    as this is the one special library\n     +    that is automatically loaded upon launch.\n      \n          Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n      \n     @@ compat/mingw.c: int wmain(int argc, const wchar_t **wargv)\n       {\n      -\tunsigned v = (unsigned)GetVersion();\n      +\tunion winprocaddr RtlGetVersionInternal;\n     -+\tOSVERSIONINFOA version;\n     ++\tOSVERSIONINFOW version;\n     ++\n     ++\tmemset(&version, 0, sizeof(version));\n     ++\tversion.dwOSVersionInfoSize = sizeof(version);\n      +\n     ++\t/* RtlGetVersion always gets the true Windows version, even when running\n     ++\t * under Windows's compatibility mode*/\n      +\tRtlGetVersionInternal.procaddr =\n      +\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n     -+\tif (!RtlGetVersionInternal.procaddr) {\n     -+\t\t/* if this is reached, something is seriously, seriously wrong\n     -+\t\t */\n     -+\t\tperror(\"Could not call RtlGetVersion in ntdll.dll\");\n     -+\t\tabort();\n     -+\t}\n      +\n     -+\tversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n     -+\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n     ++\tif (RtlGetVersionInternal.procaddr) {\n     ++\t\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n     ++\t} else {\n     ++\t\t/* Should not happen, but just in case, fallback to deprecated\n     ++\t\t * GetVersionExW */\n     ++\t\tGetVersionExW(&version);\n     ++\t}\n      +\n       \tmemset(buf, 0, sizeof(*buf));\n       \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n\n\n compat/mingw.c | 39 +++++++++++++++++++++++++++++++++------\n 1 file changed, 33 insertions(+), 6 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex af397e68a1d..b1d75c93cfe 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -3081,15 +3081,42 @@ int wmain(int argc, const wchar_t **wargv)\n \treturn exit_status;\n }\n \n+/*\n+ * for RtlGetVersion in uname\n+ */\n+\n+typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n+union winprocaddr {\n+\tFARPROC procaddr;\n+\tRtlGetVersionPtr procGetVersion;\n+};\n+\n int uname(struct utsname *buf)\n {\n-\tunsigned v = (unsigned)GetVersion();\n+\tunion winprocaddr RtlGetVersionInternal;\n+\tOSVERSIONINFOW version;\n+\n+\tmemset(&version, 0, sizeof(version));\n+\tversion.dwOSVersionInfoSize = sizeof(version);\n+\n+\t/* RtlGetVersion always gets the true Windows version, even when running\n+\t * under Windows's compatibility mode*/\n+\tRtlGetVersionInternal.procaddr =\n+\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n+\n+\tif (RtlGetVersionInternal.procaddr) {\n+\t\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n+\t} else {\n+\t\t/* Should not happen, but just in case, fallback to deprecated\n+\t\t * GetVersionExW */\n+\t\tGetVersionExW(&version);\n+\t}\n+\n \tmemset(buf, 0, sizeof(*buf));\n \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n-\txsnprintf(buf->release, sizeof(buf->release),\n-\t\t \"%u.%u\", v & 0xff, (v >> 8) & 0xff);\n-\t/* assuming NT variants only.. */\n-\txsnprintf(buf->version, sizeof(buf->version),\n-\t\t  \"%u\", (v >> 16) & 0x7fff);\n+\txsnprintf(buf->release, sizeof(buf->release), \"%lu.%lu\",\n+\t\t  version.dwMajorVersion, version.dwMinorVersion);\n+\txsnprintf(buf->version, sizeof(buf->version), \"%lu\",\n+\t\t  version.dwBuildNumber);\n \treturn 0;\n }\n\nbase-commit: 904d404274fef6695c78a6b055edd184b72e2f9b\n-- \ngitgitgadget\n"},{"id":"470846","messageId":"pull.1438.v4.git.git.1674331462560.gitgitgadget@gmail.com","threadId":"59118","inReplyTo":"pull.1438.v3.git.git.1674330625069.gitgitgadget@gmail.com","subject":"[PATCH v4] mingw: prefer RtlGetVersion over GetVersion","fromName":"Rose via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-01-21T20:04:22Z","receivedAt":"2023-01-21T20:04:29Z","isPatch":true,"sender":{"key":"ckelsch@jgrcpa.com","avatar":null},"body":"From: Seija Kijin <doremylover123@gmail.com>\n\nThe previous way is deprecated and returns\nthe wrong value in Windows 8 and up,\nreturning the manifest Windows data\nas opposed to the actual Windows data.\n\nRtlGetVersion is the correct way\nto get the Windows version now.\n\nNote: ntdll does not need to be\nmanually loaded into the runtime,\nas this is the one special library\nthat is automatically loaded upon launch.\n\nSigned-off-by: Seija Kijin <doremylover123@gmail.com>\n---\n    mingw: prefer RtlGetVersion over GetVersion\n    \n    GetVersion has its behavior changed in Windows 8 and above anyway, so\n    this is the right way to do it now.\n    \n    The previous way returns the wrong value in Windows 8 and up, returning\n    the manifest Windows data as opposed to the actual Windows data.\n    \n    Signed-off-by: Seija Kijin doremylover123@gmail.com\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1438%2FAtariDreams%2Fmingw-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1438/AtariDreams/mingw-v4\nPull-Request: https://github.com/git/git/pull/1438\n\nRange-diff vs v3:\n\n 1:  31f778a6b34 ! 1:  8293e868970 mingw: replace deprecated GetVersion with RtlGetVersion\n     @@ Metadata\n      Author: Seija Kijin <doremylover123@gmail.com>\n      \n       ## Commit message ##\n     -    mingw: replace deprecated GetVersion with RtlGetVersion\n     +    mingw: prefer RtlGetVersion over GetVersion\n      \n          The previous way is deprecated and returns\n          the wrong value in Windows 8 and up,\n\n\n compat/mingw.c | 39 +++++++++++++++++++++++++++++++++------\n 1 file changed, 33 insertions(+), 6 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex af397e68a1d..b1d75c93cfe 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -3081,15 +3081,42 @@ int wmain(int argc, const wchar_t **wargv)\n \treturn exit_status;\n }\n \n+/*\n+ * for RtlGetVersion in uname\n+ */\n+\n+typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n+union winprocaddr {\n+\tFARPROC procaddr;\n+\tRtlGetVersionPtr procGetVersion;\n+};\n+\n int uname(struct utsname *buf)\n {\n-\tunsigned v = (unsigned)GetVersion();\n+\tunion winprocaddr RtlGetVersionInternal;\n+\tOSVERSIONINFOW version;\n+\n+\tmemset(&version, 0, sizeof(version));\n+\tversion.dwOSVersionInfoSize = sizeof(version);\n+\n+\t/* RtlGetVersion always gets the true Windows version, even when running\n+\t * under Windows's compatibility mode*/\n+\tRtlGetVersionInternal.procaddr =\n+\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n+\n+\tif (RtlGetVersionInternal.procaddr) {\n+\t\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n+\t} else {\n+\t\t/* Should not happen, but just in case, fallback to deprecated\n+\t\t * GetVersionExW */\n+\t\tGetVersionExW(&version);\n+\t}\n+\n \tmemset(buf, 0, sizeof(*buf));\n \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n-\txsnprintf(buf->release, sizeof(buf->release),\n-\t\t \"%u.%u\", v & 0xff, (v >> 8) & 0xff);\n-\t/* assuming NT variants only.. */\n-\txsnprintf(buf->version, sizeof(buf->version),\n-\t\t  \"%u\", (v >> 16) & 0x7fff);\n+\txsnprintf(buf->release, sizeof(buf->release), \"%lu.%lu\",\n+\t\t  version.dwMajorVersion, version.dwMinorVersion);\n+\txsnprintf(buf->version, sizeof(buf->version), \"%lu\",\n+\t\t  version.dwBuildNumber);\n \treturn 0;\n }\n\nbase-commit: 904d404274fef6695c78a6b055edd184b72e2f9b\n-- \ngitgitgadget\n"},{"id":"474226","messageId":"8b236f96-4b1c-0784-3a25-becc20e3e806@gmx.de","threadId":"59118","inReplyTo":"pull.1438.v4.git.git.1674331462560.gitgitgadget@gmail.com","subject":"Re: [PATCH v4] mingw: prefer RtlGetVersion over GetVersion","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2023-03-27T09:25:09Z","receivedAt":"2023-03-27T09:25:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 21 Jan 2023, Rose via GitGitGadget wrote:\n\n> From: Seija Kijin <doremylover123@gmail.com>\n>\n> The previous way is deprecated and returns\n\nLet's always provide references for such claims (which would otherwise\nrisk suspicion for being taken out of thin air).\nhttps://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversion\nhas this to say:\n\n\t*GetVersion* may be altered or unavailable for releases after\n\tWindows 8.1.\n\nThe suggestion is to switch to using version helpers, but those version\nhelpers do not get you a version number, they instead help you determine\nwhich major version you're on, which is not what we need.\n\nPlease note that the documentation in no way or form suggests to switch to\nusing `RtlGetVersion()`.\n\n> the wrong value in Windows 8 and up,\n> returning the manifest Windows data\n> as opposed to the actual Windows data.\n\nThis is correct only if you ignore the reality that\n`compat/win32/git.manifest` contains the values required to make it work.\n\n> RtlGetVersion is the correct way\n> to get the Windows version now.\n\nHere, we would need a reference to support that claim. Seeing as I failed\nto find any, I suspect that the claim can safely be considered to be\nrefuted and therefore the patch must be taken into doubt.\n\nCiao,\nJohannes\n\n>\n> Note: ntdll does not need to be\n> manually loaded into the runtime,\n> as this is the one special library\n> that is automatically loaded upon launch.\n>\n> Signed-off-by: Seija Kijin <doremylover123@gmail.com>\n> ---\n>     mingw: prefer RtlGetVersion over GetVersion\n>\n>     GetVersion has its behavior changed in Windows 8 and above anyway, so\n>     this is the right way to do it now.\n>\n>     The previous way returns the wrong value in Windows 8 and up, returning\n>     the manifest Windows data as opposed to the actual Windows data.\n>\n>     Signed-off-by: Seija Kijin doremylover123@gmail.com\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1438%2FAtariDreams%2Fmingw-v4\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1438/AtariDreams/mingw-v4\n> Pull-Request: https://github.com/git/git/pull/1438\n>\n> Range-diff vs v3:\n>\n>  1:  31f778a6b34 ! 1:  8293e868970 mingw: replace deprecated GetVersion with RtlGetVersion\n>      @@ Metadata\n>       Author: Seija Kijin <doremylover123@gmail.com>\n>\n>        ## Commit message ##\n>      -    mingw: replace deprecated GetVersion with RtlGetVersion\n>      +    mingw: prefer RtlGetVersion over GetVersion\n>\n>           The previous way is deprecated and returns\n>           the wrong value in Windows 8 and up,\n>\n>\n>  compat/mingw.c | 39 +++++++++++++++++++++++++++++++++------\n>  1 file changed, 33 insertions(+), 6 deletions(-)\n>\n> diff --git a/compat/mingw.c b/compat/mingw.c\n> index af397e68a1d..b1d75c93cfe 100644\n> --- a/compat/mingw.c\n> +++ b/compat/mingw.c\n> @@ -3081,15 +3081,42 @@ int wmain(int argc, const wchar_t **wargv)\n>  \treturn exit_status;\n>  }\n>\n> +/*\n> + * for RtlGetVersion in uname\n> + */\n> +\n> +typedef NTSTATUS(WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);\n> +union winprocaddr {\n> +\tFARPROC procaddr;\n> +\tRtlGetVersionPtr procGetVersion;\n> +};\n> +\n>  int uname(struct utsname *buf)\n>  {\n> -\tunsigned v = (unsigned)GetVersion();\n> +\tunion winprocaddr RtlGetVersionInternal;\n> +\tOSVERSIONINFOW version;\n> +\n> +\tmemset(&version, 0, sizeof(version));\n> +\tversion.dwOSVersionInfoSize = sizeof(version);\n> +\n> +\t/* RtlGetVersion always gets the true Windows version, even when running\n> +\t * under Windows's compatibility mode*/\n> +\tRtlGetVersionInternal.procaddr =\n> +\t\tGetProcAddress(GetModuleHandleW(L\"ntdll.dll\"), \"RtlGetVersion\");\n> +\n> +\tif (RtlGetVersionInternal.procaddr) {\n> +\t\tRtlGetVersionInternal.procGetVersion((PRTL_OSVERSIONINFOW)&version);\n> +\t} else {\n> +\t\t/* Should not happen, but just in case, fallback to deprecated\n> +\t\t * GetVersionExW */\n> +\t\tGetVersionExW(&version);\n> +\t}\n> +\n>  \tmemset(buf, 0, sizeof(*buf));\n>  \txsnprintf(buf->sysname, sizeof(buf->sysname), \"Windows\");\n> -\txsnprintf(buf->release, sizeof(buf->release),\n> -\t\t \"%u.%u\", v & 0xff, (v >> 8) & 0xff);\n> -\t/* assuming NT variants only.. */\n> -\txsnprintf(buf->version, sizeof(buf->version),\n> -\t\t  \"%u\", (v >> 16) & 0x7fff);\n> +\txsnprintf(buf->release, sizeof(buf->release), \"%lu.%lu\",\n> +\t\t  version.dwMajorVersion, version.dwMinorVersion);\n> +\txsnprintf(buf->version, sizeof(buf->version), \"%lu\",\n> +\t\t  version.dwBuildNumber);\n>  \treturn 0;\n>  }\n>\n> base-commit: 904d404274fef6695c78a6b055edd184b72e2f9b\n> --\n> gitgitgadget\n>\n"}]}