Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.3 KiB

  1. PAGE ,132
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; LIBENTRY.ASM
  5. ;
  6. ; Windows dynamic link library entry routine
  7. ;
  8. ; This module generates a code segment called INIT_TEXT.
  9. ; It initializes the local heap if one exists and then calls
  10. ; the C routine LibMain() which should have the form:
  11. ; BOOL FAR PASCAL LibMain(HANDLE hInstance,
  12. ; WORD wDataSeg,
  13. ; WORD cbHeap,
  14. ; LPSTR lpszCmdLine);
  15. ;
  16. ; The result of the call to LibMain is returned to Windows.
  17. ; The C routine should return TRUE if it completes initialization
  18. ; successfully, FALSE if some error occurs.
  19. ;
  20. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  21. extrn LibMain:far ; the C routine to be called
  22. extrn LocalInit:far ; Windows heap init routine
  23. extrn __acrtused:abs ; ensures that Win DLL startup code is linked
  24. public LibEntry ; entry point for the DLL
  25. INIT_TEXT segment byte public 'CODE'
  26. assume cs:INIT_TEXT
  27. LibEntry proc far
  28. push di ; handle of the module instance
  29. push ds ; library data segment
  30. push cx ; heap size
  31. push es ; command line segment
  32. push si ; command line offset
  33. ; if we have some heap then initialize it
  34. jcxz callc ; jump if no heap specified
  35. ; call the Windows function LocalInit() to set up the heap
  36. ; LocalInit((LPSTR)start, WORD cbHeap);
  37. push ds ; Heap segment
  38. xor ax,ax
  39. push ax ; Heap start offset in segment
  40. push cx ; Heap end offset in segment
  41. call LocalInit ; try to initialize it
  42. or ax,ax ; did it do it ok ?
  43. jz nocall ; quit if it failed
  44. ; invoke the C routine to do any special initialization
  45. callc:
  46. call LibMain ; invoke the 'C' routine (result in AX)
  47. jmp short exit ; LibMain is responsible for stack clean up
  48. nocall: ; clean up passed params
  49. pop si ; if LocalInit fails.
  50. pop es
  51. pop cx
  52. pop ds
  53. pop di
  54. exit:
  55. ret ; return the result
  56. LibEntry endp
  57. INIT_TEXT ends
  58. end LibEntry