How to get a notification when a user creates a mount point?

First of all, here are the limitations:

  • Should work on XP
  • It is necessary to notify about the assignment of drive letters and the installation of the volume in the folder
  • You cannot “wake up” a disk if it is sleeping.
  • I would rather not poll the disk.

What I tried:

  • Google
  • I looked at WMI and the Win32_LogicalDisk class. I can determine which drives are mounted on the drive letter, but not those that are installed in the folder. The Win32_Volume * and Win32_MountPoint classes would be ideal, but not available on XP.
  • I tried trying the disks with FindFirstVolume and GetVolumePathNamesForVolumeName (although I would not want to), but it seems that the disks should be deployed before it can give me the information. And again, ew, a survey.

I considered using API connections to intercept SetVolumeMountPoint and DeleteVolumeMountPoint calls, but I don't think that would catch everything, and it looks like it could be an ugly hack anyway.

So yes, I'm looking for suggestions :)

+4
source share
1 answer

Capturing the API on SetVolumeMountPoint should allow you to intercept volumes. However, I am not sure about network resources.

But that would not be an ugly hack. What you are trying to do is that a connection has been enabled on Windows. Codeproject.com has some great tutorials on connecting the API: http://www.codeproject.com/KB/system/hooksys.aspx

So, you have actually announced your own best decision. Remember that there is also a separate API for drive letters: http://nukz.net/reference/fileio/hh/winbase/fsys_6j8z.htm

Your project sounds interesting. Usually trojans and antiviruses try to do this (and they will also catch network resources.) I am only accidentally familiar with this topic, so I hope this helps.

+2
source

All Articles