void Module::initialisePlayReportSetting()
{
   PlayReportSetting::TypeInfo = ghs::internal::makeTypeDescriptor("nn::boss::PlayReportSetting", {
      { RawUlTaskSetting::TypeInfo, 0x1600 },
   });

   PlayReportSetting::VirtualTable = ghs::internal::makeVirtualTable({
      { 0, PlayReportSetting::TypeInfo },
      { 0, findExport("__dt__Q3_2nn4boss17PlayReportSettingFv") },
      { 0, findExport("RegisterPreprocess__Q3_2nn4boss17PlayReportSettingFUiQ3_2nn4boss7TitleIDPCc") },
      RawUlTaskSetting::VirtualTable[3],
   });
}
/**
 * Find the export from a library handle.
 *
 * Note that for TLS there will be a symbol, but no section,
 * and for normal data / code there with be a section but no symbol.
 */
int
OSDynLoad_FindExport(ModuleHandle handle,
                     int isData,
                     char const *name,
                     be_val<ppcaddr_t> *outAddr)
{
   auto module = handle->ptr;
   auto addr = module->findExport(name);

   *outAddr = addr;

   if (!addr) {
      gLog->debug("OSDynLoad_FindExport export {} not found", name);
      return 0xBAD10001;
   }

   // Let's first try to verify the export type based off the section it is in
   auto section = module->findAddressSection(addr);

   if (section) {
      if (isData) {
         if (section->type != kernel::loader::LoadedSectionType::Data) {
            gLog->debug("OSDynLoad_FindExport export {} expected data, found function", name);
            return 0xBAD10001;
         }
      } else {
         if (section->type != kernel::loader::LoadedSectionType::Code) {
            gLog->debug("OSDynLoad_FindExport export {} expected function, found data", name);
            return 0xBAD10001;
         }
      }

      return 0;
   }

   // Now let's try to verify it based off it's symbol
   auto symbol = module->findSymbol(addr);

   if (symbol) {
      if (symbol->type == kernel::loader::SymbolType::TLS) {
         return 0xBAD10033;
      } else if (isData && symbol->type != kernel::loader::SymbolType::Data) {
         gLog->debug("OSDynLoad_FindExport export {} expected data, found function", name);
         return 0xBAD10001;
      } else if (!isData && symbol->type != kernel::loader::SymbolType::Function) {
         gLog->debug("OSDynLoad_FindExport export {} expected function, found data", name);
         return 0xBAD10001;
      }

      return 0;
   }

   // Couldn't find a section or a symbol for the export, this should never happen...!
   decaf_abort(fmt::format("OSDynLoad_FindExport could not find symbol or section for export address 0x{:08X}", addr));
   return 0xBAD10001;
}
Exemplo n.º 3
0
unsigned int findProc( const char * szMod, const char * szLib, unsigned int nid )
{
	unsigned int * export = findExport( szMod, szLib, nid );
	if( export )
	{
		log( "func %08x in %s of %s found:\n%08x\n",
			nid, szLib, szMod, *export );
		return *export;
	}
	return 0;
}
Exemplo n.º 4
0
int
OSDynLoad_FindExport(LoadedModuleHandleData *handle, int isData, char const *name, be_val<ppcaddr_t> *outAddr)
{
   auto module = handle->ptr;
   auto exportPtr = module->findExport(name);

   if (!exportPtr) {
      gLog->debug("OSDynLoad_FindExport export {} not found", name);
      *outAddr = 0;
      return 0xBAD10001;
   }

   *outAddr = exportPtr;
   return 0;
}
Exemplo n.º 5
0
static KernelData *
findKernelData(ModuleSymbol *msym, const char *name)
{
   if (!msym || !msym->systemModule) {
      return nullptr;
   }

   auto module = msym->systemModule;
   auto sysexp = module->findExport(name);

   if (!sysexp) {
      return nullptr;
   }

   assert(sysexp->type == KernelExport::Data);
   return reinterpret_cast<KernelData*>(sysexp);
}
Exemplo n.º 6
0
void
handlePreLaunch()
{
   // Do not add entry breakpoints if debugger is disabled
   if (!decaf::config::debugger::enabled) {
      return;
   }

   // Do not add entry breakpoints if it is disabled
   if (!decaf::config::debugger::break_on_entry) {
      return;
   }

   auto appModule = kernel::getUserModule();
   auto userPreinit = appModule->findExport("__preinit_user");

   if (userPreinit) {
      cpu::addBreakpoint(userPreinit, cpu::SYSTEM_BPFLAG);
   }

   auto start = appModule->entryPoint;
   cpu::addBreakpoint(start, cpu::SYSTEM_BPFLAG);
}