0Pricing
Reverse Engineering & Binary Analysis Basics · Lekcja

Stos i konwencje wywołań

Zagłębią się Państwo w sposób przekazywania argumentów przez funkcje, zwracania wartości i zarządzania ramką stosu — wiedzę, dzięki której zdeasemblowany kod staje się czytelny.

Stos i konwencje wywołań to bezpłatna lekcja Reverse Engineering & Binary Analysis Basics na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Reverse Engineering & Binary Analysis Basics, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Reverse Engineering & Binary Analysis Basics zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Beyond a Single Call

You can read basic x86/x64 instructions and follow control flow. To truly understand function calls you must know the stack and calling conventions.

These rules govern how arguments arrive and how cleanup happens.

What the Stack Is

The stack is a region of memory that grows downward (toward lower addresses). It stores return addresses, saved registers, and local variables.

  • push decrements RSP and writes
  • pop reads and increments RSP
push rax   ; rsp -= 8, [rsp] = rax
pop  rbx   ; rbx = [rsp], rsp += 8

RSP and RBP

Two registers track the stack:

  • RSP (stack pointer) points to the current top
  • RBP (base pointer) anchors the current frame

Locals are addressed relative to RBP, like [rbp-8].

The Function Prologue

Most functions begin with a prologue that sets up the frame: save the old base pointer, then point RBP at the new frame.

push rbp
mov  rbp, rsp
sub  rsp, 0x20   ; reserve 32 bytes for locals

The Function Epilogue

The epilogue reverses the prologue, restoring the caller's frame before returning.

mov rsp, rbp
pop rbp
ret

Calling Conventions

A calling convention is the contract for passing arguments and returning values.

  • Where arguments go (registers or stack)
  • Who cleans up the stack
  • Which registers must be preserved

System V AMD64 (Linux x64)

On Linux x64 the first six integer arguments go in registers: rdi, rsi, rdx, rcx, r8, r9. The return value comes back in rax.

Extra arguments spill onto the stack.

; foo(1, 2, 3)
mov edi, 1
mov esi, 2
mov edx, 3
call foo

Microsoft x64 Convention

Windows x64 uses different registers: the first four arguments go in rcx, rdx, r8, r9, and the caller reserves 32 bytes of shadow space.

Recognizing the OS tells you which mapping to apply when reading arguments.

; Windows: bar(a, b)
mov rcx, a
mov rdx, b
sub rsp, 0x28   ; shadow space + alignment
call bar

Caller-Saved vs Callee-Saved

Some registers may be clobbered by a call (caller-saved), others must be preserved (callee-saved).

Seeing a function push rbx, rbp, and r12-r15 in its prologue is a strong hint about which registers it intends to use.

Reading Arguments in Practice

When you land in a function, mapping registers to arguments lets you label them. If the code reads rdi first on Linux, that is argument one.

This is how raw disassembly becomes readable pseudocode like send(sock, buf, len).

Stack-Passed Arguments

When a function has more arguments than the convention allows in registers, the extras are pushed onto the stack by the caller. The callee reads them at positive offsets from RBP, like [rbp+0x10].

Spotting these accesses helps you recover the full argument list.

; 7th System V argument
mov rax, [rbp+0x10]

Quick Check

Under the System V AMD64 convention, which register holds the FIRST integer argument?

Recap

You can now decode function calls at the metal level:

  • Stack grows down; RSP tops it, RBP anchors the frame
  • Prologue/epilogue set up and tear down frames
  • Calling conventions map registers to arguments (System V vs Microsoft x64)

This turns opaque disassembly into recognizable function signatures.

Często zadawane pytania

Czy lekcja „Stos i konwencje wywołań” jest bezpłatna?

Tak — pełny tekst „Stos i konwencje wywołań” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Reverse Engineering & Binary Analysis Basics, przejdź na CoddyKit PRO. Kurs Reverse Engineering & Binary Analysis Basics zawiera 4 lekcji w sumie.

Co nauczysz się w „Stos i konwencje wywołań”?

Zagłębią się Państwo w sposób przekazywania argumentów przez funkcje, zwracania wartości i zarządzania ramką stosu — wiedzę, dzięki której zdeasemblowany kod staje się czytelny. Ćwiczysz Reverse Engineering & Binary Analysis Basics z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Reverse Engineering & Binary Analysis Basics?

Nie wymagamy żadnego doświadczenia. Reverse Engineering & Binary Analysis Basics w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Stos i konwencje wywołań”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Reverse Engineering & Binary Analysis Basics?

Tak. Każda lekcja Reverse Engineering & Binary Analysis Basics zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Podstawy asemblera x86/x64
  2. Rejestry i operacje na pamięci
  3. Przepływ sterowania i wywołania funkcji
  4. Stos i konwencje wywołań
← Powrót do Reverse Engineering & Binary Analysis Basics