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.

152 lines
2.4 KiB

  1. #define MAX_ENTRIES 20
  2. #define AGE_LIMIT_VALID_ENTRIES 300
  3. #define AGE_LIMIT_INVALID_ENTRIES 180
  4. #define CACHE_HIT 1
  5. #define CACHE_MISS 0
  6. #define INVALID_ENTRY_TYPE 0
  7. #define DOMAIN_ENTRY_TYPE 1
  8. #define COMPUTER_ENTRY_TYPE 2
  9. #define WORKGROUP_ENTRY_TYPE 3
  10. #define DOMAIN_ENTRY_TYPE_RO 4
  11. typedef struct _classentry{
  12. BOOL bInUse;
  13. SYSTEMTIME st;
  14. BOOL fCacheHit;
  15. DWORD dwElementType; // if it is type domain then we have a PDC
  16. LPWSTR pszElementName;
  17. union {
  18. LPWSTR pszDomainName;
  19. LPWSTR pszPDCName;
  20. LPWSTR pszDCName;
  21. } u;
  22. }CLASSENTRY, *PCLASSENTRY;
  23. class CObjNameCache {
  24. public:
  25. HRESULT
  26. CObjNameCache::
  27. addentry(
  28. LPWSTR pszElementName,
  29. BOOL fCacheHit,
  30. DWORD dwElementType,
  31. LPWSTR pszName // This will be PDC if Element= Domain
  32. );
  33. HRESULT
  34. CObjNameCache::
  35. findentry(
  36. LPWSTR pszElementName,
  37. PDWORD pdwIndex
  38. );
  39. HRESULT
  40. CObjNameCache::
  41. getentry(
  42. LPWSTR pszElementName,
  43. PBOOL pfHit,
  44. PDWORD pdwEntryType,
  45. LPWSTR pszName
  46. );
  47. HRESULT
  48. CObjNameCache::
  49. InvalidateStaleEntries();
  50. CObjNameCache::
  51. CObjNameCache();
  52. CObjNameCache::
  53. ~CObjNameCache();
  54. static
  55. HRESULT
  56. CObjNameCache::
  57. CreateClassCache(
  58. CObjNameCache FAR * FAR * ppClassCache
  59. );
  60. DWORD
  61. CObjNameCache::
  62. IsOlderThan(
  63. DWORD i,
  64. DWORD j
  65. );
  66. protected:
  67. DWORD _dwMaxCacheSize;
  68. CLASSENTRY _ClassEntries[MAX_ENTRIES];
  69. CRITICAL_SECTION _cs;
  70. };
  71. HRESULT
  72. WinNTGetCachedDCName(
  73. LPWSTR pszDomainName,
  74. LPWSTR pszPDCName,
  75. DWORD dwFlags
  76. );
  77. HRESULT
  78. WinNTGetCachedComputerName(
  79. LPWSTR pszComputerName,
  80. LPWSTR pszDomainName,
  81. LPWSTR pszSAMName,
  82. CWinNTCredentials& Credentials
  83. );
  84. //
  85. // helper function for the above
  86. //
  87. HRESULT
  88. WinNTGetCachedObject(
  89. LPWSTR pszElementName,
  90. DWORD dwElementType,
  91. LPWSTR pszName,
  92. LPWSTR pszSAMName,
  93. DWORD dwFlags,
  94. CWinNTCredentials& Credentials
  95. );
  96. HRESULT
  97. WinNTGetCachedName(
  98. LPWSTR pszElementName,
  99. PDWORD pdwElementType,
  100. LPWSTR pszName,
  101. LPWSTR pszSAMName,
  102. CWinNTCredentials& Credentials
  103. );
  104. LONG
  105. TimeDifference(
  106. SYSTEMTIME st1,
  107. SYSTEMTIME st2
  108. );
  109. BOOL
  110. IsAddressNumeric(
  111. LPWSTR HostName
  112. );
  113.