@@ -11,6 +11,7 @@ import strings from '../strings.js';
1111import { belongsTo , padPointer , sanitizeString } from '../utils.js' ;
1212import { parseMachoHeader , hasMainLoop } from '../darwin/index.js' ;
1313import { r2frida } from "../../plugin.js" ;
14+ import { listClassesLoaded } from './classes.js' ;
1415
1516
1617export async function dumpInfo ( ) {
@@ -186,6 +187,77 @@ export function listHeadersR2(args: string[]) : string {
186187 return "" ;
187188}
188189
190+ interface Symbol {
191+ name : string ;
192+ address : string ;
193+ }
194+
195+ export function listEntrypointSymbols ( args : string [ ] ) : string {
196+ const validEntrypoints = [
197+ "main" , "_start" , "_main" , "Main" ,
198+ "WinMain" , "wmain" , "DllMain" , "wWinMain" ,
199+ "UIApplicationMain" ,
200+ "applicationDidFinishLaunching" ,
201+ "application:didFinishLaunchingWithOptions" ,
202+ "applicationWillResignActive" ,
203+ "applicationDidEnterBackground" ,
204+ "applicationWillEnterForeground" ,
205+ "applicationDidBecomeActive" ,
206+ "applicationWillTerminate" ,
207+ "application:configurationForConnectingSceneSession:options" ,
208+ "application:didDiscardSceneSessions" ,
209+ "application:openURL:options" ,
210+ "application:performFetchWithCompletionHandler" ,
211+ "application:didReceiveRemoteNotification:fetchCompletionHandler" ,
212+ "application:handleEventsForBackgroundURLSession:completionHandler" ,
213+ "application:shouldSaveSecureApplicationState" ,
214+ "application:shouldRestoreSecureApplicationState" ,
215+ "application:didRegisterForRemoteNotificationsWithDeviceToken" ,
216+ "application:didFailToRegisterForRemoteNotificationsWithError" ,
217+ "application:didReceiveRemoteNotification" ,
218+ "application:handleOpenURL" ,
219+ "application:continueUserActivity:restorationHandler" ,
220+ "application:didUpdateUserActivity" ,
221+ "scene:willConnectToSession:options" ,
222+ "sceneDidDisconnect" ,
223+ "sceneDidBecomeActive" ,
224+ "sceneWillResignActive" ,
225+ "sceneWillEnterForeground" ,
226+ "sceneDidEnterBackground" ,
227+ "application:handleWatchKitExtensionRequest:reply" ,
228+ "main" ,
229+ "loadView" ,
230+ "viewDidLoad"
231+ ] ;
232+ const symbols = new Array < Symbol > ( ) ;
233+ if ( ObjC . available ) {
234+ const classes = ObjC . classes ;
235+ Object . keys ( classes ) . forEach ( function ( className : string ) {
236+ var cls = ObjC . classes [ className ] ;
237+ var methods = cls . $methods ; // $ownMethods?
238+ methods . forEach ( function ( methodName ) {
239+ try {
240+ var address = cls [ methodName ] . implementation ; // Get the implementation address
241+ console . log ( " Method: " + methodName + " | Address: " + address ) ;
242+ if ( validEntrypoints . includes ( methodName ) ) {
243+ symbols . push ( { name : className + "." + methodName , address : address } ) ;
244+ }
245+ } catch ( e ) {
246+ console . error ( " [Error getting implementation address for method " + methodName + "]: " + e ) ;
247+ }
248+ } ) ;
249+ } ) ;
250+ }
251+
252+ if ( symbols . length === 0 ) {
253+ return "" ;
254+ }
255+ const entries = symbols
256+ . map ( ( entry ) => {
257+ return 'f entry.' + entry . name + ' = ' + entry . address ;
258+ } ) . join ( '\n' ) ;
259+ return "fs+symbols\n" + entries + "\nfs-" ;
260+ }
189261export function listEntrypointR2 ( args : string [ ] ) : string {
190262 let n = 0 ;
191263 const entries = listEntrypointJson ( )
@@ -631,6 +703,7 @@ export default {
631703 dumpInfoJson,
632704 listEntrypointJson,
633705 listEntrypointR2,
706+ listEntrypointSymbols,
634707 listEntrypointQuiet,
635708 listEntrypoint,
636709 listImports,
0 commit comments