Beispiel #1
0
int cellSysmoduleLoadModule(u16 id)
{
	cellSysmodule.Warning("cellSysmoduleLoadModule(%s)", getModuleName(id));
	Module* m = GetModuleById(id);

	if(!m)
	{
		return CELL_SYSMODULE_ERROR_UNKNOWN;
	}

	if(m->IsLoaded())
	{
		return CELL_SYSMODULE_ERROR_DUPLICATED;
	}

	m->Load();
	return CELL_OK;
}
Beispiel #2
0
void ModuleManager::Initialize()
{
   wxArrayString audacityPathList = wxGetApp().audacityPathList;
   wxArrayString pathList;
   wxArrayString files;
   wxString pathVar;
   size_t i;

   // Code from LoadLadspa that might be useful in load modules.
   pathVar = wxGetenv(wxT("AUDACITY_MODULES_PATH"));
   if (pathVar != wxT("")) {
      wxGetApp().AddMultiPathsToPathList(pathVar, pathList);
   }

   for (i = 0; i < audacityPathList.GetCount(); i++) {
      wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
      wxGetApp().AddUniquePathToPathList(prefix + wxT("modules"),
                                         pathList);
   }

   #if defined(__WXMSW__)
   wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files);   
//   #elif defined(__WXMAC__)
//   wxGetApp().FindFilesInPathList(wxT("*.dylib"), pathList, files);
   #else
   wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);
   #endif

   for (i = 0; i < files.GetCount(); i++) {
      Module *module = new Module(files[i]);

      if (module->Load()) {
         mInstance->mModules.Add(module);
      }
      else {
         delete module;
      }
   }
}
void ModuleManager::Initialize(CommandHandler &cmdHandler)
{
   wxArrayString audacityPathList = wxGetApp().audacityPathList;
   wxArrayString pathList;
   wxArrayString files;
   wxString pathVar;
   size_t i;

   // Code from LoadLadspa that might be useful in load modules.
   pathVar = wxGetenv(wxT("AUDACITY_MODULES_PATH"));
   if (pathVar != wxT(""))
      wxGetApp().AddMultiPathsToPathList(pathVar, pathList);

   for (i = 0; i < audacityPathList.GetCount(); i++) {
      wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
      wxGetApp().AddUniquePathToPathList(prefix + wxT("modules"),
                                         pathList);
   }

   #if defined(__WXMSW__)
   wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files);   
   #else
   wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);
   #endif

   for (i = 0; i < files.GetCount(); i++) {
      // As a courtesy to some modules that might be bridges to
      // open other modules, we set the current working
      // directory to be the module's directory.
      wxString saveOldCWD = ::wxGetCwd();
      wxString prefix = ::wxPathOnly(files[i]);
      ::wxSetWorkingDirectory(prefix);

#ifdef EXPERIMENTAL_MODULE_PREFS
      if( !IsAllowedModule( files[i] ) )  // don't try and check the in-date-ness before this as that means loading the module to call it's GetVersionString, which could do anything.
#endif
      {
         wxString ShortName = wxFileName( files[i] ).GetName();
         wxString msg;
         msg.Printf(_("Module \"%s\" found."), ShortName.c_str());
         msg += _("\n\nOnly use modules from trusted sources");
         const wxChar *buttons[] = {_("Yes"), _("No"), NULL};  // could add a button here for 'yes and remember that', and put it into the cfg file.  Needs more thought.
         int action;
         action = ShowMultiDialog(msg, _("Module Loader"), buttons, _("Try and load this module?"), false);
         if(action == 1)   // "No"
            continue;
      }

      Module *module = new Module(files[i]);
      if (module->Load())   // it will get rejected if there  are version problems
      {
         mInstance->mModules.Add(module);
         // We've loaded and initialised OK.
         // So look for special case functions:
         wxLogNull logNo; // Don't show wxWidgets errors if we can't do these. (Was: Fix bug 544.)
         // (a) for scripting.
         if( scriptFn == NULL )
            scriptFn = (tpRegScriptServerFunc)(module->GetSymbol(wxT(scriptFnName)));
         // (b) for hijacking the entire Audacity panel.
         if( pPanelHijack==NULL )
         {
            pPanelHijack = (tPanelFn)(module->GetSymbol(wxT(mainPanelFnName)));
         }
      }
      else {
         delete module;
      }
      ::wxSetWorkingDirectory(saveOldCWD);
   }
   // After loading all the modules, we may have a registered scripting function.
   if(scriptFn)
   {
      ScriptCommandRelay::SetCommandHandler(cmdHandler);
      ScriptCommandRelay::SetRegScriptServerFunc(scriptFn);
      NonGuiThread::StartChild(&ScriptCommandRelay::Run);
   }
}
Beispiel #4
0
void Medusa::LoadModules(std::wstring const& rModulesPath)
{
  try
  {
    const boost::filesystem::path CurDir = rModulesPath;
    Module Module;

    Log::Write("core") << "Module directory: " << boost::filesystem::system_complete(CurDir) << LogEnd;

    boost::filesystem::directory_iterator End;
    for (boost::filesystem::directory_iterator It(CurDir);
      It != End; ++It)
    {
      std::wstring const& rFilename = It->path().wstring();

      if (rFilename.substr(rFilename.find_last_of(L".") + 1) != Module::GetExtension())
        continue;

      std::wstring FullPath = boost::filesystem::system_complete(*It).wstring();
      Log::Write("core") << "Module: \"" << rFilename << "\" ";

      void* pMod = Module.Load(FullPath);
      if (pMod == nullptr)
        continue;

      TGetLoader pGetLoader = Module.Load<TGetLoader>(pMod, "GetLoader");
      if (pGetLoader != nullptr)
      {
        Log::Write("core") << "is a loader ";

        Loader* pLoader = pGetLoader(m_Database);
        if (pLoader->IsSupported())
        {
          Loader::SharedPtr LoaderPtr(pLoader);
          m_Loaders.push_back(LoaderPtr);
          Log::Write("core") << "(loaded)" << LogEnd;
        }
        else
        {
          Log::Write("core") << "(unloaded)" << LogEnd;
          delete pLoader;
        }
        continue;
      }

      TGetArchitecture pGetArchitecture = Module.Load<TGetArchitecture>(pMod, "GetArchitecture");
      if (pGetArchitecture != nullptr)
      {
        Log::Write("core") << "is an Architecture" << LogEnd;

        Architecture* pArchitecture = pGetArchitecture();
        Architecture::SharedPtr ArchitecturePtr(pArchitecture);
        m_AvailableArchitectures.push_back(ArchitecturePtr);
        continue;
      }

      TGetOperatingSystem pGetOperatingSystem = Module.Load<TGetOperatingSystem>(pMod, "GetOperatingSystem");
      if (pGetOperatingSystem != nullptr)
      {
        Log::Write("core") << "is an operating system" << LogEnd;

        OperatingSystem* pOperatingSystem = pGetOperatingSystem(m_Database);
        OperatingSystem::SharedPtr spOperatingSystem(pOperatingSystem);
        m_CompatibleOperatingSystems.push_back(spOperatingSystem);
        continue;
      }

      TGetEmulator pGetEmulator = Module.Load<TGetEmulator>(pMod, "GetEmulator");
      if (pGetEmulator != nullptr)
      {
        Log::Write("core") << "is an Emulator" << LogEnd;

        Emulator* pEmulator = pGetEmulator(nullptr, nullptr, nullptr);
        m_Emulators[pEmulator->GetName()] = pGetEmulator;
        continue;
      }

      Log::Write("core") << "is unknown (ignored)" << LogEnd;
    }
  }
  catch (std::exception &e)
  {
    Log::Write("core") << e.what() << LogEnd;
  }
}
Beispiel #5
0
bool ELF64Loader::LoadPhdrData(u64 offset)
{
	for(u32 i=0; i<phdr_arr.size(); ++i)
	{
		phdr_arr[i].Show();

		if(phdr_arr[i].p_vaddr < min_addr)
		{
			min_addr = phdr_arr[i].p_vaddr;
		}

		if(phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz > max_addr)
		{
			max_addr = phdr_arr[i].p_vaddr + phdr_arr[i].p_memsz;
		}

		if(phdr_arr[i].p_vaddr != phdr_arr[i].p_paddr)
		{
			ConLog.Warning
			( 
				"ElfProgram different load addrs: paddr=0x%8.8x, vaddr=0x%8.8x", 
				phdr_arr[i].p_paddr, phdr_arr[i].p_vaddr
			);
		}

		if(!Memory.MainMem.IsInMyRange(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_memsz))
		{
#ifdef LOADER_DEBUG
			ConLog.Warning("Skipping...");
			ConLog.SkipLn();
#endif
			continue;
		}

		switch(phdr_arr[i].p_type)
		{
			case 0x00000001: //LOAD
				if(phdr_arr[i].p_memsz)
				{
					Memory.MainMem.AllocFixed(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_memsz);

					if(phdr_arr[i].p_filesz)
					{
						elf64_f.Seek(phdr_arr[i].p_offset);
						elf64_f.Read(&Memory[offset + phdr_arr[i].p_vaddr], phdr_arr[i].p_filesz);
						Emu.GetSFuncManager().StaticAnalyse(&Memory[offset + phdr_arr[i].p_vaddr], phdr_arr[i].p_filesz, phdr_arr[i].p_vaddr);
					}
				}
			break;

			case 0x00000007: //TLS
				Emu.SetTLSData(offset + phdr_arr[i].p_vaddr, phdr_arr[i].p_filesz, phdr_arr[i].p_memsz);
			break;

			case 0x60000001: //LOOS+1
			{
				if(!phdr_arr[i].p_filesz) break;

				const sys_process_param& proc_param = *(sys_process_param*)&Memory[offset + phdr_arr[i].p_vaddr];

				if(re(proc_param.size) < sizeof(sys_process_param))
				{
					ConLog.Warning("Bad proc param size! [0x%x : 0x%x]", re(proc_param.size), sizeof(sys_process_param));
				}
	
				if(re(proc_param.magic) != 0x13bcc5f6)
				{
					ConLog.Error("Bad magic! [0x%x]", Memory.Reverse32(proc_param.magic));
				}
				else
				{
					sys_process_param_info& info = Emu.GetInfo().GetProcParam();
					info.sdk_version = re(proc_param.info.sdk_version);
					info.primary_prio = re(proc_param.info.primary_prio);
					info.primary_stacksize = re(proc_param.info.primary_stacksize);
					info.malloc_pagesize = re(proc_param.info.malloc_pagesize);
					info.ppc_seg = re(proc_param.info.ppc_seg);
					//info.crash_dump_param_addr = re(proc_param.info.crash_dump_param_addr);
#ifdef LOADER_DEBUG
					ConLog.Write("*** sdk version: 0x%x", info.sdk_version);
					ConLog.Write("*** primary prio: %d", info.primary_prio);
					ConLog.Write("*** primary stacksize: 0x%x", info.primary_stacksize);
					ConLog.Write("*** malloc pagesize: 0x%x", info.malloc_pagesize);
					ConLog.Write("*** ppc seg: 0x%x", info.ppc_seg);
					//ConLog.Write("*** crash dump param addr: 0x%x", info.crash_dump_param_addr);
#endif
				}
			}
			break;

			case 0x60000002: //LOOS+2
			{
				if(!phdr_arr[i].p_filesz) break;

				sys_proc_prx_param proc_prx_param = *(sys_proc_prx_param*)&Memory[offset + phdr_arr[i].p_vaddr];

				proc_prx_param.size = re(proc_prx_param.size);
				proc_prx_param.magic = re(proc_prx_param.magic);
				proc_prx_param.version = re(proc_prx_param.version);
				proc_prx_param.libentstart = re(proc_prx_param.libentstart);
				proc_prx_param.libentend = re(proc_prx_param.libentend);
				proc_prx_param.libstubstart = re(proc_prx_param.libstubstart);
				proc_prx_param.libstubend = re(proc_prx_param.libstubend);
				proc_prx_param.ver = re(proc_prx_param.ver);

#ifdef LOADER_DEBUG
				ConLog.Write("*** size: 0x%x", proc_prx_param.size);
				ConLog.Write("*** magic: 0x%x", proc_prx_param.magic);
				ConLog.Write("*** version: 0x%x", proc_prx_param.version);
				ConLog.Write("*** libentstart: 0x%x", proc_prx_param.libentstart);
				ConLog.Write("*** libentend: 0x%x", proc_prx_param.libentend);
				ConLog.Write("*** libstubstart: 0x%x", proc_prx_param.libstubstart);
				ConLog.Write("*** libstubend: 0x%x", proc_prx_param.libstubend);
				ConLog.Write("*** ver: 0x%x", proc_prx_param.ver);
#endif

				if(proc_prx_param.magic != 0x1b434cec)
				{
					ConLog.Error("Bad magic! (0x%x)", proc_prx_param.magic);
				}
				else
				{
					for(u32 s=proc_prx_param.libstubstart; s<proc_prx_param.libstubend; s+=sizeof(Elf64_StubHeader))
					{
						Elf64_StubHeader stub = *(Elf64_StubHeader*)Memory.GetMemFromAddr(offset + s);

						stub.s_size = re(stub.s_size);
						stub.s_version = re(stub.s_version);
						stub.s_unk0 = re(stub.s_unk0);
						stub.s_unk1 = re(stub.s_unk1);
						stub.s_imports = re(stub.s_imports);
						stub.s_modulename = re(stub.s_modulename);
						stub.s_nid = re(stub.s_nid);
						stub.s_text = re(stub.s_text);

						const std::string& module_name = Memory.ReadString(stub.s_modulename);
						Module* module = Emu.GetModuleManager().GetModuleByName(module_name);
						if(module)
						{
							//module->SetLoaded();
						}
						else
						{
							ConLog.Warning("Unknown module '%s'", module_name.c_str());
						}

#ifdef LOADER_DEBUG
						ConLog.SkipLn();
						ConLog.Write("*** size: 0x%x", stub.s_size);
						ConLog.Write("*** version: 0x%x", stub.s_version);
						ConLog.Write("*** unk0: 0x%x", stub.s_unk0);
						ConLog.Write("*** unk1: 0x%x", stub.s_unk1);
						ConLog.Write("*** imports: %d", stub.s_imports);
						ConLog.Write("*** module name: %s [0x%x]", module_name.c_str(), stub.s_modulename);
						ConLog.Write("*** nid: 0x%x", stub.s_nid);
						ConLog.Write("*** text: 0x%x", stub.s_text);
#endif
						static const u32 section = 4 * 3;
						u64 tbl = Memory.MainMem.AllocAlign(stub.s_imports * 4 * 2);
						u64 dst = Memory.MainMem.AllocAlign(stub.s_imports * section);

						for(u32 i=0; i<stub.s_imports; ++i)
						{
							const u32 nid = Memory.Read32(stub.s_nid + i*4);
							const u32 text = Memory.Read32(stub.s_text + i*4);

							if(module)
							{
								if(!module->Load(nid))
								{
									ConLog.Warning("Unimplemented function '%s' in '%s' module", SysCalls::GetHLEFuncName(nid).c_str(), module_name.c_str());
								}
							}
#ifdef LOADER_DEBUG
							ConLog.Write("import %d:", i+1);
							ConLog.Write("*** nid: 0x%x (0x%x)", nid, stub.s_nid + i*4);
							ConLog.Write("*** text: 0x%x (0x%x)", text, stub.s_text + i*4);
#endif
							Memory.Write32(stub.s_text + i*4, tbl + i*8);

							mem32_ptr_t out_tbl(tbl + i*8);
							out_tbl += dst + i*section;
							out_tbl += Emu.GetModuleManager().GetFuncNumById(nid);

							mem32_ptr_t out_dst(dst + i*section);
							out_dst += OR(11, 2, 2, 0);
							out_dst += SC(2);
							out_dst += BCLR(0x10 | 0x04, 0, 0, 0);
						}
					}
#ifdef LOADER_DEBUG
					ConLog.SkipLn();
#endif
				}
			}
			break;
		}
#ifdef LOADER_DEBUG
		ConLog.SkipLn();
#endif
	}

	return true;
}
Beispiel #6
0
// static 
void ModuleManager::Initialize(CommandHandler &cmdHandler)
{
   wxArrayString audacityPathList = wxGetApp().audacityPathList;
   wxArrayString pathList;
   wxArrayString files;
   wxString pathVar;
   size_t i;

   // Code from LoadLadspa that might be useful in load modules.
   pathVar = wxGetenv(wxT("AUDACITY_MODULES_PATH"));
   if (pathVar != wxT(""))
      wxGetApp().AddMultiPathsToPathList(pathVar, pathList);

   for (i = 0; i < audacityPathList.GetCount(); i++) {
      wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
      wxGetApp().AddUniquePathToPathList(prefix + wxT("modules"),
                                         pathList);
   }

   #if defined(__WXMSW__)
   wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files);
   #else
   wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);
   #endif

   wxString saveOldCWD = ::wxGetCwd();
   for (i = 0; i < files.GetCount(); i++) {
      // As a courtesy to some modules that might be bridges to
      // open other modules, we set the current working
      // directory to be the module's directory.
      wxString prefix = ::wxPathOnly(files[i]);
      ::wxSetWorkingDirectory(prefix);

#ifdef EXPERIMENTAL_MODULE_PREFS
      int iModuleStatus = ModulePrefs::GetModuleStatus( files[i] );
      if( iModuleStatus == kModuleDisabled )
         continue;
      if( iModuleStatus == kModuleFailed )
         continue;
      // New module?  You have to go and explicitly enable it.
      if( iModuleStatus == kModuleNew ){
         // To ensure it is noted in config file and so
         // appears on modules page.
         ModulePrefs::SetModuleStatus( files[i], kModuleNew);
         continue;
      }

      if( iModuleStatus == kModuleAsk )
#endif
      // JKC: I don't like prompting for the plug-ins individually
      // I think it would be better to show the module prefs page,
      // and let the user decide for each one.
      {
         wxString ShortName = wxFileName( files[i] ).GetName();
         wxString msg;
         msg.Printf(_("Module \"%s\" found."), ShortName.c_str());
         msg += _("\n\nOnly use modules from trusted sources");
         const wxChar *buttons[] = {_("Yes"), _("No"), NULL};  // could add a button here for 'yes and remember that', and put it into the cfg file.  Needs more thought.
         int action;
         action = ShowMultiDialog(msg, _("Audacity Module Loader"), buttons, _("Try and load this module?"), false);
#ifdef EXPERIMENTAL_MODULE_PREFS
         // If we're not prompting always, accept the answer permanantly
         if( iModuleStatus == kModuleNew ){
            iModuleStatus = (action==1)?kModuleDisabled : kModuleEnabled;
            ModulePrefs::SetModuleStatus( files[i], iModuleStatus );
         }
#endif
         if(action == 1){   // "No"
            continue;
         }
      }
#ifdef EXPERIMENTAL_MODULE_PREFS
      // Before attempting to load, we set the state to bad.
      // That way, if we crash, we won't try again.
      ModulePrefs::SetModuleStatus( files[i], kModuleFailed );
#endif

      Module *module = new Module(files[i]);
      if (module->Load())   // it will get rejected if there  are version problems
      {
         Get().mModules.Add(module);
         // We've loaded and initialised OK.
         // So look for special case functions:
         wxLogNull logNo; // Don't show wxWidgets errors if we can't do these. (Was: Fix bug 544.)
         // (a) for scripting.
         if( scriptFn == NULL )
            scriptFn = (tpRegScriptServerFunc)(module->GetSymbol(wxT(scriptFnName)));
         // (b) for hijacking the entire Audacity panel.
         if( pPanelHijack==NULL )
         {
            pPanelHijack = (tPanelFn)(module->GetSymbol(wxT(mainPanelFnName)));
         }
#ifdef EXPERIMENTAL_MODULE_PREFS
         // Loaded successfully, restore the status.
         ModulePrefs::SetModuleStatus( files[i], iModuleStatus);
#endif
      }
      else {
         // No need to save status, as we already set kModuleFailed.
         delete module;
      }
   }
   ::wxSetWorkingDirectory(saveOldCWD);

   // After loading all the modules, we may have a registered scripting function.
   if(scriptFn)
   {
      ScriptCommandRelay::SetCommandHandler(cmdHandler);
      ScriptCommandRelay::SetRegScriptServerFunc(scriptFn);
      NonGuiThread::StartChild(&ScriptCommandRelay::Run);
   }
}
Beispiel #7
0
void Module::readSegments(ifstream &ifs) {
    for(uint i = 0; i < headers.size(); ++i) {
        Header &h = headers[i];
        //cout << "Found header: " << h.name << endl;
        switch (h.type) {
            case Header::Functions:
                {
                    ifs.seekg(h.begin);
                    //uint fcount;
                    ifs.read((char*)&this->func_count, 4);

                    this->functions = new Function*[this->func_count];

                    uint fc = 0;

                    while (ifs.tellg() != h.end) {
                        this->functions[fc] = new Function;
                        Function* fun = this->functions[fc];

                        fun->ret = (Type)ifs.get();
                        //cout << "ifs.tellg() = " << hex << ifs.tellg() << endl;
                        ifs.get(fun->sign, SIGN_LENGTH, '\0').ignore();
                        //cout << "ifs.tellg() = " << hex << ifs.tellg() << dec << endl;
                        char ch = ifs.get();
                        uint arg_addr = 0;
                        while(ch != '\0') {
                            fun->args[fun->argc].type = (Type)ch;
                            fun->args[fun->argc].addr = arg_addr;
                            arg_addr += Runtime::Sizeof(fun->args[fun->argc].type) + 1;
                            ++fun->argc;
                            ch = ifs.get();
                        }
                        fun->args_size = arg_addr;

                        fun->isPrivate = (bool)ifs.get();
                        bool imported = (bool)ifs.get();
                        if(imported) {
                            char mod[128];
                            ifs.get(mod, 128, '\0').ignore();
                            if(!strcmp(mod, "::vm.internal")) {
                                fun->internal = true;
                            }
                            else
                            {
                                for(Module* m : rt->imported)
                                    if(m != nullptr && !strcmp(mod, m->file.c_str()))
                                    {
                                        for(uint t = 0; t < m->func_count; t++)
                                        {
                                            Function* f = m->functions[t];
                                            if(!strcmp(fun->sign, f->sign) && fun->argc == f->argc)
                                            {
                                                for(uint i = 0; i < f->argc; ++i)
                                                {
                                                    if(fun->args[i].type != f->args[i].type)
                                                        continue;
                                                    fun = f;

                                                }
                                            }
                                        }
                                        goto loop_out;
                                    }
                                Module* m = new Module;
                                m->Load(mod);
                                rt->imported.push_back(m);
                                for(uint t = 0; t < m->func_count; t++)
                                {
                                    Function* f = m->functions[t];
                                    if(!strcmp(fun->sign, f->sign) && fun->argc == f->argc)
                                    {
                                        for(uint i = 0; i < f->argc; ++i)
                                        {
                                            if(fun->args[i].type != f->args[i].type)
                                                continue;
                                            fun = f;
                                        }
                                    }
                                }
                            }
                        }
                        else {
                            //uint size;
                            ifs.read((char*)&fun->locals_size, 4);
                            if(fun->locals_size > 0) {
                                fun->locals = new LocalVar[fun->locals_size];

                                //uint local_mem_size;
                                ifs.read((char*)&fun->local_mem_size, 4);
                                //fun->locals_mem = new byte[local_mem_size];

                                uint cur_addr = 0;
                                for(uint i = 0; i < fun->locals_size; ++i) {
                                    fun->locals[i].addr = cur_addr;
                                    fun->locals[i].type = (Type)ifs.get();
                                    cur_addr += Runtime::Sizeof(fun->locals[i].type);
                                }
                                //ifs.read((char*)fun->locals, fun->locals_size);
                            }
                            ifs.read((char*)&fun->bc_size, 4);
                            fun->bytecode = new OpCode[fun->bc_size];
                            ifs.read((char*)fun->bytecode, fun->bc_size);
                        }
                        if(!strcmp(fun->sign, "__global_constructor__") && fun->argc == 0)
                            this->__global_constructor__ = fun;
                        fun->module = this;
loop_out:

                        ++fc;
                    }
                }
                break;
            case Header::Strings:
                {
                    //cout << "Strings size: " << h.end - h.begin << endl;
                    uint size = h.end - h.begin;
                    this->strings = new char[size];
                    ifs.seekg(h.begin);
                    ifs.read(this->strings, size);
                }
                break;
            case Header::Globals:
                {
                    ifs.seekg(h.begin);
                    //uint gcount;
                    ifs.read((char*)&this->globals_count, 4);
                    if(this->globals_count == 0) {
                        this->globals = nullptr;
                        continue;
                    }
                    this->globals = new GlobalVar[this->globals_count];
                    GlobalVar* gptr = globals;
                    while(ifs.tellg() != h.end) {
                        gptr->type = (Type)ifs.get();
                        gptr->isPrivate = (bool)ifs.get();
                        ifs.get(gptr->name, SIGN_LENGTH, '\0').ignore();

                        gptr->addr = rt->globals_ptr;
                        uint newsize = Runtime::Sizeof(gptr->type) + 1;
                        uint sz = size_t(rt->globals_ptr - rt->global_var_mem);
                        if(sz + newsize > rt->global_size)
                            rt->allocGlobalMem();
                        rt->globals_ptr += newsize;
                        ++gptr;
                    }
                }
                break;
            default:
                break;
        }
    }
}