mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.2.x] added: VS_FIXEDFILEINFO structure for a module
git-svn-id: https://pykd.svn.codeplex.com/svn@87133 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
d4b38e40cb
commit
222515e191
@ -70,6 +70,35 @@ bool isModuleUserMode( ULONG64 baseOffset );
|
||||
std::string getModuleVersionInfo( ULONG64 baseOffset, const std::string &value );
|
||||
void getModuleFileVersion( ULONG64 baseOffset, USHORT &majorHigh, USHORT &majorLow, USHORT &minorHigh, USHORT &minorLow );
|
||||
|
||||
struct FixedFileInfo : protected boost::noncopyable {
|
||||
DWORD Signature;
|
||||
DWORD StrucVersion;
|
||||
DWORD FileVersionMS;
|
||||
DWORD FileVersionLS;
|
||||
DWORD ProductVersionMS;
|
||||
DWORD ProductVersionLS;
|
||||
DWORD FileFlagsMask;
|
||||
DWORD FileFlags;
|
||||
DWORD FileOS;
|
||||
DWORD FileType;
|
||||
DWORD FileSubtype;
|
||||
DWORD FileDateMS;
|
||||
DWORD FileDateLS;
|
||||
|
||||
FixedFileInfo(ULONG64 baseOffset);
|
||||
};
|
||||
typedef boost::shared_ptr< FixedFileInfo > FixedFileInfoPtr;
|
||||
|
||||
enum FileFlag
|
||||
{
|
||||
FileFlagDebug = 0x00000001,
|
||||
FileFlagPreRelease = 0x00000002,
|
||||
FileFlagPatched = 0x00000004,
|
||||
FileFlagPrivateBuild = 0x00000008,
|
||||
FileFlagInfoInferred = 0x00000010,
|
||||
FileFlagSpecialBuild = 0x00000020,
|
||||
};
|
||||
|
||||
// CPU registers
|
||||
ULONG getRegIndexByName( const std::string ®Name );
|
||||
std::string getRegNameByIndex( ULONG index );
|
||||
|
@ -431,4 +431,10 @@ python::tuple Module::getVersion()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FixedFileInfoPtr Module::getFixedFileInfo() {
|
||||
return FixedFileInfoPtr( new FixedFileInfo(m_base) );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}; // end of namespace pykd
|
||||
|
@ -128,6 +128,8 @@ public:
|
||||
|
||||
python::tuple getVersion();
|
||||
|
||||
boost::shared_ptr< struct FixedFileInfo > getFixedFileInfo();
|
||||
|
||||
private:
|
||||
void completeConstruct(); // call from ctor
|
||||
|
||||
|
@ -380,6 +380,44 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
python::implicitly_convertible<intBase,ULONG>();
|
||||
python::implicitly_convertible<intBase,LONG>();
|
||||
|
||||
python::class_<FixedFileInfo, FixedFileInfoPtr, boost::noncopyable>( "FixedFileInfo",
|
||||
"Version information for a file", python::no_init )
|
||||
.def_readonly( "Signature", &FixedFileInfo::Signature,
|
||||
"Contains the value 0xFEEF04BD" )
|
||||
.def_readonly( "StrucVersion", &FixedFileInfo::StrucVersion,
|
||||
"The binary version number of this structure" )
|
||||
.def_readonly( "FileVersionMS", &FixedFileInfo::FileVersionMS,
|
||||
"The most significant 32 bits of the file's binary version number" )
|
||||
.def_readonly( "FileVersionLS", &FixedFileInfo::FileVersionLS,
|
||||
"The least significant 32 bits of the file's binary version number" )
|
||||
.def_readonly( "ProductVersionMS", &FixedFileInfo::ProductVersionMS,
|
||||
"The most significant 32 bits of the binary version number of the product with which this file was distributed" )
|
||||
.def_readonly( "ProductVersionLS", &FixedFileInfo::ProductVersionLS,
|
||||
"The least significant 32 bits of the binary version number of the product with which this file was distributed" )
|
||||
.def_readonly( "FileFlagsMask", &FixedFileInfo::FileFlagsMask,
|
||||
"Contains a bitmask that specifies the valid bits in FileFlags" )
|
||||
.def_readonly( "FileFlags", &FixedFileInfo::FileFlags,
|
||||
"Contains a bitmask that specifies the Boolean attributes of the file: FileFlag" )
|
||||
.def_readonly( "FileOS", &FixedFileInfo::FileOS,
|
||||
"The operating system for which this file was designed" )
|
||||
.def_readonly( "FileType", &FixedFileInfo::FileType,
|
||||
"The general type of file" )
|
||||
.def_readonly( "FileSubtype", &FixedFileInfo::FileSubtype,
|
||||
"The function of the file. The possible values depend on the value of FileType" )
|
||||
.def_readonly( "FileDateMS", &FixedFileInfo::FileDateMS,
|
||||
"The most significant 32 bits of the file's 64-bit binary creation date and time stamp" )
|
||||
.def_readonly( "FileDateLS", &FixedFileInfo::FileDateLS,
|
||||
"The least significant 32 bits of the file's 64-bit binary creation date and time stamp" );
|
||||
|
||||
python::enum_<FileFlag>("FileFlag", "Attributes of the file")
|
||||
.value("Debug", FileFlagDebug)
|
||||
.value("PreRelease", FileFlagPreRelease)
|
||||
.value("Patched", FileFlagPatched)
|
||||
.value("PrivateBuild", FileFlagPrivateBuild)
|
||||
.value("InfoInferred", FileFlagInfoInferred)
|
||||
.value("SpecialBuild", FileFlagSpecialBuild)
|
||||
.export_values();
|
||||
|
||||
python::class_<Module, ModulePtr, python::bases<intBase> >("module", "Class representing executable module", python::no_init )
|
||||
.def("__init__", python::make_constructor(Module::loadModuleByName) )
|
||||
.def("__init__", python::make_constructor(Module::loadModuleByOffset) )
|
||||
@ -440,6 +478,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Return string from the module's version resources" )
|
||||
.def("getVersion", &Module::getVersion,
|
||||
"Return tuple of the module's file version" )
|
||||
.def("getFixedFileInfo", &Module::getFixedFileInfo,
|
||||
"Return FixedFileInfo" )
|
||||
.def("__getattr__", &Module::getSymbolOffset,
|
||||
"Return address of the symbol" )
|
||||
.def( "__str__", &Module::print );
|
||||
@ -592,8 +632,6 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
.def( "__str__", &ExceptionInfo::print,
|
||||
"Return object as a string");
|
||||
|
||||
|
||||
|
||||
python::enum_<EVENT_TYPE>("eventType", "Type of debug event")
|
||||
.value("Breakpoint", EventTypeBreakpoint)
|
||||
.value("Exception", EventTypeException)
|
||||
|
@ -410,6 +410,39 @@ std::string getModuleVersionInfo( ULONG64 baseOffset, const std::string &value )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FixedFileInfo::FixedFileInfo(ULONG64 baseOffset)
|
||||
{
|
||||
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||
|
||||
VS_FIXEDFILEINFO Pod;
|
||||
HRESULT hres =
|
||||
g_dbgEng->symbols->GetModuleVersionInformation(
|
||||
DEBUG_ANY_ID,
|
||||
baseOffset,
|
||||
"\\",
|
||||
&Pod,
|
||||
sizeof(Pod),
|
||||
NULL );
|
||||
if ( hres != S_OK )
|
||||
throw DbgException("IDebugSymbols::GetModuleVersionInformation", hres);
|
||||
|
||||
Signature = Pod.dwSignature;
|
||||
StrucVersion = Pod.dwStrucVersion;
|
||||
FileVersionMS = Pod.dwFileVersionMS;
|
||||
FileVersionLS = Pod.dwFileVersionLS;
|
||||
ProductVersionMS = Pod.dwProductVersionMS;
|
||||
ProductVersionLS = Pod.dwProductVersionLS;
|
||||
FileFlagsMask = Pod.dwFileFlagsMask;
|
||||
FileFlags = Pod.dwFileFlags;
|
||||
FileOS = Pod.dwFileOS;
|
||||
FileType = Pod.dwFileType;
|
||||
FileSubtype = Pod.dwFileSubtype;
|
||||
FileDateMS = Pod.dwFileDateMS;
|
||||
FileDateLS = Pod.dwFileDateLS;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace pykd
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user