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