系統函數的彙編代碼(iPhone) (Assembly code to system functions (iPhone))


問題描述

系統函數的彙編代碼(iPhone) (Assembly code to system functions (iPhone))

possibly a really dumb question, but could someone explain why one could not write assembly code to trigger system functions or control hardware? For example, would it not be possible to write code to switch screen off/on or even the device's phone?

I am not talking about jailbreaking the device, nor making an app for the app store. Normal app with assembly to call system functions.

If indeed possible, anyone have a good reference or starting point of achieve such tasks?

Thanks


參考解法

方法 1:

iPhones use a memory‑protected operating system in which each user process is contained in its own virtual memory address space.  The address space is protected by the memory management unit (MMU) hardware and trying to access memory outside of regions given to the process by the OS will result in an exception.  The OS reserves hardware memory ranges to itself and does not make it available to user processes.  As such, it is not possible to directly interface to the hardware from a user process.

方法 2:

It is certainly possible to call system functions from assembly code. And what do you think a C or C++ application does? It does exactly that. C/C++ and assembly code all ultimately convert (at compile time) into machine code that the CPU executes.

I'm not sure where the guide would be for doing things like this, but you can certainly run a C program in a debugger and see how it calls various system functions or you can disassemble this program and read the disassembly without running the program in the debugger.

In any event, you will not get more control over the device from a program written in assembly than from a program written in C. The OS should restrict direct access to certain I/O devices and memory areas at the CPU level, where there's no distinction between assembly and C, it's all the same to the CPU, just a bunch of instructions in machine code.

(by GeorgeVariable Length CoderAlexey Frunze)

參考文件

  1. Assembly code to system functions (iPhone) (CC BY‑SA 3.0/4.0)

#system #iphone #assembly #system-calls






相關問題

asp.net c# sistem login (asp.net c# login system)

系統函數的彙編代碼(iPhone) (Assembly code to system functions (iPhone))

如何跟踪系統依賴關係? (How to track System Dependencies?)

使用 system() 甚至 passthru() 從 php 運行 python 腳本不會產生任何輸出。為什麼? (Running a python script from php with system( ) or even passthru( ) produces no output. Why?)

求解線性方程 (Solving a linear equation)

C++ 中的 System() 調用及其在編程中的作用 (System() calls in C++ and their roles in programming)

找不到傳遞給使用 Perl“系統”命令調用的程序的參數 (Cannot find argument passed to program called using Perl "system" command)

如何顯示所有用戶表中的所有列/字段? (How to display all columns/fields in all user tables?)

系統文件夾中的庫未加載正確的語言 (Libraries from system folder does not load correct language)

為什麼系統不返回主值? (Why system doesn't return main's value?)

通知未顯示,因為服務或警報管理器已被終止 (Notification not showing because service or alarm manager is killed off)

通過 C++ 調用系統不一致失敗 (Calling the system through C++ inconsistently fails)







留言討論