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.

62 lines
1.7 KiB

  1. /***
  2. *getproc.c - Get the address of a procedure in a DLL.
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _getdllprocadd() - gets a procedure address by name or
  8. * ordinal
  9. *
  10. *Revision History:
  11. * 08-21-91 BWM Wrote module.
  12. * 09-30-93 GJF Resurrected for compatiblity with NT SDK.
  13. * 02-06-98 GJF Changes for Win64: changed return type to intptr_t.
  14. * 02-10-98 GJF Changes for Win64: changed 3rd arg type intptr_t.
  15. *
  16. *******************************************************************************/
  17. #include <cruntime.h>
  18. #include <oscalls.h>
  19. #include <process.h>
  20. /***
  21. *int (*)() _getdllprocaddr(handle, name, ordinal) - Get the address of a
  22. * DLL procedure specified by name or ordinal
  23. *
  24. *Purpose:
  25. *
  26. *Entry:
  27. * int handle - a DLL handle from _loaddll
  28. * char * name - Name of the procedure, or NULL to get by ordinal
  29. * int ordinal - Ordinal of the procedure, or -1 to get by name
  30. *
  31. *
  32. *Exit:
  33. * returns a pointer to the procedure if found
  34. * returns NULL if not found
  35. *
  36. *Exceptions:
  37. *
  38. *******************************************************************************/
  39. int (__cdecl * __cdecl _getdllprocaddr(
  40. intptr_t hMod,
  41. char * szProcName,
  42. intptr_t iOrdinal))()
  43. {
  44. typedef int (__cdecl * PFN)();
  45. if (szProcName == NULL) {
  46. if (iOrdinal <= 65535) {
  47. return ((PFN)GetProcAddress((HANDLE)hMod, (LPSTR)iOrdinal));
  48. }
  49. }
  50. else {
  51. if (iOrdinal == (intptr_t)(-1)) {
  52. return ((PFN)GetProcAddress((HANDLE)hMod, szProcName));
  53. }
  54. }
  55. return (NULL);
  56. }