MCPcopy Create free account
hub / github.com/APKLab/APKLab / navigateSourceCode

Function navigateSourceCode

src/tools/quark-engine.ts:216–330  ·  view source on GitHub ↗

* Search and highlight where APIs called in source code. * @param projectDir project output dir for decode/decompile/analysis. * @param parentFunction The data of parent function where APIs called from. * @param apiCalls The smali code that executes native APIs.

(
    projectDir: string,
    parentFunction: QuarkFunction,
    apiCalls: string[][],
)

Source from the content-addressed store, hash-verified

214 * @param apiCalls The smali code that executes native APIs.
215 */
216async function navigateSourceCode(
217 projectDir: string,
218 parentFunction: QuarkFunction,
219 apiCalls: string[][],
220): Promise<void> {
221 const smaliPath = functionToPath(projectDir, parentFunction);
222
223 if (!smaliPath) {
224 vscode.window.showErrorMessage(
225 "APKLab: Smali source file not found for the selected function.",
226 );
227 return;
228 }
229
230 try {
231 const doc = await vscode.workspace.openTextDocument(smaliPath);
232 const e = await vscode.window.showTextDocument(
233 doc,
234 vscode.ViewColumn.One,
235 );
236
237 const parentDecorationsArray: vscode.DecorationOptions[] = [];
238 const apiDecorationsArray: vscode.DecorationOptions[] = [];
239
240 const mdSegment: number[] | false = searchFunctionSegment(
241 doc,
242 parentFunction.method,
243 );
244 if (!mdSegment) {
245 vscode.window.showErrorMessage(
246 "APKLab: Cannot find the parent function in source code!",
247 );
248 return;
249 }
250 const parentFunctionPosition = new vscode.Position(mdSegment[0], 0);
251
252 const fstApi: vscode.Position | false = getApiCallPosition(
253 doc,
254 apiCalls[0],
255 mdSegment,
256 );
257 const secApi: vscode.Position | false = getApiCallPosition(
258 doc,
259 apiCalls[1],
260 mdSegment,
261 );
262
263 if (!fstApi || !secApi) {
264 vscode.window.showErrorMessage(
265 "APKLab: Cannot find the APIs call in source code!",
266 );
267 return;
268 }
269
270 const fstApiDecoration = {
271 range: new vscode.Range(fstApi, fstApi),
272 };
273 const secApiDecoration = {

Callers 1

showSummaryReportFunction · 0.85

Calls 3

functionToPathFunction · 0.85
searchFunctionSegmentFunction · 0.85
getApiCallPositionFunction · 0.85

Tested by

no test coverage detected