명령행 도구를 덤프 Windows DLL version?
-
03-07-2019 - |
문제
내가 필요로 명령행 도구를 덤프 표준 DLL Windows 버전 정보할 수 있도록 프로세스에 의해 그것을 강타 스크립트(Cygwin).
으로 자바 개발자에게 사용하여 Microsoft 개발 도구(긴 했지만 약간의 경험으로 Microsoft Visual 포함된 C++4.0Microsoft Visual Basic6.0).
적절한 도구가 될 것으로 보인 mt.exe, 로 에 명시된 그래서.그러나 유일한 기회는 내가 발견이 작은 응용 프로그램을 다운로드하는 것입 1.29GB ISO 의 Windows SDK 를 윈도우 서버 2008.NET Framework.내가 믿을 수 없다 이러한 방식으로만 그것을 할 수 있습니다.
나 또한 작은 응용 프로그램이 인터넷에서 불 PEView, 지만,그것을 표시합 너무 많(고 쓸모 없는 나의 케이스에서)정보 및 그것은 명령이 아니라 줄 응용 프로그램입니다.
준 objdump 내장되 Cygwin 할 수 있도 덤프에 대한 일부 정보를 DLL 파일이 있지만 나는 볼 수 없는 옵션을 덤프 DLL 버전입니다.Note MajorImageVersion,MinorImageVersion 및 다른 분야에 의해 버려진 이 도구(옵션)과 관련되지 않은 자신의 DLL 버전입니다.
어떤 대안에 대해 무엇을 할까?어쩌면 나는 몇 가지 중요한 objdump 옵션?가 mt.exe 나의 유일한 선택입니까?이 경우,가능한 그것은 그것을 얻을 별도로 윈도우에서 SDK?
해결책
도 볼 수 있습니다 filever.exe 다운로드할 수 있는 부분으로 Windows XP SP2 를 지원 도구 패키지-4.7MB 다운로드합니다.
다른 팁
당신이 사용할 수 있습 PowerShell 를 얻을 당신이 원하는 정보.
(Get-Item C:\Path\To\MyFile.dll).VersionInfo
기본적으로 표시됩니다 ProductVersion 및 FileVersion 그러나 전체 VERSIONINFO 사용할 수 있습니다.I.e.을 반환 댓글
(Get-Item C:\Path\To\MyFile.dll).VersionInfo.Comments
사 Microsoft Sysinternals Sigcheck.이 샘플에서 출력 그냥 버전:
sigcheck -q -n foo.dll
압축을 푼 sigcheck.exe 만 228KB 입니다.
를 작성할 수 있습니다 VBScript 스크립트 파일을 얻을 수있는 버전 정보:
VersionInfo.vbs
set args = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
WScript.Echo fso.GetFileVersion(args(0))
Wscript.Quit
호출할 수 있는 이 명령행에서 다음과 같다:
cscript //nologo VersionInfo.vbs C:\Path\To\MyFile.dll
거나 구축할 수 있습니다.VS 열기를 만들고,새로운 콘솔 응용 프로그램입니다.간단한 프로젝트 만들기 없 ATL 또는 MFC 지원을 떠나 stdafx 옵션을 검사하지만 확인하지 않는'빈 프로젝트는'그리고 전화 VersionInfo.
당신은 간단한 프로젝트 2 파일:VersionInfo.cpp 고 VersionInfo.h
열 cpp 파일에 다음을 복사하여 붙여넣으로,그것을 컴파일.를 실행할 수 있도록,처음 인수는 전체 파일명을,그것을 인쇄할 "제품:5.6.7.8File:1.2.3.4" 기반 버전에 자원을 차단합니다.이 없는 경우 버전원 것-1 을 반환,그렇지 않으면 0.
로 컴파일되 8k 바이너리를 사용하여 dll CRT,60k 모든 것을 정적으로 링크된(설정에서는 C++옵션에는 변경"코드를 생성,페이지 옵션 런타임"을"/MT")
HTH.
PS.당신이 원하지 않는 경우 Visual Studio 를 사용하여,그것은 아직도 컴파일을 사용하여 c++컴파일러(손가락을 넘어),하지만 당신은 거의 확실하게 변경#pragma-지정 lib 링커에서 설정을 대신 pragma 의 속기를 자동으로 링크와 함께하는 라이브러리입니다.
// VersionInfo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#pragma comment(lib, "version.lib")
int _tmain(int argc, _TCHAR* argv[])
{
DWORD handle = 0;
DWORD size = GetFileVersionInfoSize(argv[1], &handle);
BYTE* versionInfo = new BYTE[size];
if (!GetFileVersionInfo(argv[1], handle, size, versionInfo))
{
delete[] versionInfo;
return -1;
}
// we have version information
UINT len = 0;
VS_FIXEDFILEINFO* vsfi = NULL;
VerQueryValue(versionInfo, L"\\", (void**)&vsfi, &len);
WORD fVersion[4], pVersion[4];
fVersion[0] = HIWORD(vsfi->dwFileVersionMS);
fVersion[1] = LOWORD(vsfi->dwFileVersionMS);
fVersion[2] = HIWORD(vsfi->dwFileVersionLS);
fVersion[3] = LOWORD(vsfi->dwFileVersionLS);
pVersion[0] = HIWORD(vsfi->dwProductVersionMS);
pVersion[1] = LOWORD(vsfi->dwProductVersionMS);
pVersion[2] = HIWORD(vsfi->dwProductVersionLS);
pVersion[3] = LOWORD(vsfi->dwProductVersionLS);
printf("Product: %d.%d.%d.%d File: %d.%d.%d.%d\n",
pVersion[0], pVersion[1],
pVersion[2], pVersion[3],
fVersion[0], fVersion[1],
fVersion[2], fVersion[3]);
delete[] versionInfo;
return 0;
}
C:\>wmic datafile where name="C:\\Windows\\System32\\kernel32.dll" get version
Version
6.1.7601.18229
이 listdlls 에서 도구를 Systernals 할 수 있는 일: http://technet.microsoft.com/en-us/sysinternals/bb896656.aspx
listdlls -v -d mylib.dll
이 기능을 반환합니다 ntfs Windows 파일에 대해 자세한 정보를 사용하여 파일 Cygwin bash(실제 r-클릭 속성-정보)하기
통과하는 파일의 경로를 finfo(),될 수 있는 유닉스 경로,dos 경로,상대 또는 절대적이다.파일 변환로 절대적인 유닉스 경로,그 확인을 보면 그것은에-실제로 정기적/기존 파일을 변경할 수 있습니다.다음으로는 절대 windows 경로로 전송"wmic".그런 다음 마법,windows 파일의 세부 사항 오른쪽에서 터미널도 있습니다.를 사용:cygwin,cygpath,sed 및 awk.구 Windows WMI"wmic.exe"을 운용합니다.출력 수정을 위한 쉬운...
$ finfo notepad.exe
$ finfo "C:\windows\system32\notepad.exe"
$ finfo /cygdrive/c/Windows/System32/notepad.exe
$ finfo "/cygdrive/c/Program Files/notepad.exe"
$ finfo ../notepad.exe
finfo() {
[[ -e "$(cygpath -wa "$@")" ]] || { echo "bad-file"; return 1; }
echo "$(wmic datafile where name=\""$(echo "$(cygpath -wa "$@")" | sed 's/\\/\\\\/g')"\" get /value)" |\
sed 's/\r//g;s/^M$//;/^$/d' | awk -F"=" '{print $1"=""\033[1m"$2"\033[0m" }'
}
Powershell 을 사용하여 그것은 그냥 버전 문자열을,즉2.3.4 에서 어떤 dll 또는 exe 다음과 같은 명령
(Get-Item "C:\program files\OpenVPN\bin\openvpn.exe").VersionInfo.ProductVersion
테스트 Windows10
가 명령 라인 응용 프로그램"이라고 ShowVer"에 CodeProject:
ShowVer.exe 명령줄 VERSIONINFO 디스플레이 프로그램
평소와 같이 응용 프로그램을 함께 제공됩신의 소스 코드(visual c++6).
밖으로 출력한 메타 데이터를 사용:
독일 Win7 시스템에 대한 출력 user32.dll 는 다음과 같습니다:
VERSIONINFO for file "C:\Windows\system32\user32.dll": (type:0)
Signature: feef04bd
StrucVersion: 1.0
FileVersion: 6.1.7601.17514
ProductVersion: 6.1.7601.17514
FileFlagsMask: 0x3f
FileFlags: 0
FileOS: VOS_NT_WINDOWS32
FileType: VFT_DLL
FileDate: 0.0
LangID: 040704B0
CompanyName : Microsoft Corporation
FileDescription : Multi-User Windows USER API Client DLL
FileVersion : 6.1.7601.17514 (win7sp1_rtm.101119-1850)
InternalName : user32
LegalCopyright : ® Microsoft Corporation. Alle Rechte vorbehalten.
OriginalFilename : user32
ProductName : Betriebssystem Microsoft« Windows«
ProductVersion : 6.1.7601.17514
Translation: 040704b0
하나의 방법으로 makecab
:
; @echo off
;;goto :end_help
;;setlocal DsiableDelayedExpansion
;;;
;;;
;;; fileinf /l list of full file paths separated with ;
;;; fileinf /f text file with a list of files to be processed ( one on each line )
;;; fileinf /? prints the help
;;;
;;:end_help
; REM Creating a Newline variable (the two blank lines are required!)
; set NLM=^
; set NL=^^^%NLM%%NLM%^%NLM%%NLM%
; if "%~1" equ "/?" type "%~f0" | find ";;;" | find /v "find" && exit /b 0
; if "%~2" equ "" type "%~f0" | find ";;;" | find /v "find" && exit /b 0
; setlocal enableDelayedExpansion
; if "%~1" equ "/l" (
; set "_files=%~2"
; echo !_files:;=%NL%!>"%TEMP%\file.paths"
; set _process_file="%TEMP%\file.paths"
; goto :get_info
; )
; if "%~1" equ "/f" if exist "%~2" (
; set _process_file="%~2"
; goto :get_info
; )
; echo incorect parameters & exit /b 1
; :get_info
; set "file_info="
; makecab /d InfFileName=%TEMP%\file.inf /d "DiskDirectory1=%TEMP%" /f "%~f0" /f %_process_file% /v0>nul
; for /f "usebackq skip=4 delims=" %%f in ("%TEMP%\file.inf") do (
; set "file_info=%%f"
; echo !file_info:,=%nl%!
; )
; endlocal
;endlocal
; del /q /f %TEMP%\file.inf 2>nul
; del /q /f %TEMP%\file.path 2>nul
; exit /b 0
.set DoNotCopyFiles=on
.set DestinationDir=;
.set RptFileName=nul
.set InfFooter=;
.set InfHeader=;
.Set ChecksumWidth=8
.Set InfDiskLineFormat=;
.Set Cabinet=off
.Set Compress=off
.Set GenerateInf=ON
.Set InfDiskHeader=;
.Set InfFileHeader=;
.set InfCabinetHeader=;
.Set InfFileLineFormat=",file:*file*,date:*date*,size:*size*,csum:*csum*,time:*time*,vern:*ver*,vers:*vers*,lang:*lang*"
예 출력(이것은 문자열을 가지고 있는 작은 외 wmic 방법:)):
c:> fileinfo.bat /l C:\install.exe
file:install.exe
date:11/07/07
size:562688
csum:380ef239
time:07:03:18a
vern:9.0.21022.8
vers:9.0.21022.8 built by: RTM
lang:1033
그리고 하나 더 사용 쉘입니다.응용 프로그램 와 하이브리드 배치\jscript.기 tooptipInfo.bat :
@if (@X)==(@Y) @end /* JScript comment
@echo off
rem :: the first argument is the script name as it will be used for proper help message
cscript //E:JScript //nologo "%~f0" %*
exit /b %errorlevel%
@if (@X)==(@Y) @end JScript comment */
//////
FSOObj = new ActiveXObject("Scripting.FileSystemObject");
var ARGS = WScript.Arguments;
if (ARGS.Length < 1 ) {
WScript.Echo("No file passed");
WScript.Quit(1);
}
var filename=ARGS.Item(0);
var objShell=new ActiveXObject("Shell.Application");
/////
//fso
ExistsItem = function (path) {
return FSOObj.FolderExists(path)||FSOObj.FileExists(path);
}
getFullPath = function (path) {
return FSOObj.GetAbsolutePathName(path);
}
//
//paths
getParent = function(path){
var splitted=path.split("\\");
var result="";
for (var s=0;s<splitted.length-1;s++){
if (s==0) {
result=splitted[s];
} else {
result=result+"\\"+splitted[s];
}
}
return result;
}
getName = function(path){
var splitted=path.split("\\");
return splitted[splitted.length-1];
}
//
function main(){
if (!ExistsItem(filename)) {
WScript.Echo(filename + " does not exist");
WScript.Quit(2);
}
var fullFilename=getFullPath(filename);
var namespace=getParent(fullFilename);
var name=getName(fullFilename);
var objFolder=objShell.NameSpace(namespace);
var objItem=objFolder.ParseName(name);
//https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx
WScript.Echo(fullFilename + " : ");
WScript.Echo(objFolder.GetDetailsOf(objItem,-1));
}
main();
에 대해 사용 cmd.exe :
C:\Windows\System32\cmd.exe :
File description: Windows Command Processor
Company: Microsoft Corporation
File version: 6.3.9600.16384
Date created: ?22-?Aug-?13 ??13:03
Size: 347 KB