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.

288 lines
6.5 KiB

  1. /*
  2. File : ASTRA_RAS.h
  3. */
  4. #include <ATK_RAS.h>
  5. static int siRasDllLoaded = RAS_DLL_NOT_LOADED ;
  6. static HINSTANCE hRasDllInst=NULL;
  7. static RASGETENTRYPROPERTIES pRasGetEntryProperties;
  8. static RASSETENTRYPROPERTIES pRasSetEntryProperties;
  9. static RASDELETEENTRY pRasDelEntry;
  10. static RASGETERRORSTRING pRasGetErrorString;
  11. static RASDIAL pRasDial;
  12. static RASHANGUP pRasHangup;
  13. static RASENUMDEVICES pRasEnumDevices;
  14. static RASENUMCONNECTIONS pRasEnumConnections;
  15. static RASGETCOUNTRYINFO pRasGetCountryInfo;
  16. static RASGETCOUNTRYINFO pRasGetCountryInfoA;
  17. static RASGETCONNECTIONSTATUS pRasGetConnectionStatus;
  18. int ATK_IsRasDllOk()
  19. {
  20. if(siRasDllLoaded == RAS_DLL_NOT_LOADED ) {
  21. hRasDllInst = LoadLibrary(_T("RASAPI32.DLL"));
  22. if(hRasDllInst == NULL) {
  23. siRasDllLoaded = ERROR_LOADING_RAS_DLL;
  24. }else {
  25. //
  26. //
  27. // Get All Function Pointers;
  28. #ifdef _UNICODE
  29. pRasGetEntryProperties = (RASGETENTRYPROPERTIES)
  30. GetProcAddress(hRasDllInst, "RasGetEntryPropertiesW");
  31. #else
  32. pRasGetEntryProperties = (RASGETENTRYPROPERTIES)
  33. GetProcAddress(hRasDllInst, "RasGetEntryPropertiesA");
  34. #endif
  35. #ifdef _UNICODE
  36. pRasSetEntryProperties= (RASSETENTRYPROPERTIES)
  37. GetProcAddress(hRasDllInst, "RasSetEntryPropertiesW");
  38. #else
  39. pRasSetEntryProperties= (RASSETENTRYPROPERTIES)
  40. GetProcAddress(hRasDllInst, "RasSetEntryPropertiesA");
  41. #endif
  42. #ifdef _UNICODE
  43. pRasDelEntry = (RASDELETEENTRY)
  44. GetProcAddress(hRasDllInst, "RasDeleteEntryW");
  45. #else
  46. pRasDelEntry = (RASDELETEENTRY)
  47. GetProcAddress(hRasDllInst, "RasDeleteEntryA");
  48. #endif
  49. #ifdef _UNICODE
  50. pRasGetErrorString = (RASGETERRORSTRING)
  51. GetProcAddress(hRasDllInst, "RasGetErrorStringW");
  52. #else
  53. pRasGetErrorString = (RASGETERRORSTRING)
  54. GetProcAddress(hRasDllInst, "RasGetErrorStringA");
  55. #endif
  56. #ifdef _UNICODE
  57. pRasDial = (RASDIAL)
  58. GetProcAddress(hRasDllInst, "RasDialW");
  59. #else
  60. pRasDial = (RASDIAL)
  61. GetProcAddress(hRasDllInst, "RasDialA");
  62. #endif
  63. #ifdef _UNICODE
  64. pRasHangup = (RASHANGUP)
  65. GetProcAddress(hRasDllInst, "RasHangUpW");
  66. #else
  67. pRasHangup = (RASHANGUP)
  68. GetProcAddress(hRasDllInst, "RasHangUpA");
  69. #endif
  70. #ifdef _UNICODE
  71. pRasEnumDevices = (RASENUMDEVICES )
  72. GetProcAddress(hRasDllInst, "RasEnumDevicesW");
  73. #else
  74. pRasEnumDevices = (RASENUMDEVICES )
  75. GetProcAddress(hRasDllInst, "RasEnumDevicesA");
  76. #endif
  77. #ifdef _UNICODE
  78. pRasEnumConnections = (RASENUMCONNECTIONS)
  79. GetProcAddress(hRasDllInst, "RasEnumConnectionsW");
  80. #else
  81. pRasEnumConnections = (RASENUMCONNECTIONS)
  82. GetProcAddress(hRasDllInst, "RasEnumConnectionsA");
  83. #endif
  84. #ifdef _UNICODE
  85. pRasGetCountryInfo = (RASGETCOUNTRYINFO)
  86. GetProcAddress(hRasDllInst, "RasGetCountryInfoW");
  87. #else
  88. pRasGetCountryInfo = (RASGETCOUNTRYINFO)
  89. GetProcAddress(hRasDllInst, "RasGetCountryInfoA");
  90. #endif
  91. pRasGetCountryInfoA = (RASGETCOUNTRYINFO)
  92. GetProcAddress(hRasDllInst, "RasGetCountryInfoA");
  93. #ifdef _UNICODE
  94. pRasGetConnectionStatus = (RASGETCONNECTIONSTATUS)
  95. GetProcAddress(hRasDllInst, "RasGetConnectionStatusW");
  96. #else
  97. pRasGetConnectionStatus = (RASGETCONNECTIONSTATUS)
  98. GetProcAddress(hRasDllInst, "RasGetConnectionStatusA");
  99. #endif
  100. siRasDllLoaded = RAS_DLL_LOADED;
  101. }
  102. }
  103. return siRasDllLoaded;
  104. }
  105. DWORD ATK_RasGetEntryProperties(
  106. LPTSTR lpszPhonebook,
  107. LPTSTR lpszEntry,
  108. LPRASENTRY lpRasEntry,
  109. LPDWORD lpdwEntryInfoSize,
  110. LPBYTE lpbDeviceInfo,
  111. LPDWORD lpdwDeviceInfoSize )
  112. {
  113. return (*pRasGetEntryProperties) ( lpszPhonebook,
  114. lpszEntry,
  115. lpRasEntry,
  116. lpdwEntryInfoSize,
  117. lpbDeviceInfo,
  118. lpdwDeviceInfoSize);
  119. }
  120. DWORD ATK_RasSetEntryProperties(
  121. LPTSTR lpszPhonebook,
  122. LPTSTR lpszEntry,
  123. LPRASENTRY lpRasEntry,
  124. DWORD dwEntryInfoSize,
  125. LPBYTE lpbDeviceInfo,
  126. DWORD dwDeviceInfoSize )
  127. {
  128. return (*pRasSetEntryProperties) (
  129. lpszPhonebook,
  130. lpszEntry,
  131. lpRasEntry,
  132. dwEntryInfoSize,
  133. lpbDeviceInfo,
  134. dwDeviceInfoSize);
  135. }
  136. DWORD ATK_RasDeleteEntry( LPTSTR lpszPhonebook,
  137. LPTSTR lpszEntry)
  138. {
  139. return (*pRasDelEntry)(lpszPhonebook,lpszEntry);
  140. }
  141. DWORD ATK_RasGetErrorString( UINT uErrorValue,
  142. LPTSTR lpszErrorString,
  143. DWORD cBufSize )
  144. {
  145. return (*pRasGetErrorString)(uErrorValue,lpszErrorString,cBufSize);
  146. }
  147. DWORD ATK_RasHangUp( HRASCONN hrasconn )
  148. {
  149. return (*pRasHangup)(hrasconn);
  150. }
  151. DWORD ATK_RasDial( LPRASDIALEXTENSIONS lpRasDial,
  152. LPTSTR lpPhBk,
  153. LPRASDIALPARAMS lpDialParam,
  154. DWORD dwNotifyType,
  155. LPVOID lpNotifier,
  156. LPHRASCONN lphRasConn)
  157. {
  158. return (*pRasDial) ( lpRasDial,
  159. lpPhBk,
  160. lpDialParam,
  161. dwNotifyType,
  162. lpNotifier,
  163. lphRasConn);
  164. }
  165. DWORD ATK_RasEnumDevices( LPRASDEVINFO lpRasDevInfo,
  166. LPDWORD lpcb,
  167. LPDWORD lpcDevices)
  168. {
  169. return (*pRasEnumDevices)(lpRasDevInfo,
  170. lpcb,
  171. lpcDevices);
  172. }
  173. DWORD ATK_RasEnumConnections ( LPRASCONN lprasconn,
  174. LPDWORD lpcb,
  175. LPDWORD lpcConnections)
  176. {
  177. return (*pRasEnumConnections) (lprasconn,lpcb,
  178. lpcConnections);
  179. }
  180. #define MAX_ACTIVE_RAS_CONNECTION 5
  181. /*
  182. Returns +VE value if there is an active connection
  183. */
  184. int IsDialupConnectionActive()
  185. {
  186. RASCONN RasConn[MAX_ACTIVE_RAS_CONNECTION];
  187. DWORD dwSizeConn,dwConnections,dwRet;
  188. int iCount;
  189. dwConnections = 0;
  190. for(iCount=0;iCount < MAX_ACTIVE_RAS_CONNECTION ;iCount++) {
  191. RasConn[iCount].dwSize= sizeof(RASCONN);
  192. }
  193. dwSizeConn = sizeof(RASCONN) * MAX_ACTIVE_RAS_CONNECTION;
  194. dwRet = ATK_RasEnumConnections ( RasConn,
  195. &dwSizeConn,
  196. &dwConnections);
  197. switch(dwRet)
  198. {
  199. case ERROR_BUFFER_TOO_SMALL :
  200. ;
  201. //cout << "\n Buffer Too Small "<< flush;
  202. case ERROR_NOT_ENOUGH_MEMORY :
  203. ;
  204. //cout << "\n Not enough memory "<< flush;
  205. default :
  206. break;
  207. }
  208. if(dwConnections) {
  209. return ((int)dwConnections);
  210. }else {
  211. return 0;
  212. }
  213. }
  214. DWORD ATK_RasGetCountryInfo( LPRASCTRYINFO lpRasCtryInfo,
  215. LPDWORD lpdwSize )
  216. {
  217. return (*pRasGetCountryInfo) (lpRasCtryInfo,lpdwSize);
  218. }
  219. DWORD ATK_RasGetCountryInfoA( LPRASCTRYINFO lpRasCtryInfo,
  220. LPDWORD lpdwSize )
  221. {
  222. return (*pRasGetCountryInfoA) (lpRasCtryInfo,lpdwSize);
  223. }
  224. DWORD ATK_RasGetConnectionStatus( HRASCONN hrasconn,LPRASCONNSTATUS lprasconnstatus )
  225. {
  226. return (*pRasGetConnectionStatus) (hrasconn,lprasconnstatus);
  227. }