home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / pespin132.exe / pespin132 / Examples / asm / markers_test.asm < prev    next >
Encoding:
Assembly Source File  |  2005-05-20  |  4.8 KB  |  181 lines

  1. COMMENT #
  2. ;************************************************************************************************
  3. ;This example shows a way how use:
  4.     - CLEAR_START, CLEAR_END
  5.     - CRYPT_START, CRYPT_END
  6.     in your application
  7. ;************************************************************************************************    
  8. #
  9. ;************************************************************************************************
  10. ;                                         MODEL
  11. ;************************************************************************************************
  12. .586p
  13. .model flat,stdcall
  14.  
  15. ;************************************************************************************************
  16. ;                                           INCLUDES
  17. ;************************************************************************************************
  18.  
  19. include c:\masm32\include\windows.inc
  20.  
  21. include c:\masm32\include\user32.inc
  22. include c:\masm32\include\kernel32.inc
  23. include c:\masm32\include\comctl32.inc
  24. include c:\masm32\include\gdi32.inc 
  25.  
  26. includelib c:\masm32\lib\comctl32.lib
  27. includelib c:\masm32\lib\user32.lib
  28. includelib c:\masm32\lib\kernel32.lib
  29. includelib c:\masm32\lib\Gdi32.lib
  30.  
  31. include    ..\pespin.inc
  32.  
  33. DlgProc        PROTO :DWORD,:DWORD,:DWORD,:DWORD
  34. assume        fs:flat
  35.  
  36. ;************************************************************************************************
  37. ;                        CONST
  38. ;************************************************************************************************
  39. .const        
  40.         IDC_PASSWORD    equ 1000
  41.         IDC_CHECK    equ 1001
  42.         IDC_EXIT    equ 1002
  43.            ID_ICON     equ 666     
  44.  
  45.  
  46. ;************************************************************************************************
  47. ;                                         DATA?
  48. ;************************************************************************************************    
  49. .data
  50.  
  51.     dlgname         db "MARKERS",0
  52.     MutexName    db "Markers_test",0
  53.     szGood        db "Good!",0,0
  54.     szBad        db "Wrong!, try password:PESpin"
  55. ;************************************************************************************************
  56. ;                        DATA
  57. ;************************************************************************************************      
  58. .data?
  59.  
  60.     hInstance    dd ?          ; handler      
  61.     szPassword    db 7   dup(?)
  62.     
  63. ;************************************************************************************************
  64. ;                        CODE
  65. ;************************************************************************************************  
  66. .code
  67. start:
  68.     
  69.         sub    eax,eax
  70.     push    offset MutexName
  71.     push    eax
  72.     push    eax
  73.     call    CreateMutexA
  74.     call    GetLastError
  75.     cmp    eax,ERROR_ALREADY_EXISTS
  76.     jz    @end
  77.     
  78.     ;this code will decrypted before using and after use removed
  79.     ;tip: This type of blocks is very good use in initialize part of program
  80.     ;(load DLL(s), initialize data, fill some special variables and etc.)
  81.     
  82.     CLEAR_START
  83.     invoke    GetModuleHandle, NULL
  84.     mov    hInstance, eax
  85.     invoke    DialogBoxParam,hInstance,offset dlgname,0,offset DlgProc,0
  86.     CLEAR_END
  87. @end:    
  88.     invoke    ExitProcess,0
  89.  
  90.  
  91. ;************************************************************************************************
  92. ;                                 DIALOG PROC
  93. ;************************************************************************************************
  94. DlgProc proc STDCALL uses ebx edi esi, hWnd:DWORD, wmsg:DWORD, _wparam:DWORD, _lparam:DWORD
  95.  
  96.     movzx    eax,word ptr [wmsg]
  97.     cmp    ax,WM_COMMAND
  98.     je    _wmcommand
  99.     cmp    ax,WM_INITDIALOG
  100.     je    _initdlg
  101.     cmp    ax,WM_DESTROY
  102.     je    _wmdestroy
  103.     cmp    ax,WM_CLOSE
  104.     je    _wmdestroy
  105.       
  106.          sub    eax,eax
  107.     ret                
  108.     
  109. _wmcommand:
  110.  
  111.     cmp    word ptr[_wparam],IDC_CHECK 
  112.     je    _check
  113.  
  114.         cmp    word ptr[_wparam],IDC_EXIT
  115.     je    _wmdestroy
  116.     sub    eax,eax
  117.     ret
  118.  
  119. _initdlg:
  120.  
  121.     CLEAR_START
  122.     
  123.     invoke    LoadIcon,hInstance,ID_ICON            
  124.         invoke    SendMessage,hWnd,WM_SETICON,0,eax       
  125.     sub    eax,eax
  126.     
  127.     CLEAR_END
  128.        ret
  129.  
  130. _wmdestroy:
  131.     push    0            
  132.     push    hWnd            
  133.     call    EndDialog        
  134.     ret            
  135.  
  136. _check:
  137.       CRYPT_START
  138.     invoke    SendDlgItemMessageA,hWnd,IDC_PASSWORD,WM_GETTEXT,7,offset szPassword  ; get serial
  139.     cmp    al,6
  140.     CRYPT_END        ;[i]CRYPT_END must be before jump, because You will skip end of encrypted block!
  141.     jnz    @bad_password
  142.     
  143.     CRYPT_START
  144.     lea    esi,szPassword
  145.     sub    ebx,ebx
  146.     mov    eax,dword ptr[esi]
  147.     mov    bx,word ptr[esi+4]
  148.     push    255
  149.     pop    ecx
  150. @mix:
  151.     inc    eax
  152.     dec    ebx
  153.     rol    ebx,16
  154.     xor    eax,ebx
  155.     shr    eax,1
  156.     xor    eax,'test'
  157.     sub    ebx,eax
  158.     
  159.     loop    @mix
  160.     add    eax,ebx
  161.     CRYPT_END
  162.     
  163.     cmp    eax,0FD4B82Ah
  164.     jnz    @bad_password
  165.     cmp    ebx,0A70C6EFDh
  166.     jnz    @bad_password
  167.     
  168.     
  169.     CRYPT_START
  170.     lea    eax,szGood
  171.     invoke    SendDlgItemMessageA,hWnd,IDC_PASSWORD,WM_SETTEXT,0,eax ; ustaw text
  172.     CRYPT_END
  173.     ret        ;[i]CRYPT_END must be before jump, because You will skip end of encrypted block!
  174.     
  175. @bad_password:                
  176.     invoke MessageBoxA,0,offset szBad,offset dlgname,MB_OK or MB_ICONINFORMATION
  177.     ret 
  178.  
  179. DlgProc endp
  180.  
  181. end start