L
L
LoliDeveloper2021-10-16 21:49:56
API
LoliDeveloper, 2021-10-16 21:49:56

What is lpNumberOfBytesWritten in the WINAPI WriteFile function and why?

BOOL WriteFile(
  [in]                HANDLE       hFile,
  [in]                LPCVOID      lpBuffer,
  [in]                DWORD        nNumberOfBytesToWrite,
  [out, optional]     LPDWORD      lpNumberOfBytesWritten,
  [in, out, optional] LPOVERLAPPED lpOverlapped
);

I do not understand what the fourth parameter is responsible for here. This is a pointer to a variable that stores the number of bytes written, but in the example there is just some kind of magic and nothing explains how these bytes are stored and where they come from.
asm - NASM
; DWORD  bytes;    
    mov     ebp, esp
    sub     esp, 4

    ; hStdOut = GetstdHandle( STD_OUTPUT_HANDLE)
    push    -11
    call    [email protected]
    mov     ebx, eax    

    ; WriteFile( hstdOut, message, length(message), &bytes, 0);
    push    0
    lea     eax, [ebp-4] ; ВОТ ЭТА СТРОКА ЭТО ЧТО? ПОЧЕМУ ТАК?
    push    eax ; и тут он передаёт как четвёртый аргумент. 
    push    (message_end - message)
    push    message
    push    ebx
    call    [email protected]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-10-16
@LoliDeveloper

Duc is written in English in white - long pointer to a variable in which the number of written bytes will be returned.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question