Exemple #1
0
Archive::Archive(const string& filename, const std::string& regname)
    : name(filename),
      info(filename, Read),
      second_level_xor_key_(NULL),
      regname_(regname) {
  readTOC();
  readOverrides();

  if (regname == "KEY\\CLANNAD_FV") {
    second_level_xor_key_ =
      libReallive::Compression::clannad_full_voice_xor_mask;
  } else if (regname == "\x4b\x45\x59\x5c\x83\x8a\x83\x67\x83\x8b\x83"
             "\x6f\x83\x58\x83\x5e\x81\x5b\x83\x59\x81\x49") {
    second_level_xor_key_ =
      libReallive::Compression::little_busters_xor_mask;
  } else if (regname ==
             "\x4b\x45\x59\x5c\x83\x8a\x83\x67\x83\x8b\x83\x6f\x83\x58\x83\x5e"
             "\x81\x5b\x83\x59\x81\x49\x82\x64\x82\x77") {
    // "KEY\<little busters in katakana>!EX", with all fullwidth latin
    // characters.
    second_level_xor_key_ =
        libReallive::Compression::little_busters_ex_xor_mask;
  } else if (regname == "StudioMebius\\SNOWSE") {
    second_level_xor_key_ =
        libReallive::Compression::snow_standard_edition_xor_mask;
  }
}
Exemple #2
0
/*******Protected Methods**************/
RtPnor::RtPnor()
{
    errlHndl_t l_err = readTOC();
    if (l_err)
    {
        errlCommit(l_err, PNOR_COMP_ID);
    }
}
Exemple #3
0
Serializer::Serializer(const std::string &filename, bool write_)
    : mFilename(filename), mWrite(write_), mCompatibility(false) {
    mFile.open(filename, write_ ? (std::ios::out | std::ios::trunc | std::ios::binary)
                                : (std::ios::in  | std::ios::binary));
    if (!mFile.is_open())
        throw std::runtime_error("Could not open \"" + filename + "\"!");

    if (!mWrite)
        readTOC();
    seek(serialized_header_size);
    mPrefixStack.push_back("");
}
Exemple #4
0
	void ResourcePack::load(String path)
	{
		std::cout << "Loading resource pack: " << path << std::endl;
		name = path;
		FILE* fp = fopen(path.c_str(), "rb");
		if (!fp) throw Exception("Unable to open resource pack: "+path);

		readHeader(fp);
		readTOC(fp);

		fileP = fp;
	}
Exemple #5
0
/*******Protected Methods**************/
RtPnor::RtPnor()
{
    do {
    errlHndl_t l_err = getMasterProcId();
    if (l_err)
    {
        errlCommit(l_err, PNOR_COMP_ID);
        break;
    }
    l_err = readTOC();
    if (l_err)
    {
        errlCommit(l_err, PNOR_COMP_ID);
        break;
    }
    } while (0);
}
void QHelpProjectDataPrivate::readFilterSection()
{
    filterSectionList.append(QHelpDataFilterSection());
    while (!atEnd()) {
        readNext();
        if (isStartElement()) {
            if (name() == QLatin1String("filterAttribute"))
                filterSectionList.last().addFilterAttribute(readElementText());
            else if (name() == QLatin1String("toc"))
                readTOC();
            else if (name() == QLatin1String("keywords"))
                readKeywords();
            else if (name() == QLatin1String("files"))
                readFiles();
            else
                raiseUnknownTokenError();
        } else if (isEndElement() && name() == QLatin1String("filterSection")) {
            break;
        }
    }
}
Exemple #7
0
Archive::Archive(const string& filename)
  : name(filename), info(filename, Read), second_level_xor_key_(NULL) {
  readTOC();
  readOverrides();
}
Exemple #8
0
/**
 * @brief Initialize the daemon
 */
void PnorRP::initDaemon()
{
    TRACUCOMP(g_trac_pnor, "PnorRP::initDaemon> " );
    errlHndl_t l_errhdl = NULL;

    do
    {
        // read the TOC in the PNOR to compute the sections
        l_errhdl = readTOC();
        if( l_errhdl )
        {
            break;
        }

        // create a message queue
        iv_msgQ = msg_q_create();

        // create a Block, passing in the message queue
        int rc = mm_alloc_block( iv_msgQ, (void*) BASE_VADDR, TOTAL_SIZE );
        if( rc )
        {
            TRACFCOMP( g_trac_pnor, "PnorRP::initDaemon> Error from mm_alloc_block : rc=%d", rc );
            /*@
             * @errortype
             * @moduleid     PNOR::MOD_PNORRP_INITDAEMON
             * @reasoncode   PNOR::RC_EXTERNAL_ERROR
             * @userdata1    Requested Address
             * @userdata2    rc from mm_alloc_block
             * @devdesc      PnorRP::initDaemon> Error from mm_alloc_block
             * @custdesc    A problem occurred while accessing the boot flash.
             */
            l_errhdl = new ERRORLOG::ErrlEntry(
                           ERRORLOG::ERRL_SEV_UNRECOVERABLE,
                           PNOR::MOD_PNORRP_INITDAEMON,
                           PNOR::RC_EXTERNAL_ERROR,
                           TO_UINT64(BASE_VADDR),
                           TO_UINT64(rc),
                           true /*Add HB SW Callout*/);
            l_errhdl->collectTrace(PNOR_COMP_NAME);
            break;
        }

        //Register this memory range to be FLUSHed during a shutdown.
        INITSERVICE::registerBlock(reinterpret_cast<void*>(BASE_VADDR),
                                   TOTAL_SIZE,PNOR_PRIORITY);

        // Need to set permissions to R/W
        rc = mm_set_permission((void*) BASE_VADDR,TOTAL_SIZE,
                               WRITABLE | WRITE_TRACKED);



        // start task to wait on the queue
        task_create( wait_for_message, NULL );

    } while(0);

    if( l_errhdl )
    {
        iv_startupRC = l_errhdl->reasonCode();
        errlCommit(l_errhdl,PNOR_COMP_ID);
    }

    // call ErrlManager function - tell him that PNOR is ready!
    ERRORLOG::ErrlManager::errlResourceReady(ERRORLOG::PNOR);

    TRACUCOMP(g_trac_pnor, "< PnorRP::initDaemon" );
}
Exemple #9
0
int main(int argc, char ** argv)
{
    lua_State * L = luaL_newstate();
    
    if (!readTOC(L, argv[0]))
    {
        if (argc < 2)
        {
            // display usage message and exit
            printf("This copy of enceladus has no embedded lua program to run\n");
            printf("Please embed one: enceladus main.lua lib.lua ...\n");
            return 1;
        }
        
        // parse command line and embed lua code, then exit
        parse_args(&argc, &argv);
        
        char * outname = embed(L, argc, argv);
        if (outname)
        {
            printf("Embed successful. Output file: %s\n", outname);
        } else {
            fprintf(stderr, "Embed failed. Aborting.\n");
        }
        
        return 0;
    }
    
    // TOC read successful - we have an embedded lua program to run
    // initialize standard libraries
    luaL_openlibs(L);
    
    // load any statically linked libraries
    enceladus_init_static_libs(L);
    
    // grab the entry point
    // the name is on top of the stack and the table of packed files right
    // below, thanks to readTOC
    lua_gettable(L, -2); // toc{} main()
    if (lua_type(L, -1) != LUA_TFUNCTION)
    {
        fprintf(stderr, "Error loading entry point: %s\n", lua_tostring(L, -1));
        return 1;
    }
    
    // install our custom loader for the embedded libraries
    lua_insert(L, -2);
    if (!registerLoader(L))
    {
        fprintf(stderr, "Error registering custom loader: %s\n", lua_tostring(L, -1));
        return 1;
    }
    
    // marshal arguments into lua
    lua_newtable(L); // toc{} main() arg{}
    for (int i = 0; i < argc; ++i)
    {
        lua_pushstring(L, argv[i]); // toc{} main() arg{} argv[i]
        lua_rawseti(L, -2, i); // toc{} main() arg{}
    }
    lua_setglobal(L, "arg"); // toc{} main()
    
    for (int i = 1; i < argc; ++i)
    {
        lua_pushstring(L, argv[i]); // toc{} main() argv[i]...
    }
    
    // call
    lua_getglobal(L, "debug"); // ... debug
    lua_getfield(L, -1, "traceback"); // ... debug debug.traceback
    lua_insert(L, 1); // debug.traceback ... debug
    lua_pop(L, 1); // debug.traceback ...
    
    if (lua_pcall(L, argc-1, 0, 1) != 0)
    {
        // error handling
        fprintf(stderr, "error: %s\n", lua_tostring(L, -1));
        return 1;
    }
    
    return 0;
}