MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / Init

Method Init

view/md1rom/md1rom.cpp:114–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112
113
114bool Md1romView::Init()
115{
116 if (m_mainRomFound)
117 {
118 uint64_t mainRomBase = MAIN_ROM_BASE;
119 Ref<Settings> settings = GetLoadSettings(GetTypeName());
120 if (settings && settings->Contains("loader.imageBase"))
121 mainRomBase = settings->Get<uint64_t>("loader.imageBase", this);
122
123 AddAutoSegment(mainRomBase + m_mainRom.addr, m_mainRom.length, m_mainRom.dataStart, m_mainRom.length,
124 SegmentExecutable | SegmentReadable | SegmentDenyWrite);
125 AddAutoSection(m_mainRom.name, mainRomBase + m_mainRom.addr, m_mainRom.length, ReadOnlyCodeSectionSemantics);
126 m_entryPoint = mainRomBase + m_mainRom.addr;
127
128 if (settings && settings->Contains("loader.platform")) // handle overrides
129 {
130 Ref<Platform> platformOverride = Platform::GetByName(settings->Get<string>("loader.platform", this));
131 if (platformOverride)
132 {
133 m_plat = platformOverride;
134 m_arch = m_plat->GetArchitecture();
135 }
136 }
137 else
138 {
139 m_plat = Platform::GetByName("nanomips");
140 m_arch = Architecture::GetByName("nanomips");
141 if (!m_arch)
142 {
143 LogWarn("nanoMIPS architecture not found. Code cannot be disassembled. If you are interested in purchasing "
144 "the nanoMIPS architecture plugin, please contact us via https://binary.ninja/support/");
145 }
146 }
147
148 if (m_arch && m_plat)
149 {
150 SetDefaultArchitecture(m_arch);
151 SetDefaultPlatform(m_plat);
152 }
153 }
154
155 // Finished for parse only mode
156 if (m_parseOnly)
157 {
158 return true;
159 }
160
161 if (m_plat)
162 {
163 AddEntryPointForAnalysis(m_plat, m_entryPoint);
164 // _start is defined by the dbginfo, so we use a different name
165 DefineAutoSymbol(new Symbol(FunctionSymbol, "_entry_point", m_entryPoint, GlobalBinding));
166 }
167
168 // Create the type for the segment header
169 StructureBuilder builder;
170 builder.AddMember(Type::IntegerType(4, false), "magic");
171 builder.AddMember(Type::IntegerType(4, false), "length");

Callers 1

Calls 13

IntegerTypeClass · 0.85
ArrayTypeClass · 0.85
StructureTypeClass · 0.85
Get<uint64_t>Method · 0.80
Get<string>Method · 0.80
AddMemberMethod · 0.80
DefineTypeMethod · 0.80
DefineDataVariableMethod · 0.80
AddAutoSectionMethod · 0.80
ProcessMethod · 0.80
ContainsMethod · 0.45
GetArchitectureMethod · 0.45

Tested by

no test coverage detected