xref: /PHP-7.4/win32/build/deplister.c (revision 92ac598a)
103d426f6SWez Furlong /*
203d426f6SWez Furlong   +----------------------------------------------------------------------+
3d0cb7153SJohannes Schlüter   | PHP Version 7                                                        |
403d426f6SWez Furlong   +----------------------------------------------------------------------+
5*0cf7de1cSZeev Suraski   | Copyright (c) The PHP Group                                          |
603d426f6SWez Furlong   +----------------------------------------------------------------------+
75bd93221Sfoobar   | This source file is subject to version 3.01 of the PHP license,      |
803d426f6SWez Furlong   | that is bundled with this package in the file LICENSE, and is        |
903d426f6SWez Furlong   | available through the world-wide-web at the following url:           |
105bd93221Sfoobar   | http://www.php.net/license/3_01.txt                                  |
1103d426f6SWez Furlong   | If you did not receive a copy of the PHP license and are unable to   |
1203d426f6SWez Furlong   | obtain it through the world-wide-web, please send a note to          |
1303d426f6SWez Furlong   | license@php.net so we can mail you a copy immediately.               |
1403d426f6SWez Furlong   +----------------------------------------------------------------------+
1503d426f6SWez Furlong   | Author: Wez Furlong <wez@thebrainroom.com>                           |
1603d426f6SWez Furlong   +----------------------------------------------------------------------+
1703d426f6SWez Furlong */
1803d426f6SWez Furlong 
1903d426f6SWez Furlong /* This little application will list the DLL dependencies for a PE
2003d426f6SWez Furlong  * module to it's stdout for use by distro/installer building tools */
2103d426f6SWez Furlong 
2203d426f6SWez Furlong #include <windows.h>
230a173501SKalle Sommer Nielsen #include <stdio.h>
2403d426f6SWez Furlong #include <imagehlp.h>
2503d426f6SWez Furlong 
StatusRoutine(IMAGEHLP_STATUS_REASON reason,PSTR image_name,PSTR dll_name,ULONG va,ULONG param)2603d426f6SWez Furlong BOOL CALLBACK StatusRoutine(IMAGEHLP_STATUS_REASON reason,
2703d426f6SWez Furlong 		PSTR image_name, PSTR dll_name,
2803d426f6SWez Furlong 		ULONG va, ULONG param)
2903d426f6SWez Furlong {
3003d426f6SWez Furlong 	switch (reason) {
3103d426f6SWez Furlong 		case BindImportModuleFailed:
3203d426f6SWez Furlong 			printf("%s,NOTFOUND\n", dll_name);
3303d426f6SWez Furlong 			return TRUE;
3403d426f6SWez Furlong 
3503d426f6SWez Furlong 		case BindImportModule:
3603d426f6SWez Furlong 			printf("%s,OK\n", dll_name);
3703d426f6SWez Furlong 			return TRUE;
3803d426f6SWez Furlong 	}
3903d426f6SWez Furlong 	return TRUE;
4003d426f6SWez Furlong }
4103d426f6SWez Furlong 
4203d426f6SWez Furlong /* usage:
4303d426f6SWez Furlong  * deplister.exe path\to\module.exe path\to\symbols\root
4403d426f6SWez Furlong  * */
4503d426f6SWez Furlong 
main(int argc,char * argv[])4603d426f6SWez Furlong int main(int argc, char *argv[])
4703d426f6SWez Furlong {
4803d426f6SWez Furlong 	return BindImageEx(BIND_NO_BOUND_IMPORTS | BIND_NO_UPDATE | BIND_ALL_IMAGES,
49b7a7b1a6SStanislav Malyshev 		argv[1], NULL, argv[2], StatusRoutine);
5003d426f6SWez Furlong }