Update idevice to fix retransmission and debug proxy issue https://github.com/jkcoxson/idevice/pull/14 (#213)

This commit is contained in:
Huge_Black 2025-07-06 00:48:23 +08:00 • committed by GitHub
parent 354333d873
commit 4e0d0b4a93
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 20 additions and 22 deletions

View file

@ -17,7 +17,7 @@ NSString* handleJSContextSendDebugCommand(JSContext* context, NSString* commandS
command = debugserver_command_new([commandStr UTF8String], NULL, 0);
char* attach_response = 0;
IdeviceFfiError* err = debug_proxy_send_command2(debugProxy, command, &attach_response);
IdeviceFfiError* err = debug_proxy_send_command(debugProxy, command, &attach_response);
debugserver_command_free(command);
if (err) {
context.exception = [JSValue valueWithObject:[NSString stringWithFormat:@"error code %d, msg %s", err->code, err->message] inContext:context];

View file

@ -12,7 +12,8 @@ import JavaScriptCore
class RunJSViewModel : ObservableObject {
var context: JSContext?
@Published var logs: [String] = []
@Published var scriptName : String = "Script"
@Published var scriptName: String = "Script"
@Published var executionInterrupted = false
var pid: Int
var debugProxy: OpaquePointer?
var semaphore: dispatch_semaphore_t?
@ -33,8 +34,12 @@ class RunJSViewModel : ObservableObject {
let sendCommandFunction: @convention(block) (String?) -> String? = { commandStr in
guard let commandStr else {
self.context?.exception = JSValue(object: "command should not be nil", in: self.context!)
return nil
self.context?.exception = JSValue(object: "Command should not be nil.", in: self.context!)
return ""
}
if self.executionInterrupted {
self.context?.exception = JSValue(object: "Script execution is interrupted by StikDebug.", in: self.context!)
return ""
}
return handleJSContextSendDebugCommand(self.context, commandStr, self.debugProxy) ?? ""

View file

@ -321,6 +321,7 @@ struct HomeView: View {
}
.onChange(of: scriptViewShow) { oldValue, newValue in
if !newValue, let jsModel {
jsModel.executionInterrupted = true
jsModel.semaphore?.signal()
}
}

View file

@ -18,20 +18,6 @@
#include "jit.h"
IdeviceFfiError* debug_proxy_send_command2(struct DebugProxyHandle *handle, struct DebugserverCommandHandle *command, char **response) {
IdeviceFfiError* err = debug_proxy_send_command(handle, command, response);
if(err) {
return err;
}
for(int i = 0; i < 10; ++i) {
if(*response) {
return err;
}
debug_proxy_read_response(handle, response);
}
return err;
}
void runDebugServerCommand(int pid, DebugProxyHandle* debug_proxy, LogFuncC logger, DebugAppCallback callback) {
// enable QStartNoAckMode
char *disableResponse = NULL;
@ -49,6 +35,7 @@ void runDebugServerCommand(int pid, DebugProxyHandle* debug_proxy, LogFuncC logg
callback(pid, debug_proxy, semaphore);
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
err = debug_proxy_send_raw(debug_proxy, "\x03", 1);
usleep(500);
} else {
// Send vAttach command with PID in hex
char attach_command[64];
@ -61,7 +48,7 @@ void runDebugServerCommand(int pid, DebugProxyHandle* debug_proxy, LogFuncC logg
}
char *attach_response = NULL;
err = debug_proxy_send_command2(debug_proxy, attach_cmd, &attach_response);
err = debug_proxy_send_command(debug_proxy, attach_cmd, &attach_response);
debugserver_command_free(attach_cmd);
if (err) {
@ -79,11 +66,12 @@ void runDebugServerCommand(int pid, DebugProxyHandle* debug_proxy, LogFuncC logg
logger("Failed to create detach command");
} else {
char *detach_response = NULL;
err = debug_proxy_send_command2(debug_proxy, detach_cmd, &detach_response);
err = debug_proxy_send_command(debug_proxy, detach_cmd, &detach_response);
debugserver_command_free(detach_cmd);
if (err) {
logger("Failed to detach from process: %d", err);
logger("Failed to detach from process: %d", err->code);
idevice_error_free(err);
} else if (detach_response != NULL) {
logger("Detach response: %s", detach_response);
idevice_string_free(detach_response);
@ -188,6 +176,11 @@ int debug_app(IdeviceProviderHandle* tcp_provider, const char *bundle_id, LogFun
return 1;
}
printf("Successfully launched app with PID: %llu\n", pid);
char* path = malloc(2048);
snprintf(path, 2048, "%s/Documents/debugProxy.pcap", getenv("HOME"));
adapter_pcap(adapter, path);
free(path);
printf("\n=== Setting up Debug Proxy ===\n");

View file

@ -13,7 +13,6 @@
typedef void (^LogFuncC)(const char* message, ...);
typedef void (^DebugAppCallback)(int pid, struct DebugProxyHandle* debug_proxy, dispatch_semaphore_t semaphore);
int debug_app(IdeviceProviderHandle* tcp_provider, const char *bundle_id, LogFuncC logger, DebugAppCallback callback);
IdeviceFfiError* debug_proxy_send_command2(struct DebugProxyHandle *handle, struct DebugserverCommandHandle *command, char **response);
int debug_app_pid(IdeviceProviderHandle* tcp_provider, int pid, LogFuncC logger, DebugAppCallback callback);
#endif /* JIT_H */

Binary file not shown.