xref: /PHP-7.4/win32/build/deplister.c (revision 92ac598a)
1 /*
2   +----------------------------------------------------------------------+
3   | PHP Version 7                                                        |
4   +----------------------------------------------------------------------+
5   | Copyright (c) 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