· Начало · Статистика · Поиск · FAQ · Правила · Установки · Язык · Выход · WASM.RU · Noir.Ru ·

 WASM Phorum —› WASM.NETWORKS —› Read 139 port

<< . 1 . 2 .

Посл.отвђт Сообщенiе


Дата: Авг 22, 2004 20:12:44 · Поправил: Stub

Получается что-то типа этого (могу ошибаться):
SESSION_INFO_10 STRUCT
     sesi10_cname      DWORD  ?
     sesi10_username   DWORD  ?
     sesi10_time       DWORD  ?
     sesi10_idle_time  DWORD  ?
SESSION_INFO_10 ENDS
PSESSION_INFO_10  PTR SESSION_INFO_10
LPSESSION_INFO_10 PTR SESSION_INFO_10


Дата: Авг 23, 2004 10:13:09

Flasher
Вот чего добился
Imho топчешся на месте.
;
; console application for 
;
.386
.model flat,stdcall

.nolist
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
include netapi32.inc
includelib netapi32.lib
.list

.const
  align 4
  szServer              db '\\192.168.0.1',0
  align 4
  szNetSessionEnumError db 'NetSessionEnum failed %d',0
  align 4
  szFormat              db 13,10,9,'Client: %s',13,10
                        db       9,'User:   %s',13,10
                        db       9,'Active: %d',13,10
                        db       9,'Idle:   %d',13,10,0

.code
;----------------------------------------------------------
  align 4
  SimplePrintf proc C, pszFormat : ptr byte, param:VARARG
    local buffer[4092]:byte
    local hOutPut:dword
    local bWritten:dword

    lea ecx,param
    invoke wvsprintf, addr buffer, pszFormat, ecx
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hOutPut,eax
    invoke lstrlen,addr buffer
    mov ecx,eax
    invoke WriteFile, hOutPut, addr buffer, ecx, addr bWritten, NULL
    mov eax, bWritten
    ret
  SimplePrintf endp

;----------------------------------------------------------
  align 4
  AllocZeroMem proc ; nBytes : dword
    mov   eax,[esp+04h]
    test  eax,eax
    jz    short @2
    test  al,0Fh
    jz    short @1
    and   eax,not 0Fh
    add   eax,10h
    jc    short @2
@1: push  eax
    call  GetProcessHeap
    pop   ecx
    test  eax,eax
    jz    short @2
    push  ecx
    push  HEAP_ZERO_MEMORY
    push  eax
    call  HeapAlloc
@2: ret   4
  AllocZeroMem endp

;----------------------------------------------------------
  align 4
  FreeMem proc ; pMem : dword
    mov   eax,[esp+04h]
    test  eax,eax
    jz    short @F
    push  eax
    call  GetProcessHeap
    pop   ecx
    test  eax,eax
    jz    short @F
    push  ecx
    push  0
    push  eax
    call  HeapFree
@@: ret   4
  FreeMem endp

;----------------------------------------------------------
  align 4
  CharToWideChar proc ; pcszSrc : dword
    mov   eax,[esp+04h]
    push  eax
    push  -1
    push  eax
    call  IsBadStringPtrA
    or    eax,eax
    pop   eax
    jnz   short @1
    push  eax
    call  lstrlenA
    test  eax,eax
    js    short @1
    inc   eax
    js    short @1
    push  eax
    shl   eax,1
    push  eax
    call  AllocZeroMem
    pop   ecx
    or    eax,eax
    jz    short @2
    mov   edx,[esp+04h]
    push  eax
    push  ecx
    push  eax
    push  -1
    push  edx
    push  0
    push  CP_ACP
    call  MultiByteToWideChar
    or    eax,eax
    pop   eax
    jnz   short @2
    push  eax
    call  FreeMem
@1: xor   eax,eax
@2: ret   4
  CharToWideChar endp

;----------------------------------------------------------
  align 4
  WideCharToChar proc ; pwszSrc : dword
    mov   eax,[esp+04h]
    push  eax
    push  -1
    push  eax
    call  IsBadStringPtrW
    or    eax,eax
    pop   eax
    jnz   short @1
    push  eax
    call  lstrlenW
    inc   eax
    jz    short @2
    push  eax
    push  eax
    call  AllocZeroMem
    pop   ecx
    or    eax,eax
    jz    short @2
    mov   edx,[esp+04h]
    push  eax
    push  0
    push  0
    push  ecx
    push  eax
    push  -1
    push  edx
    push  0
    push  CP_ACP
    call  WideCharToMultiByte
    or    eax,eax
    pop   eax
    jnz   short @2
    push  eax
    call  FreeMem
@1: xor   eax,eax
@2: ret   4
  WideCharToChar endp

;----------------------------------------------------------
  align 4
  q_q proc uses ebx edi, pszServ : ptr byte

    local pBuffer     : ptr SESSION_INFO_10
    local dwRead      : dword
    local dwTotal     : dword
    local hResume     : dword
    local pwszServ    : dword
    local pszCName    : dword
    local pszUserName : dword

    xor  eax,eax
    mov  dwRead,eax
    mov  dwTotal,eax
    mov  hResume,eax
    mov  pwszServ,eax

    push pszServ
    call CharToWideChar
    or   eax,eax
    jz   @7
    mov  pwszServ,eax

  @1:
    mov  pBuffer,0
    invoke NetSessionEnum, pwszServ, NULL, NULL, 10, addr pBuffer, -1,\
                           addr dwRead, addr dwTotal, addr hResume
    push eax
    cmp  eax,NERR_Success
    jz   short @2
    cmp  eax,ERROR_MORE_DATA
    jnz  short @4
  @2:
    mov  ebx,pBuffer
    mov  edi,dwRead
  @3:
    or   edi,edi
    jz   short @5
    or   ebx,ebx
    jz   short @5

    push (SESSION_INFO_10 ptr [ebx]).sesi10_cname
    call WideCharToChar
    mov  pszCName,eax
    or   eax,eax
    jz   short @F

    push (SESSION_INFO_10 ptr [ebx]).sesi10_username
    call WideCharToChar
    mov  pszUserName,eax
    or   eax,eax
    jz   short @F

    invoke SimplePrintf, offset szFormat, pszCName, pszUserName,\
                         (SESSION_INFO_10 ptr [ebx]).sesi10_time,\
                         (SESSION_INFO_10 ptr [ebx]).sesi10_idle_time
  @@:
    push pszUserName
    call FreeMem
    push pszCName
    call FreeMem

    add  ebx,sizeof SESSION_INFO_10
    dec  edi
    jmp short @3
  @4:
    invoke SimplePrintf, offset szNetSessionEnumError, eax
  @5:
    cmp pBuffer,0
    jz  short @6
    invoke NetApiBufferFree, pBuffer
  @6:
    pop eax
    cmp eax,ERROR_MORE_DATA
    jz  @1

  @7:
    push pwszServ
    call FreeMem

    ret
  q_q endp

;----------------------------------------------------------
  align 4
  start:
    invoke q_q, offset szServer
    invoke ExitProcess, 0
end start


Дата: Авг 23, 2004 11:29:17

q_q, Век не забуду! :)
Большое спасибо!

<< . 1 . 2 .