sbWindowsDeviceUtils.cpp File Reference

Songbird Windows Device Utilities Source. More...

#include "sbWindowsDeviceUtils.h"
#include <sbWindowsUtils.h>
#include <dbt.h>
#include <winioctl.h>
Include dependency graph for sbWindowsDeviceUtils.cpp:

Go to the source code of this file.

Functions

nsresult sbWinCreateDeviceFile (HANDLE *aDevFile, DEVINST aDevInst, const GUID *aGUID, DWORD aDesiredAccess, DWORD aShareMode, LPSECURITY_ATTRIBUTES aSecurityAttributes, DWORD aCreationDisposition, DWORD aFlagsAndAttributes, HANDLE aTemplateFile)
 
nsresult sbWinCreateAncestorDeviceFile (HANDLE *aDevFile, DEVINST aDevInst, const GUID *aGUID, DWORD aDesiredAccess, DWORD aShareMode, LPSECURITY_ATTRIBUTES aSecurityAttributes, DWORD aCreationDisposition, DWORD aFlagsAndAttributes, HANDLE aTemplateFile)
 
nsresult sbWinDeviceHasInterface (DEVINST aDevInst, const GUID *aGUID, PRBool *aHasInterface)
 
nsresult sbWinGetDevicePath (DEVINST aDevInst, const GUID *aGUID, nsAString &aDevicePath)
 
static nsresult _sbWinFindDevicesByInterface (nsTArray< DEVINST > &aDevInstList, DEVINST aRootDevInst, const GUID *aGUID, PRBool aSearchAncestors)
 
nsresult sbWinFindDevicesByInterface (nsTArray< DEVINST > &aDevInstList, DEVINST aRootDevInst, const GUID *aGUID, PRBool aSearchAncestors)
 
nsresult sbWinFindDeviceByClass (DEVINST *aDevInst, PRBool *aFound, DEVINST aRootDevInst, const nsAString &aClass)
 
nsresult sbWinGetDevInfoData (DEVINST aDevInst, HDEVINFO aDevInfo, PSP_DEVINFO_DATA aDevInfoData)
 
nsresult sbWinGetDevDetail (PSP_DEVICE_INTERFACE_DETAIL_DATA *aDevIfDetailData, SP_DEVINFO_DATA *aDevInfoData, HDEVINFO aDevInfo, const GUID *aGUID, DWORD aDevIndex)
 
nsresult sbWinGetDevInterfaceDetail (PSP_DEVICE_INTERFACE_DETAIL_DATA *aDevIfDetailData, HDEVINFO aDevInfo, SP_DEVINFO_DATA *aDevInfoData, const GUID *aGUID)
 
nsresult sbWinGetDeviceInstanceIDFromDeviceInterfaceName (nsAString &aDeviceInterfaceName, nsAString &aDeviceInstanceID)
 
nsresult sbWinGetDeviceInstanceID (DEVINST aDevInst, nsAString &aDeviceInstanceID)
 
nsresult sbWinDeviceEject (DEVINST aDevInst)
 
nsresult sbWinDeviceEject (nsAString const &aMountPath)
 
nsresult sbWinDeviceIsDescendantOf (DEVINST aDevInst, DEVINST aDescendantDevInst, PRBool *aIsDescendant)
 
nsresult sbWinRegisterDeviceHandleNotification (HDEVNOTIFY *aDeviceNotification, HWND aEventWindow, DEVINST aDevInst, const GUID &aGUID)
 

Variables

static const GUID GUID_DEVINTERFACE_USB_HUB
 

Detailed Description

Songbird Windows Device Utilities Source.

Definition in file sbWindowsDeviceUtils.cpp.

Function Documentation

nsresult _sbWinFindDevicesByInterface ( nsTArray< DEVINST > &  aDevInstList,
DEVINST  aRootDevInst,
const GUID *  aGUID,
PRBool  aSearchAncestors 
)
static

Search the device specified by aRootDevInst and all of its descendents or ancestors for device instances providing the device interface specified by aGUID. Return all found device instances in aDevInstList. If aSearchAncestors is true, search all ancestors; otherwise, search all descendents. If searching ancestors, the returned list will be ordered by most immediate ancestors first.

Parameters
aDevInstListReturned list of found device instances.
aRootDevInstRoot device instance from which to begin search.
aGUIDDevice interface class for which to search.
aSearchAncestorsIf true, search ancestors.

Definition at line 368 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinCreateAncestorDeviceFile ( HANDLE *  aDevFile,
DEVINST  aDevInst,
const GUID *  aGUID,
DWORD  aDesiredAccess,
DWORD  aShareMode,
LPSECURITY_ATTRIBUTES  aSecurityAttributes,
DWORD  aCreationDisposition,
DWORD  aFlagsAndAttributes,
HANDLE  aTemplateFile 
)

Create a device file for an ancestor of the device instance specified by aDevInst and device interface class specified by aGUID. Create the device file for the first ancestor implementing the specified device interface class. Return the created device file handle in aDevFile

Parameters
aDevFileReturned created device file handle.
aDevInstDevice instance for which to create file.
aGUIDDevice interface class for which to create file.
aDesiredAccessFile creation arguments.
aShareMode
aSecurityAttributes
aCreationDisposition
aFlagsAndAttributes
aTemplateFile
Returns
NS_ERROR_NOT_AVAILABLE if the device interface is not available for any of the device ancestors.

Definition at line 162 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinCreateDeviceFile ( HANDLE *  aDevFile,
DEVINST  aDevInst,
const GUID *  aGUID,
DWORD  aDesiredAccess,
DWORD  aShareMode,
LPSECURITY_ATTRIBUTES  aSecurityAttributes,
DWORD  aCreationDisposition,
DWORD  aFlagsAndAttributes,
HANDLE  aTemplateFile 
)

Create a device file for the device instance specified by aDevInst and device interface class specified by aGUID. Return the created device file handle in aDevFile

Parameters
aDevFileReturned created device file handle.
aDevInstDevice instance for which to create file.
aGUIDDevice interface class for which to create file.
aDesiredAccessFile creation arguments.
aShareMode
aSecurityAttributes
aCreationDisposition
aFlagsAndAttributes
aTemplateFile
Returns
NS_ERROR_NOT_AVAILABLE if the device interface is not available for the device.

Definition at line 102 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinDeviceEject ( DEVINST  aDevInst)

Eject the device specified by aDevInst.

Parameters
aDevInstDevice instance to eject.

Definition at line 775 of file sbWindowsDeviceUtils.cpp.

nsresult sbWinDeviceEject ( nsAString const &  aMountPath)

Ejects the USB drive using the supplied drive (X:) via the DeviceIoControl functions. I used MSDN KB165721 to create this code.

Definition at line 827 of file sbWindowsDeviceUtils.cpp.

nsresult sbWinDeviceHasInterface ( DEVINST  aDevInst,
const GUID *  aGUID,
PRBool *  aHasInterface 
)

Check if the device instance specified by aDevInst provides the device interface specified by aGUID. If it does, return true in aHasInterface.

Parameters
aDevInstDevice instance to check.
aGUIDDevice interface class.
aHasInterfaceReturned true if device instance provides the specified interface.

Definition at line 223 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinDeviceIsDescendantOf ( DEVINST  aDevInst,
DEVINST  aDescendantDevInst,
PRBool *  aIsDescendant 
)

Determine whether the device specified by aDescendantDevInst is a descendant of the device specified by aDevInst. If it is, return true in aIsDescendant.

Parameters
aDevInstAncestor device.
aDescendantDevInstDescendant device.
aIsDesendantReturned true if descendant device is a descendant of ancestor device.

Definition at line 941 of file sbWindowsDeviceUtils.cpp.

nsresult sbWinFindDeviceByClass ( DEVINST *  aDevInst,
PRBool *  aFound,
DEVINST  aRootDevInst,
const nsAString &  aClass 
)

Search the device specified by aRootDevInst and all of its descendents for a device instance of the class specified by aClass. If one is found, this function returns the found device instance in aDevInst and true in aFound.

Parameters
aDevInstReturned found device instance.
aFoundReturned true if device was found.
aRootDevInstRoot device instance.
aClassDevice class for which to search.

Definition at line 434 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinFindDevicesByInterface ( nsTArray< DEVINST > &  aDevInstList,
DEVINST  aRootDevInst,
const GUID *  aGUID,
PRBool  aSearchAncestors 
)

Definition at line 353 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

nsresult sbWinGetDevDetail ( PSP_DEVICE_INTERFACE_DETAIL_DATA *  aDevIfDetailData,
SP_DEVINFO_DATA *  aDevInfoData,
HDEVINFO  aDevInfo,
const GUID *  aGUID,
DWORD  aDevIndex 
)

Return in aDevIfDetailData and aDevInfoData the device details for a device. The device is specified by the enumeration handle aDevInfo. The device class GUID is specified by aGUID, and the device enumeration index is specified by aDevIndex.

Parameters
aDevIfDetailDataReturned device detail data.
aDevInfoDataReturned device info data.
aDevInfoDevice info enumeration handle.
aGUIDDevice class GUID.
aDevIndexDevice enumeration index.

Definition at line 549 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinGetDeviceInstanceID ( DEVINST  aDevInst,
nsAString &  aDeviceInstanceID 
)

Return in aDeviceInstanceID the device instance ID for the device specified by aDevInst.

Parameters
aDevInstDevice instance for which to get ID.
aDeviceInstanceIDReturned device instance ID.

Definition at line 753 of file sbWindowsDeviceUtils.cpp.

Here is the caller graph for this function:

nsresult sbWinGetDeviceInstanceIDFromDeviceInterfaceName ( nsAString &  aDeviceInterfaceName,
nsAString &  aDeviceInstanceID 
)

Return in aDeviceInstanceID the device instance ID for the device with the device interface name specified by aDeviceInterfaceName.

Parameters
aDeviceInterfaceNameDevice interface name.
aDeviceInstanceIDReturned device instance ID.

Definition at line 708 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinGetDevicePath ( DEVINST  aDevInst,
const GUID *  aGUID,
nsAString &  aDevicePath 
)

Return in aDevicePath the device file path for the device specified by aDevInst and device interface class specified by aGUID.

Parameters
aDevInstDevice instance for which to get path.
aGUIDDevice interface class.
aDevicePathReturned device path.

Definition at line 283 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinGetDevInfoData ( DEVINST  aDevInst,
HDEVINFO  aDevInfo,
PSP_DEVINFO_DATA  aDevInfoData 
)

Return in aDevInfoData the device info for the device instance specified by aDevInst using the device info set specified by aDevInfo.

Parameters
aDevInstDevice instance for which to get device info.
aDevInfoDevice info set handle.
aDevInfoDataReturned device info.
Returns
NS_ERROR_NOT_AVAILABLE if the device instance does not have device info.

Definition at line 504 of file sbWindowsDeviceUtils.cpp.

Here is the caller graph for this function:

nsresult sbWinGetDevInterfaceDetail ( PSP_DEVICE_INTERFACE_DETAIL_DATA *  aDevIfDetailData,
HDEVINFO  aDevInfo,
SP_DEVINFO_DATA *  aDevInfoData,
const GUID *  aGUID 
)

Return in aDevIfDetailData the device interface details for the device specified by aDevInfoData and the device interface class specified by aGUID using the device info set specified by aDevInfo. If the specified device does not provide the specified interface, return NS_ERROR_NOT_AVAILABLE. The caller is responsible for calling NS_Free for the returned device interface details data record.

Parameters
aDevIfDetailDataReturned device detail data.
aDevInfoDevice info set handle.
aDevInfoDataDevice info data for which to get device interface details.
aGUIDDevice interface class GUID.
Returns
NS_ERROR_NOT_AVAILABLE if the device interface is not available for the device.

Definition at line 634 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult sbWinRegisterDeviceHandleNotification ( HDEVNOTIFY *  aDeviceNotification,
HWND  aEventWindow,
DEVINST  aDevInst,
const GUID &  aGUID 
)

Register device handle notification for the device specified by aDevInst with the device interface specified by aGUID. Send the notification to the window specified by aEventWindow. Return the device notification handle in aDeviceNotification.

Parameters
aDeviceNotificationReturned device notification handle.
aEventWindowWindow to which to send notification.
aDevInstDevice for which to register notification.
aGUIDDevice interface for which to register notification.

Definition at line 988 of file sbWindowsDeviceUtils.cpp.

Here is the call graph for this function:

Variable Documentation

const GUID GUID_DEVINTERFACE_USB_HUB
static
Initial value:
=
{
0xF18A0E88,
0xC30C,
0x11D0,
{ 0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8 }
}

Definition at line 67 of file sbWindowsDeviceUtils.cpp.