home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / PCTRIAL.ASM < prev    next >
Encoding:
Assembly Source File  |  1999-01-24  |  6.1 KB  |  206 lines

  1. include windows.inc 
  2. includelib user32.lib 
  3. includelib kernel32.lib 
  4. includelib gdi32.lib 
  5.  
  6. AboutProc PROTO :HWND, :DWORD, :DWORD, :DWORD
  7. DrawIcon PROTO ,:dword,:dword,:dword,:dword
  8.  
  9. .data 
  10. AppName db "KeyGen for PC trial crackme -- by Bjanes",0
  11. ClassName db "DLGCLASS",0 
  12. MenuName db "MyMenu",0 
  13. DlgName db "MyDialog",0 
  14. NoName db "You have to enter the name!",0
  15.  
  16. .data? 
  17. hInstance HINSTANCE ? 
  18. CommandLine LPSTR ? 
  19. username db 40 dup(?),0 
  20. serial db 4 dup(?),0
  21. paints PAINTSTRUCT <?>
  22. Iconh dd ?
  23. hand dd ?
  24.  
  25. .const 
  26. IDC_EDIT equ 3000 
  27. IDC_EDIT2 equ 3003
  28. IDC_BUTTON equ 3001
  29. IDC_BUTTON2 equ 3004
  30. IDM_EXIT equ 11
  31. IDM_GETTEXT equ 32000 
  32. IDM_CLEAR equ 32001 
  33. IDI_ICON equ 01h
  34. IDM_ABOUT equ 02h
  35.  
  36. .code 
  37. start: 
  38. invoke GetModuleHandle, NULL 
  39. mov hInstance,eax 
  40. invoke GetCommandLine 
  41. invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT 
  42. invoke ExitProcess,eax 
  43. WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD 
  44. LOCAL wc:WNDCLASSEX 
  45. LOCAL msg:MSG 
  46. LOCAL hDlg:HWND 
  47. mov wc.cbSize,SIZEOF WNDCLASSEX 
  48. mov wc.style, CS_HREDRAW or CS_VREDRAW 
  49. mov wc.lpfnWndProc, OFFSET WndProc 
  50. mov wc.cbClsExtra,NULL 
  51. mov wc.cbWndExtra,DLGWINDOWEXTRA 
  52. push hInstance 
  53. pop wc.hInstance 
  54. mov wc.hbrBackground,COLOR_BTNFACE+1 
  55. mov wc.lpszMenuName,OFFSET MenuName 
  56. mov wc.lpszClassName,OFFSET ClassName 
  57. invoke LoadIcon,hInst,IDI_ICON
  58. mov Iconh, eax
  59. mov wc.hIcon,eax 
  60. mov wc.hIconSm,0 
  61. invoke LoadCursor,NULL,IDC_ARROW 
  62. mov wc.hCursor,eax 
  63. invoke RegisterClassEx, addr wc 
  64. invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL 
  65. mov hDlg,eax 
  66. invoke ShowWindow, hDlg,SW_SHOWNORMAL 
  67. invoke UpdateWindow, hDlg 
  68. invoke GetDlgItem,hDlg,IDC_EDIT 
  69. invoke SetFocus,eax 
  70. .WHILE TRUE 
  71. invoke GetMessage, ADDR msg,NULL,0,0 
  72. .BREAK .IF (!eax) 
  73. invoke IsDialogMessage, hDlg, ADDR msg 
  74. .IF eax ==FALSE 
  75. invoke TranslateMessage, ADDR msg 
  76. invoke DispatchMessage, ADDR msg 
  77. .ENDIF 
  78. .ENDW 
  79. mov eax,msg.wParam 
  80. ret 
  81. WinMain endp 
  82.  
  83. WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM 
  84. mov eax,uMsg 
  85. .IF eax==WM_DESTROY 
  86. invoke PostQuitMessage,NULL 
  87. .ELSEIF eax==WM_COMMAND 
  88. mov eax,wParam 
  89. .IF lParam==0 
  90. .IF ax==IDM_ABOUT
  91. invoke    DialogBoxParam, hInstance, IDM_ABOUT, hWnd, ADDR AboutProc, NULL
  92. .ELSEIF ax==IDM_EXIT
  93. invoke DestroyWindow,hWnd 
  94. invoke PostQuitMessage,NULL 
  95. .ENDIF 
  96. .ELSE 
  97. .IF ax==IDC_BUTTON 
  98. shr eax,16 
  99. .IF ax==BN_CLICKED                               ;'GET SERIAL' BUTTON IS PUSHED
  100. invoke GetDlgItemText,hWnd,IDC_EDIT, ADDR username,40  ;GET NAME FROM TEXTBOX
  101. xor eax,eax                 ; EAX = 0
  102. xor edx,edx                 ; EDX = 0 
  103. xor ecx,ecx                 ; ECX = 0
  104. mov eax, OFFSET username    ; EAX = Address of Name
  105. cmp BYTE PTR [eax], dl      ; Is there name?
  106. jz @end2                    ; If not the jump to @end2
  107. mov edi,offset serial       ; EDI = Address for Serial
  108. mov [edi], ecx              ; Clear memory for Serial
  109. @loop:                      ; DO 
  110.    mov cl, BYTE PTR [eax]   ; AL = First char of Name
  111.    ror ecx,08               ; Rotate bits in ECX to the right 8 times
  112.    add edx,ecx              ; EDX = EDX + ECX
  113.    inc eax                  ; EAX = EAX + 1; Point to the next char of name
  114.    cmp BYTE PTR [eax], 0    ; Is END of name
  115. jnz @loop                   ; If no the LOOP this
  116.    ror edx,08               ; Rotate bits in EDX to the right 8 times
  117. cmp dl, 0                   ; Is DL(first byte of EDX) = 0 ?
  118. jz @nedodaj                 ; If yes then skip next two lines
  119. mov [edi], dl               ; If no then DL is first char of correct serial
  120. inc edi                     ; EDI = EDI + 1; Where to save next char of Serial
  121. @nedodaj:                   
  122. xor ebx,ebx                 ; EBX = 0
  123. xor ecx,ecx                 ; ECX = 0
  124. mov esi, 3                  ; ESI = 3
  125.  
  126. @loop2:                     ; DO
  127. mov bl, dl                  ; BL = DL
  128. rol edx, 08                 ; Rotate bits in EDX to the right 8 times
  129. mov cl,dl                   ; CL = DL
  130. sub cl,bl                   ; CL = CL - BL
  131. jz @nedodaj2                ; If CL = 0 then skip next two lines
  132. mov [edi], cl               ; If not then CL is next char of correct serial
  133. inc edi                     ; EDI = EDI + 1; Where to save next char of Serial
  134. @nedodaj2:                  
  135. dec esi                     ; ESI = ESI - 1
  136. jnz @loop2                  ; Loop until ESI = 0
  137.  
  138. invoke SetDlgItemText,hWnd,IDC_EDIT2,ADDR serial ; Print correct Serial
  139. jmp @end              ; Jump to END
  140. @end2:                ; If there is no name entered then execute next few lines
  141. xor eax,eax           ; EAX = 0
  142. xor edx,edx           ; EDX = 0
  143. mov edx, OFFSET username     ; EDX = Address of Name
  144. mov [edx], EAX               ; Clear memory location for Serial   
  145. invoke SetDlgItemText,hWnd,IDC_EDIT2,ADDR NoName  ; Display "You have to enter the name"
  146. @end:   ; END
  147.  
  148. .ENDIF
  149. .IF ax==BN_CLICKED 
  150. invoke SendMessage,hWnd,WM_COMMAND,IDM_EXIT,0 
  151. .ENDIF 
  152. .ENDIF 
  153. .ENDIF 
  154. .ELSE 
  155. invoke DefWindowProc,hWnd,uMsg,wParam,lParam 
  156. ret 
  157. .ENDIF 
  158. xor eax,eax 
  159. ret 
  160. WndProc endp 
  161.  
  162. AboutProc PROC hWnd:HWND,iMsg:DWORD,wParam:WPARAM, lParam:LPARAM
  163.          mov  eax,iMsg
  164.         .if eax==WM_INITDIALOG
  165.                 invoke GetDlgItem,hWnd,IDC_EDIT
  166.                 invoke SetFocus,eax
  167.         .ELSEIF eax==WM_PAINT       
  168.               call _printicon
  169.        
  170.      .elseif eax==WM_CLOSE
  171.                 invoke EndDialog,hWnd,NULL
  172.         .elseif eax==WM_COMMAND
  173.                 mov eax,wParam
  174.                 .if eax==IDC_BUTTON2
  175.                         invoke EndDialog,hWnd,NULL
  176.                 .endif
  177.         .else
  178.                 mov eax,FALSE
  179.                 ret
  180.         .endif
  181.         mov  eax,TRUE
  182.         ret
  183.  
  184. _printicon:
  185.       push offset paints
  186.          push hWnd
  187.          call BeginPaint
  188.          push Iconh
  189.          push 7
  190.          push 15
  191.          mov hand, eax
  192.          push hand
  193.          call DrawIcon
  194.          push Iconh
  195.          push 7
  196.          push 180
  197.          push hand
  198.          call DrawIcon
  199.          push offset paints
  200.          push hWnd
  201.          call EndPaint
  202.         
  203. ret
  204.  
  205. AboutProc endp
  206. END start