You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: macos-hardening/macos-security-and-privilege-escalation/macos-proces-abuse/macos-ipc-inter-process-communication/README.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -1034,7 +1034,9 @@ For more information about how this **communication work** on how it **could be
1034
1034
1035
1035
## MIG - Mach Interface Generator
1036
1036
1037
-
MIG was created to **simplify the process of Mach IPC** code creation. It basically **generates the needed code** for server and client to communicate with a given definition. Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
1037
+
MIG was created to **simplify the process of Mach IPC** code creation. This is because a lot of work to program RPC involves the same actions (packing arguments, sending the msg, unpacking the data in the server...).
1038
+
1039
+
MIC basically **generates the needed code** for server and client to communicate with a given definition (in IDL -Interface Definition language-). Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
Copy file name to clipboardexpand all lines: macos-hardening/macos-security-and-privilege-escalation/macos-proces-abuse/macos-ipc-inter-process-communication/macos-mig-mach-interface-generator.md
+22-1
Original file line number
Diff line number
Diff line change
@@ -14,8 +14,27 @@ Other ways to support HackTricks:
14
14
15
15
</details>
16
16
17
+
## Basic Information
18
+
17
19
MIG was created to **simplify the process of Mach IPC** code creation. It basically **generates the needed code** for server and client to communicate with a given definition. Even if the generated code is ugly, a developer will just need to import it and his code will be much simpler than before.
18
20
21
+
The definition is specified in Interface Definition Language (IDL) using the `.defs` extension.
22
+
23
+
These definitions have 5 sections:
24
+
25
+
***Subsystem declaration**: The keyword subsystem is used to indicate the **name** and the **id**. It's also possible to mark it as **`KernelServer`** if the server should run in the kernel.
26
+
***Inclusions and imports**: MIG uses the C-prepocessor, so it's able to use imports. Moreover, it's possible to use `uimport` and `simport` for user or server generated code.
27
+
***Type declarations**: It's possible to define data types although usually it will import `mach_types.defs` and `std_types.defs`. For custom ones some syntax can be used:
28
+
*\[i`n/out]tran`: Function that needs to be trasnlated from an incoming or to an outgoing message
29
+
*`c[user/server]type`: Mapping to another C type.
30
+
*`destructor`: Call this function when the type is released.
31
+
***Operations**: These are the definitions of the RPC methods. There are 5 different types:
32
+
*`routine`: Expects reply
33
+
*`simpleroutine`: Doesn't expect reply
34
+
*`procedure`: Expects reply
35
+
*`simpleprocedure`: Doesn't expect reply
36
+
*`function`: Expects reply
37
+
19
38
### Example
20
39
21
40
Create a definition file, in this case with a very simple function:
@@ -37,7 +56,9 @@ simpleroutine Subtract(
37
56
```
38
57
{% endcode %}
39
58
40
-
Now use mig to generate the server and client code that will be able to comunicate within each other to call the Subtract function:
59
+
Note that the first **argument is the port to bind** and MIG will **automatically handle the reply port** (unless calling `mig_get_reply_port()` in the client code). Moreover, the **ID of the operations** will be **sequential** starting by the indicated subsystem ID (so if an operation is deprecated it's deleted and `skip` is used to still use its ID).
60
+
61
+
Now use MIG to generate the server and client code that will be able to communicate within each other to call the Subtract function:
0 commit comments