@@ -99,6 +99,33 @@ php_core_globals core_globals;
99
99
PHPAPI int core_globals_id ;
100
100
#endif
101
101
102
+ #ifdef PHP_WIN32
103
+ #include "win32_internal_function_disabled.h"
104
+
105
+ static php_win32_disable_functions ( ) {
106
+ int i ;
107
+ TSRMLS_FETCH ();
108
+
109
+ if (EG (windows_version_info ).dwMajorVersion < 5 ) {
110
+ for (i = 0 ; i < function_name_cnt_5 ; i ++ ) {
111
+ if (zend_hash_del (CG (function_table ), function_name_5 [i ], strlen (function_name_5 [i ]) + 1 )== FAILURE ) {
112
+ php_printf ("Unable to disable function '%s'\n" , function_name_5 [i ]);
113
+ return FAILURE ;
114
+ }
115
+ }
116
+ }
117
+
118
+ if (EG (windows_version_info ).dwMajorVersion < 6 ) {
119
+ for (i = 0 ; i < function_name_cnt_6 ; i ++ ) {
120
+ if (zend_hash_del (CG (function_table ), function_name_6 [i ], strlen (function_name_6 [i ]) + 1 )== FAILURE ) {
121
+ php_printf ("Unable to disable function '%s'\n" , function_name_6 [i ]);
122
+ return FAILURE ;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ #endif
128
+
102
129
#define SAFE_FILENAME (f ) ((f)?(f):"-")
103
130
104
131
/* {{{ PHP_INI_MH
@@ -1677,6 +1704,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
1677
1704
#ifdef ZTS
1678
1705
zend_executor_globals * executor_globals ;
1679
1706
void * * * tsrm_ls ;
1707
+ #ifdef PHP_WIN32
1708
+ DWORD dwVersion = GetVersion ();
1709
+ #endif
1680
1710
1681
1711
php_core_globals * core_globals ;
1682
1712
#endif
@@ -1685,16 +1715,12 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
1685
1715
WSADATA wsaData ;
1686
1716
#endif
1687
1717
#ifdef PHP_WIN32
1688
- {
1689
- DWORD dwVersion = GetVersion ();
1690
-
1691
1718
/* Get build numbers for Windows NT or Win95 */
1692
1719
if (dwVersion < 0x80000000 ){
1693
1720
php_os = "WINNT" ;
1694
1721
} else {
1695
1722
php_os = "WIN32" ;
1696
1723
}
1697
- }
1698
1724
#if defined(_MSC_VER ) && (_MSC_VER >= 1400 )
1699
1725
old_invalid_parameter_handler =
1700
1726
_set_invalid_parameter_handler (dummy_invalid_parameter_handler );
@@ -1752,6 +1778,18 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
1752
1778
#endif
1753
1779
gc_globals_ctor (TSRMLS_C );
1754
1780
1781
+ #ifdef PHP_WIN32
1782
+ {
1783
+ OSVERSIONINFOEX * osvi = & EG (windows_version_info );
1784
+
1785
+ ZeroMemory (osvi , sizeof (OSVERSIONINFOEX ));
1786
+ osvi -> dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX );
1787
+ if ( !GetVersionEx ((OSVERSIONINFO * ) osvi )) {
1788
+ php_printf ("\nGetVersionEx unusable. %d\n" , GetLastError ());
1789
+ return FAILURE ;
1790
+ }
1791
+ }
1792
+ #endif
1755
1793
EG (bailout ) = NULL ;
1756
1794
EG (error_reporting ) = E_ALL & ~E_NOTICE ;
1757
1795
@@ -1927,6 +1965,11 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
1927
1965
module -> info_func = PHP_MINFO (php_core );
1928
1966
}
1929
1967
1968
+ #ifdef PHP_WIN32
1969
+ /* Disable incompatible functions for the running platform */
1970
+ php_win32_disable_functions ();
1971
+ #endif
1972
+
1930
1973
#ifdef ZTS
1931
1974
zend_post_startup (TSRMLS_C );
1932
1975
#endif
0 commit comments