mirror of https://github.com/tongzx/nt5src
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
152 lines
2.4 KiB
#define MAX_ENTRIES 20
|
|
|
|
#define AGE_LIMIT_VALID_ENTRIES 300
|
|
#define AGE_LIMIT_INVALID_ENTRIES 180
|
|
|
|
#define CACHE_HIT 1
|
|
#define CACHE_MISS 0
|
|
|
|
#define INVALID_ENTRY_TYPE 0
|
|
#define DOMAIN_ENTRY_TYPE 1
|
|
#define COMPUTER_ENTRY_TYPE 2
|
|
#define WORKGROUP_ENTRY_TYPE 3
|
|
#define DOMAIN_ENTRY_TYPE_RO 4
|
|
|
|
typedef struct _classentry{
|
|
BOOL bInUse;
|
|
SYSTEMTIME st;
|
|
BOOL fCacheHit;
|
|
DWORD dwElementType; // if it is type domain then we have a PDC
|
|
LPWSTR pszElementName;
|
|
union {
|
|
LPWSTR pszDomainName;
|
|
LPWSTR pszPDCName;
|
|
LPWSTR pszDCName;
|
|
} u;
|
|
|
|
}CLASSENTRY, *PCLASSENTRY;
|
|
|
|
class CObjNameCache {
|
|
|
|
public:
|
|
|
|
HRESULT
|
|
CObjNameCache::
|
|
addentry(
|
|
LPWSTR pszElementName,
|
|
BOOL fCacheHit,
|
|
DWORD dwElementType,
|
|
LPWSTR pszName // This will be PDC if Element= Domain
|
|
);
|
|
|
|
HRESULT
|
|
CObjNameCache::
|
|
findentry(
|
|
LPWSTR pszElementName,
|
|
PDWORD pdwIndex
|
|
);
|
|
|
|
HRESULT
|
|
CObjNameCache::
|
|
getentry(
|
|
LPWSTR pszElementName,
|
|
PBOOL pfHit,
|
|
PDWORD pdwEntryType,
|
|
LPWSTR pszName
|
|
);
|
|
|
|
|
|
HRESULT
|
|
CObjNameCache::
|
|
InvalidateStaleEntries();
|
|
|
|
CObjNameCache::
|
|
CObjNameCache();
|
|
|
|
CObjNameCache::
|
|
~CObjNameCache();
|
|
|
|
static
|
|
HRESULT
|
|
CObjNameCache::
|
|
CreateClassCache(
|
|
CObjNameCache FAR * FAR * ppClassCache
|
|
);
|
|
|
|
DWORD
|
|
CObjNameCache::
|
|
IsOlderThan(
|
|
DWORD i,
|
|
DWORD j
|
|
);
|
|
|
|
protected:
|
|
|
|
DWORD _dwMaxCacheSize;
|
|
|
|
CLASSENTRY _ClassEntries[MAX_ENTRIES];
|
|
|
|
CRITICAL_SECTION _cs;
|
|
|
|
};
|
|
|
|
|
|
HRESULT
|
|
WinNTGetCachedDCName(
|
|
LPWSTR pszDomainName,
|
|
LPWSTR pszPDCName,
|
|
DWORD dwFlags
|
|
);
|
|
|
|
|
|
HRESULT
|
|
WinNTGetCachedComputerName(
|
|
LPWSTR pszComputerName,
|
|
LPWSTR pszDomainName,
|
|
LPWSTR pszSAMName,
|
|
CWinNTCredentials& Credentials
|
|
);
|
|
|
|
//
|
|
// helper function for the above
|
|
//
|
|
HRESULT
|
|
WinNTGetCachedObject(
|
|
LPWSTR pszElementName,
|
|
DWORD dwElementType,
|
|
LPWSTR pszName,
|
|
LPWSTR pszSAMName,
|
|
DWORD dwFlags,
|
|
CWinNTCredentials& Credentials
|
|
);
|
|
|
|
|
|
HRESULT
|
|
WinNTGetCachedName(
|
|
LPWSTR pszElementName,
|
|
PDWORD pdwElementType,
|
|
LPWSTR pszName,
|
|
LPWSTR pszSAMName,
|
|
CWinNTCredentials& Credentials
|
|
);
|
|
|
|
LONG
|
|
TimeDifference(
|
|
SYSTEMTIME st1,
|
|
SYSTEMTIME st2
|
|
);
|
|
|
|
BOOL
|
|
IsAddressNumeric(
|
|
LPWSTR HostName
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|