コード例 #1
0
ファイル: test_fileform.py プロジェクト: nevinhappy/nrs
def test_extract_header():
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)
        assert header is not None
        assert len(header.blocks) == fileform.BLOCKS_COUNT
        assert len(header.install_types) == 33
コード例 #2
0
ファイル: test_fileform.py プロジェクト: Logan-lu/nrs
def test_extract_header():
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)
        assert header is not None
        assert len(header.blocks) == fileform.BLOCKS_COUNT
        assert len(header.install_types) == 33
コード例 #3
0
ファイル: test_fileform.py プロジェクト: Logan-lu/nrs
def test_findheader_found():
    # Header found in NSIS installer.
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        assert firstheader is not None
        assert firstheader.siginfo == 0xDEADBEEF
        assert firstheader.magics == b'NullsoftInst'
        assert firstheader.c_size < firstheader.u_size
コード例 #4
0
ファイル: test_fileform.py プロジェクト: nevinhappy/nrs
def test_findheader_found():
    # Header found in NSIS installer.
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        assert firstheader is not None
        assert firstheader.siginfo == 0xDEADBEEF
        assert firstheader.magics == b'NullsoftInst'
        assert firstheader.c_size < firstheader.u_size
コード例 #5
0
ファイル: test_fileform.py プロジェクト: Logan-lu/nrs
def test_extract_blocks():
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)

        for block_id in [fileform.NB_PAGES, fileform.NB_SECTIONS,
                fileform.NB_ENTRIES, fileform.NB_STRINGS,
                fileform.NB_LANGTABLES, fileform.NB_CTLCOLORS]:
            pages_block = fileform._extract_block(nsis_file, firstheader, block_id)
            assert pages_block is not None
コード例 #6
0
ファイル: test_fileform.py プロジェクト: nevinhappy/nrs
def test_extract_blocks():
    with open(os.path.join(utils.SAMPLES_DIR, 'example1.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)

        for block_id in [
                fileform.NB_PAGES, fileform.NB_SECTIONS, fileform.NB_ENTRIES,
                fileform.NB_STRINGS, fileform.NB_LANGTABLES,
                fileform.NB_CTLCOLORS
        ]:
            pages_block = fileform._extract_block(nsis_file, firstheader,
                                                  block_id)
            assert pages_block is not None
コード例 #7
0
ファイル: test_fileform.py プロジェクト: Logan-lu/nrs
def test_extract_lzma_solid():
    with open(os.path.join(utils.SAMPLES_DIR, 'example_lzma_solid.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)
        assert header is not None
コード例 #8
0
ファイル: test_fileform.py プロジェクト: Logan-lu/nrs
def test_findheader_not_found():
    # Header should not be found in non-nsisi files.
    with open(os.path.join(utils.SAMPLES_DIR, 'empty'), 'rb') as empty:
        assert fileform._find_firstheader(empty) is None
コード例 #9
0
ファイル: loader.py プロジェクト: isra17/nrs
def accept_file(li, n):
    li.seek(0)
    if n == 0 and fileform._find_firstheader(li):
        return "NSIS (NullSoft Installer)"
    return 0
コード例 #10
0
ファイル: test_fileform.py プロジェクト: nevinhappy/nrs
def test_extract_lzma_solid():
    with open(os.path.join(utils.SAMPLES_DIR, 'example_lzma_solid.exe'), 'rb') \
            as nsis_file:
        firstheader = fileform._find_firstheader(nsis_file)
        header = fileform._extract_header(nsis_file, firstheader)
        assert header is not None
コード例 #11
0
ファイル: test_fileform.py プロジェクト: nevinhappy/nrs
def test_findheader_not_found():
    # Header should not be found in non-nsisi files.
    with open(os.path.join(utils.SAMPLES_DIR, 'empty'), 'rb') as empty:
        assert fileform._find_firstheader(empty) is None