diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-04-16 19:59:41 +0200 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-04-16 19:59:41 +0200 |
commit | 460e42dbc6812af02dfdfb50a19ccf5a88cb5d70 (patch) | |
tree | f592ba8201cb69440b321c02bf3a3b228ab89e3f | |
parent | 2ee6bd7b5d840375b8887d68a89ad53b6bd53c00 (diff) | |
download | luarocks-460e42dbc6812af02dfdfb50a19ccf5a88cb5d70.tar.gz luarocks-460e42dbc6812af02dfdfb50a19ccf5a88cb5d70.tar.bz2 luarocks-460e42dbc6812af02dfdfb50a19ccf5a88cb5d70.zip |
update to version 0.3
-rw-r--r-- | win32/pe-parser.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/win32/pe-parser.lua b/win32/pe-parser.lua index 30bb8390..6b3a48c8 100644 --- a/win32/pe-parser.lua +++ b/win32/pe-parser.lua | |||
@@ -1,7 +1,11 @@ | |||
1 | --------------------------------------------------------------------------------------- | 1 | --------------------------------------------------------------------------------------- |
2 | -- Lua module to parse a Portable Executable (.exe , .dll, etc.) file and extract metadata. | 2 | -- Lua module to parse a Portable Executable (.exe , .dll, etc.) file and extract metadata. |
3 | -- | 3 | -- |
4 | -- Version 0.1, [copyright (c) 2013 - Thijs Schreijer](http://www.thijsschreijer.nl) | 4 | -- NOTE: numerical information is extracted as strings (hex) to prevent numerical overflows in |
5 | -- case of 64 bit fields (bit/flag fields). Pointer arithmetic is still done numerically, so for | ||
6 | -- very large files this could lead to undefined results. Use with care! | ||
7 | -- | ||
8 | -- Version 0.3, [copyright (c) 2013-2015 Thijs Schreijer](http://www.thijsschreijer.nl) | ||
5 | -- @name pe-parser | 9 | -- @name pe-parser |
6 | -- @class module | 10 | -- @class module |
7 | 11 | ||
@@ -238,7 +242,7 @@ local function readstring(f) | |||
238 | end | 242 | end |
239 | 243 | ||
240 | --- Parses a file and extracts the information. | 244 | --- Parses a file and extracts the information. |
241 | -- All numbers are delivered as "string" types containing hex values, see `toHex` and `toDec` conversion functions. | 245 | -- All numbers are delivered as "string" types containing hex values (to prevent numerical overflows in case of 64bit sizes or bit-fields), see `toHex` and `toDec` conversion functions. |
242 | -- @return table with data, or nil + error | 246 | -- @return table with data, or nil + error |
243 | -- @usage local pe = require("pe-parser") | 247 | -- @usage local pe = require("pe-parser") |
244 | -- local obj = pe.parse("c:\lua\lua.exe") | 248 | -- local obj = pe.parse("c:\lua\lua.exe") |
@@ -524,9 +528,9 @@ function M.msvcrt(infile) | |||
524 | 528 | ||
525 | for i, dll in ipairs(obj.DataDirectory.ImportTable) do | 529 | for i, dll in ipairs(obj.DataDirectory.ImportTable) do |
526 | dll = dll.Name:upper() | 530 | dll = dll.Name:upper() |
527 | local result = dll:match('(MSVCR%d*)%.DLL') | 531 | local result = dll:match('(MSVCR%d*D?)%.DLL') |
528 | if not result then | 532 | if not result then |
529 | result = dll:match('(MSVCRT)%.DLL') | 533 | result = dll:match('(MSVCRTD?)%.DLL') |
530 | end | 534 | end |
531 | -- success, found it return name + binary where it was found | 535 | -- success, found it return name + binary where it was found |
532 | if result then return result, infile end | 536 | if result then return result, infile end |