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.

166 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. nlnetapi.c
  5. Abstract:
  6. This module loads Netapi.dll at runtime and sets up pointers to
  7. the APIs called by Msv1_0.
  8. Author:
  9. Dave Hart (DaveHart) 25-Mar-1992
  10. Environment:
  11. User mode Win32 - msv1_0 authentication package DLL
  12. Revision History:
  13. Dave Hart (DaveHart) 26-Mar-1992
  14. Added RxNetUserPasswordSet.
  15. Dave Hart (DaveHart) 30-May-1992
  16. Removed NetRemoteComputerSupports, added NetApiBufferAllocate.
  17. Chandana Surlu 21-Jul-1996
  18. Stolen from \\kernel\razzle3\src\security\msv1_0\nlnetapi.c
  19. Scott Field (sfield) 19-May-1999
  20. Use DELAYLOAD against ntdsapi.dll and netapi32.dll
  21. --*/
  22. #include "msp.h"
  23. #include "nlp.h"
  24. typedef NTSTATUS
  25. (*PI_NetNotifyNetlogonDllHandle) (
  26. IN PHANDLE Role
  27. );
  28. VOID
  29. NlpLoadNetlogonDll (
  30. VOID
  31. )
  32. /*++
  33. Routine Description:
  34. Uses Win32 LoadLibrary and GetProcAddress to get pointers to functions
  35. in Netlogon.dll that are called by Msv1_0.
  36. Arguments:
  37. None.
  38. Return Value:
  39. None. If successful, NlpNetlogonDllHandle is set to non-null and function
  40. pointers are setup.
  41. --*/
  42. {
  43. HANDLE hModule = NULL;
  44. PI_NetNotifyNetlogonDllHandle pI_NetNotifyNetlogonDllHandle = NULL;
  45. //
  46. // Load netlogon.dll also.
  47. //
  48. hModule = LoadLibraryA("netlogon");
  49. if (NULL == hModule) {
  50. #if DBG
  51. DbgPrint("Msv1_0: Unable to load netlogon.dll, Win32 error %d.\n", GetLastError());
  52. #endif
  53. goto Cleanup;
  54. }
  55. NlpNetLogonSamLogon = (PNETLOGON_SAM_LOGON_PROCEDURE)
  56. GetProcAddress(hModule, "NetrLogonSamLogon");
  57. if (NlpNetLogonSamLogon == NULL) {
  58. #if DBG
  59. DbgPrint(
  60. "Msv1_0: Can't find entrypoint NetrLogonSamLogon in netlogon.dll.\n"
  61. " Win32 error %d.\n", GetLastError());
  62. #endif
  63. goto Cleanup;
  64. }
  65. NlpNetLogonMixedDomain = (PNETLOGON_MIXED_DOMAIN_PROCEDURE)
  66. GetProcAddress(hModule, "I_NetLogonMixedDomain");
  67. if (NlpNetLogonMixedDomain == NULL) {
  68. #if DBG
  69. DbgPrint(
  70. "Msv1_0: Can't find entrypoint I_NetLogonMixedDomain in netlogon.dll.\n"
  71. " Win32 error %d.\n", GetLastError());
  72. #endif
  73. goto Cleanup;
  74. }
  75. NlpNetLogonSamLogoff = (PNETLOGON_SAM_LOGOFF_PROCEDURE)
  76. GetProcAddress(hModule, "NetrLogonSamLogoff");
  77. if (NlpNetLogonSamLogoff == NULL) {
  78. #if DBG
  79. DbgPrint(
  80. "Msv1_0: Can't find entrypoint NetrLogonSamLogoff in netlogon.dll.\n"
  81. " Win32 error %d.\n", GetLastError());
  82. #endif
  83. goto Cleanup;
  84. }
  85. //
  86. // Find the address of the I_NetNotifyNetlogonDllHandle procedure.
  87. // This is an optional procedure so don't complain if it isn't there.
  88. //
  89. pI_NetNotifyNetlogonDllHandle = (PI_NetNotifyNetlogonDllHandle)
  90. GetProcAddress( hModule, "I_NetNotifyNetlogonDllHandle" );
  91. //
  92. // Found all the functions needed, so indicate success.
  93. //
  94. NlpNetlogonDllHandle = hModule;
  95. hModule = NULL;
  96. //
  97. // Notify Netlogon that we've loaded it.
  98. //
  99. if( pI_NetNotifyNetlogonDllHandle != NULL ) {
  100. (VOID) (*pI_NetNotifyNetlogonDllHandle)( &NlpNetlogonDllHandle );
  101. }
  102. Cleanup:
  103. if ( hModule != NULL ) {
  104. FreeLibrary( hModule );
  105. }
  106. return;
  107. }