Sunday 26 December 2010

WaveASM / WaterEffect / WaveObject From asm.yeah.net - Luo Yun Bin


Some of you know the cool water effect, maked by this Chinese Guy
The problem with the code he have made...
Dialog was created in the asm file with CreateWindowEx, and the .rc is just used for the bmp.
I've wanted to done the dialog with the ressource file so..
Some pictures of the water effect

From a keygen:

From a unpackMe (with a MouseMove feature):

From a KeygenMe (Bitmap inside a static):

Original:

My version (using rc for the dialog):

base.asm:
.486
.model  flat, stdcall
option  casemap :none   ; case sensitive

include         windows.inc
include         user32.inc
include         kernel32.inc
include         gdi32.inc
include         C:\masm32\macros\macros.asm
include         WaveObject.asm
includelib          user32.lib
includelib          kernel32.lib
includelib          gdi32.lib

DlgProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
szTitle     db  'Error',0
szError     db  'An error has occured',0

.data?
hInstance   dd  ?
stWaveObj   WAVE_OBJECT <?>
xWin dd ?
hBitmap dd ?
bitmp dd ?

.const
IDC_EXIT    equ     1005

.code
start:
    invoke  GetModuleHandle, NULL
    mov hInstance, eax
    invoke  DialogBoxParam, hInstance, 101, 0, ADDR DlgProc, 0
    invoke  ExitProcess, eax
; -----------------------------------------------------------------------
DlgProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
        local   @stPs:PAINTSTRUCT,@hDc,@stRect:RECT
        local   @stBmp:BITMAP
   LOCAL hMemDC:HDC
    .if uMsg==WM_INITDIALOG
    invoke LoadBitmap,hInstance,1
    mov hBitmap,eax
        push    hBitmap
        invoke  _WaveInit,addr stWaveObj,hWin,hBitmap,30,0
        .if eax
            invoke  MessageBox,hWin,addr szError,addr szTitle,MB_OK or MB_ICONSTOP
        call    _Quit
        .else
        .endif

        pop hBitmap
        invoke  DeleteObject,hBitmap
        invoke  _WaveEffect,addr stWaveObj,1,5,4,250
    .elseif uMsg == WM_PAINT
      invoke BeginPaint,hWin,addr @stPs
      mov @hDc,eax
      invoke CreateCompatibleDC,@hDc
      mov hMemDC,eax
      invoke SelectObject,hMemDC,hBitmap
      invoke GetClientRect,hWin,addr @stRect
      invoke BitBlt,@hDc,10,10,@stRect.right,@stRect.bottom,hMemDC,0,0,MERGECOPY
      invoke DeleteDC,hMemDC
      invoke _WaveUpdateFrame,addr stWaveObj,eax,TRUE
      invoke EndPaint,hWin,addr @stPs
            xor eax,eax
            ret
    .elseif uMsg==WM_COMMAND
        mov eax,wParam
        .if eax==IDC_EXIT
            invoke SendMessage,hWin,WM_CLOSE,0,0
        .endif     
    .elseif uMsg == WM_LBUTTONDOWN
            mov eax,lParam
            movzx   ecx,ax      ; x
            shr eax,16      ; y
            invoke  _WaveDropStone,addr stWaveObj,ecx,eax,2,256
;   .elseif uMsg== WM_MOUSEMOVE
;           mov eax,lParam
;           movzx   ecx,ax      ; x
;           shr eax,16      ; y
;           invoke  _WaveDropStone,addr stWaveObj,ecx,eax,2,256
    .elseif uMsg == WM_CLOSE
        call    _Quit
        invoke EndDialog,xWin,0
    .elseif uMsg==WM_DESTROY
      invoke DeleteObject,hBitmap
        invoke PostQuitMessage,NULL
        .endif
    xor eax,eax
    ret
DlgProc endp
_Quit proc
invoke  _WaveFree,addr stWaveObj
invoke  DestroyWindow,xWin
invoke  PostQuitMessage,NULL
ret
_Quit endp
end start

base.rc:
;This Resource Script was generated by WinAsm Studio.

#define IDC_EXIT 1005

1 BITMAP DISCARDABLE "5ab9y001.bmp"

101 DIALOGEX 0,0,381,111
CAPTION "Base"
FONT 8,"Tahoma"
STYLE 0x80ca0880
EXSTYLE 0x00000008
BEGIN
    CONTROL "Exit",IDC_EXIT,"Button",0x50010000,340,95,40,13,0x00020000
END

And for WaveObject.asm the file have over 900 lines so get with with google (it's just the origial file coded by the author)
Also thanks to my mate Xsp!d3r who have helped me to find a way.




Edit 28 Dec 2k10:




WaveEffect in a static.


base.asm:
.486
.model  flat, stdcall
option  casemap :none   ; case sensitive

include         windows.inc
include         user32.inc
include         kernel32.inc
include         gdi32.inc
include         C:\masm32\macros\macros.asm
include         WaveObject.asm
includelib      user32.lib
includelib      kernel32.lib
includelib      gdi32.lib

DlgProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD
szTitle     db  'Error',0
szError     db  'An error has occured',0

.data?
hInstance   dd  ?
stWaveObj   WAVE_OBJECT <?>
xWin dd ?
hBitmap dd ?
bitmp dd ?

.const
IDC_EXIT   equ     1005

.code
start:
    invoke  GetModuleHandle, NULL
    mov hInstance, eax
    invoke  DialogBoxParam, hInstance, 101, 0, ADDR DlgProc, 0
    invoke  ExitProcess, eax
; -----------------------------------------------------------------------
DlgProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
        local   @stPs:PAINTSTRUCT,@hDc,@stRect:RECT
        local   @stBmp:BITMAP
   LOCAL hMemDC:HDC
    .if uMsg==WM_INITDIALOG
invoke LoadBitmap,hInstance,1
        mov hBitmap,eax
        invoke  GetDlgItem,hWin,1008
        push    hBitmap
        invoke  _WaveInit,addr stWaveObj,eax,hBitmap,30,0
        .if eax
            invoke  MessageBox,hWin,addr szError,addr szTitle,MB_OK or MB_ICONSTOP
            call    _Quit
        .else
        .endif
        pop hBitmap
        invoke  DeleteObject,hBitmap
        invoke  _WaveEffect,addr stWaveObj,1,5,4,250
    .elseif uMsg == WM_PAINT
      invoke BeginPaint,hWin,addr @stPs
      mov @hDc,eax
      invoke CreateCompatibleDC,@hDc
      mov hMemDC,eax
      invoke SelectObject,hMemDC,hBitmap
      invoke GetClientRect,hWin,addr @stRect
      invoke BitBlt,@hDc,10,10,@stRect.right,@stRect.bottom,hMemDC,0,0,MERGECOPY
      invoke DeleteDC,hMemDC
      invoke _WaveUpdateFrame,addr stWaveObj,eax,TRUE
      invoke EndPaint,hWin,addr @stPs
            xor eax,eax
            ret
    .elseif uMsg==WM_COMMAND
        mov eax,wParam
        .if eax==IDC_EXIT
            invoke SendMessage,hWin,WM_CLOSE,0,0
        .endif    
    .elseif uMsg == WM_LBUTTONDOWN
            mov eax,lParam
            movzx   ecx,ax      ; x
            shr eax,16      ; y
            invoke  _WaveDropStone,addr stWaveObj,ecx,eax,2,256
;   .elseif uMsg== WM_MOUSEMOVE
;           mov eax,lParam
;           movzx   ecx,ax      ; x
;           shr eax,16      ; y
;           invoke  _WaveDropStone,addr stWaveObj,ecx,eax,2,256
    .elseif uMsg == WM_CLOSE
        call    _Quit
        invoke EndDialog,xWin,0
    .elseif uMsg==WM_DESTROY
      invoke DeleteObject,hBitmap
        invoke PostQuitMessage,NULL
        .endif
    xor eax,eax
    ret
DlgProc endp
_Quit proc
invoke  _WaveFree,addr stWaveObj
invoke  DestroyWindow,xWin
invoke  PostQuitMessage,NULL
ret
_Quit endp
end start

base.rc:
;This Resource Script was generated by WinAsm Studio.

#define IDC_EXIT 1005
#define IDC_IMAGE1008 1008
1 BITMAP DISCARDABLE "5ab9y001.bmp"

101 DIALOGEX 0,0,391,118
CAPTION "Base"
FONT 8,"Tahoma"
STYLE 0x80ca0880
EXSTYLE 0x00000008
BEGIN
    CONTROL "Exit",IDC_EXIT,"Button",0x50010000,347,102,40,13,0x00020000
    CONTROL "#1",IDC_IMAGE1008,"Static",0x5080020e,3,3,384,93,0x00000000
END


And there is not only one cool effect
try this line:
invoke  _WaveEffect,addr stWaveObj,2,5,4,250

And you will see:

Cool nah ?

2 comments:

  1. THX Xylitol ;)

    Sous XP, ça plante si on n'est pas en mode compatibilité (95,98 ou 2000).

    ReplyDelete
  2. Oops...My mistake :P
    Pas de problème sous XP ;)

    Merki Xylitol

    ReplyDelete