From babb2c08569fb28d092f5c41f21df9c2cc3836f7 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 13 Sep 2021 14:15:52 -0700 Subject: [PATCH] [AltServer] Fixes incorrectly parsing thread state as decimal value when enabling JIT Thread state is hexadecimal, so we now explicitly use NSScanner to parse string as base-16. --- AltServer/Connections/ALTDebugConnection.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/AltServer/Connections/ALTDebugConnection.mm b/AltServer/Connections/ALTDebugConnection.mm index cdcd7486..e7e2598a 100644 --- a/AltServer/Connections/ALTDebugConnection.mm +++ b/AltServer/Connections/ALTDebugConnection.mm @@ -258,8 +258,13 @@ char *bin2hex(const unsigned char *bin, size_t length) NSString *mainThread = components[1]; NSString *threadState = [[mainThread componentsSeparatedByString:@":"] lastObject]; + NSScanner *scanner = [NSScanner scannerWithString:threadState]; + + unsigned long long mainThreadState = 0; + [scanner scanHexLongLong:&mainThreadState]; + // If main thread state == 0, app is not running. - if ([threadState longLongValue] == 0) + if (mainThreadState == 0) { if (error) {