home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Mib / BBCRACK.ZIP / BBCRACK.ASM next >
Encoding:
Assembly Source File  |  1998-08-18  |  19.0 KB  |  742 lines

  1. ;Brains Breaker v2.1 crack
  2. ;Written by Cruehead as a part of the 1999 +HCU strainer
  3.  
  4. .386
  5. locals
  6. jumps
  7. .model flat,STDCALL
  8. include win32.inc                                ;Some very usefull includes
  9.  
  10. ;-------------------------------------------
  11. ; .-.-.- Begining of the DATA segment -.-.-.
  12. ;-------------------------------------------
  13.  
  14. .data
  15.  
  16. FILE_ATTRIBUTE_NORMAL    EQU        080h            ;Some constants that we declare here
  17. GENERIC_WRITE            EQU        40000000h
  18. GENERIC_READ            EQU        80000000h
  19. OPEN_EXISTING            EQU        3h
  20. OPEN_ALWAYS                EQU        4h
  21. FILE_BEGIN                EQU        0h
  22. FILE_CURRENT            EQU        1h
  23. FILE_END                EQU        2h
  24. SW_SHOWNORMAL              EQU        1h
  25. KEY_EXECUTE                EQU        3C000007h
  26.  
  27. MyHwnd             dd 0                            ;We'll save the handle for the window here
  28. GoButHwnd        dd 0                            ;The handle for the 'Patch it" button
  29. ExitButHwnd        dd 0                            ;The handle for the 'Exit' button
  30. EditHwnd        dd 0                            ;The handle for the edit field
  31. NameHwnd        dd 0                            ;The handle for the name edit field
  32.  
  33. msg             MSGSTRUCT   <?>
  34. wc              WNDCLASS    <?>
  35. lppaint         PAINTSTRUCT <?>
  36.  
  37. szNULL           db 0
  38. ymenu            dd 0
  39.  
  40. hInst           dd 0
  41. hMenu           dd 0
  42. hDlg            dd 0
  43.  
  44. SubKey            db 'SOFTWARE\Classes\BrainsBreaker_Puzzle\ID',0
  45. TheID            db 'ID',0
  46. BBID            db 105h dup (0)
  47. HowManyBytes    dd 105h
  48. RegHandle        dd 0
  49.  
  50.  
  51. Counter            db 0
  52. IniFile            db 'BBRK.INI',0
  53. Serial            db '$L25OOO'
  54. UserID            db '123'
  55. INIInfo            db 13,10,'[PackFull]',13,10
  56.                 db '0=                                      ',13,10 ;Name
  57.                 db '1=123',13,10                                    ;ID
  58.                 db '2=                                      ',13,10 ;EncSerial
  59.                 db '3=2100',13,10                                     ;Version?
  60.                 db '4=                                      ',13,10 ;EncName
  61.                 db '5=                                      ',13,10 ;EncID
  62.                 db 0
  63.  
  64. EncrSource        db 8 dup (0)
  65. UserName        db 20 dup (0)
  66. UserLength        db 0
  67.  
  68. EnterName        db '--- Enter your name ---'
  69. TitleName       db 'Crack for Brains Breaker v2.21 - Written By Cruehead',0
  70. ClassName       db 'ASMCLASS32',0
  71. ClassButton        db 'BUTTON',0
  72. ClassEdit        db 'EDIT',0
  73. TransStr        db 'TRANSPARENT',0
  74. PatchText        db 'Lets go - Crack it!',0
  75. ExitText        db 'Exit!',0
  76.  
  77. ;--- Different action messages so the user knows what's happening ---
  78.  
  79. EditWaiting        db '                         Action: Waiting...',0
  80. Error1             db '            Error: BBRK32.EXE not found!',0
  81. Error2             db ' Error: File already cracked / Wrong version!',0
  82. Error3            db '                    Error: Wrong filesize!',0
  83. Error4            db '    Error: Registry information not found!',0
  84. Done             db '                        Done! Enjoy it!',0
  85.  
  86. ;--- What we need to open the file ---
  87.  
  88. filename        db 'BBRK32.EXE',0                
  89. handle            dd 0
  90.  
  91. ;--- What we need to read the file ---
  92.  
  93. ReadBuffer        db 2 dup (0)                    ;We will read two bytes to this location
  94. BytesRead        dd 0                            ;Will hold how many bytes actually read
  95.  
  96. ;--- What we need to write to the file ---
  97.  
  98. WriteBuffer     db 090h,090h,0FFh,0EBh,052h        ;We will patch the program with this
  99.                                                 ;(the bytes are in reverse order)
  100. BytesWritten    dd 0                            ;Will hold how many bytes actually written
  101.  
  102. CorrectFileSize    dd 091000h                        ;FileSize of the correct file
  103. Original        dw 02E75h                        ;This is the original word that we will change
  104.                                                 ;(the bytes are in reverse order)
  105. ;----------------------------------------
  106. ; .-.-.- Code Segment starts here -.-.-.
  107. ;----------------------------------------
  108.  
  109. .code
  110.  
  111. start:
  112.         push    0
  113.         call    GetModuleHandle                 ;get hmod (in eax)
  114.         mov     [hInst], eax                    ;hInstance is same as HMODULE
  115.                                                 ;in the Win32 world
  116.         push    0
  117.         push    offset ClassName
  118.         call    FindWindow              
  119.         or      eax,eax                         ;More than one program opened?
  120.         jz      reg_class              
  121.         ret                                        ;No, only one open at time
  122.  
  123. reg_class:
  124. ;
  125. ; initialize the WndClass structure
  126. ;
  127.  
  128.         mov     [wc.clsStyle], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS
  129.         mov     [wc.clsLpfnWndProc], offset WndProc
  130.         mov     [wc.clsCbClsExtra], 0
  131.         mov     [wc.clsCbWndExtra], 0
  132.  
  133.         mov     eax, [hInst]
  134.         mov     [wc.clsHInstance], eax
  135.  
  136.         push    IDC_ARROW             
  137.         push    0
  138.         call    LoadCursor
  139.         mov     [wc.clsHCursor], eax
  140.  
  141.         mov     [wc.clsHbrBackground], COLOR_BACKGROUND
  142.         mov     dword ptr [wc.clsLpszClassName], offset ClassName
  143.  
  144.         push    offset wc
  145.         call    RegisterClass
  146.  
  147. ;Create the main window
  148.  
  149.         push    0                                  ;lpParam
  150.         push    [hInst]                          ;hInstance
  151.         push    0                                  ;menu
  152.         push    0                                  ;parent hwnd
  153.         push    270                               ;height
  154.         push    390                               ;width
  155.         push    150                                ;y
  156.         push    170                                ;x
  157.         push    WS_OVERLAPPEDWINDOW                ;Style
  158.         push    offset TitleName                   ;Title string
  159.         push    offset ClassName                   ;Class name
  160.         push    0                                   ;Extra style
  161.         call    CreateWindowEx
  162.         mov     [MyHwnd], eax                    ;Save the handle for later use
  163.  
  164. ;This creates the 'Patch it' Button
  165.  
  166.         push    0                                  ;lpParam
  167.         push    0                                 ;hInstance
  168.         push    0                                  ;menu
  169.         push    [MyHwnd]                           ;parent hwnd
  170.         push    30                               ;height
  171.         push    140                               ;width
  172.         push    85                                ;y
  173.         push    120                                ;x
  174.         push    WS_CHILD+BS_DEFPUSHBUTTON        ;Style
  175.         push    offset PatchText                 ;Title string
  176.         push    offset ClassButton                 ;Class name
  177.         push    0                                   ;Extra style
  178.         call    CreateWindowEx
  179.         mov     [GoButHwnd], eax                ;Save this handle
  180.  
  181. ;This creates the 'Exit' Button
  182.  
  183.         push    0                                  ;lpParam
  184.         push    0                                 ;hInstance
  185.         push    0                                  ;menu
  186.         push    [MyHwnd]                           ;parent hwnd
  187.         push    30                               ;height
  188.         push    140                               ;width
  189.         push    118                             ;y
  190.         push    120                                ;x
  191.         push    WS_CHILD+BS_DEFPUSHBUTTON        ;Style
  192.         push    offset ExitText                 ;Title string
  193.         push    offset ClassButton                 ;Class name
  194.         push    0                                   ;Extra style
  195.         call    CreateWindowEx
  196.         mov     [ExitButHwnd], eax                ;Save the handle
  197.  
  198. ;Create the edit field
  199.  
  200.         push    0                                  ;lpParam
  201.         push    0                                 ;hInstance
  202.         push    0                                  ;menu
  203.         push    [MyHwnd]                           ;parent hwnd
  204.         push    20                               ;height
  205.         push    300                               ;width
  206.         push    200                                ;y
  207.         push    40                                ;x
  208.         push    WS_CHILD+ES_READONLY            ;Style
  209.         push    offset EditWaiting                 ;Title string
  210.         push    offset ClassEdit                 ;Class name
  211.         push    WS_EX_CLIENTEDGE                ;Extra style
  212.         call    CreateWindowEx
  213.         mov     [EditHwnd], eax                    ;Save the handle
  214.  
  215. ;Create the name edit field
  216.  
  217.         push    0                                  ;lpParam
  218.         push    0                                 ;hInstance
  219.         push    0                                  ;menu
  220.         push    [MyHwnd]                           ;parent hwnd
  221.         push    20                               ;height
  222.         push    280                               ;width
  223.         push    45                                ;y
  224.         push    50                                ;x
  225.         push    WS_CHILD                        ;Style
  226.         push    0                                ;Title string
  227.         push    offset ClassEdit                 ;Class name
  228.         push    WS_EX_CLIENTEDGE                ;Extra style
  229.         call    CreateWindowEx
  230.         mov     [NameHwnd], eax                    ;Save the handle
  231.  
  232.         push    SW_SHOWNORMAL                    ;Show the Main window
  233.         push    [MyHwnd]
  234.         call    ShowWindow
  235.  
  236.         push    SW_SHOWNORMAL                    ;Show the 'Patch it" button
  237.         push    [GoButHwnd]
  238.         call    ShowWindow
  239.         
  240.         push    SW_SHOWNORMAL                    ;Show the 'Exit" button
  241.         push    [ExitButHwnd]
  242.         call    ShowWindow
  243.  
  244.         push    SW_SHOWNORMAL                    ;Show the edit filed
  245.         push    [EditHwnd]
  246.         call    ShowWindow
  247.          
  248.         push    SW_SHOWNORMAL                    ;Show the name edit filed
  249.         push    [NameHwnd]
  250.         call    ShowWindow
  251.  
  252.         push    [MyHwnd]                        ;We have to do this in order to 
  253.         call    UpdateWindow                    ;show the buttons and the edit field
  254.  
  255. ;Here we come to the messageloop - A very important thing in a win32 program
  256.  
  257. msg_loop:
  258.         push    0
  259.         push    0
  260.         push    0
  261.         push    offset msg
  262.         call    GetMessage
  263.  
  264.         cmp     ax, 0
  265.         je      end_loop
  266.  
  267.         push    offset msg
  268.         call    TranslateMessage
  269.  
  270.         push    offset msg
  271.         call    DispatchMessage
  272.  
  273.         jmp     msg_loop
  274.  
  275. end_loop:
  276.         push    [msg.msWPARAM]
  277.         call    ExitProcess             
  278.  
  279.  
  280. ;----------------------------------------------------------------------------
  281. ; WARNING: Win32 requires that EBX, EDI, and ESI be preserved!  
  282. ;
  283. ; Here we put the events we want to respond on.
  284. ;----------------------------------------------------------------------------
  285.  
  286. WndProc proc hwnd:DWORD, wmsg:DWORD, wparam:DWORD, lparam:DWORD
  287.         push    esi
  288.         push    edi
  289.         push    ebx
  290.         LOCAL   theDC:DWORD
  291.  
  292.         cmp     [wmsg], WM_DESTROY
  293.         je      wmdestroy
  294.         cmp        [wmsg], WM_PAINT
  295.         je        wmpaint    
  296.         cmp     [wmsg], WM_SIZE
  297.         je      wmsize
  298.         cmp        [wmsg], WM_COMMAND
  299.         je        wmcommand
  300.         jmp     defwndproc
  301.  
  302. wmcommand:
  303.         mov        eax ,[lparam]
  304.         cmp        [GoButHwnd], eax                ;Did the user click on the 'Patch it' button?
  305.         je        StartMeUp                        ;Then jump
  306.         cmp        [ExitButHwnd], eax                ;Did the user click on the 'Exit' button?
  307.         je        wmdestroy                        ;If so - lets jump
  308.         mov        eax,0
  309.         jmp        finish
  310.  
  311. ;----
  312. ; Here is the start of the real interesting part
  313. ;                                             ----
  314.  
  315. StartMeUp:                
  316.  
  317.         push    20
  318.         push    offset UserName
  319.         push    [NameHwnd]
  320.         call    GetWindowTextA
  321.         
  322.         test    eax,eax
  323.         jnz        NoProblem
  324.     
  325.         mov        eax,0
  326.         jmp        finish
  327.  
  328.     NoProblem:        
  329.  
  330.         mov        UserLength,al
  331.         push    offset [RegHandle]
  332.         push    offset [SubKey]
  333.         push    080000002h                        ;HKEY_LOCAL_MACHINE
  334.         call    RegOpenKeyA
  335.  
  336.         test    eax,eax
  337.         je        ContinuePlease
  338.  
  339.         push    -1
  340.         call    MessageBeep                        ;Just a cute litle beep
  341.  
  342.         push    offset Error4                    ;"Registry error" message
  343.         push    [EditHwnd]
  344.         call    SetWindowTextA
  345.  
  346.         push    [EditHwnd]                        ;We need to do this in order to show the
  347.         call    UpdateWindow                    ;above message
  348.  
  349.         mov        eax,0
  350.         jmp        finish
  351.  
  352.     ContinuePlease:
  353.         push    offset [HowManyBytes]
  354.         push    offset [BBID]        
  355.         push    0h
  356.         push    [RegHandle]
  357.         call    RegQueryValueA
  358.  
  359.         test    eax,eax
  360.         je        RegistryFine
  361.  
  362.         push    -1
  363.         call    MessageBeep                        ;Just a cute litle beep
  364.  
  365.         push    offset Error4                    ;"Registry error" message
  366.         push    [EditHwnd]
  367.         call    SetWindowTextA
  368.  
  369.         push    [EditHwnd]                        ;We need to do this in order to show the
  370.         call    UpdateWindow                    ;above message
  371.  
  372.         mov        eax,0
  373.         jmp        finish
  374.  
  375.  
  376.     RegistryFine:
  377.         push    0                                ;Must be zero if win95
  378.         push    FILE_ATTRIBUTE_NORMAL            ;We're dealing with a normal file
  379.         push     OPEN_EXISTING                    ;Opens a file if it exists, otherwise error
  380.         push    0                                ;Cant be inherited
  381.         push    0                                ;File can't be shared
  382.         push    GENERIC_READ+GENERIC_WRITE        ;Read and write access
  383.         push    offset filename                    ;offset to our filename
  384.         call    CreateFileA
  385.  
  386.         cmp        eax,-1                            ;Did an error occur?
  387.         jnz        FileFound                        ;Take the jump if everything is ok
  388.  
  389.         push    -1
  390.         call    MessageBeep                        ;Just a cute litle beep
  391.  
  392.         push    offset Error1                    ;"File not found" message
  393.         push    [EditHwnd]
  394.         call    SetWindowTextA
  395.  
  396.         push    [EditHwnd]                        ;We need to do this in order to show the
  397.         call    UpdateWindow                    ;above message
  398.  
  399.         mov        eax,0
  400.         jmp        finish
  401.  
  402.     FileFound:
  403.         mov        handle,eax
  404.  
  405.         push    0
  406.         push    [handle]
  407.         call    GetFileSize                        ;Get the filesize in eax
  408.  
  409.         cmp        eax,CorrectFileSize                ;Is it the correct filesize?
  410.         je        GoodFileSize                    ;If yes - take the jump and continue
  411.  
  412.         push    [handle]                        ;Close the file
  413.         call    CloseHandle
  414.     
  415.         push    -1
  416.         call    MessageBeep                        ;Just a cute litle beep
  417.  
  418.         push    offset Error3                    ;"File length dont match" message
  419.         push    [EditHwnd]
  420.         call    SetWindowTextA
  421.  
  422.         push    [EditHwnd]                        ;We need to do this in order to show the
  423.         call    UpdateWindow                    ;above message
  424.  
  425.         mov        eax,0
  426.         jmp        finish
  427.  
  428.     GoodFileSize:        
  429.         push    FILE_BEGIN                        ;Move the filepointer from the start of the file
  430.         push    0
  431.         push    0403B8h                            ;Here is the address where we shall read/patch
  432.         push    handle                            ;Filehandle
  433.         call    SetFilePointer
  434.  
  435.         push    0        
  436.         push    offset BytesRead                ;How many bytes actually read
  437.         push    2                                ;Read 2 bytes
  438.         push    offset ReadBuffer                ;Address to the readbuffer
  439.         push    [handle]                        ;Filehandle
  440.         call    ReadFile
  441.  
  442.         mov        ax,word ptr [ReadBuffer]        ;Get the word we just read from the file in ax
  443.         cmp        ax, Original                    ;Compare this word with what it should be if
  444.                                                 ;this is an uncracked version
  445.         je        LetsPatch                        ;If they matches everything is ok, take the jump
  446.  
  447.         push    [handle]                        ;Close the file
  448.         call    CloseHandle
  449.  
  450.         push    -1
  451.         call    MessageBeep                        ;Just a cute litle beep
  452.  
  453.         push    offset Error2                    ;"Already Patched / wrong version" message
  454.         push    [EditHwnd]
  455.         call    SetWindowTextA
  456.  
  457.         push    [EditHwnd]                        ;We need to do this in order to show the
  458.         call    UpdateWindow                    ;above message
  459.  
  460.         mov        eax,0
  461.         jmp        finish
  462.  
  463.     LetsPatch:
  464.  
  465. ;--- Because the ReadFile functions also increases the filepointer we have to move it ---
  466. ; backwards in order to make it point to the correct patching posision. We read two bytes
  467. ; and so the filepointer was moved two bytes ahead - we must move it back two bytes backwards
  468. ; to make it point to the correct position
  469.  
  470.         push    FILE_CURRENT                    ;Move the filepointer from the current position
  471.         push    0
  472.         push    -2                                ;Move the filepointer two bytes backwards
  473.         push    handle                            ;Filehandle
  474.         call    SetFilePointer
  475.  
  476.         push    0
  477.         push    offset BytesWritten                ;How many bytes actually written
  478.         push    2                                ;Write 2 bytes
  479.         push    offset WriteBuffer                ;Write from this buffer
  480.         push    [handle]                        ;the file handle
  481.         call    WriteFile
  482.  
  483.         push    FILE_BEGIN                        ;Move the filepointer from the start of the file
  484.         push    0
  485.         push    059300h                            ;Here is the address where we shall read/patch
  486.         push    handle                            ;Filehandle
  487.         call    SetFilePointer
  488.  
  489.         push    0
  490.         push    offset BytesWritten                ;How many bytes actually written
  491.         push    3                                ;Write 3 bytes
  492.         push    offset WriteBuffer+2            ;Write from this buffer
  493.         push    [handle]                        ;the file handle
  494.         call    WriteFile
  495.  
  496.         push    [handle]                        ;Now we're ready so lets close the file
  497.         call    CloseHandle
  498.  
  499. ;Patching done, now lets concentrate on the .INI file part:
  500.  
  501.         mov        al,BBID[4]                        ;Create the Encryption Source
  502.         mov        EncrSource[0],al                ;from the ID which BrainsBreaker
  503.         mov        al,BBID[9]                        ;creates the first time it's executed
  504.         mov        EncrSource[1],al
  505.         mov        al,BBID[7]
  506.         mov        EncrSource[2],al
  507.         mov        al,BBID[12]
  508.         mov        EncrSource[3],al
  509.         mov        al,BBID[16]
  510.         mov        EncrSource[4],al
  511.         mov        al,BBID[18]
  512.         mov        EncrSource[5],al
  513.         mov        al,BBID[21]
  514.         mov        EncrSource[6],al
  515.         mov        al,BBID[37]
  516.         mov        EncrSource[7],al
  517.  
  518.         lea        esi,EncrSource
  519.         xor        ebx,ebx
  520.         call    FixEncrSource                    ;EncrSource is now 4 bytes long
  521.  
  522.         lea        edi,INIInfo+16
  523.         lea        esi,UserName
  524.         xor        ecx,ecx
  525.         mov        cl,UserLength
  526.         rep        movsb
  527.  
  528.         push    0                                ;Must be zero if win95
  529.         push    FILE_ATTRIBUTE_NORMAL            ;We're dealing with a normal file
  530.         push     OPEN_ALWAYS                        ;Opens a file if it exists - if not it's created
  531.         push    0                                ;Cant be inherited
  532.         push    0                                ;File can't be shared
  533.         push    GENERIC_READ+GENERIC_WRITE        ;Read and write access
  534.         push    offset IniFile                    ;offset to our filename
  535.         call    CreateFileA
  536.         mov        [handle],eax
  537.                 
  538.         push    FILE_END                        ;Move the filepointer from the start of the file
  539.         push    0
  540.         push    0                                ;Here is the address where we shall read/patch
  541.         push    [handle]                        ;Filehandle
  542.         call    SetFilePointer
  543.  
  544.         lea        esi,UserName
  545.         lea        edi,EncrSource
  546.         lea        ebx,INIInfo+115
  547.         mov        cl,UserLength
  548.     EncUserName:
  549.         mov        al,[esi]
  550.         xor        al,[edi]
  551.         call    DivideItUp        
  552.         mov        [ebx],ah
  553.         mov        [ebx+1],al        
  554.         add        ebx,2
  555.         inc        Counter
  556.         cmp        Counter,4
  557.         jne        GoOn
  558.         mov        Counter,0
  559.         sub        edi,4
  560.     GoOn:
  561.         inc        esi
  562.         inc        edi
  563.         dec        cl
  564.         cmp        cl,0
  565.         jnz        EncUserName
  566.  
  567.         mov        Counter,0
  568.  
  569.         lea        esi,Serial
  570.         lea        edi,EncrSource
  571.         lea        ebx,INIInfo+65
  572.         mov        cl,7
  573.     EncSerial:
  574.         mov        al,[esi]
  575.         xor        al,[edi]
  576.         call    DivideItUp        
  577.         mov        [ebx],ah
  578.         mov        [ebx+1],al        
  579.         add        ebx,2
  580.         inc        Counter
  581.         cmp        Counter,4
  582.         jne        GoOn2
  583.         mov        Counter,0
  584.         sub        edi,4
  585.     GoOn2:
  586.         inc        esi
  587.         inc        edi
  588.         dec        cl
  589.         cmp        cl,0
  590.         jnz        EncSerial
  591.  
  592.         mov        Counter,0
  593.  
  594.         lea        esi,UserID
  595.         lea        edi,EncrSource
  596.         lea        ebx,INIInfo+157
  597.         mov        cl,3
  598.     EncID:
  599.         mov        al,[esi]
  600.         xor        al,[edi]
  601.         call    DivideItUp        
  602.         mov        [ebx],ah
  603.         mov        [ebx+1],al        
  604.         add        ebx,2
  605.         inc        Counter
  606.         cmp        Counter,4
  607.         jne        GoOn3
  608.         mov        Counter,0
  609.         sub        edi,4
  610.     GoOn3:
  611.         inc        esi
  612.         inc        edi
  613.         dec        cl
  614.         cmp        cl,0
  615.         jnz        EncID
  616.  
  617.         push    0
  618.         push    offset BytesWritten                ;How many bytes actually written
  619.         push    197                                ;Write 197
  620.         push    offset INIInfo                    ;Write from this buffer
  621.         push    [handle]                        ;the file handle
  622.         call    WriteFile
  623.  
  624.         push    [handle]                        ;Now we're ready so lets close the file
  625.         call    CloseHandle
  626.  
  627.         push    offset Done                        ;"Everything went ok" message
  628.         push    [EditHwnd]
  629.         call    SetWindowTextA
  630.  
  631.         push    [EditHwnd]                        ;We need to do this in order to show the
  632.         call    UpdateWindow                    ;above message
  633.  
  634.         mov        eax,0
  635.         jmp        finish
  636.  
  637. wmpaint:
  638.         push    offset lppaint
  639.         push    [hwnd]
  640.         call    BeginPaint
  641.         push    eax                                ;The device context
  642.  
  643.         push    offset TransStr
  644.         push    eax
  645.         call    SetBkMode
  646.  
  647.         pop        eax                                ;Device context in eax again
  648.         push    23                                ;Numbers of chars
  649.         push    offset EnterName                 ;The string
  650.         push    25                                ;Y
  651.         push    121                                ;X
  652.         push    eax                                ;DC
  653.         call    TextOut
  654.  
  655.         push    offset lppaint
  656.         push    [hwnd]
  657.         call    EndPaint
  658.  
  659.         mov        eax,0
  660.         jmp        finish
  661.  
  662. defwndproc:
  663.         push    [lparam]
  664.         push    [wparam]
  665.         push    [wmsg]
  666.         push    [hwnd]
  667.         call    DefWindowProc
  668.         jmp     finish
  669.  
  670. wmdestroy:
  671.  
  672.         push    0
  673.         call    PostQuitMessage
  674.         mov     eax, 0
  675.         jmp     finish
  676.  
  677. wmsize:
  678.         mov     eax, 0
  679.         jmp     finish
  680.         
  681. finish:
  682.         pop     ebx                             ;Remember we must restore these registers
  683.         pop     edi                             ;because the OS need them
  684.         pop     esi
  685.         ret
  686. WndProc          endp
  687.  
  688. public WndProc
  689.  
  690. FixEncrSource:
  691.         mov        cl,[esi+ebx]
  692.         cmp        cl,039h
  693.         ja        FixLetter
  694.         sub        cl,030h
  695.         jmp        DoneFirstPart
  696.     FixLetter:
  697.         sub        cl,057h
  698.     DoneFirstPart:
  699.         xor        dx,dx
  700.         mov        ax,010h
  701.         mul        cl
  702.         mov        dl,al
  703.         mov        cl,[esi+ebx+1]
  704.         cmp        cl,039h
  705.         ja        FixLetter2
  706.         sub        cl,030h
  707.         jmp        DoneSecondPart
  708.     FixLetter2:
  709.         sub        cl,057h
  710.     DoneSecondPart:
  711.         add        cl,dl
  712.         mov        [esi],cl
  713.         inc        ebx
  714.         inc        esi
  715.         cmp        ebx,4
  716.         jne        FixEncrSource
  717. ret
  718.  
  719. DivideItUp:
  720.         xor        ah,ah
  721.         shl        ax,4
  722.         cmp        ah,9
  723.         jbe        L1
  724.         add        ah,037h
  725.         jmp        Done1
  726.     L1:
  727.         add        ah,030h
  728.     Done1:
  729.         mov        dl,ah
  730.         shr        ax,4
  731.         and        ax,0fh
  732.         cmp        al,9
  733.         jbe        L2
  734.         add        al,037h
  735.         jmp        Done2
  736.     L2:
  737.         add        al,030h
  738.     Done2:
  739.         mov        ah,dl
  740. ret
  741. end start
  742.