From d946db623c3b0fe383593b57218108e1eb9de8db Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Mon, 27 Jan 2014 10:38:29 +0000 Subject: [PATCH] [0.3.x] added : version_info for module git-svn-id: https://pykd.svn.codeplex.com/svn@87162 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/pymod.cpp | 45 +++++++++++++++++++++++++++++++++++++++++---- pykd/pymodule.cpp | 12 ++++++++++++ pykd/pymodule.h | 9 +++++++++ 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 0e9c640..d1f321f 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -489,10 +489,10 @@ BOOST_PYTHON_MODULE( pykd ) "Returns a flag that the module was unloaded" ) .def("um", ModuleAdapter::isUserMode, "Returns a flag that the module is a user-mode module" ) - //.def("queryVersion", &Module::queryVersion, - // "Return string from the module's version resources" ) - //.def("getVersion", &Module::getVersion, - // "Return tuple of the module's file version" ) + .def("queryVersion", ModuleAdapter::getVersionInfo, + "Return string from the module's version resources" ) + .def("getFixedFileInfo", ModuleAdapter::getFixedFileInfo, + "Return FixedFileInfo" ) .def("__getattr__", ModuleAdapter::getSymbolVa, "Return address of the symbol" ) .def( "__str__", &ModuleAdapter::print ); @@ -672,6 +672,34 @@ BOOST_PYTHON_MODULE( pykd ) .def("__str__", pykd::printSystemVersion, "Return object as a string"); + python::class_( + "FixedFileInfo", "Version information for a file", python::no_init ) + .def_readonly( "Signature", &kdlib::FixedFileInfo::Signature, + "Contains the value 0xFEEF04BD" ) + .def_readonly( "StrucVersion", &kdlib::FixedFileInfo::StrucVersion, + "The binary version number of this structure" ) + .def_readonly( "FileVersionMS", &kdlib::FixedFileInfo::FileVersionMS, + "The most significant 32 bits of the file's binary version number" ) + .def_readonly( "FileVersionLS", &kdlib::FixedFileInfo::FileVersionLS, + "The least significant 32 bits of the file's binary version number" ) + .def_readonly( "ProductVersionMS", &kdlib::FixedFileInfo::ProductVersionMS, + "The most significant 32 bits of the binary version number of the product with which this file was distributed" ) + .def_readonly( "ProductVersionLS", &kdlib::FixedFileInfo::ProductVersionLS, + "The least significant 32 bits of the binary version number of the product with which this file was distributed" ) + .def_readonly( "FileFlagsMask", &kdlib::FixedFileInfo::FileFlagsMask, + "Contains a bitmask that specifies the valid bits in FileFlags" ) + .def_readonly( "FileFlags", &kdlib::FixedFileInfo::FileFlags, + "Contains a bitmask that specifies the Boolean attributes of the file: FileFlag" ) + .def_readonly( "FileOS", &kdlib::FixedFileInfo::FileOS, + "The operating system for which this file was designed" ) + .def_readonly( "FileType", &kdlib::FixedFileInfo::FileType, + "The general type of file" ) + .def_readonly( "FileSubtype", &kdlib::FixedFileInfo::FileSubtype, + "The function of the file. The possible values depend on the value of FileType" ) + .def_readonly( "FileDateMS", &kdlib::FixedFileInfo::FileDateMS, + "The most significant 32 bits of the file's 64-bit binary creation date and time stamp" ) + .def_readonly( "FileDateLS", &kdlib::FixedFileInfo::FileDateLS, + "The least significant 32 bits of the file's 64-bit binary creation date and time stamp" ); python::class_( "exceptionInfo", "Exception information", python::no_init ) @@ -690,6 +718,15 @@ BOOST_PYTHON_MODULE( pykd ) .def( "__str__", pykd::printExceptionInfo, "Return object as a string"); + python::enum_("FileFlag", "Attributes of the file") + .value("Debug", kdlib::FileFlagDebug) + .value("PreRelease", kdlib::FileFlagPreRelease) + .value("Patched", kdlib::FileFlagPatched) + .value("PrivateBuild", kdlib::FileFlagPrivateBuild) + .value("InfoInferred", kdlib::FileFlagInfoInferred) + .value("SpecialBuild", kdlib::FileFlagSpecialBuild) + .export_values(); + python::enum_("eventType", "Type of debug event") .value("Breakpoint", kdlib::EventTypeBreakpoint) .value("Exception", kdlib::EventTypeException) diff --git a/pykd/pymodule.cpp b/pykd/pymodule.cpp index e9c3e62..0866ebd 100644 --- a/pykd/pymodule.cpp +++ b/pykd/pymodule.cpp @@ -6,6 +6,18 @@ namespace pykd { /////////////////////////////////////////////////////////////////////////////// +FixedFileInfoPtr ModuleAdapter::getFixedFileInfo( kdlib::Module& module ) +{ + AutoRestorePyState pystate; + + kdlib::FixedFileInfo fixedFileInfo; + module.getFixedFileInfo(fixedFileInfo); + + return FixedFileInfoPtr( new kdlib::FixedFileInfo(fixedFileInfo) ); +} + +/////////////////////////////////////////////////////////////////////////////// + std::wstring ModuleAdapter::print( kdlib::Module& module ) { AutoRestorePyState pystate; diff --git a/pykd/pymodule.h b/pykd/pymodule.h index a651f26..ad54419 100644 --- a/pykd/pymodule.h +++ b/pykd/pymodule.h @@ -9,6 +9,7 @@ namespace pykd { +typedef boost::shared_ptr< kdlib::FixedFileInfo > FixedFileInfoPtr; struct ModuleAdapter : public kdlib::Module { @@ -140,6 +141,14 @@ struct ModuleAdapter : public kdlib::Module return module.isUserMode(); } + static std::string getVersionInfo( kdlib::Module& module, const std::string &value ) + { + AutoRestorePyState pystate; + return module.getVersionInfo(value); + } + + static FixedFileInfoPtr getFixedFileInfo( kdlib::Module& module ); + static std::wstring print( kdlib::Module& module ); static python::list enumSymbols( kdlib::Module& module, const std::wstring &mask = L"*" );