home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Tools / TASM V5 / DLLWIN.PAK / DLLWIN.ASM next >
Encoding:
Assembly Source File  |  1996-02-21  |  3.1 KB  |  118 lines

  1. LOCALS
  2. .MODEL LARGE, WINDOWS PASCAL
  3. .286
  4.  
  5. INCLUDE WINDOWS.INC
  6.  
  7. extrn   UNLOCKSEGMENT:PROC
  8. extrn   LOCALINIT:PROC
  9.  
  10. .DATA
  11.             db    16 dup( 0 ) ; Required for Task Header!!
  12. hInstance   dw       ?
  13.  
  14.  
  15. .CODE
  16.  
  17. ; =====================================================================
  18. LibMain     proc hinst:word, hdataseg:word, heapsize:word, cmdline:dword
  19.             mov ax, [heapsize]
  20.             or  ax,ax
  21.             jz  @@0001
  22.             push -1
  23.             call UnlockSegment
  24. @@0001:     mov ax, 1
  25.             ret
  26. LibMain     endp
  27.  
  28.  
  29. ; =====================================================================
  30. WEP         proc    SysExit:word
  31.             mov     ax, 1
  32.             ret
  33. WEP         endp
  34.  
  35.  
  36. ; =====================================================================
  37. AStrRev proc far uses es ds si di, string:DWORD
  38.             les di, string
  39.             push es
  40.             pop ds
  41.             push di
  42.             mov cx, -1
  43.             mov al, 0
  44.             repne scasb
  45.             not cx
  46.             dec cx
  47.             pop si
  48.             mov bx, di
  49.             sub bx, 2
  50.             mov di, si
  51.  
  52.             shr cx, 1
  53.  
  54. loop1:
  55.             lodsb
  56.             xchg al, es:[bx]
  57.             stosb
  58.             dec bx
  59.             loop loop1
  60.             ret
  61. AStrRev     endp
  62.  
  63.  
  64.  
  65. Start:
  66. ;Windows initialization.  Sets up registers and stack.
  67.  
  68. LibEntry        proc far
  69.                 mov     hInstance, di   ;save SI and DI
  70.                 push    si
  71.  
  72.                 push    di              ;handle of the module instance
  73.                 push    ds              ;library data segment
  74.                 push    cx              ;heap size
  75.                 push    es              ;command line segment
  76.                 push    si              ;command line offset
  77.  
  78.                 ;if we have some heap then initialize it
  79.                 jcxz    @@Init          ;jump if no heap specified
  80.  
  81.                 ;call the Windows function LocalInit() to set up the heap
  82.                 ;LocalInit((LPSTR)start, WORD cbHeap);
  83.  
  84.                 push    ds              ;Heap segment
  85.                 xor     ax,ax
  86.                 push    ax              ;Heap start offset in segment
  87.                 push    cx              ;Heap end offset in segment
  88.                 call    LOCALINIT
  89.                 xchg    ax,cx
  90.                 jcxz    @@JmpExit       ;quit if it failed
  91.                 jmp     short @@Init
  92. @@JmpExit:      jmp     @@Exit
  93.  
  94. @@Init:
  95.  
  96. @@Main:         call    LIBMAIN         
  97.                 mov     di, hInstance ;restore SI and DI
  98.                 pop     si
  99.                 ret
  100.  
  101. @@Exit:         mov ax, 0               ;set return code
  102.                 pop si                  ;remove arguments to LIBMAIN
  103.                 pop es                  ;  since we didn't call it.
  104.                 pop cx
  105.                 pop ds
  106.                 pop di
  107.                 pop si                  ;restore saved SI.  DI is restored
  108.                 ret                     ;  by removing arguments to LIBMAIN
  109.                 endp
  110.  
  111.  
  112.  
  113. PUBLICDLL   WEP
  114. PUBLICDLL   AStrRev
  115.  
  116. END         Start
  117.  
  118.