Skip to content

The process was terminated due to an unhandled exception #13

@npendlington

Description

@npendlington

Using a really simple test to check that I'm able to hook anything in my target application.
Android 11, Pixel 2, rooted and successfully able to use frida-trace and frida cli to get hooks into the application.

	DeviceManager deviceManager;
	deviceManager = new DeviceManager(Dispatcher.CurrentDispatcher);
	var devices = deviceManager.EnumerateDevices();
	var usbDevice = devices.Where(d => d.Type == DeviceType.Usb).SingleOrDefault();
	if (usbDevice != null)
	{
		uint targetProcessPid = usbDevice.Spawn(applicationToSpawnName, null, null, null, null);
		Thread.Sleep(TimeSpan.FromSeconds(1));
		var session = usbDevice.Attach(targetProcessPid);
		usbDevice.Resume(targetProcessPid);
		var clientScript = session.CreateScript(File.ReadAllText(@"C:\Temp\js\poc.js"));
		clientScript.Message += ClientScriptMessageHandler;
		clientScript.Load();
		Thread.Sleep(Timeout.Infinite);
	}	

My .js is just a simple output to make sure the script is loaded and Java.perform is being called:

Java.perform(function () {
	console.log("hello");
});

I've tried a couple of different methods for pausing the thread / waiting while my output is received by the handler, but the process dies every time with the error The process was terminated due to an unhandled exception.

The eventlog records the .net runtime crash:

Application: test-frida.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentException
   at System.Runtime.InteropServices.GCHandle.InternalCheckDomain(IntPtr)
   at System.Runtime.InteropServices.GCHandle.FromIntPtr(IntPtr)
   at <Module>.msclr.gcroot<Frida::Script ^>.->(msclr.gcroot<Frida::Script ^>*)
   at <Module>.Frida.?A0x6d48abc7.OnScriptMessage(_FridaScript*, SByte*, _GBytes*, Void*)

and

Faulting application name: test-frida.exe, version: 1.0.0.0, time stamp: 0x57158fd2
Faulting module name: KERNELBASE.dll, version: 10.0.22000.918, time stamp: 0xb42fa627
Exception code: 0xe0434352
Fault offset: 0x000000000004474c
Faulting process ID: 0x6a18
Faulting application start time: 0x01d8ddade22a9c8a
Faulting application path: C:\projects\sandbox\frida-test\test-frida.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report ID: aa6a7c05-f113-41f4-ab01-5d558b52fbed
Faulting package full name: 
Faulting package-relative application ID: 

I'm referencing the 64bit version of the frida clr .dll downloaded at the same time as the frida-server which is running fine on the device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions