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.

161 lines
4.7 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. pcache.h
  7. Definitions for password cache code
  8. FILE HISTORY:
  9. gregj 06/25/92 Created
  10. gregj 07/13/92 Finishing up lots more stuff, incl. classes
  11. gregj 04/23/93 Ported to Chicago environment
  12. gregj 09/16/93 Added memory-only entry support for Chicago
  13. gregj 11/30/95 Support for new file format
  14. gregj 08/13/96 Removed everything but MSPWL32 API definitions
  15. */
  16. #ifndef _PWLAPI_H_
  17. #define _PWLAPI_H_
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef unsigned char UCHAR;
  22. typedef UINT APIERR;
  23. #include <pcerr.h>
  24. #ifndef _SIZE_T_DEFINED
  25. # include <stddef.h>
  26. #endif
  27. #ifndef PCE_STRUCT_DEFINED
  28. #define PCE_STRUCT_DEFINED /* for benefit of pcache.h */
  29. struct PASSWORD_CACHE_ENTRY {
  30. USHORT cbEntry; /* size of this entry in bytes, incl. pad */
  31. /* high bit marks end of bucket */
  32. USHORT cbResource; /* size of resource name in bytes */
  33. USHORT cbPassword; /* size of password in bytes */
  34. UCHAR iEntry; /* index number of this entry, for MRU */
  35. UCHAR nType; /* type of entry (see below) */
  36. CHAR abResource[1]; /* resource name (may not be ASCIIZ at all) */
  37. // CHAR abPassword[cbPassword]; /* password (also may not be ASCIIZ) */
  38. // CHAR abPad[]; /* WORD padding */
  39. };
  40. typedef BOOL (*CACHECALLBACK)( struct PASSWORD_CACHE_ENTRY *pce, DWORD dwRefData );
  41. #endif /* PCE_STRUCT_DEFINED */
  42. /*
  43. the following nType values are only for the purposes of enumerating
  44. entries from the cache. note that PCE_ALL is reserved and should not
  45. be the nType value for any entry.
  46. */
  47. // NOTE BENE! All of the following MUST be synchronized with
  48. // \\flipper\wb\src\common\h\pcache.hxx!
  49. #define PCE_DOMAIN 0x01 /* entry is for a domain */
  50. #define PCE_SERVER 0x02 /* entry is for a server */
  51. #define PCE_UNC 0x03 /* entry is for a server/share combo */
  52. #define PCE_MAIL 0x04 /* entry is a mail password */
  53. #define PCE_SECURITY 0x05 /* entry is a security entry */
  54. #define PCE_MISC 0x06 /* entry is for some other resource */
  55. #define PCE_NDDE_WFW 0x10 /* entry is WFW DDE password */
  56. #define PCE_NDDE_NT 0x11 /* entry is NT DDE password */
  57. #define PCE_NW_SERVER 0x12 /* entry is Netware server*/
  58. #define PCE_PCONN 0x81 /* persistent connection */
  59. #define PCE_DISKSHARE 0x82 /* persistent disk share */
  60. #define PCE_PRINTSHARE 0x83 /* persistent print share */
  61. #define PCE_DOSPRINTSHARE 0x84 /* persistent DOS print share */
  62. #define PCE_NW_PSERVER 0x85 /* for NetWare Print Server login (MSPSRV.EXE) */
  63. #define PCE_NOTMRU 0x80 /* bit set if entry is exempt from MRU aging */
  64. #define PCE_ALL 0xff /* retrieve all entries */
  65. #define MAX_ENTRY_SIZE 250 /* so total file size < 64K */
  66. struct CACHE_ENTRY_INFO {
  67. USHORT cbResource; /* size of resource name in bytes */
  68. USHORT cbPassword; /* size of password in bytes */
  69. UCHAR iEntry; /* index number of entry */
  70. UCHAR nType; /* type of entry (see below) */
  71. USHORT dchResource; /* offset in buffer to resource name */
  72. USHORT dchPassword; /* offset in buffer to password */
  73. };
  74. /*
  75. Externally exposed API-like things.
  76. */
  77. typedef LPVOID HPWL;
  78. typedef HPWL *LPHPWL;
  79. APIERR OpenPasswordCache(
  80. LPHPWL lphCache,
  81. const CHAR *pszUsername,
  82. const CHAR *pszPassword,
  83. BOOL fWritable );
  84. APIERR ClosePasswordCache( HPWL hCache, BOOL fDiscardMemory );
  85. APIERR CreatePasswordCache(
  86. LPHPWL lphCache,
  87. const CHAR *pszUsername,
  88. const CHAR *pszPassword );
  89. APIERR DeletePasswordCache(const CHAR *pszUsername);
  90. APIERR CheckCacheVersion( HPWL hCache, ULONG ulVersion );
  91. APIERR LoadCacheImage( HPWL hCache );
  92. APIERR MakeCacheDirty( HPWL hCache );
  93. APIERR FindCacheResource(
  94. HPWL hCache,
  95. const CHAR *pbResource,
  96. WORD cbResource,
  97. CHAR *pbBuffer,
  98. WORD cbBuffer,
  99. UCHAR nType );
  100. APIERR DeleteCacheResource(
  101. HPWL hCache,
  102. const CHAR *pbResource,
  103. WORD cbResource,
  104. UCHAR nType );
  105. APIERR AddCacheResource(
  106. HPWL hCache,
  107. const CHAR *pbResource,
  108. WORD cbResource,
  109. const CHAR *pbPassword,
  110. WORD cbPassword,
  111. UCHAR nType,
  112. UINT fnFlags );
  113. #define PCE_MEMORYONLY 0x01
  114. APIERR EnumCacheResources(
  115. HPWL hCache,
  116. const CHAR *pbPrefix,
  117. WORD cbPrefix,
  118. UCHAR nType,
  119. CACHECALLBACK pfnCallback,
  120. DWORD dwRefData );
  121. APIERR UpdateCacheMRU(
  122. HPWL hCache,
  123. const struct CACHE_ENTRY_INFO *pce );
  124. APIERR SetCachePassword(
  125. HPWL hCache,
  126. const CHAR *pszNewPassword );
  127. APIERR GetCacheFileName(
  128. const CHAR *pszUsername,
  129. CHAR *pszFilename,
  130. UINT cbFilename );
  131. #ifdef __cplusplus
  132. } /* extern "C" */
  133. #endif
  134. #endif /* _PWLAPI_H_ */