Post

Replies

Boosts

Views

Activity

Convert Parallels Desktop disk image to a VZDiskImageStorageDeviceAttachment compatible image
Hello, I am working with Virtualization framework in an Xcode swift project. I have also installed Parallels Desktop on my mac (Apple Silicon). I would like to convert a Parallels Desktop hard drive (hds file) to an image compatible with my Virtualization framework project. My goal is to run my Parallels Desktop virtual machine in my Xcode project. Is there a way to do that ? Thanks
1
1
764
Nov ’23
Write in /System folder on macOS Sonoma
Hello, I know this is not a good practice but i want to make a test. I would like to write a file into /System folder on macOS Sonoma. I have tried to reboot in recovery mode. I have disabled SIP. But i can't write into /System. This folder is mounted as read only. How can i write into this folder ? I know there is a kind of checksum mechanism to check if something has been modified in /System folder and i want to see what happens if this checksum does not match. Thanks
3
1
2.5k
Jul ’24
How virtualization framework works internally
Hello, I am trying to understand how macOS virtualization framework and Virtualization products work on M1 chips. I have tried Parallels Desktop. There are no third party kernel extensions (kext) installed with this product. When i plug an USB device on my mac, i get a popup asking me if i want to plug this device to my host mac or to the current Parallels virtual machine. How can this be possible without kext ? Device management is handled at kernel level... and there are no virtualization framework API for that... I have create a Linux virtual machine with Virtualization framework (similar to GNULinuxVirtualMachineSampleApp project): It works but I don't understand why i can't run Windows Virtual machines. Parallels Desktop seems to work with Virtualization framework too and this product can run ARM Windows Virtual Machine. How can they do that ? Is there a way to simulate key sending with Virtualization framework ? I have create a 64Gb disk (VZDiskImageStorageDeviceAttachment). I have a 64Gb file on my host mac, but i am using only 10Gb on the virtual machine at this moment. Is there a way to optimize the disk image file size ? VZVirtualMachine provides a "pause" method. I don't understand where the virtual machine state (RAM memory, ...) is saved on the host. Thanks a lot
2
0
2.9k
Oct ’23
Simulate sending key to an NSView on a macOS application
Hello, I am trying to simulate a keystroke inside a macOS application. Here is what i've done: let src = CGEventSource(stateID: CGEventSourceStateID.hidSystemState) let cmd_down = CGEvent(keyboardEventSource: src, virtualKey: 0x38, keyDown: true) let cmd_up = CGEvent(keyboardEventSource: src, virtualKey: 0x38, keyDown: false) cmd_down?.post(tap: .cghidEventTap) cmd_up?.post(tap: .cghidEventTap) macOS is asking me to allow my application on TCC accessibility. This is a global privilege and needs admin rights. And i want to avoid that. Is there an alternative to simulate a key stroke inside my application ? Thanks
2
0
914
Jan ’24
SwiftUI error when using NumberFormatter
Hello, I do not understand something in my code bellow: @Observable class Dog: Identifiable { var name = "Test" var age = 3 } struct ContentView: View { @State private var model = Dog() let nf = NumberFormatter() var body: some View { Form { Section { TextField("Name", text: $model.name) } Section { TextField("Age", text: $model.age, formatter: nf) } } } } I have a compilation error: "Trailing closure passed to parameter of type 'FormStyleConfiguration' that does not accept a closure" If i remove the age TextField, everything works fine. Do you have any idea ? Maybe i have made something wrong with text formatter ? Thanks
1
0
580
Oct ’23
SwiftUI Closures return value
Hello, Look at this SwiftUI view: struct ContentView: View { var body: some View { Text("Hello !") } } The Text("Hello") line is a closure. Am I wrong ? There is an implicit return. I can write this: struct ContentView: View { var body: some View { return Text("Hello !") } } I can put multiple lines like this: struct ContentView: View { var body: some View { Text("Hello !") Text("Hello2 !") } } I don't understand how works internally the implicit return in this case because we have 2 components. Also, can you explain me why i can't put a basic swift line code like this: struct ContentView: View { var body: some View { Text("Hello !") print("Hello") Text("Hello2 !") } } Thanks
2
0
1k
Oct ’23
Bypass ASLR for debugging purposes
Hello, Look at this basic C program: #include <stdio.h> int main() { printf("%llx\n", main); return 0; } The displayed address change on each run. This is due to ASLR. Is there a way to launch a program by forcing the main module's base address I would like to do something like that in my terminal: $ BASE_ADDRESS=0x10000 ./a.out How can i do that on mac os ? Is it possible to force base address loading for shared libraries too ? Thanks
3
0
1.3k
Oct ’23
Load a library with LC_LOAD_DYLIB instead of LC_LOAD_WEAK_DYLIB
Hello, I have create a dynamic library with gcc: gcc -dynamiclib liblib1.c -o liblib1.dylib I have create a binary which needs this dynamic library: gcc -L./ -llib1 test.c -o test I have looked at mach-o commands in test binary. I have seen the library is loaded with LC_LOAD_WEAK_DYLIB. How can i load the library with LC_LOAD_DYLIB instead of LC_LOAD_WEAK_DYLIB ? And i have a second question: Is it possible to compile the binary with a static linking of the library ? I have tried with -static option, like i do on Linux but it does not work on macOS and i don't understand why... Thanks
1
0
1.4k
Nov ’23
Getting IP address of VZVirtioNetworkDeviceConfiguration
Hello, I am setting up a Linux virtual machine with Virtualization framework. It works fine. Here is how i am creating a network interface: let network_device = VZVirtioNetworkDeviceConfiguration() network_device.attachment = VZNATNetworkDeviceAttachment() vm_config.networkDevices = [network_device] As you can see, this is a NAT network. I would like to know the IP address assigned to this interface. macOS emulates a DHCP server and i would like to know the IP in my Xcode program. How can i do that ? Thanks
3
0
1.2k
Nov ’23
Why variable store is not needed for macOS guests
Hello I have looked at Virtualization framework samples source code provided by Apple. There is something strange: For a linux guest OS, i can see a variable store: let variableStore = try VZEFIVariableStore(creatingVariableStoreAt: xxxx) ... let bootloader = VZEFIBootLoader() ... bootloader.variableStore = variableStore It seems this variable store is linked with NVRAM. For a macOS guest OS, there is no variable store. (The bootloader is created with VZMacOSBootLoader) My question is why macOS guest doesn't need variable store ? Thanks
1
0
595
Nov ’23
Secure XPC service call
I would like to develop a macOS application in Swift. This application will consist of 2 programs: a main program to be run by the user (standard account) and another one that will run with root privileges. The second program will only be invoked to perform privileged tasks. Running the main program under root permanently would be too risky. XPC will be used to trigger calls from the main program to the privileged program. How can I secure the privileged program to ensure that the calling program is indeed my main program and not another unauthorized program?
1
0
759
Dec ’23
Access Desktop folder from appstore macOS application (sandboxed)
Hello, I am writing a Desktop application for macOS with XCode. This application will be available on app store. So, i have to put sandbox entitlement. So, this application won't be able to access Desktop folder. It will be jailed into a specific directory to store datas. I have installed a macOS application from appstore. When I launched this application, I got a TCC prompt, asking me to allow this application to access Desktop (or Downloads I don't remember). How can this be possible ? I have tried to write a sandboxed application which tries to access to Desktop folder. I didn't get any TCC prompt: My access was rejected. How can I ask to access Desktop folder from I sandboxed application ? Thanks a lot
2
0
1.3k
Apr ’24