How to open USB drive in read-only/write protected mode in OSX, programmatically using objective C? - objective-c

I'm trying to write a mac app to access USB. The USB can be written through app only and not in other means. I want to make sure,app is having exclusive write access to it. I tried to find some apis in disarbitration but all efforts are gone in vain.
Adding Further details ::
I'm not trying to make all USB ports as read-only. When I plugin USB drive to the system, it should ask for password. If authentication fails, then user can view the files but can't write to it.

Related

Android Emulator connect external storage Device while running

I have an App that needs to detect, if a USB Storage device is getting mounted. Can i simulate the mounting of an USB Storage Device while the Emulator is already running? This way i can debug the behavior of my app.
As i know, for registering the mounting and unmounting of the USB Storage Device i can use the StorageVolumeCallback(). What do i have to do to write a simple .txt File to that attached USB Storage Device?
Im having trubble to create a StorageManager inside my ViewModel because i do not have access to the Context.
Im thankful for any Tipp related to USB Storage Management at all.
Info:
API Version: 31
IDE: Android Studio
Language: Kotlin
Edit:
So i do not necessarily need to have a external usb drive mounted at startup. If its possible with adb it would be great if i could just forward a usb Pendrive to the running emulator when i need it. Something like adb connectUsbDevice -deviceid=****,vendorid=***
There isn't a .NET library I'm aware of which can do this. However, please refer to this post where the brilliant answer shows how to do this interfacing with the Win 32 API.
How do I disable a system device programmatically?
You'll need a combination of this, and a WMI query to find an attached PnP device of type storage. As a clue:
using (var searcher = new ManagementObjectSearcher(#"SELECT * FROM Win32_USBHub"))
{
collection = searcher.Get();
}
Change Win32_USBHub to the correct class if this isn't giving you what you're looking for.
EDIT: Be warned. If you're disabling storage devices, make sure they're not in use. That's what the "Safely remove USB" option is for in Windows.
Another option, if you don't need to emulate this in code, use a real USB storage device inserted in the system and use PowerShell to get, disable, and enable the device.
The Cmdlets you'll need are:
Get-PnpDevice
Disable-PnpDevice
Enable-PnpDevice

Mxchip IoT DevKit - Can't access the USB flash drive

H,
I am trying to flash a new firmware image to my MXChip as per this quick-start guide
https://learn.microsoft.com/en-us/azure/iot-develop/quickstart-devkit-mxchip-az3166
I can build the .bin file, and when I connect the Devkit over USB I see a new usb flash drive called "(D:) AZ3166", but I cannot access this drive to copy the binary file to it. I get the error message "D:\ is not accessible. Access is denied.".
I found this page here
https://www.linkedin.com/pulse/mxchip-devkit-iot-central-firmware-flashing-errors-ben-vollmer/
But it didn't help because nothing happens when I press A+B. I also tried all 8 methods described here:
https://www.anyrecover.com/storage-device-tips/usb-access-denied/
But it didn't solve the problem.
Anyone has already had this? I ordered a batch of 5 MXChip boards, and it is the same on all of them.

Headless Setup of Asus Tinker Board S

I am trying to set up Tinker Board headlessly as I don't have access to a wired keyboard and mouse.
One method I know that works for Raspi is by creating an SSH file while setting it up and a wpa_supplicant.conf file to provide wifi details. I have flashed the latest Tinker OS v2.2.9 onto the eMMC present on the board as per the instructions. But, in this case I am not able to access the drive once flashed (Contrary to raspi setup).
Is there a way to set it up headlessly?
Thank you for taking out time to read this and helping out.

Restart/shutdown mac remotely from iOS through SSH?

I set up my old laptop as a media server and created a mac application in AppleScript that would remotely restart or shutdown the mac depending on which button was pressed, using this code:
tell application "Finder" of machine "eppc://USERNAME:PASSWORD#MYSERVER"
shut down
end tell
It's super simple, and was easy to write, but now I want to create an iPad app that can accompany the mac one. Ideally, I'd like to use AppleScript as, like I said, it's very simple, but I feel like that's not an option.
What are some other ways to do this? Where I would click a button, then it would connect to my mac and either shutdown or restart.
I feel like the best way would be to use SSH, and right now I'm looking at https://github.com/x2on/libssh2-for-iOS. Any other ideas?
Okay, just to brainstorm.... Dropbox is a great way to share content among machines, but it's also a pretty darn decent communication mechanism.
I use Dropbox to fire up (legal only!) bittorrent downloads on my home machine by setting up my torrent client to watch a dropbox folder for incoming .torrent files. I can then save .torrents into that directory on any machine I have Dropbox on, or in principle from a browser on my iOS devices that could share to Dropbox, and ta-da, instant remote kickoff. I can sit on another machine, save a .torrent to that directory, watch its file extension change to .torrent.imported, and know that when I get back to my main machine, that thing will be downloaded.
You could use folder actions or a cron job to watch a certain Dropbox folder for commands, and then put files into that folder that trigger those scripts to perform certain behaviors. Dropbox has a very nice iOS client library, making it totally possible to store stuff to Dropbox from a custom app.

iPad Camera Connection kit?

Does anyone know if it is possible to access the iPad's camera connection kit? I would like to read the files off the connected mass storage device. Would this be possible or is this something that only Apple can do in their apps.
Thanks
I know this is an old question, but google brought me here so I thought I'd add this link for the next person to come along.
The good news is this. USB drives do mount properly and show up in the system as /dev/disk2s1. Yay. You can even add more drives via a hub. The iPad supports both FAT and HFS+ drives.
The bad news is this. As iPhone developer Dustin Howett discovered,
that mount point is sandboxed away from normal developer use. You
cannot read from or write to that disk using standard iPhone SDK
applications.