Home User CP Donate Chat Register Today!  
  Get New posts Faq / Help?
   


Go Back   Hackint0sh > Projects and Hacks > iPhone > iPhone 3G (Rev. 2) > iPhone OS 3.x

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2009, 01:15 PM
netkas's Avatar
netkas
Status: Offline
Engineer
 
Join Date: Oct 2006
Posts: 235
Rep Power: 10
netkas has disabled reputation
Default About binary difference of 2g/3g and 3gs

As you all know, 3gs has new cpu.
the main difference for us is that new cpu support thumb2 instructions set, and 2g/3g cpu doesnt support it

binaries for 2g/3g has cpu subtype = 6, 3gs - cpu subtype = 9

3gs can run both binaries, 2g/3g only with subtype=6, you can edit cpu subtype with this app - hte.sf.net , then fix signature with ldid, for example compass app runs, but crashes trying to access compass

3 important instructions from thumb2 which are used in 3gs binaries is - CBZ, CBNZ, IT


that's why no need expect voice control on 2g/3g anytime soon.

Last edited by netkas; 06-29-2009 at 01:18 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 06-29-2009, 05:02 PM
appleguru
Status: Offline
Senior Member
 
Join Date: Jul 2006
Posts: 215
Rep Power: 15
appleguru is on a distinguished road
Default

So the old 3G has no If/Then assembly instruction, and no Compare and Branch if Zero/Non-Zero.. fun.

I haven't played with disassembling much, but is it possible? (disassemble, replace missing instructions with ones supported on both architectures...)
__________________
Latest iPhone Tool File Mirrors (Pwnage Tool, Redsn0w, Black Ra1n, etc): http://g.appleguru.org/

FREE, EASY 3.1.2 Tethering Tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 06-29-2009, 05:36 PM
appleguru
Status: Offline
Senior Member
 
Join Date: Jul 2006
Posts: 215
Rep Power: 15
appleguru is on a distinguished road
Default

Just thinking outloud... we can replace CBZ and CBNZ with code that compares to zero (cmp) and then branches if equal/not equal (bne, beq)... One caveat is that doing this will change the condition flags, and CBZ/CBNZ do not. Maybe need to push cond flags to the stack and pop off after branching?

IT can be similarly replicated with cmps and standard conditional branch commands.

This is all hypothetical though; we'd still need to be able to disassemble for this to be at all useful... And the only thing it really helps us get without serious re-coding would be voice control, which probably wouldn't run very well due to memory constraints on the 3G anyways. Boo!
__________________
Latest iPhone Tool File Mirrors (Pwnage Tool, Redsn0w, Black Ra1n, etc): http://g.appleguru.org/

FREE, EASY 3.1.2 Tethering Tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #4 (permalink)  
Old 06-29-2009, 08:16 PM
netkas's Avatar
netkas
Status: Offline
Engineer
 
Join Date: Oct 2006
Posts: 235
Rep Power: 10
netkas has disabled reputation
Default

cmp then branch is two instructions, 4 bytes in thumb mode
cb/cbnz is just 2 bytes

u cant fit it

Turbo made an userspace sse3 emu for osx86(cathing unknown opcode interrupt and etc), i think it can be ported to iphone to emulate those instr

Last edited by netkas; 06-30-2009 at 08:06 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 06-30-2009, 09:13 AM
appleguru
Status: Offline
Senior Member
 
Join Date: Jul 2006
Posts: 215
Rep Power: 15
appleguru is on a distinguished road
Default

Quote:
Originally Posted by netkas View Post
cmp then branch is two instructions, 4 bytes in thumb mode
cb/cbnz is just 2 bytes

u cant fit it

Turbo made an userspace sse3 emu for osx86(cathing unknown opcode interrupt and etc), i think it can be ported to iphone to emulate those instr
Interesting Don't suppose the source is anywhere to play with? Also, is it really a userspace app? I'd have thought you'd need to run in kernel mode to intercept/handle opcodes/instructions directly...
__________________
Latest iPhone Tool File Mirrors (Pwnage Tool, Redsn0w, Black Ra1n, etc): http://g.appleguru.org/

FREE, EASY 3.1.2 Tethering Tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 06-30-2009, 08:30 PM
kwoodall
Status: Offline
Junior Member
 
Join Date: Jun 2009
Posts: 7
Rep Power: 0
kwoodall is on a distinguished road
Default

Except that the Voice Control was developed originally on a 2G iPhone so it's not necessarily likely they compiled to use any 3GS specific instructions.

Kermit Woodall
Managing Editor
GadgetNutz.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #7 (permalink)  
Old 07-01-2009, 08:47 AM
appleguru
Status: Offline
Senior Member
 
Join Date: Jul 2006
Posts: 215
Rep Power: 15
appleguru is on a distinguished road
Default

Quote:
Originally Posted by kwoodall View Post
Except that the Voice Control was developed originally on a 2G iPhone so it's not necessarily likely they compiled to use any 3GS specific instructions.

Kermit Woodall
Managing Editor
GadgetNutz.com
You're comment doesn't make much sense; apple doesn't do much coding in assembly; most of it is objective C and c++...In this case, they did indeed target the 3gs's subtype 9 arm processor when they compiled. It is up to the compiler to decide what machine language to translate it into, and as such if there's a block of code that translates best into a cbz or an IT the compiler will (should) choose it over less efficient legacy code to accomplish the same thing.

Your comment could be re-written for macs to read something like "Except that Calculator.app was developed originally on a PPC mac so it's not necessarily likely they compiled to use any Intel specific instructions."

In my analogy, the "Calculator.app" in question would have been written on a PPC mac, but compiled with x86 as the build target. (IE, not a universal binary). Such an app would indeed only run on an intel mac
__________________
Latest iPhone Tool File Mirrors (Pwnage Tool, Redsn0w, Black Ra1n, etc): http://g.appleguru.org/

FREE, EASY 3.1.2 Tethering Tutorial
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8 (permalink)  
Old 07-01-2009, 12:50 PM
f41qu3's Avatar
f41qu3
Status: Offline
IRC Netadmin
Team of Hackint0sh
 
Join Date: Nov 2006
Posts: 1,520
Rep Power: 10
f41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud off41qu3 has much to be proud of
Default

Theorically, to run Voice Control (for example) in 2G, needs a source code for it, and recompiling using build instructions for 2G/3G arch (and including a instructions emulator like old SSE3 emus for SSE2 processors).

Time to haz a reunion of dev-team and osx86 hackers?
__________________
"the truth is out there"

hack1 = Mac OS X Snow Leopard 10.6.2 Build 10C531
hack2 = Mac OS X Server Snow Leopard 10.6.1 Build 10C504
iBook G3 DualUSB = Mac OS X Jaguar 10.2.8 Build 6R73
MacBook 403LL/A = Mac OS X Snow Leopard 10.6.2 Build 10C531
iPhone 3G = iPhone OS 3.1.2 Build 7D11 Baseband 05.11.07 Bootloader 05.09 [G2M3S2] ClaroBR 5.0
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9 (permalink)  
Old 07-01-2009, 03:33 PM
kwoodall
Status: Offline
Junior Member
 
Join Date: Jun 2009
Posts: 7
Rep Power: 0
kwoodall is on a distinguished road
Default

Quote:
Originally Posted by appleguru View Post
You're comment doesn't make much sense; apple doesn't do much coding in assembly; most of it is objective C and c++ (edit)
That's precisely my point. They would have to deliberately compile for the 3GS. Has anyone actually checked Voice Control and Video Recording to see if they're using the 3GS specific instructions? That would end this discussion. However it wouldn't change the fact that Voice Control and Video Recording were not originally developed for or on the 3GS processor and could be offered on all iPhones if Apple wasn't artificially restricting them to the 3GS.

Kermit Woodall
Managing Editor
GadgetNutz.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Sponsored links Remove advertisements
Advertisement
Advertisement

  #10 (permalink)  
Old 07-01-2009, 03:47 PM
iWhacko
Status: Offline
Junior Member
 
Join Date: Jun 2009
Posts: 6
Rep Power: 0
iWhacko is on a distinguished road
Default

Quote:
Originally Posted by netkas View Post
cmp then branch is two instructions, 4 bytes in thumb mode
cb/cbnz is just 2 bytes

u cant fit it

Turbo made an userspace sse3 emu for osx86(cathing unknown opcode interrupt and etc), i think it can be ported to iphone to emulate those instr
I did a tiny bit of programming on game trainers in the past. "We" had this method called "code injection".

basicly what you do is take an instruction you want to replace with more code.
replace it with a JMP to a memory location with your injection code. Then JMP back to the original flow. But you'd have to find some "code caves" (locations that are filled with NOPs) that are big enough to place your injection code. if you push the memory location you came from to the stack, you can re-use the code to replace all CBZ/CBNZ by POP'ing the memory location off the stack again, and JMP'ing back.

Not sure if this is at all possible, but just thought I'd share.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +2. The time now is 09:53 AM.



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 Ad Management by RedTyger
follow us on Twitter!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105