示例#1
0
/**
 * Process a single INI file.
 * The file should have a [templates] group, where each item is one template.
 * Variables in a template have the form '\$[_a-z0-9]+' (a literal '$' followed
 * by one or more '_', lowercase letters, or lowercase numbers).
 *
 * After loading, the [pre-amble] group is copied verbatim if it exists.
 *
 * For every group with a name that matches a template name the template is written.
 * It starts with a optional \c \#if line if an 'if' item exists in the group. The item
 * value is used as condition. Similarly, \c \#ifdef and \c \#ifndef lines are also written.
 * Below the macro processor directives, the value of the template is written
 * at a line with its variables replaced by item values of the group being written.
 * If the group has no item for the variable, the [defaults] group is tried as fall back.
 * Finally, \c \#endif lines are written to match the macro processor lines.
 *
 * Last but not least, the [post-amble] group is copied verbatim.
 *
 * @param fname  Ini file to process. @return Exit status of the processing.
 */
static void ProcessIniFile(const char *fname)
{
	IniLoadFile *ini_data = LoadIniFile(fname);
	DumpGroup(ini_data, PREAMBLE_GROUP_NAME);
	DumpSections(ini_data);
	DumpGroup(ini_data, POSTAMBLE_GROUP_NAME);
	delete ini_data;
}
void gl_CreateSections()
{
	SectionLines.Clear();
	SectionLoops.Clear();
	Sections.Clear();
	SectionForSubsector.Resize(numsubsectors);
	memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0]));
	FSectionCreator creat;
	creat.CreateSections();
	if (dumpsections) DumpSections();
}
示例#3
0
void main( void ) {
    /*****************/

    static const dw_funcs cli_funcs = {
        CLIReloc,
        CLIWrite,
        CLISeek,
        CLITell,
        CLIAlloc,
        CLIFree
    };
    dw_init_info        info;
    dw_loc_handle       seg;
    dw_cu_info          cuinfo;

    info.language = DW_LANG_C89;
    info.compiler_options = DW_CM_BROWSER;
    info.producer_name = "testcli";
    if( setjmp( info.exception_handler ) == 0 ) {
        info.funcs = cli_funcs;

        RelocValues[ DW_W_LOW_PC ] = 0x135;
        RelocValues[ DW_W_HIGH_PC ] = 0x34561ul;
        RelocValues[ DW_W_UNIT_SIZE ] = 0x34561ul - 0x135;
        Client = DWInit( &info );
        if( Client == NULL ) {
            fputs( "error in DWInit()\n", stderr );
            exit( 1 );
        }
        seg = DWLocFini( Client, DWLocInit( Client ) );
        memset( &cuinfo, 0, sizeof( cuinfo ));
        cuinfo.source_filename = "foo.bar";
        cuinfo.directory = "somewhere\\over\\the\\rainbow";

        DWBeginCompileUnit( Client, &cuinfo );
        Test();
        DWEndCompileUnit( Client );
        cuinfo.source_filename = "empty.unit";
        cuinfo.directory = "in\\a\\land\\far\\far\\away";
        DWBeginCompileUnit( Client, &cuinfo );
        DWEndCompileUnit( Client );
        DWLocTrash( Client, seg );
        DWFini( Client );
        DumpSections();
    } else {
        fputs( "fatal error %d in dwarf library\n", stderr );
        exit( 1 );
    }
    exit( 0 );
}
示例#4
0
void DumpPeFile(hadesmem::Process const& process,
                hadesmem::PeFile const& pe_file,
                std::wstring const& path)
{
  std::wostream& out = GetOutputStreamW();

  ClearWarnForCurrentFile();

  WriteNewline(out);
  std::wstring const architecture_str{pe_file.Is64() ? L"64-Bit File: Yes"
                                                     : L"64-Bit File: No"};
  WriteNormal(out, architecture_str, 1);

  std::uint32_t const k1MB = (1U << 20);
  std::uint32_t const k100MB = k1MB * 100;
  if (pe_file.GetSize() > k100MB)
  {
    // Not actually unsupported, just want to flag large files for use in perf
    // testing.
    WriteNewline(out);
    WriteNormal(out, L"WARNING! File is over 100MB.", 0);
    // WarnForCurrentFile(WarningType::kUnsupported);
  }

  DumpHeaders(process, pe_file);

  DumpSections(process, pe_file);

  DumpOverlay(process, pe_file);

  DumpTls(process, pe_file);

  DumpExports(process, pe_file);

  bool has_new_bound_imports_any = false;
  DumpImports(process, pe_file, has_new_bound_imports_any);

  DumpBoundImports(process, pe_file, has_new_bound_imports_any);

  DumpRelocations(process, pe_file);

  if (!g_quiet && g_strings)
  {
    DumpStrings(process, pe_file);
  }

  HandleWarnings(path);
}
示例#5
0
static void ProcessPdbFile(const char *fileNameA)
{
    HRESULT             hr;
    IDiaDataSource *    dia = NULL;
    IDiaSession *       session = NULL;
    str::Str<char>      report;

    dia = LoadDia();
    if (!dia)
        return;

    ScopedMem<WCHAR> fileName(str::conv::FromAnsi(fileNameA));
    hr = dia->loadDataForExe(fileName, 0, 0);
    if (FAILED(hr)) {
        logf("  failed to load %s or its debug symbols from .pdb file\n", fileNameA);
        goto Exit;
    }

    hr = dia->openSession(&session);
    if (FAILED(hr)) {
        log("  failed to open DIA session\n");
        goto Exit;
    }

    if (g_dumpTypes)
        DumpTypes(session);

    if (g_dumpSections)
        DumpSections(session);

    if (g_dumpSymbols)
        DumpSymbols(session);

    fputs("Format: 1\n", stdout);
    if (g_compact) {
        str::Str<char> res;
        GetInternedStringsReport(res);
        fputs(res.Get(), stdout);
    }
    fputs(g_report.Get(), stdout);

Exit:
    UnkReleaseSafe(session);
}
示例#6
0
文件: main.cpp 项目: lvous/hadesmem
void DumpPeFile(hadesmem::Process const& process,
                hadesmem::PeFile const& pe_file,
                std::wstring const& path)
{
  std::wostream& out = std::wcout;

  ClearWarnForCurrentFile();

  std::uint32_t const k1MB = (1U << 20);
  std::uint32_t const k100MB = k1MB * 100;
  if (pe_file.GetSize() > k100MB)
  {
    // Not actually unsupported, just want to flag large files.
    WriteNewline(out);
    WriteNormal(out, L"WARNING! File is over 100MB.", 0);
    WarnForCurrentFile(WarningType::kUnsupported);
  }

  DumpHeaders(process, pe_file);

  DumpSections(process, pe_file);

  DumpTls(process, pe_file);

  DumpExports(process, pe_file);

  bool has_new_bound_imports_any = false;
  DumpImports(process, pe_file, has_new_bound_imports_any);

  DumpBoundImports(process, pe_file, has_new_bound_imports_any);

  DumpRelocations(process, pe_file);

  DumpStrings(process, pe_file);

  HandleWarnings(path);
}
示例#7
0
int main( int argc, char *argv[] )
/********************************/
{
    orl_handle                  o_hnd;
    orl_file_handle             o_fhnd;
    orl_file_format             type;
    orl_file_flags              o_flags;
    FILE                        *fp;
    int                         c;
    char                        *secs[MAX_SECS];
    int                         num_secs = 0;
    ORLSetFuncs( orl_cli_funcs, objRead, objSeek, TRMemAlloc, TRMemFree );

    if( argc < 2 ) {
        printf( "Usage:  dwdump <file>\n" );
        printf( "Where <file> is a COFF, ELF or OMF object file\n" );
        printf( "dwdump reads and dumps DWARF debugging information\n" );
        return( EXIT_SUCCESS );
    }

    dump.sections++;

    fp = fopen( argv[1], "rb" );
    if( fp == NULL ) {
        printf( "Error opening file.\n" );
        return( EXIT_FAILURE );
    }
    TRMemOpen();
    o_hnd = ORLInit( &orl_cli_funcs );
    if( o_hnd == NULL ) {
        printf( "Got NULL orl_handle.\n" );
        return( EXIT_FAILURE );
    }
    type = ORLFileIdentify( o_hnd, fp );
    if( type == ORL_UNRECOGNIZED_FORMAT ) {
        printf( "The object file is not in either ELF, COFF or OMF format." );
        return( EXIT_FAILURE );
    }
    switch( type ) {
    case ORL_OMF:
        printf( "OMF" );
        break;
    case ORL_ELF:
        printf( "ELF" );
        break;
    case ORL_COFF:
        printf( "COFF" );
        break;
    default:
        printf( "Unknown" );
        break;
    }
    printf( " object file.\n" );
    o_fhnd = ORLFileInit( o_hnd, fp, type );
    if( o_fhnd == NULL ) {
        printf( "Got NULL orl_file_handle.\n" );
        return( EXIT_FAILURE );
    }

    o_flags = ORLFileGetFlags( o_fhnd );

#ifdef __BIG_ENDIAN__
    if( o_flags & ORL_FILE_FLAG_LITTLE_ENDIAN ) {
        byte_swap = true;
    }
#else
    if( o_flags & ORL_FILE_FLAG_BIG_ENDIAN ) {
        byte_swap = true;
    }
#endif

    if( num_secs ) {
        for( c = 0; c < num_secs; c++ ) {
            sectionFound = 0;
            if( ORLFileScan( o_fhnd, secs[c], &DoSection ) != ORL_OKAY ) {
                printf( "Error occured in scanning section '%s'.\n", secs[c] );
            }
            if( !sectionFound ) {
                printf( "Section '%s' not found in object.\n", secs[c] );
            }
        }
    } else {
        if( ORLFileScan( o_fhnd, NULL, &DoSection ) != ORL_OKAY ) {
            printf( "Error occured in scanning file.\n" );
            return( EXIT_FAILURE );
        }
    }

    setSects( o_fhnd );

    if( ORLFileFini( o_fhnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFileFini.\n" );
        return( EXIT_FAILURE );
    }
    if( fclose( fp ) ) {
        printf( "Error closing file.\n" );
        return( EXIT_FAILURE );
    }
    if( ORLFini( o_hnd ) != ORL_OKAY ) {
        printf( "Error calling ORLFini.\n" );
    }

    DumpSections();

    freeBuffList();
#ifdef TRMEM
    TRMemPrtList();
#endif
    TRMemClose();
    return( EXIT_SUCCESS );
}