google / smali

Other
210 stars 35 forks source link

VerifyError caused by smali'd invoke-custom #79

Open IgorEisberg opened 1 month ago

IgorEisberg commented 1 month ago

So Android 15 brought the use of java.lang.Record classes. They have become a huge pain because simply baksmaling them and smaling them back will produce a VerifyError due to incorrect number of arguments. I'm not very knowledgeable about "invoke-custom", this is the first time I'm seeing them in baksmali'd source.

Example from service-art.jar:

.method public final equals(Ljava/lang/Object;)Z
    .locals 0

    invoke-custom {p0, p1}, call_site_0("equals", (Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;Ljava/lang/Object;)Z, Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;, "dmPath;config", instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->dmPath:Lcom/android/server/art/DexMetadataPath;, instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->config:Lcom/android/server/art/proto/DexMetadataConfig;)@Ljava/lang/runtime/ObjectMethods;->bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;

    move-result p0

    return p0
.end method

.method public final hashCode()I
    .locals 0

    invoke-custom {p0}, call_site_1("hashCode", (Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;)I, Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;, "dmPath;config", instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->dmPath:Lcom/android/server/art/DexMetadataPath;, instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->config:Lcom/android/server/art/proto/DexMetadataConfig;)@Ljava/lang/runtime/ObjectMethods;->bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;

    move-result p0

    return p0
.end method

.method public final toString()Ljava/lang/String;
    .locals 0

    invoke-custom {p0}, call_site_2("toString", (Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;)Ljava/lang/String;, Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;, "dmPath;config", instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->dmPath:Lcom/android/server/art/DexMetadataPath;, instance-get@Lcom/android/server/art/DexMetadataHelper$DexMetadataInfo;->config:Lcom/android/server/art/proto/DexMetadataConfig;)@Ljava/lang/runtime/ObjectMethods;->bootstrap(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/TypeDescriptor;Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/Object;

    move-result-object p0

    return-object p0
.end method
IgorEisberg commented 1 month ago

Fixed by https://github.com/google/smali/pull/76#issuecomment-2392967966