下载链接: https://pan.baidu.com/s/1CWcoPXg889km_15G4uobdQ?pwd=1qbr
这次编译的体积只有5KB,且不依赖任何多余DLL,是同类命令行工具中功能最强,速度最快,体积最小的。
下载pdll增强版链接: https://pan.baidu.com/s/1SGHgBSC8LfmOtq7y7UHVSg?pwd=adwa
增强版携带极为强悍之功能,可在32位系统下直接查看64位exe或dll文件的依赖关系和导入导出函数表,增强版用法源码不再贴出。
版本:
PDLL.EXE VERSION 1.0 (DLLS DEPEND ON TOOL, BY HAPPY)(外链图,随时失效)
摘要:
=====================================================
PDLL.EXE 查询、复制可执行模块DLL依赖。对EXE、DLL后缀的文件均可分析DLL依赖,并
且智能的分析DLL的必需性,有选择的复制依赖DLL到被查询文件目录。已兼容XP、WIN7、
WIN8.1等WIN系统,复制的兼容性可以达到在微小WINPE系统中正常运行。 代码做了非常
严密的逻辑判断,让依赖性分析更加智能。纯C语言书写,本工具不依赖任何DLL。
=====================================================
用法:
查询DLL依赖
PDLL [要查询的可执行文件名]
复制DLL依赖
PDLL /C [要查询的可执行文件名]
演示一:
查看QQ.EXE的DLL依赖情况
演示二:
复制KERNEL32.DLL的底层API依赖
源码:- /*
- CONSOLE DLLS DEPEND ON TOOL, COPYRIGHT@2017~2019 BY HAPPY, VERSION 1.0
- PDLL.EXE
- */
-
- #include <io.h>
- #include <stdio.h>
- #include <windows.h>
-
- //定义容器安全长度
- #define _SAFE_SIZE 512
-
- //系统必需DLL列表
- static LPCSTR SYSTEM_DLLS[]= {"aclui", "activeds", "adsldpc", "advapi32", "apphelp", "atl", "authz", "basesrv", "batmeter", "cabinet", "cfgmgr32", "clb", "comdlg32", "crypt32", "cryptdll", "cryptui", "csrsrv", "devmgr", "diskcopy", "dmdlgs", "dmdskmgr", "dmdskres", "dmintf", "dmocx", "dmutil", "dnsapi", "duser", "filemgmt", "fmifs", "gdi32", "hal", "halmacpi", "hhsetup", "ifsutil", "imagehlp", "imm32", "kdcom", "kernel32", "lpk", "lsasrv", "mfc42u", "mmcbase", "mmcndmgr", "mmcshext", "mpr", "msasn1", "msimg32", "msprivs", "msv1_0", "msvcp60", "msvcrt", "msvfw32", "mycomput", "ncobjapi", "netapi32", "ntdll", "ntdsapi", "ntmarta", "odbc32", "odbcbcp", "ole32", "oleacc", "oleaccrc", "oleaut32", "oledlg", "olepro32", "osuninst", "pdh", "powrprof", "psapi", "rpcrt4", "rpcss", "rsaenh", "rshx32", "samlib", "samsrv", "scesrv", "secur32", "setupapi", "shdocvw", "shell32", "shfolder", "shlwapi", "srvsvc", "stobject", "sxs", "uexfat", "ufat", "ulib", "umpnpmgr", "untfs", "urlmon", "user32", "userenv", "usp10", "uxtheme", "version", "wimgapi", "wininet", "winmm", "winsrv", "winsta", "wintrust", "ws2_32", "wsock32", NULL};
-
- //定义帮助说明
- #define HELP_INFORMATION "\
- pdll version 1.0 - Console DLLS depend on tool - Copyright (C) 2017-2019\n\
- Usage: pdll [options] [file] ...\n\
- \n\
- General options:\n\
- List all depends on dlls name\n\
- /C Copy all depends on dlls to current file\n\
- \n\
- Official website:\n\
- http://www.bathome.net/thread-44056-1-1.html\n"
-
- //字符串转大写
- LPCSTR LPCSTR2UPR(LPCSTR instr, LPSTR ostr)
- {
- LPSTR cp=(LPSTR)instr, op=ostr;
- while(*cp)
- {
- *op=('a'<=*cp && *cp<='z')?*cp-32:*cp, cp++, op++;
- }
- *op='\0';
- return (LPCSTR)ostr;
- }
-
- //识别必需DLL
- int ItifyWords(LPCSTR strARGV)
- {
- int i, SN;
- for(SN=0; SYSTEM_DLLS[SN]; SN++)
- {
- LPSTR op=(LPSTR)strARGV, kp=(LPSTR)SYSTEM_DLLS[SN];
- while(*op!='.' && *kp!='\0')
- {
- if( (('a'<= *op && *op<='z')?*op-32:*op) != (('a'<= *kp && *kp<='z')?*kp-32:*kp) )
- {
- break;
- }
- op++, kp++;
- }
- if(*op=='.' && *kp=='\0')
- {
- return SN;
- }
- }
- return -1;
- }
-
- //获取DLL依赖
- int GetDependDlls(HMODULE hMOD, LPCSTR pePATH, BOOL peMODE)
- {
- IMAGE_DOS_HEADER* imageDosHeader = (IMAGE_DOS_HEADER*)hMOD;
- IMAGE_OPTIONAL_HEADER * imageOptionalHeader = (IMAGE_OPTIONAL_HEADER*)((BYTE*)hMOD + imageDosHeader->e_lfanew +24);
- IMAGE_IMPORT_DESCRIPTOR* imageImportDescriptor = (IMAGE_IMPORT_DESCRIPTOR*) ((BYTE*)hMOD + imageOptionalHeader->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
-
- LPSTR srcDllPath = (LPSTR)malloc(_SAFE_SIZE);
- LPSTR copyDllPath = (LPSTR)malloc(_SAFE_SIZE);
- LPSTR touprStrTain = (LPSTR)malloc(_SAFE_SIZE);
-
- while(imageImportDescriptor->FirstThunk)
- {
- LPSTR dllNAME = (LPSTR)((BYTE*)hMOD + imageImportDescriptor->Name);
- HMODULE hdMOD = LoadLibraryExA(dllNAME, NULL, DONT_RESOLVE_DLL_REFERENCES);
-
- if(hdMOD != 0)
- {
- GetModuleFileNameA(hdMOD, srcDllPath, _SAFE_SIZE);
- }
- else
- {
- *srcDllPath='\0';
- }
-
- if(peMODE)
- {
- if(ItifyWords(dllNAME) == -1)
- {
- sprintf(copyDllPath, "%s\\%s", pePATH, dllNAME);
-
- //判断DLL是否存在,不存在则复制
- if(_access(copyDllPath, F_OK) != 0)
- {
- if(*srcDllPath && CopyFileA(srcDllPath, copyDllPath, TRUE))
- {
- fprintf(stdout, "Copy... \"%s\" succeed\n", LPCSTR2UPR(dllNAME, touprStrTain));
- }
- else
- {
- fprintf(stdout, "Copy... \"%s\" failed\n", LPCSTR2UPR(dllNAME, touprStrTain));
- }
- }
- }
- }
- else
- {
- if(strlen(dllNAME) >18)
- {
- //打印API名称
- fprintf(stdout, "%s\n", LPCSTR2UPR(dllNAME, touprStrTain));
- }
- else
- {
- //打印DLL名称
- fprintf(stdout, "%-16.16s ", LPCSTR2UPR(dllNAME, touprStrTain));
-
- //打印DLL路径
- fprintf(stderr, "%s\n", LPCSTR2UPR(srcDllPath, touprStrTain));
- }
- }
-
- FreeLibrary(hdMOD);
- imageImportDescriptor++;
- }
-
- free(srcDllPath);
- free(copyDllPath);
- free(touprStrTain);
-
- return 0;
- }
-
- //MAIN主函数入口
- int main(int argc, char* argv[])
- {
- //参数不足,抛出使用说明
- if(argc <= 1)
- {
- fputs(HELP_INFORMATION, stdout);
- return 1;
- }
-
- //获取查询模式
- BOOL pdMODE = (stricmp(argv[1], "/C")==0) ?TRUE :FALSE;
-
- //缺少必要参数,抛出错误
- if(pdMODE && argc==2)
- {
- fputs("Needs executable file\n", stdout);
- return 1;
- }
-
- //获取可执行文件名
- LPSTR peFILE = (pdMODE) ?(LPSTR)argv[2] :(LPSTR)argv[1];
-
- if(_access(peFILE, F_OK) != 0)
- {
- fprintf(stdout, "The file \"%s\" is not exists\n", peFILE);
- return 1;
- }
-
- //仅装在DLL,而不初始化
- HMODULE hMOD = LoadLibraryExA(peFILE, NULL, DONT_RESOLVE_DLL_REFERENCES);
- if(hMOD == 0)
- {
- //加载模块失败,显示错误信息
- fprintf(stderr, "Failed to load executable file \"%s\"\n", peFILE);
- return 2;
- }
-
- //获取可执行文件路径
- LPSTR lp = strrchr(peFILE, '\\');
- LPSTR pePATH = (lp==NULL) ?(LPSTR)".\\" :(*lp='\0', peFILE);
-
- //打印可执行文件名
- //fprintf(stderr, "File Name: %s\n", peFILE);
-
- //执行DLL依赖查询
- GetDependDlls(hMOD, pePATH, pdMODE);
-
- //释放装载模块
- FreeLibrary(hMOD);
-
- return 0;
- }
复制代码
|