How to detect IoTHub configuration changes. Detect properties.desired changes and raise a event in Simulated Device. Need c# example.s - azure-iot-hub

I have to monitor properties.desired properties changes from SimulatedDevice app, if any change (in my case fwVersion change) in the properties.desired then immediately my SimulatedDevice should be notified and start download the firmware image.
Since I could not find a relevant sourcecode in C# to try it out pl suggest.

Assuming your SimulatedDevice is using the Microsoft.Azure.Devices.Client NuGet package to connect to your IoTHub, you can subscribe to the device twin updates. To subscribe, use the DeviceClient.SetDesiredPropertyUpdateCallbackAsync method.
You can find an official sample in this repository. The file where they subscribe to the twin updates is this one.

Related

How does an IoT client report a changed property to the IoT Hub?

I'm using the azure-iot-sdk-c library for an iot device to talk to an IoT hub. I use IoTHubDeviceClient_LL_SetDeviceTwinCallback() to register a callback function in my client code that gets called whenever a device twin state property changes. In that code, I modify my device's properties and call IoTHubDeviceClient_LL_SendReportedState() to notify the hub that I did the changes that were requested.
But what happens if someone walks into the room where my device lies and changes one of those properties. My device code gets a notification of that property change but I would like to use that opportunity to let the IoT hub know that a property changed. How do I do that? There is no "set_desired_property" in the client sdk.
You would send it back as a reported state. For example, if the device is monitoring a light and someone physically turns it off then the light's state is off. You send that as the light's reported state.

Intel Pin: Attaching to an existing process using the Pin API

I'm doing a bit of research on Intel Pin. I'm looking to see if there is a way of attaching a Pin tool to an existing process using the Pin API.
I can see there is a way of running the pin executable on an already running process using pin.exe -pid <process_id> but I can't see anything in the pin documentation.
EDIT: As per a previous comment, I'm updating the question with an example.
The problem I'm trying to solve is instrumenting an injected process (this is for malware analysis).
If the process/binary I'm instrumenting creates a child process then pin can seamlessly attach itself to said child process. Wonderful!
If, however, the binary process/binary I'm instrumenting injects into another process (i.e. OpenProcess > VirtualAllocEx > WriteProcessMemory > CreateRemoteThread) then Pin will NOT attach to the injected process. I need to be able to tell pin to attach dynamically at runtime.
You'll have to implement something like that yourself - instrument the system calls and if you see an injection pattern, attach pin to the process.

Is there a way to get an event when a device twins reported properties change?

Looking through the apis for DeviceClient, ServiceClient, and RegistryManager it doesn't look like there is any obvious way to get an event/callback when the reported properties for a device have changed. Therefore it seems like something consuming the IoTHub information wouldn't have any idea properties have changed without constantly polling. That seems rather inefficient and error prone. What am I missing?
The device twins has built-in an event driven notification model when the changes on the tags and properties are published via the Azure IoT Hub Routes path to the custom endpoints. See more details here.
The following screen snippet shows an example of the Azure IoT Hub Routes for TwinChangeEvents notifications:

Can wifi / geo triggers be invoked even if the Worklight app is not running, including not in the background?

In Android, an app which is not currently running can be notified when certain event happens (like wifi scan results available, boot process completed) through Broadcast Receivers mechanism. Is this possible in anyway so that the wifi/geo triggers can be invoked even if the Worklight app is not running, including not running in the background?
Regarding wifi/connectivity changes notifying your app, that looks possible since it is a standard system event. It would likely take custom native code since you'd need to implement a broadcast receiver. And you'd need to register your receiver in your app's AndroidManifest.xml file. Take a look at http://developer.android.com/reference/android/net/ConnectivityManager.html and http://www.grokkingandroid.com/android-getting-notified-of-connectivity-changes/
Regarding geolocation triggers, it is unclear what sort of triggers you are looking for. This is all I see in the Android docs: http://developer.android.com/reference/android/location/GpsStatus.html and the standard broadcast actions at http://developer.android.com/reference/android/content/Intent.html#constants
If you are looking for something like geofencing, it would take application logic to determine when to fire events, so that means an app or service needs to be running. So although your broadcast receiver's onReceive() method can get called upon a geo event, who is going to fire that event?
Having the triggers activate when the application is not running at all (not even in background) isn't supported through the Worklight APIs.
You could try and use Worklight Android Native SDK together with cmarcelk's suggestions. Or you could use the Worklight Android triggers within a native service, together with the Broadcast Receivers mechanism so that it will run automatically on boot. You could then use an Intent to open the application from the trigger callback.

How to get notification for any application launched

i am working on an application for windows mobile 6.5, which need to know whenever any application is launched.
Is there any way to get notified when any application is launched?
Can we do something like this?
ManagementEventWatcher
I don't think there is a way to get an event when a new process is created. However, you can get a list of processes using the ToolHelp API, so it should be possible to get the necessary information, but you need to continuously poll in order to detect when a process is started.
Access to the ToolHelp API is not provided in compact framework but you can use the native API instead. An example can be found here: http://msdn.microsoft.com/en-us/library/aa446560.aspx
I think you're going to have to poll for the available processes using Allan's suggestion. I've worked on custom Windows CE shells, and they use the RegisterTaskBar(HWND) to receive notification when windows are created, raised, and destroyed. But that doesn't means every process has a window.