I have been trying to see if there is a method to consistently monitor for the connection of new USB Devices ( Not all of these are going to be external drives or flash drives ).
Originally I was looking at possibly putting a script together that will run upon start up that creates a scheduled task that will wait for an event of a device being connected then running a script to handle that devices properties as needed.
I haven't been able to find the proper Event ID nor Task Trigger to make this a reality. Does anyone have another idea of how to proceed with this?
Alright after digging further there is a way to watch,
Creating a Scheduled task that has a Trigger set to "On an event"
Log: Microsoft-Windows-DriverFrameworks-UserMode/Operational
Source: DriverFrameworks-UserMode
Event ID: 2003
It will monitor for when the UMDF Host Process asks for drivers for the new device, which will happen every time a new USB device is loaded.
Related
I started learning AutoHotKey and wanted to know if it was possible to write a script that allows me to enable/disable a device in device manager without having to manually unplug/plug the device from the computer. I wasn't sure if I needed to run the script on the command line and somehow access the API of the Device Manager through there and write one/two lines of code that allows to enable/disable. I did stumble across the API: DeviceIoControl. I think I can get the handle of the device by using the CreateFile function that has the name of the device. The problem is I'm not sure how to properly use the name of the device in order to enable/disable it.
I'm taking advantage of macOS's hidutil command to perform custom key mappings, as per this link from Apple here. The issue is we're using a KVM which keeps disconnecting, then re-connecting the keyboard and every time that happens, our custom key maps get wiped out and we have to manually re-execute the script.
I'm trying to find if there's some system event we can monitor, or some launch agent or similar that we can utilize to execute the script for us automatically.
If there is any other way you can think of that would persist these settings, that would work too.
Ref: https://developer.apple.com/library/archive/technotes/tn2450/_index.html
I've been playing around with NSRunningApplication in Swift 3, and I've come up with a few questions.
What's the best way to "pause" an application while it's launching. Don't quit it, but don't let it launch completely either. Just keep the icon bouncing in the dock (i.e. "freeze" the launch) for some arbitrary time. After that time, if I decide I want to quit the app after all, I can do NSRunningApplication(withBundleIdentifier: "xyz").terminate() or .forceTerminate(), and I can confirm with .isTerminated(). Otherwise, I can just "unfreeze" the app and let it finish launching.
What's the least power-hungry way of checking constantly for an app launch? I could just schedule a Timer to check every half-second or so, but I believe that hogs a fair amount of memory. Can I set a listener or notification to check for a 3rd-party app launch? (i.e. to run a function every time the Notes app changes isTerminated state).
Thanks!
You can't reliably target another process and control it from Swift (or any other User-mode program), as you really need to do that in the kernel, with a kernel extension (Kext).
Apple's official framework for this is the Kernel Authorization framework (KAuth). Using the File Operation Scope (described in the documentation), a kernel extension will be notified of various operations, including a program's execution and can allow or deny its access.
A working example of its usage can be seen in the open source code of Google Santa, which they use to manage their own employees' computers. As its documentation states:
It consists of a kernel extension that monitors for executions, a userland daemon that makes execution decisions based on the contents of a SQLite database, a GUI agent that notifies the user in case of a block decision and a command-line utility for managing the system and synchronizing the database with a server.
I'm currently implementing suspend/resume for embedded Linux on some non-android network device.
The requirement is to implement a sleep manager task in kernel which would trigger system suspend in case that no task is currently running and there's no traffic pending.
I guess there should be some similar implementation existing already but failed to find.
Can anyone refer me to some kind of similar project on this subject?
Thanks a lot
If you don't mind doing some porting, the wakelocks from the Android kernel is exactly what you seem to need. User space acquires a wakelock when it needs to remain active (e.g. a task is running or traffic is taking place) and releases it when it doesn't anymore. When the number of held wakelocks reaches zero, the kernel enters suspend mode.
Got a customer request but no idea can it be done. So need your opinions on this. This might be a utterly stupid thing to ask but yet need some facts so can work out best solution.
Scenario,
My Customer is an OEM Manufacturer. They make an automated system with a embedded touch screen (Windows XPe) this system got a button panel with some LED indicators (apart from keyboard) and 7 USB Ports. These button panels and USB ports are checked before sending to QC process. Currently a USB thumb drive with standalone executable with all indicators and controls flags is inserted to one of the USBs and then will run the exe. This exe capture user inputs from button panel and indicate which button is pressed so that it can be verify as working. And from program user can set LED indicators to different states (flashing, steady and off) so they can be verified as well. Once this is done then USB thumb drive will be inserted to each port and will verify it recognise. But after each verify step it needs to safely remove the drive from task bar. Once each test is finish user required to fill up the sheet with all pass and fail states for the entire button panel, indicators and USB ports. This is a quite length process when its come to mass production.
Apart from this embedded system all other components which suppose to connect to one of above embedded systems are tested via a program which I make and records all test outputs as they are tested. This program installed and components are connected to a testing embedded system.
Requirement,
What customer asks, can my program test completed embedded system with our host system (testing embedded system, may be via USB to USB) Its more like Testing a PC from another PC. Any ideas ?
Additional Info.
Apart from USBs there is one Network Port.
Thanks for looking, Feel Free to ask any questions. Any opinion is appreciated.
I'm not an expert on this topic, but it seems like this would be problematic because USB is an assymetrical protocol. There are hosts and there are devices. Hosts make the requests, and devices fulfill the requests. The problem is that PCs are USB hosts, not USB devices, so you would have two hosts trying to get the guy on the other side to do what he wants. Testing with a USB thumb drive worked because the thumb drive is a device.
It sounds like the unit to be tested doesn't have an ethernet port, which is a shame, because that would be the easiest way to go. If it has a serial port you could do it that way, but that is both slow and a hassle.