Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finding symbols from oat/dex files #143

Merged
merged 17 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
/captures
.externalNativeBuild
.cxx
local.properties
local.properties
.kotlin
1 change: 1 addition & 0 deletions frontend/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("debug")
}
}
buildFeatures {
Expand Down
15 changes: 4 additions & 11 deletions frontend/client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,17 @@ android {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
kotlinOptions { jvmTarget = "11" }

// Flavors and build types need to at least contain the ones of the app
flavorDimensions.add("version")
productFlavors {
create("real") {
dimension = "version"
}
create("mock") {
dimension = "version"
}
create("real") { dimension = "version" }
create("mock") { dimension = "version" }
}
}

dependencies {

val realImplementation by configurations.getting
val testRealImplementation by configurations.getting
val testRealDebugImplementation by configurations.creating
Expand All @@ -70,4 +63,4 @@ tasks.cyclonedxBom {
setIncludeBomSerialNumber(false)
setIncludeLicenseText(true)
setIncludeMetadataResolution(true)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]>
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -38,6 +39,10 @@ sealed class Event {

data class Process(val pid: Int, val ppid: Int, val state: String, val cmd: Command?)

data class StringResponse(val name: String)

data class Symbol(val method: String, val offset: ULong)

sealed class Command {
data class Cmdline(val components: List<String>) : Command()

Expand Down Expand Up @@ -67,6 +72,10 @@ interface Client {

suspend fun setConfiguration(configuration: Configuration)

suspend fun getOdexFiles(pid: UInt): Flow<String>

suspend fun getSymbols(odexFilePath: String): Flow<Symbol>

suspend fun initStream(): Flow<Event>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]>
// SPDX-FileCopyrightText: 2024 Luca Bretting <[email protected]>
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -109,6 +110,56 @@ object RustClient : Client {
}
}
}

override suspend fun getOdexFiles(pid: UInt): Flow<String> = flow {
emit("/system/framework/oat/x86_64/android.test.base.odex")
emit("/system/framework/oat/x86_64/android.hidl.base-V1.0-java.odex")
emit("/system/framework/oat/x86_64/org.apache.http.legacy.odex")
emit("/system/framework/oat/x86_64/android.hidl.manager-V1.0-java.odex")
emit("/system_ext/framework/oat/x86_64/androidx.window.sidecar.odex")
emit(
"/data/app/~~0cD8TtY5ggbzXOrlKANgwQ==/de.amosproj3.ziofa-Sm8ZemAtgxCr5VAK1Cwi8Q==/oat/x86_64/base.odex"
)

emit("/system_ext/framework/oat/x86_64/androidx.window.extensions.odex")
}

override suspend fun getSymbols(odexFilePath: String): Flow<Symbol> = flow {
emit(
Symbol(
Mr-Kanister marked this conversation as resolved.
Show resolved Hide resolved
method =
"void androidx.compose.material3.SearchBarDefaults\$InputField\$1\$1.<init>(kotlin.jvm.functions.Function1)",
offset = 6012800u,
)
)
emit(
Symbol(
method =
"void kotlin.collections.ArraysKt___ArraysKt\$asSequence\$\$inlined\$Sequence\$2.<init>(byte[])",
offset = 5915712u,
)
)
emit(
Symbol(
method =
"boolean androidx.compose.ui.platform.ViewLayer\$Companion.getHasRetrievedMethod()",
offset = 24010112u,
)
)
emit(
Symbol(
method =
"androidx.core.app.NotificationCompat\$BubbleMetadata androidx.core.app.NotificationCompat\$BubbleMetadata\$Api29Impl.fromPlatform(android.app.Notification\$BubbleMetadata)",
offset = 25453376u,
)
)
emit(
Symbol(
method = "byte androidx.emoji2.text.flatbuffer.FlexBuffers\$Blob.get(int)",
offset = 26906336u,
)
)
}
}

class RustClientFactory(val url: String) : ClientFactory {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: 2024 Felix Hilgers <[email protected]>
// SPDX-FileCopyrightText: 2024 Robin Seidl <[email protected]>
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -77,6 +78,10 @@ private fun Configuration.into() =
},
)

private fun uniffi.shared.StringResponse.into() = StringResponse(name)

private fun uniffi.shared.Symbol.into() = Symbol(method, offset)

class RustClient(private val inner: uniffi.client.Client) : Client {

override suspend fun serverCount(): Flow<UInt> = inner.serverCountFlow()
Expand All @@ -102,6 +107,12 @@ class RustClient(private val inner: uniffi.client.Client) : Client {
override suspend fun setConfiguration(configuration: Configuration) =
inner.setConfiguration(configuration.into())

override suspend fun getOdexFiles(pid: UInt): Flow<String> =
inner.getOdexFilesFlow(pid).mapNotNull { it.into().name }

override suspend fun getSymbols(odexFilePath: String): Flow<Symbol> =
luca-dot-sh marked this conversation as resolved.
Show resolved Hide resolved
inner.getSymbolFlow(odexFilePath).mapNotNull { it.into() }

override suspend fun initStream(): Flow<Event> = inner.initStreamFlow().mapNotNull { it.into() }
}

Expand Down Expand Up @@ -141,3 +152,19 @@ fun uniffi.client.Client.initStreamFlow() = flow {
}
}
}

fun uniffi.client.Client.getOdexFilesFlow(pid: UInt) = flow {
getOdexFiles(pid).use { stream ->
while (true) {
stream.next()?.also { file -> emit(file) } ?: break
}
}
}

fun uniffi.client.Client.getSymbolFlow(odexFilePath: String) = flow {
luca-dot-sh marked this conversation as resolved.
Show resolved Hide resolved
getSymbols(odexFilePath).use { stream ->
while (true) {
stream.next()?.also { symbol -> emit(symbol) } ?: break
}
}
}
Loading