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.

165 lines
5.1 KiB

  1. #include <windows.h>
  2. #include <windowsx.h>
  3. #include <ole2.h>
  4. #include <wchar.h>
  5. #include <commctrl.h>
  6. #include <shellapi.h>
  7. #include <lm.h>
  8. #include <msshrui.h>
  9. extern "C"
  10. {
  11. #include <icanon.h>
  12. }
  13. #include <messages.h>
  14. #define DONT_WANT_SHELLDEBUG
  15. #include <shlobj.h>
  16. #include <shlobjp.h> // SHObjectProperties
  17. #include <shlwapi.h> // PathCombine
  18. #include <shlwapip.h> // IsOS
  19. #include <shfusion.h>
  20. #include <debug.h>
  21. #define ARRAYLEN(a) (sizeof(a) / sizeof((a)[0]))
  22. ////////////////////////////////////////////////////////////////////////////
  23. //
  24. // Hard-coded constants: user limit on shares
  25. //
  26. // Note: the maximum number of users on the workstation is hard-coded in the
  27. // server as 10. The max number on the server is essentially a dword, but we
  28. // are using the common up/down control, which only supports a word value.
  29. //
  30. // Note that DEFAULT_MAX_USERS must be <= both the server and workstation
  31. // maximums!
  32. #define MAX_USERS_ON_WORKSTATION 10
  33. #define MAX_USERS_ON_SERVER UD_MAXVAL
  34. #define DEFAULT_MAX_USERS 10
  35. ////////////////////////////////////////////////////////////////////////////
  36. //
  37. // functions
  38. //
  39. STDAPI CanShareFolderW(LPCWSTR pszPath);
  40. STDAPI ShowShareFolderUIW(HWND hwndParent, LPCWSTR pszPath);
  41. ////////////////////////////////////////////////////////////////////////////
  42. //
  43. // global variables
  44. //
  45. extern UINT g_NonOLEDLLRefs;
  46. extern HINSTANCE g_hInstance;
  47. extern BOOL g_fSharingEnabled;
  48. extern UINT g_uiMaxUsers; // max number of users based on product type
  49. extern WCHAR g_szAdminShare[]; // ADMIN$
  50. extern WCHAR g_szIpcShare[]; // IPC$
  51. extern const WCHAR c_szReadonlyShareSD[];
  52. //////////////////////////////////////////////////////////////////////////////
  53. //////////////////////////////////////////////////////////////////////////////
  54. //
  55. // Debugging stuff
  56. //
  57. //////////////////////////////////////////////////////////////////////////////
  58. //////////////////////////////////////////////////////////////////////////////
  59. //
  60. // Fix the warning levels
  61. //
  62. #pragma warning(3:4092) // sizeof returns 'unsigned long'
  63. #pragma warning(3:4121) // structure is sensitive to alignment
  64. #pragma warning(3:4125) // decimal digit in octal sequence
  65. #pragma warning(3:4130) // logical operation on address of string constant
  66. #pragma warning(3:4132) // const object should be initialized
  67. #pragma warning(4:4200) // nonstandard zero-sized array extension
  68. #pragma warning(4:4206) // Source File is empty
  69. #pragma warning(3:4208) // delete[exp] - exp evaluated but ignored
  70. #pragma warning(3:4212) // function declaration used ellipsis
  71. #pragma warning(3:4220) // varargs matched remaining parameters
  72. #pragma warning(4:4509) // SEH used in function w/ _trycontext
  73. #pragma warning(error:4700) // Local used w/o being initialized
  74. #pragma warning(3:4706) // assignment w/i conditional expression
  75. #pragma warning(3:4709) // command operator w/o index expression
  76. //////////////////////////////////////////////////////////////////////////////
  77. #if DBG == 1
  78. DECLARE_DEBUG(Sharing)
  79. #define appDebugOut(x) SharingInlineDebugOut x
  80. #define appAssert(x) Win4Assert(x)
  81. #define CHECK_HRESULT(hr) \
  82. if ( FAILED(hr) ) \
  83. { \
  84. appDebugOut((DEB_IERROR, \
  85. "**** ERROR RETURN <%s @line %d> -> 0x%08lx\n", \
  86. __FILE__, __LINE__, hr)); \
  87. }
  88. #define CHECK_NEW(p) \
  89. if ( NULL == (p) ) \
  90. { \
  91. appDebugOut((DEB_IERROR, \
  92. "**** NULL POINTER (OUT OF MEMORY!) <%s @line %d>\n", \
  93. __FILE__, __LINE__)); \
  94. }
  95. #define CHECK_NULL(p) \
  96. if ( NULL == (p) ) \
  97. { \
  98. appDebugOut((DEB_IERROR, \
  99. "**** NULL POINTER <%s @line %d>: %s\n", \
  100. __FILE__, __LINE__, #p)); \
  101. }
  102. #define CHECK_THIS appAssert(NULL != this && "'this' pointer is NULL")
  103. #define DECLARE_SIG ULONG __sig
  104. #define INIT_SIG(class) __sig = SIG_##class
  105. #define CHECK_SIG(class) \
  106. appAssert((NULL != this) && "'this' pointer is NULL"); \
  107. appAssert((SIG_##class == __sig) && "Signature doesn't match")
  108. #else // DBG == 1
  109. #define appDebugOut(x)
  110. #define appAssert(x)
  111. #define CHECK_HRESULT(hr)
  112. #define CHECK_NEW(p)
  113. #define CHECK_NULL(p)
  114. #define CHECK_THIS
  115. #define DECLARE_SIG
  116. #define INIT_SIG(class)
  117. #define CHECK_SIG(class)
  118. #endif // DBG == 1
  119. #if DBG == 1
  120. #define SIG_CSharingPropertyPage 0xabcdef00
  121. #define SIG_CShare 0xabcdef01
  122. #define SIG_CShareInfo 0xabcdef02
  123. #define SIG_CDlgNewShare 0xabcdef03
  124. #define SIG_CShareCF 0xabcdef04
  125. #define SIG_CBuffer 0xabcdef05
  126. #define SIG_CStrHashBucketElem 0xabcdef06
  127. #define SIG_CStrHashBucket 0xabcdef07
  128. #define SIG_CStrHashTable 0xabcdef08
  129. #define SIG_CShareCopyHook 0xabcdef09
  130. #define SIG_CShareBase 0xabcdef0a
  131. #define SIG_CSimpleSharingPage 0xabcdef0b
  132. #endif // DBG == 1