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.

95 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. dllmain.c
  5. Abstract:
  6. This module implements the initialization routines for RDP mini redirector network
  7. provider router interface DLL
  8. Author:
  9. Joy Chik 1/17/2000
  10. --*/
  11. #include <windows.h>
  12. #include <process.h>
  13. #include <windef.h>
  14. #include <ntsecapi.h>
  15. // TS Network Provider Name
  16. WCHAR ProviderName[MAX_PATH];
  17. UNICODE_STRING DrProviderName;
  18. #define TSNETWORKPROVIDER \
  19. L"SYSTEM\\CurrentControlSet\\Services\\RDPNP\\NetworkProvider"
  20. #define TSNETWORKPROVIDERNAME \
  21. L"Name"
  22. // NOTE:
  23. //
  24. // Function: DllMain
  25. //
  26. // Return: TRUE => Success
  27. // FALSE => Failure
  28. BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved)
  29. {
  30. BOOL bStatus = FALSE;
  31. WORD wVersionRequested;
  32. LONG status;
  33. HKEY regKey;
  34. LONG sz;
  35. switch (fdwReason) {
  36. case DLL_PROCESS_ATTACH:
  37. DisableThreadLibraryCalls(hDLLInst);
  38. bStatus = TRUE;
  39. break;
  40. case DLL_PROCESS_DETACH:
  41. bStatus = TRUE;
  42. break;
  43. default:
  44. break;
  45. }
  46. //
  47. // Read the TS Network Provider out of the registry
  48. //
  49. ProviderName[0] = L'\0';
  50. status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TSNETWORKPROVIDER, 0,
  51. KEY_READ, &regKey);
  52. if (status == ERROR_SUCCESS) {
  53. sz = sizeof(ProviderName);
  54. status = RegQueryValueEx(regKey, TSNETWORKPROVIDERNAME, NULL,
  55. NULL, (PBYTE)ProviderName, &sz);
  56. RegCloseKey(regKey);
  57. }
  58. if (status == ERROR_SUCCESS) {
  59. // make sure ProviderName is null terminated
  60. ProviderName[MAX_PATH - 1] = L'\0';
  61. }
  62. else {
  63. ProviderName[0] = L'\0';
  64. }
  65. DrProviderName.Length = wcslen(ProviderName) * sizeof(WCHAR);
  66. DrProviderName.MaximumLength = DrProviderName.Length + sizeof(WCHAR);
  67. DrProviderName.Buffer = ProviderName;
  68. return bStatus;
  69. }