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.

122 lines
3.6 KiB

  1. //-----------------------------------------------------------------------------
  2. // RNAAPI class
  3. //
  4. // This class provides a series of cover function for the RNAPH/RASAPI32 dlls
  5. //
  6. // Created 1-29-96 ChrisK
  7. // ############################################################################
  8. // INCLUDES
  9. #include "pch.hpp"
  10. //#include "ras.h"
  11. #include <ras.h>
  12. #pragma pack (4)
  13. //#if !defined(WIN16)
  14. //#include <rnaph.h>
  15. //#endif
  16. #pragma pack ()
  17. #include "rnaapi.h"
  18. #include "debug.h"
  19. // ############################################################################
  20. // RNAAPI class
  21. CRNAAPI::CRNAAPI()
  22. {
  23. m_hInst = LoadLibrary("RASAPI32.DLL");
  24. m_hInst2 = LoadLibrary("RNAPH.DLL");
  25. m_fnRasEnumDeviecs = NULL;
  26. m_fnRasValidateEntryName = NULL;
  27. m_fnRasSetEntryProperties = NULL;
  28. m_fnRasGetEntryProperties = NULL;
  29. }
  30. // ############################################################################
  31. CRNAAPI::~CRNAAPI()
  32. {
  33. // Clean up
  34. if (m_hInst) FreeLibrary(m_hInst);
  35. if (m_hInst2) FreeLibrary(m_hInst2);
  36. }
  37. // ############################################################################
  38. DWORD CRNAAPI::RasEnumDevices(LPRASDEVINFO lpRasDevInfo, LPDWORD lpcb,
  39. LPDWORD lpcDevices)
  40. {
  41. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  42. // Look for the API if we haven't already found it
  43. LoadApi("RasEnumDevices",(FARPROC*)&m_fnRasEnumDeviecs);
  44. if (m_fnRasEnumDeviecs)
  45. dwRet = (*m_fnRasEnumDeviecs) (lpRasDevInfo, lpcb, lpcDevices);
  46. return dwRet;
  47. }
  48. // ############################################################################
  49. BOOL CRNAAPI::LoadApi(LPSTR pszFName, FARPROC* pfnProc)
  50. {
  51. if (*pfnProc == NULL)
  52. {
  53. // Look for the entry point in the first DLL
  54. if (m_hInst)
  55. *pfnProc = GetProcAddress(m_hInst,pszFName);
  56. // if that fails, look for the entry point in the second DLL
  57. if (m_hInst2 && !(*pfnProc))
  58. *pfnProc = GetProcAddress(m_hInst2,pszFName);
  59. }
  60. return (pfnProc != NULL);
  61. }
  62. // ############################################################################
  63. DWORD CRNAAPI::RasValidateEntryName(LPSTR lpszPhonebook,LPSTR lpszEntry)
  64. {
  65. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  66. // Look for the API if we haven't already found it
  67. LoadApi("RasValidateEntryName",(FARPROC*)&m_fnRasValidateEntryName);
  68. if (m_fnRasValidateEntryName)
  69. dwRet = (*m_fnRasValidateEntryName) (lpszPhonebook, lpszEntry);
  70. return dwRet;
  71. }
  72. // ############################################################################
  73. DWORD CRNAAPI::RasSetEntryProperties(LPSTR lpszPhonebook, LPSTR lpszEntry,
  74. LPBYTE lpbEntryInfo, DWORD dwEntryInfoSize,
  75. LPBYTE lpbDeviceInfo, DWORD dwDeviceInfoSize)
  76. {
  77. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  78. // Look for the API if we haven't already found it
  79. LoadApi("RasSetEntryProperties",(FARPROC*)&m_fnRasSetEntryProperties);
  80. if (m_fnRasSetEntryProperties)
  81. dwRet = (*m_fnRasSetEntryProperties) (lpszPhonebook, lpszEntry,
  82. lpbEntryInfo, dwEntryInfoSize,
  83. lpbDeviceInfo, dwDeviceInfoSize);
  84. return dwRet;
  85. }
  86. // ############################################################################
  87. DWORD CRNAAPI::RasGetEntryProperties(LPSTR lpszPhonebook, LPSTR lpszEntry,
  88. LPBYTE lpbEntryInfo, LPDWORD lpdwEntryInfoSize,
  89. LPBYTE lpbDeviceInfo, LPDWORD lpdwDeviceInfoSize)
  90. {
  91. DWORD dwRet = ERROR_DLL_NOT_FOUND;
  92. // Look for the API if we haven't already found it
  93. LoadApi("RasGetEntryProperties",(FARPROC*)&m_fnRasGetEntryProperties);
  94. if (m_fnRasGetEntryProperties)
  95. dwRet = (*m_fnRasGetEntryProperties) (lpszPhonebook, lpszEntry,
  96. lpbEntryInfo, lpdwEntryInfoSize,
  97. lpbDeviceInfo, lpdwDeviceInfoSize);
  98. return dwRet;
  99. }