Source code of Windows XP (NT5)
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.

81 lines
2.3 KiB

  1. PAGE,132
  2. ;***************************************************************************
  3. ;*
  4. ;* DLLENTRY.ASM
  5. ;*
  6. ;* VER.DLL Entry code
  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. INCLUDE CMACROS.INC
  22. externFP <LIBMAIN> ;The C routine to be called
  23. ifndef SEGNAME
  24. SEGNAME equ <_TEXT> ; default seg name
  25. endif
  26. createSeg %SEGNAME, CodeSeg, word, public, CODE
  27. sBegin CodeSeg ; this defines what seg this goes in
  28. assumes cs,CodeSeg
  29. ?PLM=0 ;'C'naming
  30. externA <_acrtused> ;Ensures that Win DLL startup code is linked
  31. ?PLM=1 ;'PASCAL' naming
  32. externFP <LOCALINIT> ;Windows heap init routine
  33. cProc LibEntry, <PUBLIC,FAR> ;Entry point into DLL
  34. cBegin
  35. push di ;Handle of the module instance
  36. push ds ;Library data segment
  37. push cx ;Heap size
  38. push es ;Command line segment
  39. push si ;Command line offset
  40. ;** If we have some heap then initialize it
  41. jcxz callc ;Jump if no heap specified
  42. ;** Call the Windows function LocalInit() to set up the heap
  43. ;** LocalInit((LPSTR)start, WORD cbHeap);
  44. xor ax,ax
  45. cCall LOCALINIT <ds, ax, cx>
  46. or ax,ax ;Did it do it ok ?
  47. jz error ;Quit if it failed
  48. ;** Invoke the C routine to do any special initialization
  49. callc:
  50. call LIBMAIN ;Invoke the 'C' routine (result in AX)
  51. jmp short exit ;LibMain is responsible for stack clean up
  52. error:
  53. pop si ;Clean up stack on a LocalInit error
  54. pop es
  55. pop cx
  56. pop ds
  57. pop di
  58. exit:
  59. cEnd
  60. sEnd _thisseg
  61. END LibEntry