Jump to content

Device Management API


weaponx
 Share

Recommended Posts

  • 6 months later...
  • Replies 76
  • Created
  • Last Reply

Top Posters In This Topic

Hi Hows this project coming?

I think it woul dbe useful if this can give a quick listing on which drivers arent installed properly or on any unknown devices

jamie

Not to thread-jack, more a shameless plug..... :huh2:

A new version of my HWID-based driver installer is being worked on by myself, Danny35d, and Storme which will be able to install your missing drivers (all or just devices you choose), and if it can't find a good match it will at least let you have quick clipboard access to the HWID so you can Google it. We will also have a backup option available, as well as an updater.

Posted Image

A timetable is hard to say but a huge chunk of the features are done already.

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 1 month later...

I was trying to add the function SetupDiRemoveDevice. I'm using this amazing script to remove some orphaned volume shadow copies. The function I added was as follows:

; #FUNCTION# ====================================================================================================================
; Name...........: _DeviceAPI_RemoveDevice
; Description ...: Get class name from class GUID
; Syntax.........: -
; Parameters ....: -
; Return values .: Success      - String
;                  Failure      - NULL String, @ERROR set
; Author ........: Matthew Horn (weaponx)
; Modified.......: -
; Remarks .......: -
; Related .......: -
; Link ..........; @@MsdnLink@@ - http://msdn.microsoft.com/en-us/library/ms792990.aspx
; Example .......; Yes
; ===============================================================================================================================
Func _DeviceAPI_RemoveDevice()
    Local $result = DllCall($setupapi_dll,"int","SetupDiRemoveDevice","hwnd", $hDevInfo,"ptr", $pSP_DEVINFO_DATA)
    If @ERROR Then
        Return SetError(@ERROR,@EXTENDED,"")
    Else
        ;Check for WinAPI error
        $WinAPI_Error = _WinAPI_GetLastError()
        If $WinAPI_Error <> 0 Then
            ;ConsoleWrite("Error " & _WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage())
            ;Exit
            Return SetError(1,1,0)
        Else
            ;Debug($result)
            Return $result[1]
        EndIf
    EndIf
EndFunc

The function doesn't appear to be removing the device. Any suggestions? Does this function already exist in the code?

Rob

Link to comment
Share on other sites

Here is the function that worked for me.

; #FUNCTION# ====================================================================================================================
; Name...........: _DeviceAPI_RemoveDevice
; Description ...: Get class name from class GUID
; Syntax.........: -
; Parameters ....: -
; Return values .: Success      - String
;                  Failure      - NULL String, @ERROR set
; Author ........: Matthew Horn (weaponx)
; Modified.......: -
; Remarks .......: -
; Related .......: -
; Link ..........; @@MsdnLink@@ - http://msdn.microsoft.com/en-us/library/ms792990.aspx
; Example .......; Yes
; ===============================================================================================================================
Func _DeviceAPI_RemoveDevice()
    Local $result = DllCall($setupapi_dll,"int","SetupDiCallClassInstaller","dword", 5,"hwnd", $hDevInfo,"ptr", $pSP_DEVINFO_DATA)
    If @ERROR Then
        Return SetError(@ERROR,@EXTENDED,"")
    Else
        ;Check for WinAPI error
        $WinAPI_Error = _WinAPI_GetLastError()
        If $WinAPI_Error <> 0 Then
            ;ConsoleWrite("Error " & _WinAPI_GetLastError() & ": " & _WinAPI_GetLastErrorMessage())
            ;Exit
            Return SetError(1,1,0)
        Else
            ;Debug($result)
            Return $result[3]
        EndIf
    EndIf
EndFunc
Link to comment
Share on other sites

  • 7 months later...

This is exactly what i was looking for. However i cant get it to work. When i run the example scripts i just can blank rows like this:

Class Name:

Class GUID:

Hardware ID:

Unique Instance ID: 0

Manufacturer:

Driver:

Friendly Name:

Physical Device Object Name:

Upper Filters:

Lower Filters:

Enumerator:

Link to comment
Share on other sites

  • 1 month later...

I am experiencing a strange behavior. If I run a simple script (based on example) it does not return any info if run from a network path (compiled or not).

Any insight as to why that may be?

#include <DeviceAPI.au3>

;Build list of ALL device classes
_DeviceAPI_GetAllDevices()

;Loop through all devices by index
While _DeviceAPI_EnumDevices()
    $string = "+"& _DeviceAPI_GetDeviceRegistryProperty($SPDRP_DEVICEDESC) & @CRLF
    $string &= "Class Name: " & _DeviceAPI_GetClassName(_DeviceAPI_GetDeviceRegistryProperty($SPDRP_CLASSGUID)) & @CRLF
    $string &= "Manufacturer: " & _DeviceAPI_GetDeviceRegistryProperty($SPDRP_MFG) & @CRLF
    $string &= @CRLF

    FileWriteLine("C:tempdevices.txt", $string)
WEnd

_DeviceAPI_DestroyDeviceInfoList() ;Cleanup for good measure

Edit: I figured it out. I needed to call _DeviceAPI_Open(); strange that even though it doesn't get called it still works if run locally.

Edited by spudw2k
Link to comment
Share on other sites

  • 7 months later...

I'm trying to use the DeviceAPI.au3 to monitor some USB device connection. Following the example, I have created the following codes to check for device appearing in the Device Manager. What I noticed is that DeviceAPI can only list out devices already ready before running the script. If I unplug the device first and plug it in again during script run, the looping of _DeviceAPI_GetClassArray() cannot detect the device. Is there any other ways to do this?

$DeviceName = "Microsoft Hardware USB Mouse"
$DeviceClass = "Human Interface Devices"

Do
ConsoleWrite(@CRLF & "Checking for [" & $DeviceName & "]...")
Sleep(5000)
Until HWDevice_Detect($DeviceName, $DeviceClass) = True

Func HWDevice_Detect($devicename, $classname)
Local $DeviceListed = False
Local $aClasses = _DeviceAPI_GetClassArray()
For $X = 0 to Ubound($aClasses)-1
     If $aClasses[$X][2] = $classname Then
         Local $aDevices = _DeviceAPI_GetDeviceArray($aClasses[$X][0])
         For $Y = 0 to Ubound($aDevices)-1
         If $aDevices[$Y][1] = $devicename Then
             $DeviceListed = True
         EndIf
     Next
     EndIf
Next

If $DeviceListed = True Then
     Return True
Else
     Return False
EndIf
EndFunc
Link to comment
Share on other sites

@VAG

Either use WMI

$objWMIService = ObjGet("winmgmts:" & $strComputer & "rootCIMV2")
$m_MediaConnectWatcher = $objWMIService.ExecNotificationQuery("SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_DiskDrive'")

Or use the WM_DEVICECHANGE API approach shwon here

Rgds,

ptrex

Link to comment
Share on other sites

Here ya go.

DeviceAPI.au3

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 1 year later...

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

  • 2 weeks later...

Quite useful, thanks.

It seems  _DeviceAPI_GetDeviceRegistryProperty($SPDRP_COMPATIBLEIDS) returns only one of the compatible IDs.

Looking at SetupApi.au3 here, which couldn't get going either, there are a few more structures and cases needed, if I get it right.

Can someone experienced shed some light? I was trying to go through MSDN documentation without much success.

Added:

Got SetupApi.au3 from above working as in here:

#include <SetupApi.au3>

Dim $hDevs, $tDevInfo, $sDeviceID, $devicename[1][2] = [[0]]
$hDevs = _SetupDiGetClassDevs($DIGCF_ALLCLASSES)

While _SetupDiEnumDeviceInfo($hDevs, $devicename[0][0], $tDevInfo)
    $devicename[0][0] += 1
    ConsoleWrite("----------- Index: " & $devicename[0][0] & " -------------" & @CRLF )
    $sDescr = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_DEVICEDESC)
    $sName = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_FRIENDLYNAME)
    $sHWID = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_HARDWAREID)
    $sCHWID = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, $SPDRP_COMPATIBLEIDS)
    ConsoleWrite("Description: " & $sDescr & @CRLF)
    ConsoleWrite("Friendly Name: " & $sName & @CRLF)
    ConsoleWrite("Hardware IDs: " & @CRLF & $sHWID & @CRLF)
    ConsoleWrite("Compatible HardwareIDs:  " & @CRLF & $sCHWID & @CRLF)
;    ConsoleWrite("------------------------" & @CRLF & @CRLF)
    ReDim $devicename[$devicename[0][0] + 1][2]

WEnd
_SetupDiDestroyDeviceInfoList($hDevs)

It appears that _DeviceAPI_GetDeviceRegistryProperty in DeviceAPI.au3 and $SPDRP_HARDWAREID should be returning some more data, all the HardwareIDs, just like with $SPDRP_COMPATIBLEIDS.

Another question, what would be Matching Device ID, as displayed in Device manager details page? I can't see any similar SPDRP_ constant.

Edited by ilko
Link to comment
Share on other sites

  • 4 months later...
  • Moderators

Windows what Enterprise (7 or 8)? And please post a specific reproducer that does not work for you.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

devman.jpg

Is this what you are seeing with the DeviceAPI_GUI_Example script?  I run Win 7 x64, and confirm the DeviceAPI_GUI_Example script does not seem right.  Oddly, an abandoned project using the same DeviceAPI.au3 still works properly.  If I get a chance I'll try to look in to why the original DeviceAPI_GUI_Example is not happy.

BTW, I tested with AutoIt 3.3.12.0

Ian

My projects:

  • IP Scanner - Multi-threaded ping tool to scan your available networks for used and available IP addresses, shows ping times, resolves IPs in to host names, and allows individual IPs to be pinged.
  • INFSniff - Great technicians tool - a tool which scans DriverPacks archives for INF files and parses out the HWIDs to a database file, and rapidly scans the local machine's HWIDs, searches the database for matches, and installs them.
  • PPK3 (Persistent Process Killer V3) - Another for the techs - suppress running processes that you need to keep away, helpful when fighting spyware/viruses.
  • Sync Tool - Folder sync tool with lots of real time information and several checking methods.
  • USMT Front End - Front End for Microsoft's User State Migration Tool, including all files needed for USMT 3.01 and 4.01, 32 bit and 64 bit versions.
  • Audit Tool - Computer audit tool to gather vital hardware, Windows, and Office information for IT managers and field techs. Capabilities include creating a customized site agent.
  • CSV Viewer - Displays CSV files with automatic column sizing and font selection. Lines can also be copied to the clipboard for data extraction.
  • MyDirStat - Lists number and size of files on a drive or specified path, allows for deletion within the app.
  • 2048 Game - My version of 2048, fun tile game.
  • Juice Lab - Ecigarette liquid making calculator.
  • Data Protector - Secure notes to save sensitive information.
  • VHD Footer - Add a footer to a forensic hard drive image to allow it to be mounted or used as a virtual machine hard drive.
  • Find in File - Searches files containing a specified phrase.
Link to comment
Share on other sites

devman.jpg

Is this what you are seeing with the DeviceAPI_GUI_Example script?  I run Win 7 x64, and confirm the DeviceAPI_GUI_Example script does not seem right.  Oddly, an abandoned project using the same DeviceAPI.au3 still works properly.  If I get a chance I'll try to look in to why the original DeviceAPI_GUI_Example is not happy.

BTW, I tested with AutoIt 3.3.12.0

Ian

Thank you, yes this is the example I refer to, the other one that outputs to consle has same results. I am using the latest version of autoit

Edited by Biatu

What is what? What is what.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...