Stupid Crash Bug 2

I spent a good two hours trying to narrow down a crash in CS:S DM on Windows. Unhelpfully, it would only crash in Release mode, making debugging very difficult.

Finally I narrowed it down to the value of the

register being corrupted, instead of being saved, by a call. Why? Dig up the “dropgate.asm” file I posted in the first Non-Virtual Function Hooking article:

	push	edi
	push	esi
; [...]
	pop	edi
	pop	esi

Oops. Right intention, but wrong order. The registers were essentially being swapped, and after the call, their values were completely wrong.

Lesson learned from this bug: Always, always, verify that you are restoring registers in the correct, reverse order.

Leave a Reply

You must be logged in to post a comment.