.586
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive


include MetaEngine.inc
include Polymorph.asm

.code

start:
	
	.data
		szBufOld	dd	?
		sz			dd @END-@BGN
	.code

@BGN:
	invoke VirtualProtect,addr start,sz,PAGE_EXECUTE_READWRITE,addr szBufOld	
	lea edi,[@POLY]
	invoke Gen_Trash_Code,512
	
	invoke Sleep,5
	
@POLY:
	db 512 dup (0)
@END:
	
	invoke GetModuleHandle,NULL
	mov		hInstance,eax
    invoke InitCommonControls
	invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
	invoke ExitProcess,0

	
;########################################################################

DlgProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

	mov		eax,uMsg
	.if eax==WM_INITDIALOG

	.elseif eax==WM_COMMAND

	.elseif eax==WM_CLOSE
		invoke EndDialog,hWin,0
	.else
		mov		eax,FALSE
		ret
	.endif
	mov		eax,TRUE
	ret

DlgProc endp

rnd2gen proc near

	; Thanks to GL#OM

	.data
		seed dd ('SLV!')
	.code
	pusha
	rdtsc
	xor seed, eax
	popa
	inc edx
	imul edx,[seed],5445414Dh
	mov [seed],edx
	mul edx
	mov eax,edx
	test eax,eax
	jge _exz
	neg eax
	.if eax==NULL
		inc eax
	.endif
_exz:
ret
rnd2gen endp

end start
