begin process at 2010 03 19 23:43:22
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Api Windows

 > RECUPERE LES INFORMATIONS DU POSTE

RECUPERE LES INFORMATIONS DU POSTE


 Information sur la source

Note :
Aucune note
Catégorie :Api Windows Niveau :Débutant Date de création :21/03/2005 Date de mise à jour :22/03/2005 20:53:40 Vu :4 414

Auteur : VBFRANCE

Ecrire un message privé
Site perso
Commentaire sur cette source (7)
Ajouter un commentaire et/ou une note

 Description

Je suis tout nouveau dans l'assembleur i86, voici mon premier petit programme. Celui ci m'as paermis de me familliariser avec les fonction Windows. Ce code n'a rien d'exceptionel, mais j'aimerais bien avoir vos avis, afin de m'aider a progressé.

Source

  • .586
  • .MMX
  • .model flat, stdcall
  • option casemap:none
  • ;================================================
  • ; These are the Inlcude files for Window calls
  • ;================================================
  • include \masm32\include\windows.inc
  • include \masm32\include\masm32.inc
  • include \masm32\include\user32.inc
  • include \masm32\include\kernel32.inc
  • include \masm32\include\ws2_32.inc
  • include \masm32\include\advapi32.inc
  • include \masm32\include\netapi32.inc
  • ;===============================================
  • ; The Lib's for those included files
  • ;================================================
  • includelib \masm32\lib\masm32.lib
  • includelib \masm32\lib\user32.lib
  • includelib \masm32\lib\kernel32.lib
  • includelib \masm32\lib\ws2_32.lib
  • includelib \masm32\lib\advapi32.lib
  • includelib \masm32\lib\netapi32.lib
  • ; --------------- Local Macros
  • SzText MACRO Name, Text:VARARG
  • LOCAL lbl
  • jmp lbl
  • Name db Text, 0
  • lbl:
  • ENDM
  • M2M MACRO M1, M2
  • push M2
  • pop M1
  • ENDM
  • Return MACRO arg
  • mov eax, arg
  • ret
  • ENDM
  • val MACRO DDvalue
  • LOCAL rvstring
  • .data
  • rvstring db 20 dup (0)
  • align 4
  • .code
  • push OFFSET rvstring
  • push DDvalue
  • call ltoa
  • EXITM <OFFSET rvstring>
  • ENDM
  • .CONST
  • PF_3DNOW_INSTRUCTIONS_AVAILABLE EQU 7
  • ; ---------------------------------------------------------------------------
  • .data
  • Screen_X dd 0
  • Screen_Y dd 0
  • MousePresent dd FALSE
  • MouseWhell dd FALSE
  • MMX_Available dd FALSE
  • XMMI_Available dd FALSE
  • D3_Available dd FALSE
  • SysDirectory db MAX_PATH dup(0)
  • WinDirectory db MAX_PATH dup(0)
  • CurDirectory db MAX_PATH dup(0)
  • TmpDirectory db MAX_PATH dup(0)
  • MacAddress db 13 dup(0)
  • IpAddress dd 100 dup(0)
  • ComputerName db 32 dup(0)
  • UserName db 32 dup(0)
  • DomaineName db 128 dup(0)
  • Free_Disk dd 0, 0
  • Total_Disk dd 0, 0
  • Free_Memory dd 0
  • Total_Memory dd 0
  • Frequence dd 0, 0
  • Time dd 0
  • Temp dd 0, 0
  • Disk db "c:\", 0
  • String_MacAdd db "* ", 0
  • .data?
  • Bytes dd ?
  • Buffer dd ?
  • INT_64 dq ?
  • Adapter_Stat STRUCT
  • Adapt ADAPTER_STATUS <> ; The ADAPTER_STATUS structure contains information about a network adapter.
  • NameBuff NAME_BUFFER 1Eh dup ({}) ; The NAME_BUFFER structure contains information about a local network name.
  • Adapter_Stat ENDS
  • l_ASTAT Adapter_Stat <>
  • l_ENUM LANA_ENUM <> ; The LANA_ENUM structure contains the numbers for the current LAN adapters.
  • l_NCB NCB <> ; The NCB structure represents a network control block
  • Memory MEMORYSTATUS <>
  • .code
  • ; ---------------------------------------------------------------------------
  • start:
  • call init
  • invoke MessageBox, 0, ADDR UserName, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR ComputerName, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR DomaineName, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR WinDirectory, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR SysDirectory, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR CurDirectory, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR TmpDirectory, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Total_Disk), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Free_Disk), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Total_Memory), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Free_Memory), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Screen_X), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Screen_Y), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR MacAddress, ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, val(Frequence), ADDR ComputerName, MB_OK
  • invoke MessageBox, 0, ADDR IpAddress, ADDR ComputerName, MB_OK
  • ;==================
  • ; Leave the program
  • ;==================
  • push eax ; [in] Exit code for the process and all threads terminated as a result of this call.
  • call ExitProcess
  • ret
  • init proc
  • .code
  • ; =========
  • ; User name
  • ; =========
  • mov Buffer, 32
  • push offset Buffer ; [in, out] On input, this variable specifies the size of the lpBuffer buffer, in TCHARs. On output, the variable receives the number of TCHARs copied to the buffer, including the terminating null character.
  • push offset UserName ; [out] Pointer to the buffer to receive the null-terminated string containing the user's logon name.
  • call GetUserName ; If the function succeeds, the return value is a nonzero value(Len of UserName+1)
  • ; =============
  • ; Computer Name
  • ; =============
  • mov Buffer, 32
  • push offset Buffer ; [in, out] On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.
  • push offset ComputerName ; [out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name.
  • push 0 ; [in] Type of name to retrieve
  • call GetComputerNameEx ; If the function succeeds, the return value is a nonzero value.
  • ; ============
  • ; Domaine Name
  • ; ============
  • mov Buffer, 128
  • push offset Buffer ; [in, out] On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.
  • push offset DomaineName ; [out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name.
  • push 2 ; [in] Type of name to retrieve
  • call GetComputerNameEx ; If the function succeeds, the return value is a nonzero value.
  • ; =================
  • ; Windows Directory
  • ; =================
  • push MAX_PATH ; [in] Size of the string buffer in TCHARs
  • push offset WinDirectory ; [out] Pointer to a string buffer that receives the null-terminated string
  • Call GetWindowsDirectory ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
  • ; ================
  • ; System Directory
  • ; ================
  • push MAX_PATH ; [in] Size of the string buffer in TCHARs
  • push offset SysDirectory ; [out] Pointer to a string buffer that receives the null-terminated string
  • Call GetSystemDirectory ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
  • ; =================
  • ; Current Directory
  • ; =================
  • push offset CurDirectory ; [out] Pointer to a string buffer that receives the null-terminated string
  • push MAX_PATH ; [in] Size of the string buffer in TCHARs
  • Call GetCurrentDirectory ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
  • ; ==============
  • ; Temp Directory
  • ; ==============
  • push offset TmpDirectory ; [out] Pointer to a string buffer that receives the null-terminated string
  • push MAX_PATH ; [in] Size of the string buffer in TCHARs
  • Call GetTempPath ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
  • ; =========
  • ; Disk info
  • ; =========
  • push offset Free_Disk
  • push offset Total_Disk
  • push offset INT_64
  • push offset Disk ; [in]Pointer to a null-terminated string that specifies a directory on the disk. If this parameter is NULL, the function uses the root of the current disk.
  • call GetDiskFreeSpaceEx ; If the function succeeds, the return value is nonzero.
  • ; ++++++++++++++++
  • ; Total Space Disk
  • ; ++++++++++++++++
  • mov eax, [Total_Disk+4]
  • mov ebx, [Total_Disk]
  • shl eax, 16 ; push high bytes of eax in low bytes
  • shr ebx, 16 ; push low bytes of ecx in high bytes
  • add eax, ebx
  • shr eax, 4 ; 4+16=20 convert octets in mega octect
  • mov Total_Disk, eax
  • ; +++++++++++++++++++++
  • ; Free disk space Total
  • ; +++++++++++++++++++++
  • mov eax, [Free_Disk+4]
  • mov ebx, [Free_Disk]
  • shl eax, 16 ; push high bytes of eax in low bytes
  • shr ebx, 16 ; push low bytes of ecx in high bytes
  • add eax, ebx
  • shr eax, 4 ; 4+16=20 convert octets in mega octect
  • mov Free_Disk, eax
  • ; ===========
  • ; Free Memory
  • ; ===========
  • push OFFSET Memory
  • call GlobalMemoryStatus
  • mov eax, Memory.dwTotalPhys ; bytes of physical memory
  • shr eax, 20 ; convert octect to Mo
  • mov Total_Memory, eax
  • mov eax, Memory.dwAvailPhys ; free physical memory bytes
  • shr eax, 20 ; convert octect to Mo
  • mov Free_Memory, eax
  • ;==========================================
  • ; Get the Screen resolution
  • ;==========================================
  • push SM_CXSCREEN ; Width of the screen of the primary display monitor, in pixels.
  • call GetSystemMetrics ; If the function succeeds, the return value is the requested system metric or configuration setting else zero.
  • Mov Screen_X, eax
  • push SM_CYSCREEN ; Height of the screen of the primary display monitor, in pixels.
  • call GetSystemMetrics ; If the function succeeds, the return value is the requested system metric or configuration setting else zero.
  • Mov Screen_Y, eax
  • ; =====================
  • ; Scan if mouse present
  • ; =====================
  • push SM_MOUSEPRESENT ; Scan if mouse is present.
  • call GetSystemMetrics ; Nonzero if a mouse is installed; zero otherwise.
  • or eax, eax
  • jz NoMouse
  • mov MousePresent, TRUE
  • NoMouse:
  • ; ===================
  • ; Scan if mouse Wheel
  • ; ===================
  • push SM_MOUSEWHEELPRESENT ; Scan if mouse Wheel.
  • call GetSystemMetrics ; Nonzero if a mouse with a wheel is installed; zero otherwise.
  • or eax, eax
  • jz NoWheel
  • mov MouseWhell, TRUE
  • NoWheel:
  • ; ===============
  • ; GET MAC ADDRESS
  • ; ===============
  • mov l_NCB.ncb_command, NCBENUM
  • mov l_NCB.ncb_length, SIZEOF l_ENUM
  • mov l_NCB.ncb_buffer, OFFSET l_ENUM
  • ; ***************************************************************************************
  • ; The Netbios function interprets and executes the specified network control block (NCB).
  • ; ***************************************************************************************
  • push OFFSET l_NCB ; Pointer to an NCB structure that describes the network control block.
  • call Netbios ; For synchronous requests, the return value is the return code of the NCB structure
  • ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • ; The RtlZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
  • ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • push SIZEOF l_NCB ; Specifies the number of bytes to be zeroed.
  • push OFFSET l_NCB ; Pointer to the memory to be filled with zeros.
  • call RtlZeroMemory ; No return
  • mov l_NCB.ncb_command, NCBRESET
  • mov esi, OFFSET l_ENUM.lana
  • mov al, [esi + ecx]
  • mov l_NCB.ncb_lana_num, al
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • ; The Netbios function interprets and executes the specified network control block (NCB).
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • push OFFSET l_NCB ; Pointer to an NCB structure that describes the network control block.
  • call Netbios ; For synchronous requests, the return value is the return code of the NCB structure
  • mov l_NCB.ncb_command, NCBASTAT
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++
  • ; The lstrcpy function copies a string to a buffer.
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++
  • push OFFSET String_MacAdd ; [in] Pointer to the null-terminated string to be copied.
  • push OFFSET l_NCB.ncb_callname ; [out] Pointer to a buffer to receive the contents of the string pointed to by the lpString2 parameter. The buffer must be large enough to contain the string, including the terminating null character.
  • call lstrcpy ; If the function succeeds, the return value is a pointer to the buffer.
  • mov l_NCB.ncb_length, SIZEOF l_ASTAT
  • mov l_NCB.ncb_buffer, OFFSET l_ASTAT
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • ; The Netbios function interprets and executes the specified network control block (NCB).
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  • push OFFSET l_NCB ; Pointer to an NCB structure that describes the network control block.
  • call Netbios ; For synchronous requests, the return value is the return code of the NCB structure
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++
  • ; 6 byte Binary Conversion to ASCII HEX (12 characters)
  • ; +++++++++++++++++++++++++++++++++++++++++++++++++++++
  • mov esi, OFFSET l_ASTAT.Adapt.adapter_address
  • mov edi, OFFSET MacAddress
  • xor ecx, ecx
  • xor ebx, ebx
  • mov cl, 0Bh
  • mov bl, 05h
  • bintohex:
  • mov al, [esi + ebx]
  • push eax
  • and al, 00001111b
  • add al, 90h
  • daa
  • adc al, 40h
  • daa
  • mov [edi + ecx], al
  • dec ecx
  • pop eax
  • shr al, 4h
  • and al, 00001111b
  • add al, 90h
  • daa
  • adc al, 40h
  • daa
  • mov [edi + ecx], al
  • dec ebx
  • dec ecx
  • jns bintohex
  • ; =======================
  • ; GET Processor Frequence
  • ; =======================
  • call GetTickCount ; The return value is the number of milliseconds that have elapsed since the system was started.
  • mov Time, eax ; Time reference
  • rdtsc ; Number of cycle since boot
  • shr eax,2 ; for support proccessor more speed than 4 Ghz (4*2^2=16)
  • mov ebx, eax ; save the result in ebx
  • time_wait: ; loop since 1, 048 seconds
  • call GetTickCount; The return value is the number of milliseconds that have elapsed since the system was started.
  • sub eax, Time ; compare eax with time reference
  • cmp eax, 1048 ; while time <1.048 seconds (2^20 microseconds)
  • jl time_wait
  • rdtsc ; Number of cycle since boot
  • shr eax,2 ; for support proccessor more speed than 4 Ghz (4*2^2=16)
  • sub eax, ebx ; Number of cycle in the lap time
  • shr eax, 18 ; Get ony the Mega cycle (18+2=20)
  • mov Frequence, eax
  • ; =====================
  • ; GET Processor Feature
  • ; =====================
  • ; ++++++++++++++++++++
  • ; MMX instruction set
  • ; ++++++++++++++++++++
  • push PF_MMX_INSTRUCTIONS_AVAILABLE
  • call IsProcessorFeaturePresent
  • mov MMX_Available, eax
  • ; +++++++++++++++++++
  • ; SSE instruction set
  • ; +++++++++++++++++++
  • push PF_XMMI_INSTRUCTIONS_AVAILABLE
  • call IsProcessorFeaturePresent
  • mov XMMI_Available, eax
  • ; ++++++++++++++++++++++
  • ; 3D-Now instruction set
  • ; ++++++++++++++++++++++
  • push PF_3DNOW_INSTRUCTIONS_AVAILABLE
  • call IsProcessorFeaturePresent
  • mov D3_Available, eax
  • ; ==============
  • ; Get IP Address
  • ; ==============
  • push offset IpAddress ; [out] Pointer to the WSADATA data structure that is to receive details of the Windows Sockets implementation.
  • push 202h ; [in] Highest version of Windows Sockets support that the caller can use.
  • call WSAStartup ; function returns zero if successful. Otherwise, it returns one of the error codes listed in the following.
  • push offset ComputerName ; [in] Pointer to the null-terminated name of the host to resolve.
  • call gethostbyname ; If no error occurs, gethostbyname returns a pointer to the hostent structure.
  • mov ecx, [eax] + 12 ; h_addr_list of the hostent structure.
  • mov ebx, [ecx]
  • mov eax, [ebx]
  • mov ebx, offset IpAddress
  • push eax ; Pointer to an in_addr structure that represents an Internet host address.
  • call inet_ntoa ; The inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.
  • iploop:
  • mov cl, [eax]
  • mov [ebx], cl
  • inc eax
  • inc ebx
  • test cl, cl
  • jnz iploop
  • ret
  • init endp
  • end start
.586
.MMX
.model flat, stdcall
option casemap:none

    ;================================================
    ; These are the Inlcude files for Window calls
    ;================================================
    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\ws2_32.inc
    include \masm32\include\advapi32.inc
    include \masm32\include\netapi32.inc

    ;===============================================
    ; The Lib's for those included files
    ;================================================
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\ws2_32.lib
    includelib \masm32\lib\advapi32.lib
    includelib \masm32\lib\netapi32.lib
                

; --------------- Local Macros
SzText MACRO Name, Text:VARARG
    LOCAL   lbl
    jmp lbl
    Name    db Text, 0
    lbl:
ENDM

M2M MACRO M1, M2
    push    M2
    pop     M1
ENDM

Return MACRO arg
    mov eax, arg
    ret
ENDM

val MACRO DDvalue           
    LOCAL rvstring
    .data
    rvstring db 20 dup (0)
    align 4
    .code
    push OFFSET rvstring
    push DDvalue
    call ltoa 
    EXITM <OFFSET rvstring>
ENDM

.CONST
    PF_3DNOW_INSTRUCTIONS_AVAILABLE     EQU 7

; ---------------------------------------------------------------------------
.data

    Screen_X            dd  0
    Screen_Y            dd  0
    
    MousePresent        dd  FALSE
    MouseWhell          dd  FALSE
    MMX_Available       dd  FALSE
    XMMI_Available      dd  FALSE
    D3_Available        dd  FALSE

    SysDirectory        db  MAX_PATH dup(0)
    WinDirectory        db  MAX_PATH dup(0)
    CurDirectory        db  MAX_PATH dup(0)
    TmpDirectory        db  MAX_PATH dup(0)
    MacAddress          db  13       dup(0)
    IpAddress           dd  100      dup(0)
    ComputerName        db  32       dup(0)
    UserName            db  32       dup(0)
    DomaineName         db  128      dup(0)
    Free_Disk           dd  0, 0
    Total_Disk          dd  0, 0
    Free_Memory         dd  0
    Total_Memory        dd  0
    Frequence           dd  0, 0
    Time                dd  0
    Temp                dd  0, 0
    
    Disk                db  "c:\", 0
    String_MacAdd       db  "* ",  0  

.data?
    Bytes               dd  ?
    Buffer              dd  ?
    INT_64              dq  ?
    
    Adapter_Stat STRUCT
        Adapt           ADAPTER_STATUS  <>              ; The ADAPTER_STATUS structure contains information about a network adapter.
        NameBuff        NAME_BUFFER 1Eh dup ({})        ; The NAME_BUFFER structure contains information about a local network name.
    Adapter_Stat ENDS
    l_ASTAT         Adapter_Stat    <>
    l_ENUM          LANA_ENUM       <>                  ; The LANA_ENUM structure contains the numbers for the current LAN adapters.
    l_NCB           NCB             <>                  ; The NCB structure represents a network control block
    Memory          MEMORYSTATUS    <>

.code
; ---------------------------------------------------------------------------

start:
        call    init                 
        invoke MessageBox, 0, ADDR UserName,        ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR ComputerName,    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR DomaineName,     ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR WinDirectory,    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR SysDirectory,    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR CurDirectory,    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR TmpDirectory,    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Total_Disk),      ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Free_Disk),       ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Total_Memory),    ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Free_Memory),     ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Screen_X),        ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Screen_Y),        ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR MacAddress,      ADDR ComputerName, MB_OK
        invoke MessageBox, 0, val(Frequence),       ADDR ComputerName, MB_OK
        invoke MessageBox, 0, ADDR IpAddress,       ADDR ComputerName, MB_OK
    ;==================
    ; Leave the program
    ;==================
    push    eax                         ; [in] Exit code for the process and all threads terminated as a result of this call.
    call    ExitProcess         
    ret


init proc   

.code
    ; =========
    ; User name
    ; =========
        mov     Buffer, 32
        push    offset Buffer           ; [in, out] On input, this variable specifies the size of the lpBuffer buffer, in TCHARs. On output, the variable receives the number of TCHARs copied to the buffer, including the terminating null character. 
        push    offset UserName         ; [out] Pointer to the buffer to receive the null-terminated string containing the user's logon name. 
        call    GetUserName             ; If the function succeeds, the return value is a nonzero value(Len of UserName+1)
    ; =============
    ; Computer Name
    ; =============
        mov     Buffer, 32
        push    offset Buffer           ; [in, out] On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.
        push    offset ComputerName     ; [out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name.
        push    0                       ; [in] Type of name to retrieve
        call    GetComputerNameEx       ; If the function succeeds, the return value is a nonzero value.
        
    ; ============
    ; Domaine Name
    ; ============
        mov     Buffer, 128
        push    offset Buffer           ; [in, out] On input, specifies the size of the buffer, in TCHARs. On output, receives the number of TCHARs copied to the destination buffer, not including the terminating null character.
        push    offset DomaineName      ; [out] Pointer to a buffer that receives a null-terminated string containing the computer name or the cluster virtual server name.
        push    2                       ; [in] Type of name to retrieve
        call    GetComputerNameEx       ; If the function succeeds, the return value is a nonzero value.
        
    ; =================
    ; Windows Directory
    ; =================
        push    MAX_PATH                ; [in] Size of the string buffer in TCHARs 
        push    offset WinDirectory     ; [out] Pointer to a string buffer that receives the null-terminated string
        Call    GetWindowsDirectory     ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
        
    ; ================
    ; System Directory
    ; ================
        push    MAX_PATH                ; [in] Size of the string buffer in TCHARs
        push    offset SysDirectory     ; [out] Pointer to a string buffer that receives the null-terminated string
        Call    GetSystemDirectory      ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
        
    ; =================
    ; Current Directory
    ; =================
        push    offset CurDirectory     ; [out] Pointer to a string buffer that receives the null-terminated string
        push    MAX_PATH                ; [in] Size of the string buffer in TCHARs
        Call    GetCurrentDirectory     ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
        
    ; ==============
    ; Temp Directory
    ; ==============
        push    offset TmpDirectory     ; [out] Pointer to a string buffer that receives the null-terminated string
        push    MAX_PATH                ; [in] Size of the string buffer in TCHARs
        Call    GetTempPath             ; If the function succeeds, the return value is the length of the string copied to the buffer, in TCHARs, not including the terminating null character.
        
    ; =========
    ; Disk info
    ; =========
        push    offset Free_Disk
        push    offset Total_Disk
        push    offset INT_64   
        push    offset Disk             ; [in]Pointer to a null-terminated string that specifies a directory on the disk. If this parameter is NULL, the function uses the root of the current disk.
        call    GetDiskFreeSpaceEx      ; If the function succeeds, the return value is nonzero.
        ; ++++++++++++++++
        ; Total Space Disk
        ; ++++++++++++++++
            mov     eax, [Total_Disk+4]
            mov     ebx, [Total_Disk]
            shl     eax, 16                 ; push high bytes of eax in low bytes
            shr     ebx, 16                 ; push low bytes of ecx in high bytes
            add     eax, ebx                        
            shr     eax, 4                  ; 4+16=20 convert octets in mega octect
            mov     Total_Disk, eax
        ; +++++++++++++++++++++
        ; Free disk space Total
        ; +++++++++++++++++++++
            mov     eax, [Free_Disk+4]
            mov     ebx, [Free_Disk]
            shl     eax, 16                 ; push high bytes of eax in low bytes
            shr     ebx, 16                 ; push low bytes of ecx in high bytes
            add     eax, ebx                        
            shr     eax, 4                  ; 4+16=20 convert octets in mega octect
            mov     Free_Disk, eax
    ; ===========
    ; Free Memory
    ; ===========
        push    OFFSET Memory
        call    GlobalMemoryStatus
        mov     eax, Memory.dwTotalPhys ; bytes of physical memory
        shr     eax, 20                 ; convert octect to Mo
        mov     Total_Memory, eax
        mov     eax, Memory.dwAvailPhys ; free physical memory bytes
        shr     eax, 20                 ; convert octect to Mo
        mov     Free_Memory, eax
        
    ;==========================================
    ; Get the Screen resolution
    ;==========================================
        push    SM_CXSCREEN             ; Width of the screen of the primary display monitor, in pixels.
        call    GetSystemMetrics        ; If the function succeeds, the return value is the requested system metric or configuration setting else zero.
        Mov     Screen_X, eax
        push    SM_CYSCREEN             ; Height of the screen of the primary display monitor, in pixels.
        call    GetSystemMetrics        ; If the function succeeds, the return value is the requested system metric or configuration setting else zero.
        Mov     Screen_Y, eax
    
    ; =====================
    ; Scan if mouse present
    ; =====================
        push    SM_MOUSEPRESENT         ; Scan if mouse is present.
        call    GetSystemMetrics        ; Nonzero if a mouse is installed; zero otherwise.
        or  eax, eax
        jz  NoMouse
            mov MousePresent, TRUE
        NoMouse:

    ; ===================
    ; Scan if mouse Wheel
    ; ===================
        push    SM_MOUSEWHEELPRESENT    ; Scan if mouse Wheel.
        call    GetSystemMetrics        ; Nonzero if a mouse with a wheel is installed; zero otherwise.
        or      eax, eax
        jz      NoWheel
            mov     MouseWhell, TRUE
        NoWheel:
        
    ; ===============
    ; GET MAC ADDRESS
    ; ===============
        mov l_NCB.ncb_command, NCBENUM
        mov l_NCB.ncb_length, SIZEOF l_ENUM
        mov l_NCB.ncb_buffer, OFFSET l_ENUM
        ; ***************************************************************************************
        ; The Netbios function interprets and executes the specified network control block (NCB).
        ; ***************************************************************************************
            push    OFFSET l_NCB                ; Pointer to an NCB structure that describes the network control block. 
            call    Netbios                     ; For synchronous requests, the return value is the return code of the NCB structure

        ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        ; The RtlZeroMemory routine fills a block of memory with zeros, given a pointer to the block and the length, in bytes, to be filled.
        ; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            push    SIZEOF l_NCB                ; Specifies the number of bytes to be zeroed.
            push    OFFSET l_NCB                ; Pointer to the memory to be filled with zeros.
            call    RtlZeroMemory               ; No return
                
        mov     l_NCB.ncb_command, NCBRESET
        mov     esi, OFFSET l_ENUM.lana
        mov     al, [esi + ecx]
        mov     l_NCB.ncb_lana_num, al
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        ; The Netbios function interprets and executes the specified network control block (NCB).
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            push    OFFSET l_NCB                ; Pointer to an NCB structure that describes the network control block. 
            call    Netbios                     ; For synchronous requests, the return value is the return code of the NCB structure
        
        mov l_NCB.ncb_command, NCBASTAT
        ; +++++++++++++++++++++++++++++++++++++++++++++++++
        ; The lstrcpy function copies a string to a buffer.
        ; +++++++++++++++++++++++++++++++++++++++++++++++++
            push    OFFSET String_MacAdd        ; [in] Pointer to the null-terminated string to be copied.
            push    OFFSET l_NCB.ncb_callname   ; [out] Pointer to a buffer to receive the contents of the string pointed to by the lpString2 parameter. The buffer must be large enough to contain the string, including the terminating null character. 
            call    lstrcpy                     ; If the function succeeds, the return value is a pointer to the buffer.
         
        mov l_NCB.ncb_length, SIZEOF l_ASTAT
        mov l_NCB.ncb_buffer, OFFSET l_ASTAT
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        ; The Netbios function interprets and executes the specified network control block (NCB).
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
            push    OFFSET l_NCB        ; Pointer to an NCB structure that describes the network control block. 
            call    Netbios             ; For synchronous requests, the return value is the return code of the NCB structure
        
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++
        ; 6 byte Binary Conversion to ASCII HEX (12 characters)
        ; +++++++++++++++++++++++++++++++++++++++++++++++++++++
            mov esi, OFFSET l_ASTAT.Adapt.adapter_address
            mov edi, OFFSET MacAddress
            xor ecx, ecx
            xor ebx, ebx
            mov cl, 0Bh
            mov bl, 05h
        bintohex:
            mov al, [esi + ebx]
            push    eax
            and al, 00001111b
            add al, 90h
            daa
            adc al, 40h
            daa
            mov [edi + ecx], al
            dec ecx
            pop eax
            shr al, 4h
            and al, 00001111b
            add al, 90h
            daa
            adc al, 40h
            daa
            mov [edi + ecx], al
            dec ebx
            dec ecx
        jns bintohex
        
    ; =======================
    ; GET Processor Frequence
    ; =======================
        call    GetTickCount    ; The return value is the number of milliseconds that have elapsed since the system was started.
        mov     Time, eax       ; Time reference
        rdtsc                   ; Number of cycle since boot
        shr eax,2               ; for support proccessor more speed than 4 Ghz (4*2^2=16)
        mov ebx, eax            ; save the result in ebx
        
        time_wait:              ; loop since 1, 048 seconds
            call    GetTickCount; The return value is the number of milliseconds that have elapsed since the system was started.
            sub eax, Time       ; compare eax with time reference
            cmp eax, 1048       ; while time <1.048 seconds (2^20 microseconds)
        jl time_wait 
        rdtsc                   ; Number of cycle since boot
        shr eax,2               ; for support proccessor more speed than 4 Ghz (4*2^2=16)
        sub eax, ebx            ; Number of cycle in the lap time
        shr eax, 18             ; Get ony the Mega cycle (18+2=20)
        mov Frequence, eax
            
    ; =====================
    ; GET Processor Feature
    ; =====================
        ; ++++++++++++++++++++
        ; MMX instruction set
        ; ++++++++++++++++++++
            push    PF_MMX_INSTRUCTIONS_AVAILABLE
            call    IsProcessorFeaturePresent
            mov     MMX_Available, eax
        ; +++++++++++++++++++
        ; SSE instruction set
        ; +++++++++++++++++++
            push    PF_XMMI_INSTRUCTIONS_AVAILABLE
            call    IsProcessorFeaturePresent
            mov     XMMI_Available, eax
        ; ++++++++++++++++++++++
        ; 3D-Now instruction set
        ; ++++++++++++++++++++++
            push    PF_3DNOW_INSTRUCTIONS_AVAILABLE
            call    IsProcessorFeaturePresent
            mov     D3_Available, eax
    ; ==============
    ; Get IP Address
    ; ==============
        push    offset IpAddress        ; [out] Pointer to the WSADATA data structure that is to receive details of the Windows Sockets implementation. 
        push    202h                    ; [in] Highest version of Windows Sockets support that the caller can use. 
        call    WSAStartup              ; function returns zero if successful. Otherwise, it returns one of the error codes listed in the following.
        push    offset ComputerName     ; [in] Pointer to the null-terminated name of the host to resolve.
        call    gethostbyname           ; If no error occurs, gethostbyname returns a pointer to the hostent structure.
        mov     ecx, [eax] + 12         ; h_addr_list of the hostent structure.
        mov     ebx, [ecx]               
        mov     eax, [ebx]
        mov     ebx, offset IpAddress
        push    eax                     ; Pointer to an in_addr structure that represents an Internet host address.
        call    inet_ntoa               ; The inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.
        iploop:
            mov cl, [eax]
            mov [ebx], cl
            inc eax
            inc ebx
            test    cl, cl
        jnz iploop
    ret
init endp

end start




 Historique

22 mars 2005 20:53:41 :
j'ai fait quelques correctifs de la source, celle ci fait parti d'un projet que j'ai commencé. Certaines declaration ne sont pas necessaire a l'heure actuelle

 Sources du même auteur

LECTEUR 3DS EN ASSEMBLEUR SOUS OPENGL
SCREENSHOT CAPTURE D'ECRAN
Source avec Zip Source avec une capture DEBUT D'UN MOTEUR 3D
Source avec Zip UN EDITEUR DE FICHIER UNIX DEPUIS WINDOWS

 Sources de la même categorie

Source avec Zip OBTENIR LA VERSION DU SYSTEME,SON ENVIRONNEMENT,LE SERVICE P... par ToutEnMasm
Source avec Zip TÉLÉCHARGER UN FICHIER DEPUIS UNE URL ET/OU ORGANISER DES CL... par ToutEnMasm
SCREENSHOT CAPTURE D'ECRAN par VBFRANCE
Source avec Zip Source avec une capture PROGRAMME DE VISUALISATION ET D'ANALYSE SPECTRALE DE FICHIER... par Nasman
Source avec Zip CRÉATION DE GRAPHIQUES AVEC LES API WINDOWS par Nasman

Commentaires et avis

Commentaire de DakM le 21/03/2005 18:40:11

Sa sent le vol de code de je sais pas ou a plein nez !
- Commentaires en anglais
Mais sa peut etre utile pour ceux qui font de l'Assembleur :]
++

Commentaire de BruNews le 21/03/2005 19:42:45 administrateur CS

Pourquoi une partie en syntaxe asm (push, call, etc...) et puis des bidules de ce genre:

invoke MessageBox, 0, val(Screen_Y), ADDR ComputerName, MB_OK

bizzare ce mélange, non ?

Commentaire de Urgo le 21/03/2005 21:15:21

Oui, et 16 MsgBox d'affilé... une DialogBox n'est pas si compliqué à faire!
Certes ici l'intérêt est de montrer l'utilisation de différentes fonctions.... mais on voit que ça reste "foulli" ton code... (cf remarques d'en haut)

Commentaire de VBFRANCE le 21/03/2005 23:19:02


Le commentaires sont tous en anglais; ils viennent de la msdn de microsoft,  je pense qu'en anglais c'est plus plus simple a comprendre que mal traduit en francais.
Pour les invoke messagebox, j'avoue que j'ai eu la fleme de faire un tas de push a la volé,
Et cela me paraissait plus simple a comprendre. Par contre je ne suis pas arriver a faire un push de
la structure 'memory' , j'ai essayé en creant moi meme la structures dans les datas, mais cela ne me paraissait pas optimisé, qq aurait-il un idée de comment je peut procédé ?
Sinon DakM, ce code n'a pas été pomper d'un autre site, je me suis inspiré de ce que font les autres, normal, je ne suis qu'un debutant sur l'asm x86, j'ai quelques bases de Z80 qui remontent a une vingtaine années.
J'utilise RadAsm pour faire le code, est il est vrai que comme cela il parait fouilli, alors que sur RAd c'est bien plus lisible.

Commentaire de BruNews le 21/03/2005 23:38:08 administrateur CS

pour PUSHer toute une structure, c'est comme le reste:
sub esp, TailleDeLaStruct

Commentaire de VBFRANCE le 22/03/2005 08:28:25

Pour PUSHer ma structure, j'y suis enfin arrivé, en fait celle ci etait mal declaré et en voulant la PUSHer cela me mettait un erreur lors de la compilation.

Commentaire de ManChesTer le 23/03/2005 21:10:30 administrateur CS

Sous radasm avec une resouce et un code plus propre ca pourais etre bien mieux fini, et surtout, l'affichage serais baucoups plus ergonomique que la volée de messagebox de ton code...

Bon Coding...

ManChesTer.

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,406 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales