Ejemplo n.º 1
0
int plf_verify(int fileIdx)
{
    int i, num_entries;

    PLF_VERIFY_IDX(fileIdx);

    num_entries = plf_get_num_sections(fileIdx);

    if (num_entries <= 0)
        return num_entries;

    for (i = 0; i < num_entries; ++i)
    {
        if (plf_check_crc(fileIdx, i) != 0)
            return PLF_E_CRC;
    }


    return 0;
}
Ejemplo n.º 2
0
void DumpPLF(int fileidx)
{
    int i, num_sections;

    s_plf_file* header = plf_get_file_header(fileidx);
    printf("         dwMagic: 0x%08x\n", header->dwMagic);
    printf("    dwHdrVersion: 0x%08x\n", header->dwHdrVersion);
    printf("       dwHdrSize: 0x%08x\n", header->dwHdrSize);
    printf("   dwSectHdrSize: 0x%08x\n", header->dwSectHdrSize);
    printf("      dwFileType: 0x%08x (%s)\n", header->dwFileType,
            (header->dwFileType == 1 ? "EXECUTABLE" : "ARCHIVE"));
    printf("    dwEntryPoint: 0x%08x\n", header->dwEntryPoint);
    printf("    dwTargetPlat: 0x%08x\n", header->dwTargetPlat);
    printf("    dwTargetAppl: 0x%08x\n", header->dwTargetAppl);
    printf("      dwHwCompat: 0x%08x\n", header->dwHwCompat);
    printf("  dwVersionMajor: 0x%08x\n", header->dwVersionMajor);
    printf("  dwVersionMinor: 0x%08x\n", header->dwVersionMinor);
    printf(" dwVersionBugfix: 0x%08x\n", header->dwVersionBugfix);
    printf("      dwLangZone: 0x%08x\n", header->dwLangZone);
    printf("      dwFileSize: 0x%08x\n", header->dwFileSize);

    num_sections = plf_get_num_sections(fileidx);
    printf("-- Number of sections: %d --\n", num_sections);

    if (segments > 0)
    {
        for (i = 0; i < num_sections; ++i)
        {
            s_plf_section* section = plf_get_section_header(fileidx, i);

            printf(
                    "Sect %04i: Type: 0x%08x, Size: 0x%08x, CRC32: 0x%08x, LoadAddr: 0x%08x, UncomprSize: 0x%08x\n",
                    i, section->dwSectionType, section->dwSectionSize,
                    section->dwCRC32, section->dwLoadAddr, section->dwUncomprSize);
        }
    }
}
Ejemplo n.º 3
0
void FileInfo(const char* filename)
{
    int verify_result;
    int installerIdx, i, num_entries;
    int fileIdx, fileIdxInstaller;
    s_plf_file *fileHdrInstaller;
    s_plf_section* installerSection = 0;
    void* buffer;

    fileIdx = plf_open_file(filename);

    DumpPLF(fileIdx);

    if (fileIdx < 0)
    {
        printf("!!! plf_open_file(%s) failed: %d\n", filename, fileIdx);
        return;
    }

    /* Verify the file */
    verify_result = plf_verify(fileIdx);

    if (verify_result < 0)
    {
        printf("!!! plf_verify(%s) failed: %d\n", filename, verify_result);
    }

    /* Find the installer section */
    num_entries = plf_get_num_sections(fileIdx);

    for(i = 0; i < num_entries; ++i)
    {
        installerSection = plf_get_section_header(fileIdx, i);

        if (installerSection != 0 && installerSection->dwSectionType == 0x0c)
            break;
    }

    if (i >= num_entries || installerSection == 0)
    {
        printf("!!! unable to find installer section in %s\n", filename);
        goto FileInfo_exit_1;
    }

    /* Found the installer */
    installerIdx = i;

    /* Now open the installer from RAM */
    buffer = malloc(installerSection->dwSectionSize);
    if (!buffer)
    {
        printf("!!!  unable to alloc %d bytes\n", installerSection->dwSectionSize);
        goto FileInfo_exit_1;
    }
    plf_get_payload_raw(fileIdx, installerIdx, buffer, 0, installerSection->dwSectionSize);

    fileIdxInstaller = plf_open_ram(buffer, installerSection->dwSectionSize);
    if (fileIdxInstaller < 0)
    {
        printf("!!! plf_open_ram for installer failed: %d\n", fileIdxInstaller);
        goto FileInfo_exit_2;
    }


    fileHdrInstaller = plf_get_file_header(fileIdxInstaller);
    printf("*** Installer found! Version: %d.%d.%d ***\n", fileHdrInstaller->dwVersionMajor, fileHdrInstaller->dwVersionMinor, fileHdrInstaller->dwVersionBugfix);

FileInfo_exit_2:
    free(buffer);

FileInfo_exit_1:
    plf_close(fileIdx);

}