www.pudn.com > asm_vxd.zip > OURVXD.ASM, change:1998-01-10,size:6616b


.486 
locals 
jumps 
.model flat,STDCALL 
 
include win32.inc            
include extrn.inc            
                                 
 
L               EQU <LARGE> 
IDM_EXIT        EQU 101 
IDM_ABOUT       EQU 103 
IDM_USE         EQU 105 
 
IDD_OK          EQU 1010         
 
TRUE            EQU 1 
FALSE           EQU 0 
NULL            EQU 0 
 
 
.data 
 
newhwnd          dd 0 
lppaint          PAINTSTRUCT <?> 
msg              MSGSTRUCT   <?> 
wc               WNDCLASS    <?> 
 
hInst            dd 0 
hMenu            dd 0 
hDlg             dd 0 
 
 
szTitleName      db 'OurVxD',0 
szClassName      db 'ASMCLASS32',0 
szMenuName       db 'MENU',0        
 
dlg_register     db 'DLG_REGIS',0 
dlg_about        db 'DLG_ABOUT',0 
 
ControlCode      dd 0 
vxdbytesret      dd 0 
Vxd_Handle       dd 0 
VxDName          db '\\.\vxdbody.vxd',0 
VxDErrorTxT      db 'Cannot load DLL',0 
ErrHeader        db 'Error',0 
Text             db 'Sorry function not implemented.',0 
 
 
.code 
 
 
start: 
 
        push    L 0 
        call    GetModuleHandle         ; get hmod (in eax) 
        mov     [hInst], eax            ; hInstance is same as HMODULE 
 
        push    L 0 
        push    offset szClassName 
        call    FindWindow               
        or      eax,eax                 ;Hay abierta otra ventana del  
        jz      reg_class               ;mismo programa? 
        ret                             ;No, only one open at time 
 
reg_class: 
        mov     [wc.clsStyle], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS 
        mov     [wc.clsLpfnWndProc], offset WndProc 
        mov     [wc.clsCbClsExtra], 0 
        mov     [wc.clsCbWndExtra], 0 
 
        mov     eax, [hInst] 
        mov     [wc.clsHInstance], eax 
 
        push    L IDI_APPLICATION       ;Tipo de Icono 
        push    L 0 
        call    LoadIcon 
        mov     [wc.clsHIcon], eax 
 
        push    L IDC_ARROW             ;Tipo de puntero de raton 
        push    L 0 
        call    LoadCursor 
        mov     [wc.clsHCursor], eax 
 
        mov     [wc.clsHbrBackground], COLOR_WINDOW + 1         ;Color fondo 
        mov     dword ptr [wc.clsLpszMenuName], offset szMenuName 
        mov     dword ptr [wc.clsLpszClassName], offset szClassName 
 
        push    offset wc 
        call    RegisterClass 
 
        push    L 0                      ; lpParam 
        push    [hInst]                  ; hInstance 
        push    L 0                      ; menu 
        push    L 0                      ; parent hwnd 
        push    L CW_USEDEFAULT          ; height 
        push    L CW_USEDEFAULT          ; width 
        push    L 110                    ; y 
        push    L 180                    ; x 
        push    L WS_OVERLAPPEDWINDOW    ; Style 
        push    offset szTitleName       ; Title string 
        push    offset szClassName       ; Class name 
        push    L 0                      ; extra style 
 
        call    CreateWindowEx 
        mov     [newhwnd], eax 
 
        call    OpenVxD 
        cmp     eax,-1 
        jne     NoError 
        call    VxDError 
        ;ret 
 
NoError: 
        push    L SW_SHOWNORMAL 
        push    [newhwnd] 
        call    ShowWindow 
 
        push    [newhwnd] 
        call    UpdateWindow 
 
msg_loop: 
        push    L 0 
        push    L 0 
        push    L 0 
        push    offset msg 
        call    GetMessage 
 
        cmp     ax, 0 
        je      end_loop 
 
        push    offset msg 
        call    TranslateMessage 
 
        push    offset msg 
        call    DispatchMessage 
 
        jmp     msg_loop 
 
end_loop: 
        push    [msg.msWPARAM] 
        call    ExitProcess              
 
 
WndProc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD 
 
        push    esi 
        push    edi 
        push    ebx 
 
        cmp     [wmsg], WM_DESTROY 
        je      wmdestroy 
        cmp     [wmsg], WM_GETMINMAXINFO 
        je      wmgetminmaxinfo 
        cmp     [wmsg],  WM_COMMAND 
        je      wmcommand 
        jmp     defwndproc 
 
 
defwndproc: 
        push    [lparam] 
        push    [wparam] 
        push    [wmsg] 
        push    [hwnd] 
        call    DefWindowProc 
        jmp     finish 
 
wmdestroy: 
        mov     eax,Vxd_Handle 
        cmp     eax,-1 
        je      NoClose 
        call    CloseVxD 
NoClose: 
        push    L 0 
        call    PostQuitMessage 
        mov     eax, 0 
        jmp     finish 
         
wmgetminmaxinfo: 
        mov     ebx, [lparam]  ; ptr to minmaxinfo struct 
        mov     [(MINMAXINFO ptr ebx).mintrackposition_x] , 160 
        mov     [(MINMAXINFO ptr ebx).mintrackposition_y] , 160 
        mov     [(MINMAXINFO ptr ebx).maxtrackposition_x] , 160 ;No X sizing 
        mov     [(MINMAXINFO ptr ebx).maxtrackposition_y] , 160 ;No Y sizing 
        mov     eax, 0 
        jmp     finish 
 
wmcommand: 
        cmp     [wparam],IDM_ABOUT 
        je      about 
        cmp     [wparam],IDM_EXIT 
        je      wmdestroy 
        cmp     [wparam],IDM_USE 
        je      use 
        jmp     finish 
 
finish: pop     ebx      
        pop     edi      
        pop     esi 
        ret 
WndProc          endp 
 
public WndProc 
 
about: 
        push    L 0                     ;No inicializo nada 
        push    offset Ab_DlgProc       ;procedure para dialog1 
        push    [hwnd] 
        push    offset dlg_about        ;About dlg resource            
        push    [hInst] 
        call    DialogBoxParamA 
        jmp     finish                  ;Back main window 
 
use:    push    L 0 
        call    MessageBeep 
        push    L MB_ICONEXCLAMATION  
        push    offset szTitleName 
        push    offset Text 
        push    [hwnd] 
        call    MessageBoxA 
        jmp     finish 
 
 
Ab_DlgProc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD 
 
        push    ebx 
        push    esi 
        push    edi 
 
        cmp     [wmsg],WM_COMMAND 
        je      ab_command 
        cmp     [wmsg], WM_CLOSE 
        je      ab_dlgdestroy 
        mov     eax,FALSE 
ab_finish: 
        pop     edi 
        pop     esi 
        pop     ebx 
        ret 
ab_command: 
        cmp     [wparam],IDD_OK 
        jne     ab_nothing 
ab_dlgdestroy: 
        push    L 0              
        push    [hwnd] 
        call    EndDialog       ;Close dialog 
        mov     eax,TRUE         
        jmp     ab_finish 
ab_nothing: 
        mov     eax,FALSE 
        jmp     ab_finish 
 
Ab_DlgProc    endp 
public Ab_DlgProc 
 
        include vxd.asm 
 
end start