winutil.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Zeev Suraski <zeev@php.net> |
  14. * Pierre Joye <pierre@php.net> |
  15. +----------------------------------------------------------------------+
  16. */
  17. #include "php.h"
  18. #include "winutil.h"
  19. #include "codepage.h"
  20. #include <bcrypt.h>
  21. #include <lmcons.h>
  22. PHP_WINUTIL_API char *php_win32_error_to_msg(HRESULT error)
  23. {/*{{{*/
  24. wchar_t *bufw = NULL, *pw;
  25. char *buf;
  26. DWORD ret = FormatMessageW(
  27. FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  28. NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&bufw, 0, NULL
  29. );
  30. if (!ret || !bufw) {
  31. return "";
  32. }
  33. /* strip trailing line breaks and periods */
  34. for (pw = bufw + wcslen(bufw) - 1; pw >= bufw && (*pw == L'\r' || *pw == L'\n' || *pw == L'.'); pw--);
  35. pw[1] = L'\0';
  36. buf = php_win32_cp_conv_w_to_any(bufw, ret, PHP_WIN32_CP_IGNORE_LEN_P);
  37. LocalFree(bufw);
  38. return (buf ? buf : "");
  39. }/*}}}*/
  40. PHP_WINUTIL_API void php_win32_error_msg_free(char *msg)
  41. {/*{{{*/
  42. if (msg && msg[0]) {
  43. free(msg);
  44. }
  45. }/*}}}*/
  46. int php_win32_check_trailing_space(const char * path, const size_t path_len)
  47. {/*{{{*/
  48. if (path_len > MAXPATHLEN - 1) {
  49. return 1;
  50. }
  51. if (path) {
  52. if (path[0] == ' ' || path[path_len - 1] == ' ') {
  53. return 0;
  54. } else {
  55. return 1;
  56. }
  57. } else {
  58. return 0;
  59. }
  60. }/*}}}*/
  61. static BCRYPT_ALG_HANDLE bcrypt_algo;
  62. static BOOL has_bcrypt_algo = 0;
  63. #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
  64. #ifdef PHP_EXPORTS
  65. BOOL php_win32_shutdown_random_bytes(void)
  66. {/*{{{*/
  67. BOOL ret = TRUE;
  68. if (has_bcrypt_algo) {
  69. ret = NT_SUCCESS(BCryptCloseAlgorithmProvider(bcrypt_algo, 0));
  70. has_bcrypt_algo = 0;
  71. }
  72. return ret;
  73. }/*}}}*/
  74. BOOL php_win32_init_random_bytes(void)
  75. {/*{{{*/
  76. if (has_bcrypt_algo) {
  77. return TRUE;
  78. }
  79. has_bcrypt_algo = NT_SUCCESS(BCryptOpenAlgorithmProvider(&bcrypt_algo, BCRYPT_RNG_ALGORITHM, NULL, 0));
  80. return has_bcrypt_algo;
  81. }/*}}}*/
  82. #endif
  83. PHP_WINUTIL_API int php_win32_get_random_bytes(unsigned char *buf, size_t size)
  84. { /* {{{ */
  85. BOOL ret;
  86. #if 0
  87. /* Currently we fail on startup, with CNG API it shows no regressions so far and is secure.
  88. Should switch on and try to reinit, if it fails too often on startup. This means also
  89. bringing locks back. */
  90. if (has_bcrypt_algo == 0) {
  91. return FAILURE;
  92. }
  93. #endif
  94. /* No sense to loop here, the limit is huge enough. */
  95. ret = NT_SUCCESS(BCryptGenRandom(bcrypt_algo, buf, (ULONG)size, 0));
  96. return ret ? SUCCESS : FAILURE;
  97. }
  98. /* }}} */
  99. /*
  100. * This functions based on the code from the UNIXem project under
  101. * the BSD like license. Modified for PHP by ab@php.net
  102. *
  103. * Home: http://synesis.com.au/software/
  104. *
  105. * Copyright (c) 2005-2010, Matthew Wilson and Synesis Software
  106. */
  107. PHP_WINUTIL_API int php_win32_code_to_errno(unsigned long w32Err)
  108. {/*{{{*/
  109. size_t i;
  110. struct code_to_errno_map
  111. {
  112. unsigned long w32Err;
  113. int eerrno;
  114. };
  115. static const struct code_to_errno_map errmap[] =
  116. {
  117. /* 1 */ { ERROR_INVALID_FUNCTION , EINVAL }
  118. /* 2 */ , { ERROR_FILE_NOT_FOUND , ENOENT }
  119. /* 3 */ , { ERROR_PATH_NOT_FOUND , ENOENT }
  120. /* 4 */ , { ERROR_TOO_MANY_OPEN_FILES , EMFILE }
  121. /* 5 */ , { ERROR_ACCESS_DENIED , EACCES }
  122. /* 6 */ , { ERROR_INVALID_HANDLE , EBADF }
  123. /* 7 */ , { ERROR_ARENA_TRASHED , ENOMEM }
  124. /* 8 */ , { ERROR_NOT_ENOUGH_MEMORY , ENOMEM }
  125. /* 9 */ , { ERROR_INVALID_BLOCK , ENOMEM }
  126. /* 10 */ , { ERROR_BAD_ENVIRONMENT , E2BIG }
  127. /* 11 */ , { ERROR_BAD_FORMAT , ENOEXEC }
  128. /* 12 */ , { ERROR_INVALID_ACCESS , EINVAL }
  129. /* 13 */ , { ERROR_INVALID_DATA , EINVAL }
  130. /* 14 */ , { ERROR_OUTOFMEMORY , ENOMEM }
  131. /* 15 */ , { ERROR_INVALID_DRIVE , ENOENT }
  132. /* 16 */ , { ERROR_CURRENT_DIRECTORY , ECURDIR }
  133. /* 17 */ , { ERROR_NOT_SAME_DEVICE , EXDEV }
  134. /* 18 */ , { ERROR_NO_MORE_FILES , ENOENT }
  135. /* 19 */ , { ERROR_WRITE_PROTECT , EROFS }
  136. /* 20 */ , { ERROR_BAD_UNIT , ENXIO }
  137. /* 21 */ , { ERROR_NOT_READY , EBUSY }
  138. /* 22 */ , { ERROR_BAD_COMMAND , EIO }
  139. /* 23 */ , { ERROR_CRC , EIO }
  140. /* 24 */ , { ERROR_BAD_LENGTH , EIO }
  141. /* 25 */ , { ERROR_SEEK , EIO }
  142. /* 26 */ , { ERROR_NOT_DOS_DISK , EIO }
  143. /* 27 */ , { ERROR_SECTOR_NOT_FOUND , ENXIO }
  144. /* 28 */ , { ERROR_OUT_OF_PAPER , EBUSY }
  145. /* 29 */ , { ERROR_WRITE_FAULT , EIO }
  146. /* 30 */ , { ERROR_READ_FAULT , EIO }
  147. /* 31 */ , { ERROR_GEN_FAILURE , EIO }
  148. /* 32 */ , { ERROR_SHARING_VIOLATION , EAGAIN }
  149. /* 33 */ , { ERROR_LOCK_VIOLATION , EACCES }
  150. /* 34 */ , { ERROR_WRONG_DISK , ENXIO }
  151. /* 35 */ , { 35 , ENFILE }
  152. /* 36 */ , { ERROR_SHARING_BUFFER_EXCEEDED , ENFILE }
  153. /* 37 */ , { ERROR_HANDLE_EOF , EINVAL }
  154. /* 38 */ , { ERROR_HANDLE_DISK_FULL , ENOSPC }
  155. #if 0
  156. /* 39 */ , { 0 , 0 }
  157. /* 40 */ , { 0 , 0 }
  158. /* 41 */ , { 0 , 0 }
  159. /* 42 */ , { 0 , 0 }
  160. /* 43 */ , { 0 , 0 }
  161. /* 44 */ , { 0 , 0 }
  162. /* 45 */ , { 0 , 0 }
  163. /* 46 */ , { 0 , 0 }
  164. /* 47 */ , { 0 , 0 }
  165. /* 48 */ , { 0 , 0 }
  166. /* 49 */ , { 0 , 0 }
  167. #endif
  168. /* 50 */ , { ERROR_NOT_SUPPORTED , ENOSYS }
  169. #if 0
  170. /* 51 */ , { 0 , 0 }
  171. /* 52 */ , { 0 , 0 }
  172. #endif
  173. /* 53 */ , { ERROR_BAD_NETPATH , ENOENT }
  174. #if 0
  175. /* 54 */ , { 0 , 0 }
  176. /* 55 */ , { 0 , 0 }
  177. /* 56 */ , { 0 , 0 }
  178. /* 57 */ , { 0 , 0 }
  179. /* 58 */ , { 0 , 0 }
  180. /* 59 */ , { 0 , 0 }
  181. /* 60 */ , { 0 , 0 }
  182. /* 61 */ , { 0 , 0 }
  183. /* 62 */ , { 0 , 0 }
  184. /* 63 */ , { 0 , 0 }
  185. /* 64 */ , { 0 , 0 }
  186. #endif
  187. /* 65 */ , { ERROR_NETWORK_ACCESS_DENIED , EACCES }
  188. #if 0
  189. /* 66 */ , { 0 , 0 }
  190. #endif
  191. /* 67 */ , { ERROR_BAD_NET_NAME , ENOENT }
  192. #if 0
  193. /* 68 */ , { 0 , 0 }
  194. /* 69 */ , { 0 , 0 }
  195. /* 70 */ , { 0 , 0 }
  196. /* 71 */ , { 0 , 0 }
  197. /* 72 */ , { 0 , 0 }
  198. /* 73 */ , { 0 , 0 }
  199. /* 74 */ , { 0 , 0 }
  200. /* 75 */ , { 0 , 0 }
  201. /* 76 */ , { 0 , 0 }
  202. /* 77 */ , { 0 , 0 }
  203. /* 78 */ , { 0 , 0 }
  204. /* 79 */ , { 0 , 0 }
  205. #endif
  206. /* 80 */ , { ERROR_FILE_EXISTS , EEXIST }
  207. #if 0
  208. /* 81 */ , { 0 , 0 }
  209. #endif
  210. /* 82 */ , { ERROR_CANNOT_MAKE , EACCES }
  211. /* 83 */ , { ERROR_FAIL_I24 , EACCES }
  212. #if 0
  213. /* 84 */ , { 0 , 0 }
  214. /* 85 */ , { 0 , 0 }
  215. /* 86 */ , { 0 , 0 }
  216. #endif
  217. /* 87 */ , { ERROR_INVALID_PARAMETER , EINVAL }
  218. #if 0
  219. /* 88 */ , { 0 , 0 }
  220. #endif
  221. /* 89 */ , { ERROR_NO_PROC_SLOTS , EAGAIN }
  222. #if 0
  223. /* 90 */ , { 0 , 0 }
  224. /* 91 */ , { 0 , 0 }
  225. /* 92 */ , { 0 , 0 }
  226. /* 93 */ , { 0 , 0 }
  227. /* 94 */ , { 0 , 0 }
  228. /* 95 */ , { 0 , 0 }
  229. /* 96 */ , { 0 , 0 }
  230. /* 97 */ , { 0 , 0 }
  231. /* 98 */ , { 0 , 0 }
  232. /* 99 */ , { 0 , 0 }
  233. /* 100 */ , { 0 , 0 }
  234. /* 101 */ , { 0 , 0 }
  235. /* 102 */ , { 0 , 0 }
  236. /* 103 */ , { 0 , 0 }
  237. /* 104 */ , { 0 , 0 }
  238. /* 105 */ , { 0 , 0 }
  239. /* 106 */ , { 0 , 0 }
  240. /* 107 */ , { 0 , 0 }
  241. #endif
  242. /* 108 */ , { ERROR_DRIVE_LOCKED , EACCES }
  243. /* 109 */ , { ERROR_BROKEN_PIPE , EPIPE }
  244. #if 0
  245. /* 110 */ , { 0 , 0 }
  246. #endif
  247. /* 111 */ , { ERROR_BUFFER_OVERFLOW , ENAMETOOLONG }
  248. /* 112 */ , { ERROR_DISK_FULL , ENOSPC }
  249. #if 0
  250. /* 113 */ , { 0 , 0 }
  251. #endif
  252. /* 114 */ , { ERROR_INVALID_TARGET_HANDLE , EBADF }
  253. #if 0
  254. /* 115 */ , { 0 , 0 }
  255. /* 116 */ , { 0 , 0 }
  256. /* 117 */ , { 0 , 0 }
  257. /* 118 */ , { 0 , 0 }
  258. /* 119 */ , { 0 , 0 }
  259. /* 120 */ , { 0 , 0 }
  260. /* 121 */ , { 0 , 0 }
  261. #endif
  262. /* 122 */ , { ERROR_INSUFFICIENT_BUFFER , ERANGE }
  263. /* 123 */ , { ERROR_INVALID_NAME , ENOENT }
  264. /* 124 */ , { ERROR_INVALID_HANDLE , EINVAL }
  265. #if 0
  266. /* 125 */ , { 0 , 0 }
  267. #endif
  268. /* 126 */ , { ERROR_MOD_NOT_FOUND , ENOENT }
  269. /* 127 */ , { ERROR_PROC_NOT_FOUND , ENOENT }
  270. /* 128 */ , { ERROR_WAIT_NO_CHILDREN , ECHILD }
  271. /* 129 */ , { ERROR_CHILD_NOT_COMPLETE , ECHILD }
  272. /* 130 */ , { ERROR_DIRECT_ACCESS_HANDLE , EBADF }
  273. /* 131 */ , { ERROR_NEGATIVE_SEEK , EINVAL }
  274. /* 132 */ , { ERROR_SEEK_ON_DEVICE , EACCES }
  275. #if 0
  276. /* 133 */ , { 0 , 0 }
  277. /* 134 */ , { 0 , 0 }
  278. /* 135 */ , { 0 , 0 }
  279. /* 136 */ , { 0 , 0 }
  280. /* 137 */ , { 0 , 0 }
  281. /* 138 */ , { 0 , 0 }
  282. /* 139 */ , { 0 , 0 }
  283. /* 140 */ , { 0 , 0 }
  284. /* 141 */ , { 0 , 0 }
  285. /* 142 */ , { 0 , 0 }
  286. /* 143 */ , { 0 , 0 }
  287. /* 144 */ , { 0 , 0 }
  288. #endif
  289. /* 145 */ , { ERROR_DIR_NOT_EMPTY , ENOTEMPTY }
  290. #if 0
  291. /* 146 */ , { 0 , 0 }
  292. /* 147 */ , { 0 , 0 }
  293. /* 148 */ , { 0 , 0 }
  294. /* 149 */ , { 0 , 0 }
  295. /* 150 */ , { 0 , 0 }
  296. /* 151 */ , { 0 , 0 }
  297. /* 152 */ , { 0 , 0 }
  298. /* 153 */ , { 0 , 0 }
  299. /* 154 */ , { 0 , 0 }
  300. /* 155 */ , { 0 , 0 }
  301. /* 156 */ , { 0 , 0 }
  302. /* 157 */ , { 0 , 0 }
  303. #endif
  304. /* 158 */ , { ERROR_NOT_LOCKED , EACCES }
  305. #if 0
  306. /* 159 */ , { 0 , 0 }
  307. /* 160 */ , { 0 , 0 }
  308. #endif
  309. /* 161 */ , { ERROR_BAD_PATHNAME , ENOENT }
  310. #if 0
  311. /* 162 */ , { 0 , 0 }
  312. /* 163 */ , { 0 , 0 }
  313. #endif
  314. /* 164 */ , { ERROR_MAX_THRDS_REACHED , EAGAIN }
  315. #if 0
  316. /* 165 */ , { 0 , 0 }
  317. /* 166 */ , { 0 , 0 }
  318. #endif
  319. /* 167 */ , { ERROR_LOCK_FAILED , EACCES }
  320. #if 0
  321. /* 168 */ , { 0 , 0 }
  322. /* 169 */ , { 0 , 0 }
  323. /* 170 */ , { 0 , 0 }
  324. /* 171 */ , { 0 , 0 }
  325. /* 172 */ , { 0 , 0 }
  326. /* 173 */ , { 0 , 0 }
  327. /* 174 */ , { 0 , 0 }
  328. /* 175 */ , { 0 , 0 }
  329. /* 176 */ , { 0 , 0 }
  330. /* 177 */ , { 0 , 0 }
  331. /* 178 */ , { 0 , 0 }
  332. /* 179 */ , { 0 , 0 }
  333. /* 180 */ , { 0 , 0 }
  334. /* 181 */ , { 0 , 0 }
  335. /* 182 */ , { 0 , 0 }
  336. #endif
  337. /* 183 */ , { ERROR_ALREADY_EXISTS , EEXIST }
  338. #if 0
  339. /* 184 */ , { 0 , 0 }
  340. /* 185 */ , { 0 , 0 }
  341. /* 186 */ , { 0 , 0 }
  342. /* 187 */ , { 0 , 0 }
  343. /* 188 */ , { 0 , 0 }
  344. /* 189 */ , { 0 , 0 }
  345. /* 190 */ , { 0 , 0 }
  346. /* 191 */ , { 0 , 0 }
  347. /* 192 */ , { 0 , 0 }
  348. /* 193 */ , { 0 , 0 }
  349. /* 194 */ , { 0 , 0 }
  350. /* 195 */ , { 0 , 0 }
  351. /* 196 */ , { 0 , 0 }
  352. /* 197 */ , { 0 , 0 }
  353. /* 198 */ , { 0 , 0 }
  354. /* 199 */ , { 0 , 0 }
  355. #endif
  356. /* 206 */ , { ERROR_FILENAME_EXCED_RANGE , ENAMETOOLONG }
  357. /* 215 */ , { ERROR_NESTING_NOT_ALLOWED , EAGAIN }
  358. /* 258 */ , { WAIT_TIMEOUT, ETIME}
  359. /* 267 */ , { ERROR_DIRECTORY , ENOTDIR }
  360. /* 336 */ , { ERROR_DIRECTORY_NOT_SUPPORTED , EISDIR }
  361. /* 996 */ , { ERROR_IO_INCOMPLETE , EAGAIN }
  362. /* 997 */ , { ERROR_IO_PENDING , EAGAIN }
  363. /* 1004 */ , { ERROR_INVALID_FLAGS , EINVAL }
  364. /* 1113 */ , { ERROR_NO_UNICODE_TRANSLATION , EINVAL }
  365. /* 1168 */ , { ERROR_NOT_FOUND , ENOENT }
  366. /* 1224 */ , { ERROR_USER_MAPPED_FILE , EACCES }
  367. /* 1314 */ , { ERROR_PRIVILEGE_NOT_HELD , EACCES }
  368. /* 1816 */ , { ERROR_NOT_ENOUGH_QUOTA , ENOMEM }
  369. , { ERROR_ABANDONED_WAIT_0 , EIO }
  370. /* 1464 */ , { ERROR_SYMLINK_NOT_SUPPORTED , EINVAL }
  371. /* 4390 */ , { ERROR_NOT_A_REPARSE_POINT , EINVAL }
  372. };
  373. for(i = 0; i < sizeof(errmap)/sizeof(struct code_to_errno_map); ++i)
  374. {
  375. if(w32Err == errmap[i].w32Err)
  376. {
  377. return errmap[i].eerrno;
  378. }
  379. }
  380. assert(!"Unrecognised value");
  381. return EINVAL;
  382. }/*}}}*/
  383. PHP_WINUTIL_API char *php_win32_get_username(void)
  384. {/*{{{*/
  385. wchar_t unamew[UNLEN + 1];
  386. size_t uname_len;
  387. char *uname;
  388. DWORD unsize = UNLEN;
  389. GetUserNameW(unamew, &unsize);
  390. uname = php_win32_cp_conv_w_to_any(unamew, unsize - 1, &uname_len);
  391. if (!uname) {
  392. return NULL;
  393. }
  394. /* Ensure the length doesn't overflow. */
  395. if (uname_len > UNLEN) {
  396. uname[uname_len] = '\0';
  397. }
  398. return uname;
  399. }/*}}}*/
  400. static zend_always_inline BOOL is_compatible(HMODULE handle, BOOL is_smaller, char *format, char **err)
  401. {/*{{{*/
  402. PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER) handle;
  403. PIMAGE_NT_HEADERS pNTHeader = (PIMAGE_NT_HEADERS)((char *) dosHeader + dosHeader->e_lfanew);
  404. DWORD major = pNTHeader->OptionalHeader.MajorLinkerVersion;
  405. DWORD minor = pNTHeader->OptionalHeader.MinorLinkerVersion;
  406. #if PHP_LINKER_MAJOR == 14
  407. /* VS 2015, 2017 and 2019 are binary compatible, but only forward compatible.
  408. It should be fine, if we load a module linked with an older one into
  409. the core linked with the newer one, but not the otherway round.
  410. Analogously, it should be fine, if a PHP build linked with an older version
  411. is used with a newer CRT, but not the other way round.
  412. Otherwise, if the linker major version is not same, it is an error, as
  413. per the current knowledge.
  414. This check is to be extended as new VS versions come out. */
  415. DWORD core_minor = (DWORD)(PHP_LINKER_MINOR/10);
  416. DWORD comp_minor = (DWORD)(minor/10);
  417. if (14 == major && (is_smaller ? core_minor < comp_minor : core_minor > comp_minor) || PHP_LINKER_MAJOR != major)
  418. #else
  419. if (PHP_LINKER_MAJOR != major)
  420. #endif
  421. {
  422. char buf[MAX_PATH];
  423. if (GetModuleFileName(handle, buf, sizeof(buf)) != 0) {
  424. spprintf(err, 0, format, buf, major, minor, PHP_LINKER_MAJOR, PHP_LINKER_MINOR);
  425. } else {
  426. spprintf(err, 0, "Can't retrieve the module name (error %u)", GetLastError());
  427. }
  428. return FALSE;
  429. }
  430. return TRUE;
  431. }/*}}}*/
  432. PHP_WINUTIL_API BOOL php_win32_image_compatible(HMODULE handle, char **err)
  433. {/*{{{*/
  434. return is_compatible(handle, TRUE, "Can't load module '%s' as it's linked with %u.%u, but the core is linked with %d.%d", err);
  435. }/*}}}*/
  436. /* Expect a CRT module handle */
  437. PHP_WINUTIL_API BOOL php_win32_crt_compatible(char **err)
  438. {/*{{{*/
  439. #if PHP_LINKER_MAJOR == 14
  440. /* Extend for other CRT if needed. */
  441. # if PHP_DEBUG
  442. const char *crt_name = "vcruntime140d.dll";
  443. # else
  444. const char *crt_name = "vcruntime140.dll";
  445. # endif
  446. HMODULE handle = GetModuleHandle(crt_name);
  447. if (handle == NULL) {
  448. spprintf(err, 0, "Can't get handle of module %s (error %u)", crt_name, GetLastError());
  449. return FALSE;
  450. }
  451. return is_compatible(handle, FALSE, "'%s' %u.%u is not compatible with this PHP build linked with %d.%d", err);
  452. #endif
  453. return TRUE;
  454. }/*}}}*/