Exemplo n.º 1
0
void main( int argc, char **argv )
{
   buf = ( unsigned char * ) malloc( BUFSIZE * sizeof ( unsigned char ) );

   if ( argc == 3 && strcmp( argv[1], "-x" ) == 0 )
      extract_zcode( argv[2] );
   else if ( argc == 2 )
      create_executable( argv[1], JZIP_NAME );
   else if ( argc == 3 )
      create_executable( argv[1], argv[2] );
   else
      fprintf( stderr, USAGE );

   exit( 0 );
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
    if (argc != 3)
    {
        fprintf(stderr, "Usage: %s <input file> <output file>\n", argv[0]);
        return 1;
    }

    FILE* stream;
    if ((stream = fopen(argv[1], "r")) == NULL)
    {
        fprintf(stderr, "%s: invalid file\n", argv[1]);
        return 1;
    }

    uint32_t magic = read_magic(stream);
    if (magic != MH_MAGIC_64)
    {
        fprintf(stderr, "%s: unsupported or unrecognized format 0x%08x\n", argv[1], magic);
        fclose(stream);
        return 1;
    }

    rewind(stream);
    if (!is_object_file(stream))
    {
        fprintf(stderr, "%s: is not an object file\n", argv[1]);
        fclose(stream);
        return 1;
    }

    uint8_t* byte_code = NULL;
    size_t length = 0;
    rewind(stream);
    extract_byte_code(stream, byte_code, length);

    fclose(stream);

    if (byte_code == NULL)
    {
        fprintf(stderr, "%s: couldn't find text section in file\n", argv[1]);
        return 2;
    }

    if ((stream = fopen(argv[2], "w")) == NULL)
    {
        fprintf(stderr, "%s: couldn't open file for writing\n", argv[2]);
        fclose(stream);
        return 1;
    }

    create_executable(stream, byte_code, length);

    fclose(stream);
    free(byte_code);

    fprintf(stderr, "DONE\n");

    return 0;
}
Exemplo n.º 3
0
SETUP()
{
	conf_setup();
	init_modes();
	init_commands();

	curr_view = &lwin;
	other_view = &rwin;
	view_setup(&lwin);

	curr_stats.load_stage = -1;
	curr_stats.save_msg = 0;

	saved_cwd = save_cwd();
	assert_success(chdir(sandbox));

	update_string(&cfg.shell, "/bin/sh");
	update_string(&cfg.shell_cmd_flag, "-c");
	stats_update_shell_type(cfg.shell);
	curr_stats.exec_env_type = EET_EMULATOR;

	update_string(&cfg.media_prg, "./script");

	create_executable("script");
}