GetReturnAddress call does not preserve 16-byte stack alignment for Linux

Aperta
#1,997 1 commento 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Kenzzer ci sta già lavorando.

Dal 14/1/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Bug dhooks

Description

Not so long ago, I delved into the DynamicHooks/DHook library in order to understand its inner workings. After thoroughly examining the library, I decided to create my own version that would be compatible with both x64 and x32 and would include the ability to work with Virtual Hook.

As I was working on this project, I encountered a small issue on 32bit. While it may not be a serious problem, I noticed that calling GetReturnAddress does not preserve 16-byte stack alignment for Linux, when HookHandler call took this into account.

Problematic Code

// Get the original return address
void* (__cdecl CHook::*GetReturnAddress)(void*) = &CHook::GetReturnAddress;
masm.push(esp);
masm.push(intptr_t(this));
masm.call(ExternalAddress((void *&)GetReturnAddress));
masm.addl(esp, 8);

->

// Get the original return address
void* (__cdecl CHook::*GetReturnAddress)(void*) = &CHook::GetReturnAddress;
masm.movl(eax, esp);
masm.subl(esp, 4);
masm.push(eax);
masm.push(intptr_t(this));
masm.call(ExternalAddress((void *&)GetReturnAddress));
masm.addl(esp, 12);
Lingua principale
C++
Stelle
1.2k
Fork
476
Merge medio
2g 9h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di alliedmodders/sourcemod

Tutte le issue di alliedmodders/sourcemod

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.