flat assembler
Message board for the users of flat assembler.

Index > Windows > What can I do to keep this console open?

Author
Thread Post new topic Reply to topic
_Rob_



Joined: 15 Dec 2012
Posts: 17
Location: Boston, MA
_Rob_ 25 Dec 2012, 01:47
What can I add to this so the console stays open? I am running XP version 2002 home addition.


Code:
; ======================================================================================================
; usbenum  v1.0    (by Roman Ovseytsev (arafel), tsech@mail.ru)
; ======================================================================================================
;
; Notes:
; ------
; * "Serial Number" field will show question mark if no SN descriptor string was provided by the device. 
; * Querying descriptor information is not implemented for zero base class.
; ======================================================================================================

; http://board.flatassembler.net/topic.php?t=12650

format PE CONSOLE 4.0
entry start

include 'win32ax.inc'


HOSTCONTROLLERS_MAX                     equ 10
CP_ACP                                  equ 0
MAX_DEVICE_ID_LEN                       equ 200
CR_SUCCESS                              equ 0
CM_DRP_DRIVER                           equ 0Ah
CM_DRP_DEVICEDESC                       equ 1
DIGCF_PRESENT                           equ 2h
DIGCF_ALLCLASSES                        equ 4h
DIGCF_PROFILE                           equ 8h
DIGCF_DEVICEINTERFACE                   equ 10h
ERROR_NO_MORE_ITEMS                     equ 259
HCD_GET_ROOT_HUB_NAME                   equ 258
USB_GET_NODE_CONNECTION_INFORMATION     equ 259
USB_GET_NODE_CONNECTION_INFORMATION_EX  equ 274
USB_GET_NODE_CONNECTION_DRIVERKEY_NAME  equ 264
USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION equ 260
USB_CONFIGURATION_DESCRIPTOR_TYPE       equ 2
METHOD_BUFFERED                         equ 0
FILE_ANY_ACCESS                         equ 0
FILE_DEVICE_UNKNOWN                     equ 22h
FILE_DEVICE_USB                         equ FILE_DEVICE_UNKNOWN
USB_GET_NODE_INFORMATION                equ 258
HCD_GET_DRIVERKEY_NAME                  equ 265
MAXIMUM_USB_STRING_LENGTH               equ 255
USB_STRING_DESCRIPTOR_TYPE              equ 3
USB_GET_NODE_CONNECTION_NAME            equ 261

IOCTL_USB_GET_NODE_INFORMATION = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_NODE_INFORMATION shl 2) or METHOD_BUFFERED

IOCTL_GET_HCD_DRIVERKEY_NAME = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (HCD_GET_DRIVERKEY_NAME shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_ROOT_HUB_NAME = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (HCD_GET_ROOT_HUB_NAME shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_NODE_CONNECTION_INFORMATION = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_NODE_CONNECTION_INFORMATION shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_NODE_CONNECTION_INFORMATION_EX shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_NODE_CONNECTION_DRIVERKEY_NAME shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION shl 2) or METHOD_BUFFERED

IOCTL_USB_GET_NODE_CONNECTION_NAME = (FILE_DEVICE_USB shl 16) or (FILE_ANY_ACCESS shl 14) or (USB_GET_NODE_CONNECTION_NAME shl 2) or METHOD_BUFFERED


struct USB_NODE_CONNECTION_NAME
 ConnectionIndex        dd ?
 ActualLength           dd ?
 NodeName               dw ?
ends

struct USB_STRING_DESCRIPTOR
 bLength                db ?
 bDescriptorType        db ?
 bString                dw ?
ends                                            

struct SETUP_PACKET
 bmRequest              db ?
 bRequest               db ?
 wValue                 dw ?
 wIndex                 dw ?
 wLength                dw ?
ends

struct USB_CONFIGURATION_DESCRIPTOR
 bLength                db ?
 bDescriptorType        db ?
 wTotalLength           dw ?
 bNumInterfaces         db ?
 bConfigurationValue    db ?
 iConfiguration         db ?
 bmAttributes           db ?
 MaxPower               db ?
ends

struct USB_DESCRIPTOR_REQUEST
 ConnectionIndex        dd ?
 SetupPacket            SETUP_PACKET
ends

struct USB_NODE_CONNECTION_DRIVERKEY_NAME
 ConnectionIndex        dd ?
 ActualLength           dd ?
 DriverKeyName          dw ?
ends

struct USB_DEVICE_DESCRIPTOR
 bLength                db ?
 bDescriptorType        db ?
 bcdUSB                 dw ?
 bDeviceClass           db ?
 bDeviceSubClass        db ?
 bDeviceProtocol        db ?
 bMaxPacketSize         db ?
 idVendor               dw ?
 idProduct              dw ?
 bcdDevice              dw ?
 iManufacturer          db ?
 iProduct               db ?
 iSerialNumber          db ?
 bNumConfigurations     db ?
ends

struct USB_ENDPOINT_DESCRIPTOR
 bLength                db ?
 bDescriptorType        db ?
 bEndpointAddress       db ?
 bmAttributes           db ?
 wMaxPacketSize         dw ?
 bInterval              db ?
ends

struct USB_PIPE_INFO
 EndpointDescriptor     USB_ENDPOINT_DESCRIPTOR 
 ScheduleOffset         dd ?
ends

struct USB_NODE_CONNECTION_INFORMATION_EX
 ConnectionIndex        dd ?
 DeviceDescriptor       USB_DEVICE_DESCRIPTOR
 CurrentConfigurationValue db ?
 Speed                  db ?
 DeviceIsHub            db ?
 DeviceAddress          dw ?
 NumberOfOpenPipes      dd ?
 ConnectionStatus       dd ?
 PipeList               USB_PIPE_INFO
ends

struct USB_NODE_CONNECTION_INFORMATION
 ConnectionIndex        dd ?
 DeviceDescriptor       USB_DEVICE_DESCRIPTOR 
 CurrentConfigurationValue db ?
 LowSpeed               db ?
 DeviceIsHub            db ?
 DeviceAddress          dw ?
 NumberOfOpenPipes      dd ?
 ConnectionStatus       dd ?
 PipeList               USB_PIPE_INFO
ends

struct USB_ROOT_HUB_NAME
 ActualLength           dd ?
 RootHubName            dw ?
ends

struct USB_HCD_DRIVERKEY_NAME
 ActualLength           dd ?
 DriverKeyName          dw ?
ends
 
struct USB_HUB_DESCRIPTOR
 bDescriptorLength      db ?
 bDescriptorType        db ?
 bNumberOfPorts         db ?
 wHubCharacteristics    dw ?
 bPowerOnToPowerGood    db ?
 bHubControlCurrent     db ?
 bRemoveAndPowerMask    db 64 dup(?)      
ends

struct USB_HUB_INFORMATION
 HubDescriptor          USB_HUB_DESCRIPTOR
 HubIsBusPowered        db ? 
ends

struct USB_MI_PARENT_INFORMATION
 NumberOfInterfaces     dd ?
ends

struct USB_NODE_INFORMATION
 NodeType               dd ?
 usb_hub_information    USB_HUB_INFORMATION
 usb_mi_parent_information USB_MI_PARENT_INFORMATION
ends

struct SP_DEVICE_INTERFACE_DATA 
 cbSize                 dd ?
 InterfaceClassGuid     db 16 dup(?)
 Flags                  dd ?
 Reserved               dd ?
ends

struct SP_INTERFACE_DEVICE_DETAIL_DATA
 cbSize                 dd ?
 DevicePath             db ?
ends


section '.data' data readable writeable

spacing         dd s1
space_cnt       dd -1
hConsole        dd ?
tmp             dd ?
tmp_buf         db 256 dup(?)
tmp_buf2        db 256 dup(?)

spacelut   dd s1
           dd s2     
           dd s3
           dd s4
                
s1      db "  ",0
s2      db "   ",0
s3      db "    ",0
s4      db "     ",0

                
; class code triplets:
;
; [base class code], [sub class code], [protocol]
;
; (0ffffh specifies values outside of defined specs.) 
 
class_codes: 
        dw 00000h, 0ffffh, 0ffffh
        dw 00001h, 0ffffh, 0ffffh
        dw 00002h, 0ffffh, 0ffffh 
        dw 00003h, 0ffffh, 0ffffh 
        dw 00005h, 0ffffh, 0ffffh 
        dw 00006h, 00001h, 00001h 
        dw 00007h, 0ffffh, 0ffffh 
        dw 00008h, 0ffffh, 0ffffh 
        dw 00009h, 00000h, 00000h
        dw 00009h, 00000h, 00001h
        dw 00009h, 00000h, 00002h
        dw 0000ah, 0ffffh, 0ffffh 
        dw 0000bh, 0ffffh, 0ffffh 
        dw 0000dh, 00000h, 00000h 
        dw 0000eh, 0ffffh, 0ffffh
        dw 000dch, 00001h, 00001h
        dw 000e0h, 00001h, 00001h  
        dw 000e0h, 00001h, 00002h  
        dw 000e0h, 00001h, 00003h
        dw 000e0h, 00002h, 00001h  
        dw 000e0h, 00002h, 00002h  
        dw 000e0h, 00002h, 00003h
        dw 000efh, 00001h, 00001h
        dw 000efh, 00001h, 00002h 
        dw 000efh, 00002h, 00001h
        dw 000efh, 00002h, 00002h
        dw 000efh, 00003h, 00001h
        dw 000feh, 00001h, 00001h
        dw 000feh, 00002h, 00000h
        dw 000feh, 00003h, 00000h
        dw 000feh, 00003h, 00001h
        dw 000ffh, 0ffffh, 0ffffh
_l: class_codes_sz equ (_l-class_codes)/6
        
class_codes_lut:
        dd _0
        dd _1
        dd _2
        dd _3
        dd _4
        dd _5
        dd _6
        dd _7
        dd _8
        dd _9
        dd _10       
        dd _11
        dd _12
        dd _13
        dd _14
        dd _15
        dd _16
        dd _17
        dd _18
        dd _19
        dd _20
        dd _21
        dd _22
        dd _23
        dd _24
        dd _25
        dd _26
        dd _27
        dd _28
        dd _29
        dd _30
        dd _31
        
_0      db " ",0                                                                  ; if 0, we should get CC info
_1      db "Audio device",0                                                       ; from interface descriptor 
_2      db "Communication device class",0
_3      db "HID device class",0
_4      db "Physical device class",0
_5      db "Still Imaging device",0
_6      db "Printer device",0
_7      db "Mass Storage device",0
_8      db "Full speed Hub",0
_9      db "Hi-speed hub with single TT",0
_10     db "Hi-speed hub with multiple TTs",0
_11     db "CDC data device",0
_12     db "Smart Card device",0
_13     db "Content Security device",0
_14     db "Video device",0
_15     db "USB2 Compliance Device",0
_16     db "Bluetooth Programming Interface",0
_17     db "UWB Radio Control Interface",0
_18     db "Remote NDIS",0
_19     db "Host Wire Adapter Control/Data interface",0
_20     db "Device Wire Adapter Control/Data interface",0
_21     db "Device Wire Adapter Isochronous interface",0
_22     db "Active Sync device",0
_23     db "Palm Sync",0
_24     db "Interface Association Descriptor",0
_25     db "Wire Adapter Multifunction Peripheral programming interface",0
_26     db "Cable Based Association Framework",0
_27     db "Device Firmware Upgrade",0
_28     db "IRDA Bridge device",0
_29     db "USB Test and Measurement Device",0
_30     db "USB Test and Measurement Device (conforming to the USBTMC USB488)",0
_31     db " ",0
        
        

section '.code' code readable executable


start:
        invoke  GetStdHandle, -11
        cmp     eax, INVALID_HANDLE_VALUE
        je      exit
        mov     [hConsole], eax
        
        invoke  WriteConsole, [hConsole], <"USB devices enumerator v1.0      (arafel, tsech@mail.ru)",13,10,13,10>,60, tmp,0
        
        xor     ebx, ebx
enum_hc:
        cinvoke wsprintf, tmp_buf, "\\.\HCD%d", ebx
        mov     edi, eax

        invoke  CreateFile, tmp_buf, GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0
        cmp     eax, INVALID_HANDLE_VALUE
        je      nxt_hc
        mov     esi, eax

        cinvoke wsprintf, tmp_buf2, <"USB Host Controler: %s",13,10>, tmp_buf
        invoke  WriteConsole, [hConsole], tmp_buf2, eax, tmp, 0
        
        stdcall usb_enumerateDevInt, esi
    
        invoke  CloseHandle, esi

nxt_hc: inc     ebx
        cmp     ebx, HOSTCONTROLLERS_MAX
        jb      enum_hc
        
exit:   invoke  ExitProcess, 0




proc usb_enumerateDevInt hHC

        local   driverkeyName:USB_HCD_DRIVERKEY_NAME
        local   driverkeyName_ptr:DWORD
        local   driverkeyName_sz:DWORD
        local   device_id[MAX_DEVICE_ID_LEN]:BYTE
        local   device_id_sz:DWORD     
        local   dnDevInst:DWORD
        local   dnDevInst_Next:DWORD
        local   roothubName:USB_ROOT_HUB_NAME
        local   roothubName_ptr:DWORD
        local   roothubName_sz:DWORD


        pushad
        
;===========================================================================================================================
;=================================================================================== get HC driver identification key which
;=================================================================================== will be used to locate needed USB UHC
;===========================================================================================================================                                                                       
        
        lea     edi, [driverkeyName]
        mov     ecx, sizeof.USB_HCD_DRIVERKEY_NAME
        xor     eax, eax
        rep     stosb
 
        invoke  DeviceIoControl, [hHC], IOCTL_GET_HCD_DRIVERKEY_NAME, addr driverkeyName, sizeof.USB_HCD_DRIVERKEY_NAME, addr driverkeyName, sizeof.USB_HCD_DRIVERKEY_NAME, tmp, 0
        test    eax, eax
        je      error0
        cmp     [tmp], sizeof.USB_HCD_DRIVERKEY_NAME
        jb      error0

        lea     esi, [driverkeyName]
        mov     edx, [esi+USB_HCD_DRIVERKEY_NAME.ActualLength]
        mov     [driverkeyName_sz], edx
        test    edx, edx
        je      error0
        
        invoke  VirtualAlloc, 0, edx, MEM_COMMIT, PAGE_READWRITE
        test    eax, eax
        je      error0
        mov     [driverkeyName_ptr], eax

        invoke  DeviceIoControl, [hHC], IOCTL_GET_HCD_DRIVERKEY_NAME, [driverkeyName_ptr], [driverkeyName_sz], [driverkeyName_ptr], [driverkeyName_sz], tmp, 0
        test    eax, eax
        je      error11

        mov     esi, [driverkeyName_ptr]
        lea     eax, [esi+USB_HCD_DRIVERKEY_NAME.DriverKeyName]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, [driverkeyName_ptr], [driverkeyName_sz], 0, 0
        mov     [driverkeyName_sz], eax
                        
                        
        cinvoke wsprintf, tmp_buf, <" Driver Key: %s",13,10>, [driverkeyName_ptr]           
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0


;===========================================================================================================================
;=================================================================================== get USB HC's ID and description  
;===========================================================================================================================

        invoke  CM_Locate_DevNode, addr dnDevInst, 0, 0
        cmp     eax, CR_SUCCESS
        jne     error22
        
search_hc:
        mov     [device_id_sz], MAX_DEVICE_ID_LEN
        invoke  CM_Get_DevNode_Registry_Property, [dnDevInst], CM_DRP_DRIVER, 0, addr device_id, addr device_id_sz, 0
        cmp     eax, CR_SUCCESS
        jne     no_match

        lea     esi, [device_id]
        mov     edi, [driverkeyName_ptr]
        mov     ecx, [driverkeyName_sz]
        repe    cmpsb
        jne     no_match

        invoke  CM_Get_Device_ID, [dnDevInst], addr device_id, MAX_DEVICE_ID_LEN, 0
        cmp     eax, CR_SUCCESS
        jne     error22
        
        cinvoke wsprintf, tmp_buf, <" ID: %s",13,10>, addr device_id
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        mov     [device_id_sz], MAX_DEVICE_ID_LEN
        invoke  CM_Get_DevNode_Registry_Property, [dnDevInst], CM_DRP_DEVICEDESC, 0, addr device_id, addr device_id_sz, 0
        cmp     eax, CR_SUCCESS
        jne     error22
        
        cinvoke wsprintf, tmp_buf, <" Description: %s",13,10>, addr device_id
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0
        jmp     hc_search_done
       
no_match:       
        invoke  CM_Get_Child, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     get_sibling
  
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax
        jmp     search_hc
        
sibling_error:
        invoke  CM_Get_Parent, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     error22
        
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax

get_sibling:
        invoke  CM_Get_Sibling, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     sibling_error
        
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax
        jmp     search_hc


hc_search_done:
        invoke  VirtualFree, [driverkeyName_ptr], 0, MEM_RELEASE
        
;===========================================================================================================================
;=================================================================================== get USB root hub 
;===========================================================================================================================


        invoke  DeviceIoControl, [hHC], IOCTL_USB_GET_ROOT_HUB_NAME, 0, 0, addr roothubName, sizeof.USB_ROOT_HUB_NAME, tmp,0
        test    eax, eax
        je      error0
        cmp     [tmp], sizeof.USB_ROOT_HUB_NAME
        jb      error0

        lea     esi, [roothubName]
        mov     eax, [esi+USB_ROOT_HUB_NAME.ActualLength]
        mov     [roothubName_sz], eax
        test    eax, eax
        je      error0

        invoke  VirtualAlloc, 0, eax, MEM_COMMIT, PAGE_READWRITE
        test    eax, eax
        je      error0
        mov     [roothubName_ptr], eax
        
        invoke  DeviceIoControl, [hHC], IOCTL_USB_GET_ROOT_HUB_NAME, 0, 0, eax, [roothubName_sz], tmp, 0
        test    eax, eax
        je      error33

        mov     edx, [roothubName_ptr]
        lea     eax, [edx+USB_ROOT_HUB_NAME.RootHubName]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, [roothubName_ptr], [roothubName_sz], 0, 0
        mov     [roothubName_sz], eax
        
        cinvoke wsprintf, tmp_buf, <" Root Hub: \\.\%s",13,10>, [roothubName_ptr]
        mov     edi, eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0  
        
        mov     eax, tmp_buf
        add     eax, edi
        mov     [eax-2], byte 0
        mov     eax, tmp_buf+11
        
        stdcall usb_enumHub, eax

        invoke  VirtualFree, [roothubName_ptr], 0, MEM_RELEASE
        jmp     __ret


error33:call    error_display
        invoke  VirtualFree, [roothubName_ptr], 0, MEM_RELEASE
        jmp     __ret

error22:invoke  VirtualFree, [driverkeyName_ptr], 0, MEM_RELEASE
        jmp     __ret

error11:call    error_display
        invoke  VirtualFree, [driverkeyName_ptr], 0, MEM_RELEASE
        jmp     __ret

error0: call    error_display

__ret:  popad
        ret
endp



proc    usb_enumHub, devname

        local   driverkeyName_ptr:DWORD
        local   driverkeyName_sz:DWORD
        local   device_id[MAX_DEVICE_ID_LEN]:BYTE
        local   device_id_sz:DWORD     
        local   dnDevInst:DWORD
        local   dnDevInst_Next:DWORD
        local   HubInfo:USB_NODE_INFORMATION
        local   connectionInfo[(sizeof.USB_NODE_CONNECTION_INFORMATION_EX)+((sizeof.USB_PIPE_INFO)*29)]:BYTE
        local   condriverkeyName:USB_NODE_CONNECTION_DRIVERKEY_NAME
        local   hHubDevice:DWORD
        local   stringDescRequest[sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH]:BYTE
        local   nodeconName:USB_NODE_CONNECTION_NAME
        local   nodeconName_ptr:DWORD
        local   nodeconName_sz:DWORD
        local   externalhub:DWORD

        pushad
        
;===========================================================================================================================
;=================================================================================== enumerate all available ports for 
;=================================================================================== current hub
;===========================================================================================================================

        mov     [externalhub], FALSE

        inc     [space_cnt]
        mov     eax, [space_cnt]
        cmp     eax, 3
        jne     k1
        mov     [space_cnt], 3     
k1:     mov     edx, [spacelut+eax*4]
        mov     [spacing], edx
        
        invoke  CreateFile, [devname], GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0
        cmp     eax, INVALID_HANDLE_VALUE
        je      error
        mov     [hHubDevice], eax
           
        lea     edi, [HubInfo]
        mov     ecx, sizeof.USB_NODE_INFORMATION
        xor     eax, eax
        rep     stosb
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_INFORMATION, addr HubInfo, sizeof.USB_NODE_INFORMATION, addr HubInfo, sizeof.USB_NODE_INFORMATION, tmp, 0
        test    eax, eax
        je      error4


        mov     ebx, 1
        
ports_enum:

        lea     edi, [connectionInfo]
        mov     ecx, sizeof.USB_NODE_CONNECTION_INFORMATION_EX+((sizeof.USB_PIPE_INFO)*29)
        xor     eax, eax
        rep     stosb

        lea     eax, [connectionInfo]
        mov     [eax+USB_NODE_CONNECTION_INFORMATION_EX.ConnectionIndex], ebx
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX, addr connectionInfo, sizeof.USB_NODE_CONNECTION_INFORMATION_EX+((sizeof.USB_PIPE_INFO)*29), addr connectionInfo, sizeof.USB_NODE_CONNECTION_INFORMATION_EX+((sizeof.USB_PIPE_INFO)*29), tmp, 0
        test    eax, eax
        je      error4


        lea     eax, [connectionInfo]                                              ; check if we got some device connected
        cmp     [eax+USB_NODE_CONNECTION_INFORMATION_EX.ConnectionStatus], 1
        je      device_con

        cinvoke wsprintf, tmp_buf, <" [Port#%d] No Device Connected",13,10>, ebx          
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0
        jmp     port_nxt


device_con:

        lea     eax, [condriverkeyName]
        mov     [eax+USB_NODE_CONNECTION_DRIVERKEY_NAME.ConnectionIndex], ebx

        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, addr condriverkeyName, sizeof.USB_NODE_CONNECTION_DRIVERKEY_NAME, addr condriverkeyName, sizeof.USB_NODE_CONNECTION_DRIVERKEY_NAME, tmp, 0
        test    eax, eax
        je      error4
        cmp     [tmp], sizeof.USB_NODE_CONNECTION_DRIVERKEY_NAME
        jb      error4
        
        lea     eax, [condriverkeyName]
        mov     edx, [eax+USB_NODE_CONNECTION_DRIVERKEY_NAME.ActualLength]
        mov     [driverkeyName_sz], edx
        test    edx, edx
        je      error4
        
        invoke  VirtualAlloc, 0, edx, MEM_COMMIT, PAGE_READWRITE
        test    eax, eax
        je      error4
        mov     [driverkeyName_ptr], eax
        
        mov     [eax+USB_NODE_CONNECTION_DRIVERKEY_NAME.ConnectionIndex], ebx
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME, [driverkeyName_ptr], [driverkeyName_sz], [driverkeyName_ptr], [driverkeyName_sz], tmp, 0

        mov     edx, [driverkeyName_ptr]
        lea     eax, [edx+USB_NODE_CONNECTION_DRIVERKEY_NAME.DriverKeyName]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, [driverkeyName_ptr], [driverkeyName_sz], 0, 0
        mov     [driverkeyName_sz], eax

        cinvoke wsprintf, tmp_buf, <" [Port#%d] Driver Key: %s",13,10>, ebx, [driverkeyName_ptr] 
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0
        
;===========================================================================================================================
;=================================================================================== get device description
;===========================================================================================================================

        invoke  CM_Locate_DevNode, addr dnDevInst, 0, 0
        cmp     eax, CR_SUCCESS
        jne     error5
        
search_dev:
        mov     [tmp], MAX_DEVICE_ID_LEN
        invoke  CM_Get_DevNode_Registry_Property, [dnDevInst], CM_DRP_DRIVER, 0, addr device_id, tmp, 0
        cmp     eax, CR_SUCCESS
        jne     no_match1
        
        lea     esi, [device_id]
        mov     edi, [driverkeyName_ptr]
        mov     ecx, [driverkeyName_sz]
        repe    cmpsb
        jne     no_match1

        mov     [tmp], MAX_DEVICE_ID_LEN
        invoke  CM_Get_DevNode_Registry_Property, [dnDevInst], CM_DRP_DEVICEDESC, 0, addr device_id, tmp, 0
        cmp     eax, CR_SUCCESS
        jne     error5
        jmp     got_desc
       
       
no_match1:       
        invoke  CM_Get_Child, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     get_sibling1
  
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax
        jmp     search_dev

sibling_error1:
        invoke  CM_Get_Parent, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     error5
        
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax

get_sibling1:
        invoke  CM_Get_Sibling, addr dnDevInst_Next, [dnDevInst], 0
        cmp     eax, CR_SUCCESS
        jne     sibling_error1
        
        mov     eax, [dnDevInst_Next]
        mov     [dnDevInst], eax
        jmp     search_dev

got_desc:  
        cinvoke wsprintf, tmp_buf, <"        %sDevice Description: %s",13,10>, [spacing], addr device_id
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0
        
        invoke  VirtualFree, [driverkeyName_ptr], 0, MEM_RELEASE

;===========================================================================================================================
;=================================================================================== display device descriptor information
;===========================================================================================================================

        lea     esi, [connectionInfo]
        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bDeviceClass]
        movzx   ecx, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bDeviceSubClass]
        movzx   edx, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bDeviceProtocol]


        mov     esi, class_codes
        xor     edi, edi
        
check_class_code:
        cmp     [esi], word ax
        jne     nxt_class_code

        cmp     [esi+2], word cx
        je      check_protocol
        cmp     [esi+2], word 0ffffh
        je      cc_match
        jmp     nxt_class_code
        
check_protocol:
        cmp     [esi+4], word dx        
        je      cc_match
        cmp     [esi+2], word 0ffffh
        je      cc_match

nxt_class_code:
        add     esi, 6
        inc     edi
        cmp     edi, class_codes_sz
        jb      check_class_code      


cc_match:
        cmp     edi, 8
        je      external_hub
        cmp     edi, 9
        je      external_hub
        cmp     edi, 10
        jne     not_external
external_hub:                                                                   
        mov     [externalhub], TRUE
not_external:


        cinvoke wsprintf, tmp_buf, <"        %sClass Code Triplet: 0x%x,0x%x,0x%x (%s)",13,10>,[spacing], eax, ecx, edx, dword [class_codes_lut+edi*4]
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0


        lea     esi, [connectionInfo]
        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bMaxPacketSize]
        cinvoke wsprintf, tmp_buf, <"        %sMaximum Packet Size: %d",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        movzx   eax, word [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.idVendor]
        cinvoke wsprintf, tmp_buf, <"        %sVendor ID: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        movzx   eax, word [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.idProduct]
        cinvoke wsprintf, tmp_buf, <"        %sProduct ID: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        movzx   eax, word [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bcdDevice]
        cinvoke wsprintf, tmp_buf, <"        %sDevice Release #: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0



        lea     edi, [stringDescRequest]                                              ; obtain list of supported languages
        mov     ecx, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH
        xor     eax, eax
        rep     stosb
        
        lea     esi, [stringDescRequest]
        mov     [esi+USB_DESCRIPTOR_REQUEST.ConnectionIndex], ebx
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wValue], USB_STRING_DESCRIPTOR_TYPE shl 8
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wIndex], 0
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wLength], MAXIMUM_USB_STRING_LENGTH
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, tmp, 0 
        test    eax, eax
        je      error_obtaining_languageIDs

        cmp     [tmp], sizeof.USB_DESCRIPTOR_REQUEST+4
        jb      error_obtaining_languageIDs

        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bLength], 2
        jbe     error_obtaining_languageIDs
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bDescriptorType], USB_STRING_DESCRIPTOR_TYPE
        jne     error_obtaining_languageIDs


                                                                                       ; obtain Manufacturer string
        mov     edi, esi
        mov     ecx, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH
        xor     eax, eax
        rep     stosb
              
        mov     [esi+USB_DESCRIPTOR_REQUEST.ConnectionIndex], ebx
        
        mov     edx, USB_STRING_DESCRIPTOR_TYPE shl 8
        lea     ecx, [connectionInfo]
        movzx   eax, byte [ecx+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iManufacturer]
        or      edx, eax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wValue], dx

        mov     ax, word [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wIndex], word ax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wLength], MAXIMUM_USB_STRING_LENGTH
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, tmp, 0 
        test    eax, eax
        je      error_obtaining_languageIDs
        
        cmp     [tmp], sizeof.USB_DESCRIPTOR_REQUEST+2
        jb      error_obtaining_languageIDs
        
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bLength], 2
        jbe     error_obtaining_languageIDs
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bDescriptorType], USB_STRING_DESCRIPTOR_TYPE
        jne     error_obtaining_languageIDs

        lea     eax, [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, tmp_buf2, 256, 0, 0

        cinvoke wsprintf, tmp_buf, <"        %sManufacturer: %s",13,10>, [spacing], tmp_buf2
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0


                                                                                       ; obtain Product string
        mov     edi, esi
        mov     ecx, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH
        xor     eax, eax
        rep     stosb
              
        mov     [esi+USB_DESCRIPTOR_REQUEST.ConnectionIndex], ebx
        
        mov     edx, USB_STRING_DESCRIPTOR_TYPE shl 8
        lea     ecx, [connectionInfo]
        movzx   eax, byte [ecx+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iProduct]
        or      edx, eax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wValue], dx

        mov     ax, word [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wIndex], word ax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wLength], MAXIMUM_USB_STRING_LENGTH
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, tmp, 0 
        test    eax, eax
        je      error_obtaining_languageIDs
        
        cmp     [tmp], sizeof.USB_DESCRIPTOR_REQUEST+2
        jb      error_obtaining_languageIDs
        
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bLength], 2
        jbe     error_obtaining_languageIDs
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bDescriptorType], USB_STRING_DESCRIPTOR_TYPE
        jne     error_obtaining_languageIDs

        lea     eax, [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, tmp_buf2, 256, 0, 0

        cinvoke wsprintf, tmp_buf, <"        %sProduct: %s",13,10>, [spacing], tmp_buf2
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

                                                                                       ; obtain the SerialNumber string
        mov     edi, esi
        mov     ecx, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH
        xor     eax, eax
        rep     stosb
              
        mov     [esi+USB_DESCRIPTOR_REQUEST.ConnectionIndex], ebx
        
        mov     edx, USB_STRING_DESCRIPTOR_TYPE shl 8
        lea     ecx, [connectionInfo]
        movzx   eax, byte [ecx+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iSerialNumber]
        or      edx, eax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wValue], dx

        mov     ax, word [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wIndex], word ax
        mov     [esi+USB_DESCRIPTOR_REQUEST.SetupPacket.wLength], MAXIMUM_USB_STRING_LENGTH
        
        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, addr stringDescRequest, sizeof.USB_DESCRIPTOR_REQUEST + MAXIMUM_USB_STRING_LENGTH, tmp, 0 
        test    eax, eax
        je      error_obtaining_languageIDs
        
        cmp     [tmp], sizeof.USB_DESCRIPTOR_REQUEST+2
        jb      error_obtaining_languageIDs
        
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bLength], 2
        jbe     error_obtaining_languageIDs
        cmp     [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bDescriptorType], USB_STRING_DESCRIPTOR_TYPE
        jne     error_obtaining_languageIDs

        lea     eax, [esi+sizeof.USB_DESCRIPTOR_REQUEST+USB_STRING_DESCRIPTOR.bString]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, tmp_buf2, 256, 0, 0

        cinvoke wsprintf, tmp_buf, <"        %sSerial Number: %s",13,10>, [spacing], tmp_buf2
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        jmp     confnum



error_obtaining_languageIDs:                                                            ; failed to get langIDs or failed
                                                                                        ; to get a particular string, so
                                                                                        ; show hex index values instead
        lea     esi, [connectionInfo]
        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iManufacturer]

        cinvoke wsprintf, tmp_buf, <"        %sManufacturer Index: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iProduct]

        cinvoke wsprintf, tmp_buf, <"        %sProduct Index: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.iSerialNumber]

        cinvoke wsprintf, tmp_buf, <"        %sSerial Number Index: 0x%x",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0


confnum:
        lea     esi, [connectionInfo]
        movzx   eax, byte [esi+USB_NODE_CONNECTION_INFORMATION_EX.DeviceDescriptor.bNumConfigurations]
        cinvoke wsprintf, tmp_buf, <"        %sPossible Configurations #: %d",13,10>, [spacing], eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0


        cmp     [externalhub], TRUE
        jne     port_nxt

;===========================================================================================================================
;=================================================================================== enumerate external hub's devices
;===========================================================================================================================

        lea     edi, [nodeconName]
        mov     ecx, sizeof.USB_NODE_CONNECTION_NAME
        xor     eax, eax
        rep     stosb
        
        lea     esi, [nodeconName]
        mov     [esi+USB_NODE_CONNECTION_NAME.ConnectionIndex], ebx

        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_CONNECTION_NAME, addr nodeconName, sizeof.USB_NODE_CONNECTION_NAME, addr nodeconName, sizeof.USB_NODE_CONNECTION_NAME, tmp, 0
        test    eax, eax
        je      error4

        mov     edx, [esi+USB_NODE_CONNECTION_NAME.ActualLength]
        mov     [nodeconName_sz], edx
        test    edx, edx
        je      error4
        
        invoke  VirtualAlloc, 0, edx, MEM_COMMIT, PAGE_READWRITE
        test    eax, eax
        je      error4
        mov     [nodeconName_ptr], eax
        
        mov     [eax+USB_NODE_CONNECTION_NAME.ConnectionIndex], ebx

        invoke  DeviceIoControl, [hHubDevice], IOCTL_USB_GET_NODE_CONNECTION_NAME, [nodeconName_ptr], [nodeconName_sz], [nodeconName_ptr], [nodeconName_sz], tmp, 0
        test    eax, eax
        je      error6

        mov     edx, [nodeconName_ptr]
        lea     eax, [edx+USB_NODE_CONNECTION_NAME.NodeName]
        invoke  WideCharToMultiByte, CP_ACP, 0, eax, -1, [nodeconName_ptr], [nodeconName_sz], 0, 0
        mov     [nodeconName_sz], eax


        cinvoke wsprintf, tmp_buf, <"        %sExternal Hub: \\.\%s",13,10>, [spacing], [nodeconName_ptr]
        mov     esi, eax
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp, 0

        
        mov     edi, tmp_buf
        add     esi, edi
        mov     [esi-2], byte 0
        mov     al, byte "\"
        mov     ecx, -1
        repne   scasb
        mov      esi, edi 
        dec      esi
        
        stdcall usb_enumHub, esi
        
        invoke  VirtualFree, [nodeconName_ptr], 0, MEM_RELEASE
        
        

port_nxt:
        inc     ebx
        lea     eax, [HubInfo]
        cmp     bl, byte [eax+USB_NODE_INFORMATION.usb_hub_information.HubDescriptor.bNumberOfPorts]
        jng     ports_enum
        
        invoke  CloseHandle, [hHubDevice]
        jmp     _ret



error6: invoke  VirtualFree, [nodeconName_ptr], 0, MEM_RELEASE
        invoke  CloseHandle, [hHubDevice]
        jmp     _ret

error5: invoke  VirtualFree, [driverkeyName_ptr], 0, MEM_RELEASE
        invoke  CloseHandle, [hHubDevice]
        jmp     _ret

error4: call    error_display
        invoke  CloseHandle, [hHubDevice]
        jmp     _ret

error:  call    error_display

_ret:   popad
        ret
        
endp




proc  error_display
        invoke  GetLastError
        invoke  FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER+FORMAT_MESSAGE_FROM_SYSTEM, 0, eax, LANG_NEUTRAL, tmp, 0, 0
        cinvoke wsprintf, tmp_buf, <13,10," Something went wrong...: %s",13,10>, [tmp]          
        invoke  WriteConsole, [hConsole], tmp_buf, eax, tmp_buf, 0
        invoke  LocalFree, [tmp]
        ret
        
endp


        

section '.idata' import data readable writeable


library kernel32,'kernel32.DLL',\
        user32,'user32.DLL',\
        setupapi, 'Setupapi.dll',\
        cfgmgr32, 'cfgmgr32.dll'



import kernel32,\
        ExitProcess,'ExitProcess',\
        GetLastError,'GetLastError',\
        SetLastError,'SetLastError',\
        FormatMessage,'FormatMessageA',\
        LocalFree,'LocalFree',\
        VirtualAlloc,'VirtualAlloc',\
        VirtualFree,'VirtualFree',\
        CreateFile,'CreateFileA',\
        LoadLibrary,'LoadLibraryA',\
        GetProcAddress,'GetProcAddress',\
        DeviceIoControl,'DeviceIoControl',\
        WriteConsole,'WriteConsoleA',\
        GetStdHandle,'GetStdHandle',\
        CloseHandle,'CloseHandle',\
        WideCharToMultiByte,'WideCharToMultiByte'

import user32,wsprintf,'wsprintfA'
        
import cfgmgr32,\
        CM_Locate_DevNode,'CM_Locate_DevNodeA',\
        CM_Get_DevNode_Registry_Property,'CM_Get_DevNode_Registry_PropertyA',\
        CM_Get_Device_ID,'CM_Get_Device_IDA',\
        CM_Get_Child,'CM_Get_Child',\
        CM_Get_Sibling,'CM_Get_Sibling',\
        CM_Get_Parent,'CM_Get_Parent'

import setupapi,\
        SetupDiGetClassDevs,'SetupDiGetClassDevsA',\
        SetupDiEnumDeviceInterfaces,'SetupDiEnumDeviceInterfaces',\
        SetupDiDestroyDeviceInfoList,'SetupDiDestroyDeviceInfoList',\
        SetupDiGetDeviceInterfaceDetail, 'SetupDiGetDeviceInterfaceDetailA'



section '.rsrc' resource data readable

directory RT_ICON,icons,RT_GROUP_ICON,group_icons

resource icons,1,LANG_NEUTRAL,icon_data 
resource group_icons,17,LANG_NEUTRAL,main_icon 
        
icon main_icon,icon_data,"main.ico"
    
Post 25 Dec 2012, 01:47
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1178
Location: Unknown
HaHaAnonymous 25 Dec 2012, 02:36
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 22:08; edited 1 time in total
Post 25 Dec 2012, 02:36
View user's profile Send private message Reply with quote
_Rob_



Joined: 15 Dec 2012
Posts: 17
Location: Boston, MA
_Rob_ 25 Dec 2012, 03:10
Sorry I don't understand; I did try and implement a few ideas I found doing searches but that did not work out for me. Obviously I am just getting my feet wet with the asm programming language. Heck I can just barely spell never mind this stuff! Very Happy

edit: I do know what you mean though.......my skills with asm are just not there yet.

Happy Holidays!
Post 25 Dec 2012, 03:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 25 Dec 2012, 04:46
The console will stay open as long as the program is running. So you need to keep the program running. Some options are to wait for keyboard input, or sleep for some predetermined time, or exit on some external event like the focus being lost or the mouse button clicked. Depending upon your needs one of those methods may be adequate.
Post 25 Dec 2012, 04:46
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1903
DOS386 25 Dec 2012, 08:01
Post 25 Dec 2012, 08:01
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 25 Dec 2012, 10:27
Some things you can do that don't require altering the program:

1) make a batch file to run the program and put a pause statement at the end.
2) open a console manually and run the command manually.
Post 25 Dec 2012, 10:27
View user's profile Send private message Visit poster's website Reply with quote
_Rob_



Joined: 15 Dec 2012
Posts: 17
Location: Boston, MA
_Rob_ 25 Dec 2012, 15:08
Thanks for all the replies!

@rev:
I ended up using you suggestion number 2.

Thanks.
Post 25 Dec 2012, 15:08
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1398
Location: Piraeus, Greece
Picnic 27 Dec 2012, 11:46
Hi,

Just for debugging purposes, this clumsy method should work in Windows, try msvcrt function 'system'.

Code:
cinvoke system, "pause"    
Post 27 Dec 2012, 11:46
View user's profile Send private message Visit poster's website Reply with quote
phytress



Joined: 04 Jan 2013
Posts: 1
phytress 04 Jan 2013, 22:13
I just use _getch from msvcrt
Code:
...
call [_getch] ; no push or anything needs to be done to the stack
...
library msvcrt, 'msvcrt.dll'
import msvcrt, _getch, '_getch'    


it just waits for ANY keyboard input
Post 04 Jan 2013, 22:13
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.