News:

Download Pelles C here: http://www.pellesc.se

Main Menu

NetUserGetInfo example

Started by Vortex, Yesterday at 09:38:12 PM

Previous topic - Next topic

Vortex

Based on the NetUserGetInfo API function, command-line application displaying the lockout status of a local account :

include LockStatus.inc

.data

f1      dw 'The account %s is NOT locked.',0
f2      dw 'The account %s is locked.',0
f3      db 'Usage : LockStatus <Account>'
        db 13,10,0

sTable  dd OFFSET f1,OFFSET f2
ErrMsg  db 'NetUserGetInfo failed.',0

.data?

ui4     dd ? ; USER_INFO_4
args    dd ?

.code

start:

    call    main
    invoke  ExitProcess,eax
   
main PROC uses esi

    invoke  GetCommandLineW
    invoke  CommandLineToArgvW,eax,ADDR args

    cmp     args,1
    jne     @f

    invoke  printf,ADDR f3
    ret
@@:
    mov     esi,eax
    invoke  NetUserGetInfo,0,\
            DWORD PTR [eax+4],4,ADDR ui4

    test    eax,eax
    jz      @f

    invoke  printf,ADDR ErrMsg
    xor     eax,eax
    ret
@@:
    mov     eax,USER_INFO_4.usri4_flags[ui4]
    and     eax,UF_LOCKOUT
    shr     eax,2
    lea     edx,[sTable+eax]
    shr     eax,2
    push    eax
    invoke  wprintf,DWORD PTR [edx],\
            DWORD PTR [esi+4]

    invoke  NetApiBufferFree,ui4
    pop     eax
    ret

main ENDP

END start
Code it... That's all...