Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add non-canonical function to test whether an MZ executable is a Windows PE executable
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f5b4bc4ee4906725ab98595006100f3b0aa5474f
User & Date: brandon 2018-10-22 21:20:27
Context
2018-11-08
22:48
Add function to determine GIF image dimensions check-in: 00fa7b52d2 user: brandon tags: trunk
2018-10-22
21:20
Add non-canonical function to test whether an MZ executable is a Windows PE executable check-in: f5b4bc4ee4 user: brandon tags: trunk
2018-10-13
20:49
Calculate a new hash IFID for twine games without an embedded IFID. check-in: 290d26e5c9 user: brandon tags: trunk
Changes

Changes to treatyofbabel/formats/executable.py.

1
2
3
4
5
6
7
8
9
10
11
12
..
18
19
20
21
22
23
24

25
26
27
28
29
30
31
..
84
85
86
87
88
89
90









# -*- coding: utf-8 -*-
#
#       executable.py
#
#       Copyright © 2011, 2012, 2013, 2014 Brandon Invergo <brandon@invergo.net>
#
#       This file is part of pyifbabel.
#
#       pyifbabel is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
................................................................................
#
#       You should have received a copy of the GNU General Public License
#       along with pyifbabel.  If not, see <http://www.gnu.org/licenses/>.


import md5
from binascii import hexlify



FORMAT = "executable"
FORMAT_EXT = [".exe"]
HOME_PAGE = "http://http://en.wikipedia.org/wiki/Executable"
HAS_COVER = False
HAS_META = False
................................................................................


def _deduce_magic(file_buffer):
    for magic, name, length in EXETYPES:
        if len(file_buffer) >= length and magic == file_buffer[0:length]:
            return name
    return None













|







 







>







 







>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
..
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
#
#       executable.py
#
#       Copyright © 2011, 2012, 2013, 2014, 2018 Brandon Invergo <brandon@invergo.net>
#
#       This file is part of pyifbabel.
#
#       pyifbabel is free software: you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation, either version 3 of the License, or
#       (at your option) any later version.
................................................................................
#
#       You should have received a copy of the GNU General Public License
#       along with pyifbabel.  If not, see <http://www.gnu.org/licenses/>.


import md5
from binascii import hexlify
from treatyofbabel.utils._binaryfuncs import read_short


FORMAT = "executable"
FORMAT_EXT = [".exe"]
HOME_PAGE = "http://http://en.wikipedia.org/wiki/Executable"
HAS_COVER = False
HAS_META = False
................................................................................


def _deduce_magic(file_buffer):
    for magic, name, length in EXETYPES:
        if len(file_buffer) >= length and magic == file_buffer[0:length]:
            return name
    return None

def is_win32_executable(file_buffer):
    if _deduce_magic(file_buffer) != "MZ":
        return False
    lfanew = file_buffer[60:62]
    offset = read_short(file_buffer, 60, "<")
    if offset > len(file_buffer) - 3:
        return False
    return file_buffer[offset:offset+2] == "PE"