public VolumeEventArgs(DriveChars driveChar)
 {
     this.DriveChar = driveChar;
 }
 private static void ApplicationEvents_Idle(object sender, EventArgs e)
 {
     DriveChars logicalDrives = (DriveChars) Windows.GetLogicalDrives();
     DriveChars readyDriveMask = GetReadyDriveMask(FDriveMask & logicalDrives);
     bool flag = false;
     int num = 1;
     for (int i = 0; i < 0x1a; i++)
     {
         DriveChars driveChar = FDriveMask & (num << i);
         if (driveChar != DriveChars.None)
         {
             if (((FReadyDriveMask & driveChar) == DriveChars.None) && ((readyDriveMask & driveChar) > DriveChars.None))
             {
                 Filter.RaiseArrived(new VolumeEventArgs(driveChar));
                 flag = true;
             }
             if (((FReadyDriveMask & driveChar) > DriveChars.None) && ((readyDriveMask & driveChar) == DriveChars.None))
             {
                 Filter.RaiseRemoved(new VolumeEventArgs(driveChar));
                 flag = true;
             }
         }
     }
     if (flag)
     {
         Filter.RaiseChanged(EventArgs.Empty);
     }
     FReadyDriveMask = readyDriveMask;
 }
 private void RaiseVolumeEvent(DriveChars chars, EventHandler<VolumeEventArgs> eventHandler)
 {
     if (eventHandler != null)
     {
         uint num = 1;
         for (int i = 0; i < 0x1a; i++)
         {
             DriveChars driveChar = chars & ((DriveChars) (num << i));
             if (driveChar != DriveChars.None)
             {
                 VolumeEventArgs e = new VolumeEventArgs(driveChar);
                 eventHandler(null, e);
             }
         }
     }
     this.RaiseChanged(EventArgs.Empty);
 }
            protected override void WndProc(ref Message m)
            {
                int msg = m.Msg;
                if (msg == 0x113)
                {
                    if (m.WParam == TimerArriveId)
                    {
                        Windows.KillTimer(base.Handle, TimerArriveId);
                        if (this.ArrivingChars != DriveChars.None)
                        {
                            this.RaiseVolumeEvent(this.ArrivingChars, this.Arrived);
                        }
                        else
                        {
                            this.RaiseChanged(EventArgs.Empty);
                        }
                        this.ArrivingChars = DriveChars.None;
                    }
                }
                else
                {
                    DriveChars none;
                    if (msg != 0x219)
                    {
                        if (m.Msg == this.MsgQueryCancelAutoPlay)
                        {
                            none = DriveChars.None;
                            if (OS.IsWinXP)
                            {
                                none = (DriveChars) (((int) 1) << ((int) m.WParam));
                                if ((this.ArrivingChars & none) > DriveChars.None)
                                {
                                    goto Label_02E5;
                                }
                                this.ArrivingChars |= none;
                            }
                            if (Windows.SetTimer(base.Handle, TimerArriveId, 100, IntPtr.Zero) == IntPtr.Zero)
                            {
                                if (none != DriveChars.None)
                                {
                                    this.RaiseArrived(new VolumeEventArgs(none));
                                }
                                this.RaiseChanged(EventArgs.Empty);
                            }
                        }
                    }
                    else
                    {
                        switch (((int) m.WParam))
                        {
                            case 0x8000:
                                none = this.GetVolumeDriveChars(m.LParam);
                                if (none != DriveChars.None)
                                {
                                    this.ArrivingChars = none;
                                    if (Windows.SetTimer(base.Handle, TimerArriveId, 0x76c, IntPtr.Zero) == IntPtr.Zero)
                                    {
                                        this.ArrivingChars = DriveChars.None;
                                        this.RaiseVolumeEvent(none, this.Arrived);
                                    }
                                }
                                goto Label_02E5;

                            case 0x8001:
                                if (DEV_BROADCAST_HDR.GetDeviceType(m.LParam) == DBT_DEVTYP.DBT_DEVTYP_HANDLE)
                                {
                                    _DEV_BROADCAST_HANDLE _dev_broadcast_handle = (_DEV_BROADCAST_HANDLE) Marshal.PtrToStructure(m.LParam, typeof(_DEV_BROADCAST_HANDLE));
                                    if (this.RemovingMap != null)
                                    {
                                        foreach (VolumeEvents.DeviceNotificationInfo info in this.RemovingMap.Values)
                                        {
                                            if (info.NotificationHandle.DangerousGetHandle() == _dev_broadcast_handle.dbch_hdevnotify)
                                            {
                                                CancelEventArgs e = new CancelEventArgs(false);
                                                info.OnNotification(e);
                                                if (e.Cancel)
                                                {
                                                    m.Result = (IntPtr) 0x424d5144;
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                                goto Label_02E5;

                            case 0x8002:
                            case 0x8003:
                                goto Label_02E5;

                            case 0x8004:
                                none = this.GetVolumeDriveChars(m.LParam);
                                if (none != DriveChars.None)
                                {
                                    this.RaiseVolumeEvent(none, this.Removed);
                                }
                                goto Label_02E5;
                        }
                    }
                }
            Label_02E5:
                base.WndProc(ref m);
            }
 private static DriveChars GetReadyDriveMask(DriveChars driveMask)
 {
     DriveChars none = DriveChars.None;
     int num = 1;
     for (int i = 0; i < 0x1a; i++)
     {
         DriveChars chars2 = driveMask & (num << i);
         if (chars2 != DriveChars.None)
         {
             VolumeInfo info = VolumeCache.Get(chars2.ToString() + @":\");
             if ((info != null) && info.IsReady)
             {
                 none |= chars2;
             }
         }
     }
     return none;
 }