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.

181 lines
3.8 KiB

  1. #include <stdlib.h> // Has exit()
  2. #include <stdio.h> // Has printf() and related ...
  3. #include <nt.h>
  4. #include <ntrtl.h>
  5. #include <nturtl.h>
  6. #include <ntioapi.h>
  7. #include <rpc.h>
  8. #include <windows.h> // Needs to come after the NT header files. Has DWORD
  9. //#define RDB DataBuffer // This is a temp hack to allow differing underlying NT versions for Bill & Scott
  10. #define RDB GenericReparseBuffer.DataBuffer // Everyone Post-Bill.
  11. //
  12. // Private #defines
  13. //
  14. #define SHARE_ALL (FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)
  15. #define GetFileAttributeError 0xFFFFFFFF
  16. #define ATTRIBUTE_TYPE DWORD // ULONG, really
  17. #define GET_ATTRIBUTES(FileName, Attributes) Attributes = GetFileAttributes(FileName)
  18. #define IF_GET_ATTR_FAILS(FileName, Attributes) GET_ATTRIBUTES(FileName, Attributes); if (Attributes == GetFileAttributeError)
  19. //
  20. // FIX to pre-processor messing me up ...
  21. // Look at this some more! 97/01/23 --fc
  22. //
  23. #define DeleteFileA DeleteFile
  24. //
  25. // Global flags shared throughout.
  26. //
  27. // ParseArgs is the place where they get set and verified for mutual
  28. // consistency.
  29. //
  30. BOOLEAN fAlternateCreateDefault = FALSE;
  31. BOOLEAN fCopy = FALSE;
  32. BOOLEAN fCreate = FALSE;
  33. BOOLEAN fDelete = FALSE;
  34. BOOLEAN fDisplay = FALSE;
  35. BOOLEAN fModify = FALSE;
  36. BOOLEAN fRename = FALSE;
  37. BOOLEAN fVerbose = FALSE;
  38. BOOLEAN fVVerbose = FALSE;
  39. //
  40. // Signatures of internal routines.
  41. //
  42. void
  43. ParseArgs(
  44. int argc,
  45. char *argv[]
  46. );
  47. void
  48. Usage(
  49. void
  50. );
  51. BOOLEAN
  52. IsFlag(
  53. char *argv
  54. );
  55. NTSTATUS
  56. CreateSymbolicLink(
  57. CHAR *SourceName,
  58. CHAR *DestinationName,
  59. ATTRIBUTE_TYPE Attributes1,
  60. BOOLEAN VerboseFlag
  61. );
  62. NTSTATUS
  63. DeleteSymbolicLink(
  64. CHAR *DestinationName,
  65. ATTRIBUTE_TYPE Attributes2,
  66. BOOLEAN VerboseFlag
  67. );
  68. NTSTATUS
  69. DisplaySymbolicLink(
  70. CHAR *DestinationName,
  71. ATTRIBUTE_TYPE Attributes2,
  72. BOOLEAN VerboseFlag
  73. );
  74. NTSTATUS
  75. CreateEmptyFile(
  76. CHAR *DestinationName,
  77. ATTRIBUTE_TYPE Attributes1,
  78. BOOLEAN VerboseFlag
  79. );
  80. NTSTATUS
  81. CopySymbolicLink(
  82. CHAR *SourceName,
  83. CHAR *DestinationName,
  84. ATTRIBUTE_TYPE Attributes1,
  85. BOOLEAN VerboseFlag
  86. );
  87. NTSTATUS
  88. RenameSymbolicLink(
  89. CHAR *SourceName,
  90. CHAR *DestinationName,
  91. ATTRIBUTE_TYPE Attributes1,
  92. BOOLEAN VerboseFlag
  93. );
  94. //
  95. // Stuff crabbed from dd\sis\sfilter\sip.h
  96. //
  97. typedef GUID CSID, *PCSID;
  98. typedef LARGE_INTEGER LINK_INDEX, *PLINK_INDEX;
  99. typedef struct _SI_REPARSE_BUFFER {
  100. //
  101. // A version number so that we can change the reparse point format
  102. // and still properly handle old ones. This structure describes
  103. // version 4.
  104. //
  105. ULONG ReparsePointFormatVersion;
  106. ULONG Reserved;
  107. //
  108. // The id of the common store file.
  109. //
  110. CSID CSid;
  111. //
  112. // The index of this link file.
  113. //
  114. LINK_INDEX LinkIndex;
  115. //
  116. // The file ID of the link file.
  117. //
  118. LARGE_INTEGER LinkFileNtfsId;
  119. //
  120. // The file ID of the common store file.
  121. //
  122. LARGE_INTEGER CSFileNtfsId;
  123. //
  124. // A "131 hash" checksum of the contents of the
  125. // common store file.
  126. //
  127. LARGE_INTEGER CSChecksum;
  128. //
  129. // A "131 hash" checksum of this structure.
  130. // N.B. Must be last.
  131. //
  132. LARGE_INTEGER Checksum;
  133. } SI_REPARSE_BUFFER, *PSI_REPARSE_BUFFER;
  134. #define SIS_REPARSE_BUFFER_FORMAT_VERSION 4
  135. #define SIS_MAX_REPARSE_DATA_VALUE_LENGTH (sizeof(SI_REPARSE_BUFFER))
  136. #define SIS_REPARSE_DATA_SIZE (sizeof(REPARSE_DATA_BUFFER)+SIS_MAX_REPARSE_DATA_VALUE_LENGTH)