Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Nasm Overflow occurred demo

[code]
;
;To compile:
; nasm -f source_file.asm
; gcc -o overflow_demo.exe source_file.o -mwindows
;

global _WinMain@16
extern _MessageBoxA@16


[section .data]
title db "experiment1 -overflow test" ,0
overflow db "overflow occurred" ,0
not_overflow db "not overflow occurred",0
[section .text]

_WinMain@16:
push ebp
mov ebp , esp

;; clear the overflow flag if it was
pushfd
pop eax ;now eax contains the EFLAGS
mov ebx , -1
xor eax , 2048
push eax
popfd
mov eax , 0x7FFFFFFF
add eax , 1
jo jump_if_overflow
jump_if_no_overflow:
push 0
push title
push not_overflow
push 0
call _MessageBoxA@16
jmp exit

jump_if_overflow:
push 0
push title
push overflow
push 0
call _MessageBoxA@16

exit:
mov esp , ebp
pop ebp
ret[/code]
Sign In or Register to comment.