xref: /PHP-7.3/win32/build/deplister.c (revision 8d3f8ca1)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 1997-2018 The PHP Group                                |
6   +----------------------------------------------------------------------+
7   | This source file is subject to version 3.01 of the PHP license,      |
8   | that is bundled with this package in the file LICENSE, and is        |
9   | available through the world-wide-web at the following url:           |
10   | http://www.php.net/license/3_01.txt                                  |
11   | If you did not receive a copy of the PHP license and are unable to   |
12   | obtain it through the world-wide-web, please send a note to          |
13   | license@php.net so we can mail you a copy immediately.               |
14   +----------------------------------------------------------------------+
15   | Author: Wez Furlong <wez@thebrainroom.com>                           |
16   +----------------------------------------------------------------------+
17 */
18 
19 /* This little application will list the DLL dependencies for a PE
20  * module to it's stdout for use by distro/installer building tools */
21 
22 #include <windows.h>
23 #include <stdio.h>
24 #include <imagehlp.h>
25 
StatusRoutine(IMAGEHLP_STATUS_REASON reason,PSTR image_name,PSTR dll_name,ULONG va,ULONG param)26 BOOL CALLBACK StatusRoutine(IMAGEHLP_STATUS_REASON reason,
27 		PSTR image_name, PSTR dll_name,
28 		ULONG va, ULONG param)
29 {
30 	switch (reason) {
31 		case BindImportModuleFailed:
32 			printf("%s,NOTFOUND\n", dll_name);
33 			return TRUE;
34 
35 		case BindImportModule:
36 			printf("%s,OK\n", dll_name);
37 			return TRUE;
38 	}
39 	return TRUE;
40 }
41 
42 /* usage:
43  * deplister.exe path\to\module.exe path\to\symbols\root
44  * */
45 
main(int argc,char * argv[])46 int main(int argc, char *argv[])
47 {
48 	return BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES,
49 		argv[1], NULL, argv[2], StatusRoutine);
50 }
51 
52 /*
53  * Local variables:
54  * tab-width: 4
55  * c-basic-offset: 4
56  * End:
57  * vim600: noet sw=4 ts=4 fdm=marker
58  * vim<600: noet sw=4 ts=4
59  */
60