xref: /PHP-8.2/win32/build/deplister.c (revision 01b3fc03)
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: Wez Furlong <wez@thebrainroom.com>                           |
14   +----------------------------------------------------------------------+
15 */
16 
17 /* This little application will list the DLL dependencies for a PE
18  * module to it's stdout for use by distro/installer building tools */
19 
20 #include <windows.h>
21 #include <stdio.h>
22 #include <imagehlp.h>
23 
StatusRoutine(IMAGEHLP_STATUS_REASON reason,PCSTR image_name,PCSTR dll_name,ULONG_PTR va,ULONG_PTR param)24 BOOL CALLBACK StatusRoutine(IMAGEHLP_STATUS_REASON reason,
25 		PCSTR image_name, PCSTR dll_name,
26 		ULONG_PTR va, ULONG_PTR param)
27 {
28 	switch (reason) {
29 		case BindImportModuleFailed:
30 			printf("%s,NOTFOUND\n", dll_name);
31 			return TRUE;
32 
33 		case BindImportModule:
34 			printf("%s,OK\n", dll_name);
35 			return TRUE;
36 	}
37 	return TRUE;
38 }
39 
40 /* usage:
41  * deplister.exe path\to\module.exe path\to\symbols\root
42  * */
43 
main(int argc,char * argv[])44 int main(int argc, char *argv[])
45 {
46 	return BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES,
47 		argv[1], NULL, argv[2], StatusRoutine);
48 }
49