Help! issues about hooking API with MobileSubstrate~

Discussion in 'iOS Development' started by freelow, Jan 15, 2010.

  1. freelow

    freelow New Member

    Joined:
    Jan 5, 2010
    Messages:
    5
    Likes Received:
    0
    [Resolved. Thanks!]Help! issues about hooking API with MobileSubstrate~

    I'm a colledge student and now trying to develop a little app under Linux+3.1.2 Toolchain. I use MobileSubstrate to implement API hook.

    Functions I want to hook are from UIKit.

    The exported functions can be hooked successfully.
    But functions which are not exported from UIKit cannot be hooked. It's always reported "undefined symbols" when building the dylib.

    Does mobilesubstrate support hooking function which is not exported???
    ------------------double post merged------------------
    If it doesn't, then how could I do my implement?

    I wanna hook the unexported API. In the API, an NSDictionary is hard coded, and I wanna change the value of the NSDictionary. I think I can hook the init* method of NSDictionary, but how could I know the init* method of NSDictionary is called within the API?


    Many Many Thanks!
  2. Jeepston

    Jeepston New Member

    Joined:
    May 17, 2009
    Messages:
    45
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    IMHO, MobileSubstrate is just for hooking SpringBoard methods...

    If you need to modify NSDictionary - inherit it and add your own methods.
  3. freelow

    freelow New Member

    Joined:
    Jan 5, 2010
    Messages:
    5
    Likes Received:
    0
    Thanks, man! I figured it out now. MobileSubstrate can be used to hook functions and class methods, not just SpringBoard methods. I find that the "undefined symbol" linking errors are caused by name mangling.

    Please Register or Log in to view images

    I add extern "C" for these functions, and it works fine.

    Please Register or Log in to view images

  4. lauNchD

    lauNchD Well-Known Member

    Joined:
    Jan 27, 2008
    Messages:
    1,844
    Likes Received:
    261
    Device:
    iPhone 5 (Black)
    MobileSubstrate can be use for hooking "anything" (even some pure C libraries) anywhere.
    Regarding your NSDictionary question: Why would you need to hook into it in the 1st place? With such wide usage in all kinds of apps, wouldn't you be messing up something?
  5. freelow

    freelow New Member

    Joined:
    Jan 5, 2010
    Messages:
    5
    Likes Received:
    0
    You're right, man!

    Please Register or Log in to view images

    I should not try to hook init* methods of NSDictionary.
    Previously I wan to to hook a function which contains a hard-coded NSDictionary. But for my mistakes (the C++ name mangling), I always got linking errors. It leads me to a wrong way and makes me try to hook NSDictionary. Now this problem is resolved, and it works ok.

Share This Page