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.

78 lines
2.1 KiB

  1. // setext.c
  2. #include "oidtst.h"
  3. int
  4. FsTestSetExtendedInfo(
  5. IN HANDLE hFile,
  6. IN PUCHAR ExtInfoBuffer
  7. )
  8. {
  9. IO_STATUS_BLOCK IoStatusBlock;
  10. NTSTATUS Status;
  11. Status = NtFsControlFile( hFile, // file handle
  12. NULL, // event
  13. NULL, // apc routine
  14. NULL, // apc context
  15. &IoStatusBlock, // iosb
  16. FSCTL_SET_OBJECT_ID_EXTENDED, // FsControlCode
  17. ExtInfoBuffer, // input buffer
  18. 48, // input buffer length
  19. NULL, // OutputBuffer for data from the FS
  20. 0 ); // OutputBuffer Length
  21. return FsTestDecipherStatus( Status );
  22. }
  23. VOID
  24. _cdecl
  25. main(
  26. int argc,
  27. char *argv[]
  28. )
  29. {
  30. HANDLE hFile;
  31. UCHAR ExtInfoBuffer[48];
  32. int retval = 0;
  33. //
  34. // Get parameters
  35. //
  36. if (argc < 3) {
  37. printf("This program sets the object id extended info for a file (ntfs only).\n\n");
  38. printf("usage: %s filename ExtendedInfo\n", argv[0]);
  39. return;
  40. }
  41. hFile = CreateFile( argv[1],
  42. GENERIC_READ | GENERIC_WRITE,
  43. FILE_SHARE_READ | FILE_SHARE_WRITE,
  44. NULL,
  45. OPEN_EXISTING,
  46. 0,
  47. NULL );
  48. if ( hFile == INVALID_HANDLE_VALUE ) {
  49. printf( "Error opening file %s %x\n", argv[1], GetLastError() );
  50. return;
  51. }
  52. RtlZeroBytes( ExtInfoBuffer, sizeof( ExtInfoBuffer ) );
  53. sscanf( argv[2], "%s", &ExtInfoBuffer );
  54. printf( "\nUsing file:%s, ExtendedInfo:%s",
  55. argv[1],
  56. ExtInfoBuffer );
  57. FsTestSetExtendedInfo( hFile, ExtInfoBuffer );
  58. CloseHandle( hFile );
  59. return;
  60. }