home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / LordLucifer / win32asm / files / win32asm.exe / Win32ASM / Win32Proto / W32PInit.asm < prev    next >
Encoding:
Assembly Source File  |  1997-11-10  |  6.8 KB  |  201 lines

  1.     Page 60,190
  2.     TITLE W32PInit - Windows 95 prototype - Initialization module.
  3.  
  4. ; ==========================================================================
  5. ; ToDo:
  6. ; ...
  7. ; ==========================================================================
  8.  
  9.  
  10.                 .586
  11.                 .MODEL FLAT,STDCALL
  12.  
  13.                 .NOLISTMACRO
  14.                 .NOLIST
  15.  
  16. UniCode         = 0
  17.  
  18.                 INCLUDE INSTR32.MAC
  19.                 INCLUDE WIN32INC.EQU
  20.  
  21.                 INCLUDE WIN32RES.EQU
  22.  
  23.                 INCLUDE KERNEL32.EQU
  24.                 INCLUDE USER32.EQU
  25.                 INCLUDE COMCTL32.EQU
  26.  
  27.                 INCLUDE W32PROTO.EQU
  28.                 .LIST
  29.  
  30.                 PUBLIC WinStart         ; Our entry point.
  31.                 PUBLIC hInst            ; This process handle.
  32.  
  33.                 .CODE
  34.  
  35. WinProc         PROTO NEAR
  36.  
  37.                 PAGE
  38. ; =========================================================================
  39. ; Constants and data.
  40. ; =========================================================================
  41.  
  42.                 .CONST
  43.  
  44. MyTitle         BYTE 'Prototype Win32 Assembly Language Program',0
  45. Already         BYTE 'A copy of this program is already running',0
  46. ClassName       BYTE 'W32Proto',0
  47.  
  48.                 ALIGN DWORD
  49.  
  50.                 .DATA
  51.  
  52. ; The following fields could possibly be made local (stack based).
  53.  
  54. Msg             MSG <?>                 ; Win message structure.
  55.  
  56. NewhWnd         DWORD 0                 ; Handle for our main window.
  57. hInst           DWORD 0                 ; Process instance.
  58. hMenu           DWORD 0                 ; Menu handle.
  59. hAccel          DWORD 0                 ;Accelerator table handle.
  60.  
  61. WC              WNDCLASS <?>
  62.  
  63.     PAGE
  64. ; =========================================================================
  65. ; Main entry point.
  66. ; =========================================================================
  67.  
  68.     .CODE
  69.  
  70. WinStart PROC PUBLIC
  71.  
  72.     INVOKE InitCommonControls           ;initialize the common ctrl lib
  73.     INVOKE GetModuleHandle,
  74.                0                        ;get hMod (in eax)
  75.     MOV hInst,EAX                       ;hInstance is same as hmodule
  76.  
  77.  
  78.       .REPEAT
  79.       INVOKE FindWindow,
  80.                OFFSET ClassName,        ;Look for windows of our
  81.                0                        ;class, any name: already running?
  82.       .BREAK .IF (EAX == 0)             ;No: No other instance, continue.
  83.                                         ;Yes.
  84.       INVOKE MessageBox,
  85.                0,                       ;No window owner,
  86.                OFFSET Already,          ;Text in msg box,
  87.                OFFSET MyTitle,          ;title of msg box,
  88.                MB_ABORTRETRYIGNORE      ;Ab/Ret/Ignore box.
  89.         .IF (EAX == IDABORT)
  90.         INVOKE ExitProcess,             ;She gives up,
  91.                  0                      ;exit (retcode 0).
  92.         .ENDIF
  93.       .CONTINUE .IF (EAX == IDRETRY)
  94.       .UNTIL (EAX == IDIGNORE)          ;Loop if IDRETRY,
  95.                                         ;else, it's IDIGNORE, fall thru
  96.                                         ;and open second instance.
  97.  
  98. ; =========================================================================
  99. ; Initialize the wndclass structure and register our class
  100. ; =========================================================================
  101.  
  102.  
  103.     MOV WC.style,CS_HREDRAW or CS_VREDRAW or CS_GLOBALCLASS
  104.     MOV WC.lpfnWndProc,OFFSET WinProc
  105.     MOV WC.cbClsExtra,0
  106.     MOV WC.cbWndExtra,0
  107.     MOV EAX,hInst
  108.     MOV WC.hInstance,EAX
  109.  
  110.     INVOKE LoadIcon,
  111.              EAX,                       ;Application instance,
  112.              IDI_W32PROTO               ;Icon resource identifier.
  113.     MOV WC.hIcon,EAX                    ;Store icon handle.
  114.  
  115.     INVOKE LoadCursor,
  116.              0,                         ;Use predefined cursor,
  117.              IDC_ARROW                  ;select standard arrow.
  118.     MOV WC.hCursor,EAX                  ;Save cursor handle in Window Class.
  119.  
  120.     MOV WC.hbrBackground,COLOR_WINDOW+1 ;Set BG color.
  121.     MOV WC.lpszMenuName,0
  122.     MOV WC.lpszClassName,OFFSET ClassName
  123.  
  124.     INVOKE RegisterClass,
  125.              OFFSET WC                  ;Register our Window Class.
  126.  
  127.  
  128. ; get our menu resource
  129.  
  130.  
  131.                 INVOKE LoadMenu,
  132.                          hInst,         ;This process,
  133.                          IDR_MENU1      ;give resource ID.
  134.                 MOV hMenu,EAX           ;Remember our menu handle.
  135.  
  136.  
  137.  
  138. ; create the main window
  139.  
  140.     INVOKE CreateWindowEx,
  141.        0,                               ;Extended Window style,
  142.        OFFSET ClassName,OFFSET MyTitle, ;Class name, Window name,
  143.        WS_EX_OVERLAPPEDWINDOW,          ;Window style,
  144.        CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
  145.        0,hMenu,hInst,0                  ;initial x,y,width,height of window.
  146.                                         ;handle for parent window (none).
  147.                                         ;window menu,
  148.                                         ;instance of this process,
  149.                                         ;lparam (none).
  150.     MOV [NewhWnd],EAX                   ;Remember our window handle.
  151.  
  152.  
  153. ; Now show the window
  154.  
  155.     INVOKE ShowWindow,
  156.              NewhWnd,                   ;Handle of just created window,
  157.              SW_SHOWNORMAL              ;show it normally.
  158.  
  159.     INVOKE UpdateWindow,                ;Force window to
  160.              NewhWnd                    ;paint itself.
  161.  
  162.  
  163. ; Load the keyboard accelerator resource.
  164.  
  165.     INVOKE LoadAccelerators,
  166.              hInst,                     ;Process handle.
  167.              IDR_ACCELERATOR1
  168.     MOV hAccel,EAX                      ;Save accelerator handle.
  169.  
  170.  
  171. ; Finally fall into main message loop.
  172.  
  173.  
  174.       .WHILE (TRUE)
  175.       INVOKE GetMessage,
  176.                OFFSET Msg,              ;Adress of Msg structure,
  177.                0,                       ;Window to get msg from,
  178.                0,                       ;Filter min,
  179.                0                        ;filter max.
  180.       .BREAK .IF (EAX == 0)             ;Exit loop if WM_QUIT message.
  181.       INVOKE TranslateAccelerator,
  182.                NewhWnd,                 ;Destination window (here),
  183.                hAccel,                  ;Handle of accelerat.
  184.                OFFSET Msg               ;table, addr of Msg str.
  185.       .CONTINUE .IF (EAX != 0)          ;Non-null return, Msg processed, loop again.
  186.       INVOKE TranslateMessage,          ;Otherwise,
  187.                OFFSET Msg               ;translate keystrokes,
  188.       INVOKE DispatchMessage,           ;dispatch msg to proper winproc, and
  189.                OFFSET Msg               ;loop again.
  190.       .ENDW
  191.  
  192.     INVOKE ExitProcess,
  193.            Msg.wParam                   ;Pass Quit message code to ExitProc.
  194.         RET
  195.  
  196. WinStart ENDP
  197.  
  198.     END WinStart
  199.  
  200.  
  201.