@@ -125,6 +125,7 @@ void InfoHandler::applyInfoToView(SharedAnalysisInfo info, BinaryViewRef bv)
125125 BinaryReader reader (bv);
126126
127127 auto taggedPointerType = namedType (bv, CustomTypes::TaggedPointer);
128+ auto categoryType = namedType (bv, CustomTypes::Category);
128129 auto cfStringType = namedType (bv, CustomTypes::CFString);
129130 auto classType = namedType (bv, CustomTypes::Class);
130131 auto classDataType = namedType (bv, CustomTypes::ClassRO);
@@ -198,6 +199,62 @@ void InfoHandler::applyInfoToView(SharedAnalysisInfo info, BinaryViewRef bv)
198199 defineSymbol (bv, ci.methodListAddress , ci.name , " ml_" );
199200 }
200201
202+ // Create data variables and symbols for the analyzed Categories.
203+ for (const auto & ci : info->categories ) {
204+ defineVariable (bv, ci.listPointer , taggedPointerType);
205+ defineVariable (bv, ci.address , categoryType);
206+
207+ defineSymbol (bv, ci.listPointer , ci.name , " catp_" );
208+ defineSymbol (bv, ci.address , ci.name , " cat_" );
209+
210+ defineReference (bv, ci.listPointer , ci.address );
211+
212+ if (ci.instanceMethods .address && !ci.instanceMethods .methods .empty ()) {
213+ auto methodType = ci.instanceMethods .hasRelativeOffsets ()
214+ ? bv->GetTypeByName (CustomTypes::MethodListEntry)
215+ : bv->GetTypeByName (CustomTypes::Method);
216+
217+ // Create data variables for each method in the method list.
218+ for (const auto & mi : ci.instanceMethods .methods ) {
219+ defineVariable (bv, mi.address , methodType);
220+ defineSymbol (bv, mi.address , sanitizeSelector (mi.selector ), " mt_" );
221+ defineVariable (bv, mi.typeAddress , stringType (mi.type .size ()));
222+
223+ defineReference (bv, ci.instanceMethods .address , mi.address );
224+ defineReference (bv, mi.address , mi.nameAddress );
225+ defineReference (bv, mi.address , mi.typeAddress );
226+ defineReference (bv, mi.address , mi.implAddress );
227+ }
228+
229+ // Create a data variable and symbol for the method list header.
230+ defineVariable (bv, ci.instanceMethodListAddress , methodListType);
231+ defineSymbol (bv, ci.instanceMethodListAddress , ci.name , " mli_" );
232+ }
233+
234+
235+ if (ci.classMethods .address && !ci.classMethods .methods .empty ()) {
236+ auto methodType = ci.classMethods .hasRelativeOffsets ()
237+ ? bv->GetTypeByName (CustomTypes::MethodListEntry)
238+ : bv->GetTypeByName (CustomTypes::Method);
239+
240+ // Create data variables for each method in the method list.
241+ for (const auto & mi : ci.classMethods .methods ) {
242+ defineVariable (bv, mi.address , methodType);
243+ defineSymbol (bv, mi.address , sanitizeSelector (mi.selector ), " mt_" );
244+ defineVariable (bv, mi.typeAddress , stringType (mi.type .size ()));
245+
246+ defineReference (bv, ci.classMethods .address , mi.address );
247+ defineReference (bv, mi.address , mi.nameAddress );
248+ defineReference (bv, mi.address , mi.typeAddress );
249+ defineReference (bv, mi.address , mi.implAddress );
250+ }
251+
252+ // Create a data variable and symbol for the method list header.
253+ defineVariable (bv, ci.classMethodListAddress , methodListType);
254+ defineSymbol (bv, ci.classMethodListAddress , ci.name , " mlc_" );
255+ }
256+ }
257+
201258 bv->CommitUndoActions ();
202259 bv->UpdateAnalysis ();
203260}
0 commit comments