home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / mdcm1.asm < prev    next >
Encoding:
Assembly Source File  |  1999-09-03  |  5.5 KB  |  210 lines

  1. ; #########################################################################
  2.  
  3.       .386
  4.       .model flat, stdcall  ; 32 bit memory model
  5.       option casemap :none  ; case sensitive
  6.  
  7.       include mdcm1.inc     ; local includes for this file
  8.  
  9. ; #########################################################################
  10.  
  11. .data
  12.  
  13.     NagWindowCaption    db  'Please register!',0
  14.     NagWindowText       db  'I want your money!  Please send me $20 to get rid of this screen!',0
  15.     GreetzText          db  'Greetz go out to:',10,'Xorolc: thanks a lot for all your help ;)',
  16.                             10,'sncs',10,'dec',10,'L4Z3R',10,'and of course:',10,'tNO',0
  17.     StaticClass         db  'STATIC',0
  18. .code
  19.  
  20. start:
  21.       invoke GetModuleHandle, NULL
  22.       mov hInstance, eax
  23.  
  24.       invoke GetCommandLine
  25.       mov CommandLine, eax
  26.  
  27.       invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
  28.       invoke ExitProcess,eax
  29.  
  30. ; #########################################################################
  31.  
  32. WinMain proc hInst     :DWORD,
  33.              hPrevInst :DWORD,
  34.              CmdLine   :DWORD,
  35.              CmdShow   :DWORD
  36.  
  37.       ;====================
  38.       ; Put LOCALs on stack
  39.       ;====================
  40.  
  41.       LOCAL wc   :WNDCLASSEX
  42.       LOCAL msg  :MSG
  43.       LOCAL Wwd  :DWORD
  44.       LOCAL Wht  :DWORD
  45.       LOCAL Wtx  :DWORD
  46.       LOCAL Wty  :DWORD
  47.  
  48.       ;==================================================
  49.       ; Fill WNDCLASSEX structure with required variables
  50.       ;==================================================
  51.  
  52.       invoke LoadIcon,hInst,500    ; icon ID
  53.       mov hIcon, eax
  54.  
  55.       szText szClassName,"mdcm_class"
  56.  
  57.       mov wc.cbSize,         sizeof WNDCLASSEX
  58.       mov wc.style,          CS_HREDRAW or CS_VREDRAW \
  59.                              or CS_BYTEALIGNWINDOW
  60.       mov wc.lpfnWndProc,    offset WndProc
  61.       mov wc.cbClsExtra,     NULL
  62.       mov wc.cbWndExtra,     NULL
  63.       m2m wc.hInstance,      hInst
  64.       mov wc.hbrBackground,  COLOR_BTNFACE+1
  65.       mov wc.lpszMenuName,   NULL
  66.       mov wc.lpszClassName,  offset szClassName
  67.       m2m wc.hIcon,          hIcon
  68.         invoke LoadCursor,NULL,IDC_ARROW
  69.       mov wc.hCursor,        eax
  70.       m2m wc.hIconSm,        hIcon
  71.  
  72.       invoke RegisterClassEx, ADDR wc
  73.  
  74.       ;================================
  75.       ; Centre window at following size
  76.       ;================================
  77.  
  78.       mov Wwd, 255
  79.       mov Wht, 145
  80.  
  81.       invoke GetSystemMetrics,SM_CXSCREEN
  82.       invoke TopXY,Wwd,eax
  83.       mov Wtx, eax
  84.  
  85.       invoke GetSystemMetrics,SM_CYSCREEN
  86.       invoke TopXY,Wht,eax
  87.       mov Wty, eax
  88.  
  89.       invoke CreateWindowEx,WS_EX_LEFT,
  90.                             ADDR szClassName,
  91.                             ADDR szDisplayName,
  92.                             WS_OVERLAPPED or WS_SYSMENU,
  93.                             Wtx,Wty,Wwd,Wht,
  94.                             NULL,NULL,
  95.                             hInst,NULL
  96.       mov   hWnd,eax
  97.  
  98.  
  99.         invoke CreateWindowEx,NULL,ADDR StaticClass, ADDR GreetzText,
  100.                 WS_VISIBLE or WS_CHILDWINDOW or SS_CENTER,
  101.                 5,5,245,245,hWnd,1000,hInst,NULL
  102.  
  103.       invoke LoadMenu,hInst,600  ; menu ID
  104.       invoke SetMenu,hWnd,eax
  105.  
  106.       invoke ShowWindow,hWnd,SW_SHOWNORMAL
  107.       invoke UpdateWindow,hWnd
  108.  
  109.       ;===================================
  110.       ; Loop until PostQuitMessage is sent
  111.       ;===================================
  112.  
  113.     StartLoop:
  114.       invoke GetMessage,ADDR msg,NULL,0,0
  115.       cmp eax, 0
  116.       je ExitLoop
  117.       invoke TranslateMessage, ADDR msg
  118.       invoke DispatchMessage,  ADDR msg
  119.       jmp StartLoop
  120.     ExitLoop:
  121.  
  122.       return msg.wParam
  123.  
  124. WinMain endp
  125.  
  126. ; #########################################################################
  127.  
  128. WndProc proc hWin   :DWORD,
  129.              uMsg   :DWORD,
  130.              wParam :DWORD,
  131.              lParam :DWORD
  132.  
  133.     LOCAL var    :DWORD
  134.     LOCAL caW    :DWORD
  135.     LOCAL caH    :DWORD
  136.     LOCAL Rct    :RECT
  137.     LOCAL hDC    :DWORD
  138.     LOCAL Ps     :PAINTSTRUCT
  139.     LOCAL buffer1[128]:BYTE  ; these are two spare buffers
  140.     LOCAL buffer2[128]:BYTE  ; for text manipulation etc..
  141.  
  142.     .if uMsg == WM_COMMAND
  143.     ;======== menu commands ========
  144.     .elseif uMsg == WM_CREATE
  145.         invoke NagWindowProc
  146.         
  147.     .elseif uMsg == WM_SIZE
  148.  
  149.     .elseif uMsg == WM_PAINT
  150.         invoke BeginPaint,hWin,ADDR Ps
  151.           mov hDC, eax
  152.           invoke Paint_Proc,hWin,hDC
  153.         invoke EndPaint,hWin,ADDR Ps
  154.         return 0
  155.  
  156.     .elseif uMsg == WM_CLOSE
  157.         invoke NagWindowProc
  158.  
  159.     .elseif uMsg == WM_DESTROY
  160.         invoke PostQuitMessage,NULL
  161.         return 0 
  162.     .endif
  163.  
  164.     invoke DefWindowProc,hWin,uMsg,wParam,lParam
  165.  
  166.     ret
  167.  
  168. WndProc endp
  169.  
  170. ; ########################################################################
  171.  
  172. TopXY proc wDim:DWORD, sDim:DWORD
  173.  
  174.     shr sDim, 1      ; divide screen dimension by 2
  175.     shr wDim, 1      ; divide window dimension by 2
  176.     mov eax, wDim    ; copy window dimension into eax
  177.     sub sDim, eax    ; sub half win dimension from half screen dimension
  178.  
  179.     return sDim
  180.  
  181. TopXY endp
  182.  
  183. ; #########################################################################
  184.  
  185. Paint_Proc proc hWin:DWORD, hDC:DWORD
  186.  
  187.     LOCAL btn_hi   :DWORD
  188.     LOCAL btn_lo   :DWORD
  189.     LOCAL Rct      :RECT
  190.  
  191.     invoke GetSysColor,COLOR_BTNHIGHLIGHT
  192.     mov btn_hi, eax
  193.  
  194.     invoke GetSysColor,COLOR_BTNSHADOW
  195.     mov btn_lo, eax
  196.  
  197.     return 0
  198.  
  199. Paint_Proc endp
  200.  
  201. ; ########################################################################
  202. NagWindowProc   proc
  203.  
  204.     invoke MessageBoxA,NULL,addr NagWindowText, addr NagWindowCaption,MB_OK
  205. NagWindowProc   endp
  206.  
  207. ; ########################################################################
  208.  
  209. end start
  210.