Since you just absolutely have to have the source (just like you must have it for the Compact Framework itself and the OS too) and since $50 seems to be too steep for you to get the source for the SDF, here's my donation to you. This is right from the SDF code base (for anyone wondering, I own it, so I'm not violating any license):
public static Guid STORE_MOUNT_GUID = new Guid(_STORE_MOUNT_GUID);
internal const string _STORE_MOUNT_GUID =
"{C1115848-46FD-4976-BDE9-D79448457004}";
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr RequestDeviceNotifications(
byte[] devclass, IntPtr hMsgQ, bool fAll);
[DllImport("coredll.dll", SetLastError = true)]
private static extern bool StopDeviceNotifications(IntPtr h);
The Queue pointer can be retrieved using Daniel Moth's P2P queue implementation (though it has known bugs that are fixed in te SDF). I'm not posting the SDF implementation because it's way too long for a post.
At this point, it becomes as simple as this:
public void StartStatusMonitoring()
{
if (!Active)
{
// Create a point-to-point message queue to get the notifications.
m_p2pmq = new P2PMessageQueue(true);
m_p2pmq.DataOnQueueChanged += new EventHandler(p2pmq_DataOnQueueChanged);
// Ask the system to notify our message queue when devices of
// the indicated class are added or removed.
m_requestHandle = RequestDeviceNotifications(m_deviceClass.ToByteArray(),
m_p2pmq.Handle, m_fAll);
}
}
I'm believe that, armed with this much info and the fact that your time has no intrinsic value, that you can string all of this together for a solution.
EDIT1
I should add to this that adding all of this code is not going to fix your issue 100%. If the code that contains this "fix" has not been JITted, or the JITted code has been pitched, and the IL for it resides in a page that is not in RAM when the storage card gets pulled, the device is still going to puke. This is true whether the code is "in" you running application code or in a separate assembly, so your belief that you have to have the source for this is erroneous.
Adding this fix certainly descreases the window of oppotunity for the bug to appear, but since the chance will still exist, and since Murphy's law certainly applies to software rollouts, you can almost guarantee that this is still going to happen in the field.