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.

67 lines
1.6 KiB

  1. /***
  2. *loaddll.c - load or free a Dynamic Link Library
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _loaddll() and _unloaddll() - load and unload DLL
  8. *
  9. *Revision History:
  10. * 08-21-91 BWM Wrote module.
  11. * 09-30-93 GJF Resurrected for compatibility with NT SDK.
  12. * 02-06-98 GJF Changes for Win64: changed return type to intptr_t.
  13. *
  14. *******************************************************************************/
  15. #include <cruntime.h>
  16. #include <oscalls.h>
  17. #include <stdlib.h>
  18. #include <process.h>
  19. /***
  20. *int _loaddll(filename) - Load a dll
  21. *
  22. *Purpose:
  23. * Load a DLL into memory
  24. *
  25. *Entry:
  26. * char *filename - file to load
  27. *
  28. *Exit:
  29. * returns a unique DLL (module) handle if succeeds
  30. * returns 0 if fails
  31. *
  32. *Exceptions:
  33. *
  34. *******************************************************************************/
  35. intptr_t __cdecl _loaddll(char * szName)
  36. {
  37. return ((intptr_t)LoadLibrary(szName));
  38. }
  39. /***
  40. *int _unloaddll(handle) - Unload a dll
  41. *
  42. *Purpose:
  43. * Unloads a DLL. The resources of the DLL will be freed if no other
  44. * processes are using it.
  45. *
  46. *Entry:
  47. * int handle - handle from _loaddll
  48. *
  49. *Exit:
  50. * returns 0 if succeeds
  51. * returns DOS error if fails
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. int __cdecl _unloaddll(intptr_t hMod)
  57. {
  58. if (!FreeLibrary((HANDLE)hMod)) {
  59. return ((int)GetLastError());
  60. }
  61. return (0);
  62. }