An interesting way to easily enable easter eggs in your app. Totally useless code, but at least educative. I personally use similar code to make some hidden switches in my apps, that show some advanced features. Or a hidden password field.




On_EasterEgg macro text,action:VARARG
local txt1,phase1
.data
phase1 db 0
txt1 db text,0
.code
mov eax,phase1
movzx eax,txt1[eax]
.if eax==wParam ; if this pressed key is the next we expect
inc phase1
mov eax,phase1
.if !txt1[eax] ; if we've typed the whole text correctly
mov phase1,0

action ; invokes whatever code this defines
.endif
.else
mov phase1,0
.endif
endm


Usage:
In your WndProc, in the WM_CHAR handler, put this macro, as follows:



WndProc proc hWnd,msg,wParam,lParam
.if msg==WM_CHAR
On_EasterEgg "hello",invoke MessageBeep,MB_ICONHAND
.else
invoke DefWindowProc,hWnd,msg,wParam,lParam
.endif
ret
WndProc endp
Posted on 2003-09-10 14:35:25 by Ultrano