summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2019-03-31 17:34:06 +0200
committerAnatol Belski <ab@php.net>2019-03-31 17:34:06 +0200
commit4e4bb56d6cabf87e76b1dd4b75618f4e2b85c15d (patch)
tree5caee4de71f235593a9d347f2c2a2a8e5b5175ef /win32
parenta58882be6c4d32d5355cd681addb5e323c6b51f5 (diff)
parentdd0aca0c11f2572e37fd9583866f37d895a80e4e (diff)
downloadphp-git-4e4bb56d6cabf87e76b1dd4b75618f4e2b85c15d.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Implement stricter CRT check
Diffstat (limited to 'win32')
-rw-r--r--win32/winutil.c38
-rw-r--r--win32/winutil.h1
2 files changed, 38 insertions, 1 deletions
diff --git a/win32/winutil.c b/win32/winutil.c
index 18f890fb33..f0dc9d69e3 100644
--- a/win32/winutil.c
+++ b/win32/winutil.c
@@ -460,7 +460,7 @@ PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *name, const char *pa
per the current knowledge.
This check is to be extended as new VS versions come out. */
- if (14 == major && PHP_LINKER_MINOR < minor
+ if (14 == PHP_LINKER_MAJOR && 14 == major && PHP_LINKER_MINOR < minor
|| PHP_LINKER_MAJOR != major) {
spprintf(err, 0, "Can't load module '%s' as it's linked with %u.%u, but the core is linked with %d.%d", name, major, minor, PHP_LINKER_MAJOR, PHP_LINKER_MINOR);
ImageUnload(img);
@@ -472,3 +472,39 @@ PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *name, const char *pa
return TRUE;
}/*}}}*/
+/* Expect a CRT name DLL. */
+PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *name, char **err)
+{/*{{{*/
+ PLOADED_IMAGE img = ImageLoad(name, NULL);
+
+ if (!img) {
+ DWORD _err = GetLastError();
+ char *err_txt = php_win32_error_to_msg(_err);
+ spprintf(err, 0, "Failed to load %s, %s", name, err_txt);
+ free(err_txt);
+ return FALSE;
+ }
+
+ DWORD major = img->FileHeader->OptionalHeader.MajorLinkerVersion;
+ DWORD minor = img->FileHeader->OptionalHeader.MinorLinkerVersion;
+
+#if PHP_LINKER_MAJOR == 14
+ DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10);
+ DWORD comp_minor = (DWORD)(minor/10);
+ if (core_minor > comp_minor) {
+ spprintf(err, 0, "'%s' %u.%u is not compatible with this PHP build linked with %d.%d", name, major, minor, PHP_LINKER_MAJOR, PHP_LINKER_MINOR);
+ ImageUnload(img);
+ return FALSE;
+ }
+#else
+ if (PHP_LINKER_MAJOR != major) {
+ spprintf(err, 0, "'%s' %u.%u is not compatible with this PHP build linked with %d.%d", name, major, minor, PHP_LINKER_MAJOR, PHP_LINKER_MINOR);
+ ImageUnload(img);
+ return FALSE;
+ }
+#endif
+ ImageUnload(img);
+
+ return TRUE;
+}/*}}}*/
+
diff --git a/win32/winutil.h b/win32/winutil.h
index 594f2d8d63..4b1d0448d5 100644
--- a/win32/winutil.h
+++ b/win32/winutil.h
@@ -56,5 +56,6 @@ PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err);
PHP_WINUTIL_API char *php_win32_get_username(void);
PHP_WINUTIL_API BOOL php_win32_image_compatible(const char *img, const char *path, char **err);
+PHP_WINUTIL_API BOOL php_win32_crt_compatible(const char *img, char **err);
#endif