Hello, i'm looking for some help as to why every time I call this function it fails.

The error code returned by GetLastError is 259 every time.

Any help would be appreciated.



SP_DEVINFO_DATA struct
  cbSize DWORD ?
  ClassGuid GUID <>
  DevInst DWORD ?
  Reserved DWORD ?
SP_DEVINFO_DATA EndS

SP_DEVICE_INTERFACE_DATA struct
cbSize DWORD ?
       InterfaceClassGuid        GUID   <>
  Flags DWORD   ?
Reserved DWORD ?
SP_DEVICE_INTERFACE_DATA EndS

.data
GUIDClassUSB GUID <36FC9E60h, 0C465h, 11CFh,{80h ,56h ,44h ,45h ,53h ,54h ,00h ,00h}>


...

invoke SetupDiGetClassDevs,NULL, NULL, NULL, DIGCF_ALLCLASSES or DIGCF_PRESENT
.IF eax == INVALID_HANDLE_VALUE
;Display error message
.ELSE
mov hDevInfoSet,eax
.WHILE(Result == TRUE)
invoke SetupDiEnumDeviceInterfaces, hDevInfoSet, NULL, ADDR GUIDClassUSB, cnt, ADDR DeviceInterfaceData
        mov Result, TRUE
                       .IF eax == FALSE
                                  invoke GetLastError
                                  ;Display error message
                       .ENDIF
                       inc cnt
               .ENDW
       .ENDIF
Posted on 2010-04-14 09:03:59 by Biorat
259 means " ERROR_NO_MORE_ITEMS ". This pretty much explains why it fails.

Are you sure you're setting the 'cnt' variable correctly?
Posted on 2010-04-14 10:53:57 by ti_mo_n
I am setting 'cnt' a few other variables like so


        LOCAL DeviceInfoData:SP_DEVINFO_DATA
LOCAL DeviceInterfaceData:SP_DEVICE_INTERFACE_DATA
LOCAL cnt:DWORD

mov eax,sizeof(SP_DEVINFO_DATA)
mov DeviceInfoData.cbSize,eax
mov eax,sizeof(SP_DEVICE_INTERFACE_DATA)
mov DeviceInterfaceData.cbSize,eax
mov cnt,0


And that is done in the same procedure the SetupDiXXX functions are being called


Posted on 2010-04-14 12:31:46 by Biorat