rovo89 / XposedBridge

The Java part of the Xposed framework.
3.91k stars 1.1k forks source link

How to replace facebook like button? #93

Closed nylonW closed 7 years ago

nylonW commented 8 years ago

i am using this

public class myapp implements IXposedHookZygoteInit, IXposedHookInitPackageResources {
    private static String MODULE_PATH = null;
    public void initZygote(StartupParam startupParam) throws Throwable {
        MODULE_PATH = startupParam.modulePath;
    }

    public void handleInitPackageResources(InitPackageResourcesParam resparam) throws Throwable {
        if (!resparam.packageName.equals("com.facebook.katana"))
            return;
        XModuleResources modRes = XModuleResources.createInstance(MODULE_PATH, resparam.res);    
        resparam.res.setReplacement("com.facebook.katana", "drawable", "reaction_token_icons", modRes.fwd(R.drawable.reaction_token_icons));
        resparam.res.setReplacement("com.facebook.katana", "drawable", "reaction_large_icons", modRes.fwd(R.drawable.reaction_large_icons));      
        resparam.res.setReplacement("com.facebook.katana", "drawable", "reactions_tab_icons", modRes.fwd(R.drawable.reactions_tab_icons));
        resparam.res.setReplacement("com.facebook.katana", "string", "ufiservices_like", "Licke");
        resparam.res.setReplacement("com.facebook.katana", "string", "feed_like_page", "Licke Page");
        resparam.res.setReplacement("com.facebook.katana", "string", "page_identity_action_like", "Licke");
        resparam.res.setReplacement("com.facebook.katana", "drawable", "fbui_like_l", modRes.fwd(R.drawable.fbui_like_l));
        resparam.res.setReplacement("com.facebook.katana", "string", "ufiservices_unlike", "UnLicke");
        resparam.res.setReplacement("com.facebook.katana", "drawable", "fbui_like_l", modRes.fwd(R.drawable.ufi_icon_like)); 
    }
}

and text is replacing but images are same as before

rovo89 commented 8 years ago

Have you made sure that these images are really the ones which are used? The most reliable way would be to replace them manually in the APK, sign it yourself and install it.

Once this is verified, please find out which method the app uses to access the images. Things like getDrawable() should work fine, but maybe they use something else or even native code.

nylonW commented 8 years ago

Yes, i am sure, I created APK file before. How can I use getDrawable() in this code? How can i find that specific method in smali or xml files? Thanks for reply.

nylonW commented 8 years ago

I have decompiled apk too

rovo89 commented 8 years ago

How can I use getDrawable() in this code?

I meant to check whether the Facebook app uses getDrawable() or something like that, not your app.

How can i find that specific method in smali or xml files?

I usually use Notepad++ to search in all files in a subdirectory. On Linux, you would obviously use grep. You should be able to find out the resource ID from public.xml (or something like that), and then you can search for it in the smali files using the tools I mentioned.

nylonW commented 8 years ago

I found

const v8, 0x7f02077a

move v1, v8

invoke-virtual {v0, v7, v1, v6}, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;-
 a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;ILcom/facebook/graphql/model/FeedUnit;)V

what should I do now?

nylonW commented 8 years ago

and

.method protected final a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenu;Lcom/facebook/feed/rows/core/props/FeedProps;Landroid/content/Context;)V
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/facebook/feed/ui/api/ChevronMenu;",
            "Lcom/facebook/feed/rows/core/props/FeedProps",
            "<",
            "Lcom/facebook/graphql/model/GraphQLStory;",
            ">;",
            "Landroid/content/Context;",
            ")V"
        }
    .end annotation
rovo89 commented 8 years ago

Formatting hint: Instead of a single backtick, use three backticks and also add "smali" to format a block of code and add syntax highlighting, see also https://guides.github.com/features/mastering-markdown/

The second method doesn't exactly match the one that was called with the constant (parameter types are different). Could you please post the full content of the method with the correct parameters?

nylonW commented 8 years ago
.method protected final a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenu;Lcom/facebook/feed/rows/core/props/FeedProps;Landroid/content/Context;)V
    .locals 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/facebook/feed/ui/api/ChevronMenu;",
            "Lcom/facebook/feed/rows/core/props/FeedProps",
            "<",
            "Lcom/facebook/graphql/model/GraphQLStory;",
            ">;",
            "Landroid/content/Context;",
            ")V"
        }
    .end annotation

    .prologue
    .line 897
    invoke-virtual {p2}, Lcom/facebook/feed/rows/core/props/FeedProps;->a()Landroid/os/Parcelable;

    move-result-object v0

    move-object v6, v0

    check-cast v6, Lcom/facebook/graphql/model/GraphQLStory;

    .line 898
    const v0, 0x7f0809e8

    invoke-virtual {p1, v0}, Lcom/facebook/feed/ui/api/BottomsheetChevronMenu;->g(I)Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;

    move-result-object v7

    .line 899
    sget-object v0, Lcom/facebook/zero/common/constants/AssistedOnboardingConst$LinkSource;->COPY_LINK:Lcom/facebook/zero/common/constants/AssistedOnboardingConst$LinkSource;

    invoke-virtual {v0}, Lcom/facebook/zero/common/constants/AssistedOnboardingConst$LinkSource;->name()Ljava/lang/String;

    move-result-object v4

    .line 900
    iget-object v0, p0, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper$BaseFeedStoryMenuOptions;->a:Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;

    invoke-virtual {p1, v7}, Lcom/facebook/feed/ui/api/BottomsheetChevronMenu;->b(Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;)I

    move-result v1

    const/4 v2, 0x0

    invoke-virtual {v0, p2, v1, v4, v2}, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;->a(Lcom/facebook/feed/rows/core/props/FeedProps;ILjava/lang/String;Z)V

    .line 901
    new-instance v0, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper$BaseFeedStoryMenuOptions$1;

    move-object v1, p0

    move-object v2, p2

    move-object v3, p1

    move-object v5, p3

    invoke-direct/range {v0 .. v5}, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper$BaseFeedStoryMenuOptions$1;-><init>(Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper$BaseFeedStoryMenuOptions;Lcom/facebook/feed/rows/core/props/FeedProps;Lcom/facebook/feed/ui/api/BottomsheetChevronMenu;Ljava/lang/String;Landroid/content/Context;)V

    invoke-virtual {v7, v0}, Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;->a(Lcom/facebook/feed/ui/api/ChevronMenuItem$OnChevronMenuItemClickListener;)V

    .line 911
    iget-object v0, p0, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper$BaseFeedStoryMenuOptions;->a:Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;

    .line 94
    const v8, 0x7f02077a

    move v1, v8

    invoke-virtual {v0, v7, v1, v6}, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;->a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;ILcom/facebook/graphql/model/FeedUnit;)V

    .line 912
    return-void
.end method
nylonW commented 8 years ago

Thanks for protip. 0x7f02077a is my drawable

rovo89 commented 8 years ago

Ok, so can you post the content of this method please? Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;->a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;ILcom/facebook/graphql/model/FeedUnit;)V

As you can see, it takes your drawable ID as second argument, so I need to know what it does with it.

nylonW commented 8 years ago
.method protected final a(Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;ILcom/facebook/graphql/model/FeedUnit;)V
    .locals 1

    .prologue
    .line 1340
    invoke-virtual {p0}, Lcom/facebook/feed/ui/BaseFeedStoryMenuHelper;->i()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 1341
    invoke-virtual {p1, p2}, Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;->c(I)V

    .line 1343
    :cond_0
    return-void
.end method
nylonW commented 8 years ago

and here is full smali file http://pastebin.com/eBiTHrt5

rovo89 commented 8 years ago

So the ID (p2 / second parameter) is passed on to Lcom/facebook/feed/ui/api/BottomsheetChevronMenuItem;->c(I)V. That would be the next method to check. Could you please follow the code flow until you get to a place where the Android SDK (not Facebook-internal code) is called?

nylonW commented 8 years ago

I can't find it, but i found another method of another drawable. This time my id is 0x7f021597

.method private b()V
    .locals 3

    .prologue
    .line 129
    const v0, 0x7f0d1e7a

    const v1, 0x7f08090c

    const v2, 0x7f021597

    invoke-direct {p0, v0, v1, v2}, Lcom/facebook/reviews/ui/ReviewFeedRowView;->a(III)Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;

    move-result-object v0

    iput-object v0, p0, Lcom/facebook/reviews/ui/ReviewFeedRowView;->s:Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;

    .line 135
    const v0, 0x7f0d1e7b

    const v1, 0x7f08090e

    const v2, 0x7f021596

    invoke-direct {p0, v0, v1, v2}, Lcom/facebook/reviews/ui/ReviewFeedRowView;->a(III)Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;

    move-result-object v0

    iput-object v0, p0, Lcom/facebook/reviews/ui/ReviewFeedRowView;->t:Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;

    .line 139
    return-void
.end method
nylonW commented 8 years ago

and i think this is it

.method private a(III)Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;
    .locals 3

    .prologue
    .line 145
    invoke-virtual {p0, p1}, Lcom/facebook/widget/CustomLinearLayout;->a(I)Landroid/view/View;

    move-result-object v0

    check-cast v0, Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;

    .line 146
    invoke-virtual {p0}, Lcom/facebook/reviews/ui/ReviewFeedRowView;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    invoke-virtual {v1, p2}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;->setText(Ljava/lang/CharSequence;)V

    .line 147
    iget-object v1, p0, Lcom/facebook/reviews/ui/ReviewFeedRowView;->b:Lcom/facebook/fbui/glyph/GlyphColorizer;

    const v2, -0x6e685d

    invoke-virtual {v1, p3, v2}, Lcom/facebook/fbui/glyph/GlyphColorizer;->a(II)Landroid/graphics/drawable/Drawable;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/facebook/fbui/widget/text/ImageWithTextView;->setImageDrawable(Landroid/graphics/drawable/Drawable;)V

    .line 149
    iget-object v1, p0, Lcom/facebook/reviews/ui/ReviewFeedRowView;->c:Ljavax/inject/Provider;

    invoke-interface {v1}, Ljavax/inject/Provider;->get()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/facebook/widget/springbutton/TouchSpring;

    invoke-virtual {v0, v1}, Lcom/facebook/feed/widget/FeedbackCustomPressStateButton;->setSpring(Lcom/facebook/widget/springbutton/TouchSpring;)V

    .line 150
    return-object v0
.end method
nylonW commented 8 years ago

what now?

rovo89 commented 8 years ago

Well, like I said - follow it down to a call to the Android SDK. This should be the next hop: invoke-virtual {v1, p3, v2}, Lcom/facebook/fbui/glyph/GlyphColorizer;->a(II)Landroid/graphics/drawable/Drawable;