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.
 
 
 
 
 
 

92 lines
2.7 KiB

// deloid.c
#include "oidtst.h"
int
FsTestDeleteOid(
IN HANDLE File
)
{
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
Status = NtFsControlFile( File, // file handle
NULL, // event
NULL, // apc routine
NULL, // apc context
&IoStatusBlock, // iosb
FSCTL_DELETE_OBJECT_ID, // FsControlCode
NULL, // input buffer
0, // input buffer length
NULL, // OutputBuffer for data from the FS
0 // OutputBuffer Length
);
return FsTestDecipherStatus( Status );
}
VOID
_cdecl
main(
int argc,
char *argv[]
)
{
HANDLE File;
IO_STATUS_BLOCK IoStatusBlock;
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjAttr;
ANSI_STRING AnsiName;
UNICODE_STRING UnicodeName;
char DriveNameBuffer[32];
strcpy( DriveNameBuffer, "\\DosDevices\\" );
strcat( DriveNameBuffer, argv[1] );
RtlInitAnsiString( &AnsiName, DriveNameBuffer );
Status = RtlAnsiStringToUnicodeString( &UnicodeName, &AnsiName, TRUE );
if (!NT_SUCCESS(Status)) {
printf( "Error initalizing strings" );
return;
}
if (argc < 2) {
printf("This program deletes the object id (if any) from a file (ntfs only).\n\n");
printf("usage: %s filename\n", argv[0]);
return;
}
RtlZeroMemory( &ObjAttr, sizeof(OBJECT_ATTRIBUTES) );
ObjAttr.Length = sizeof(OBJECT_ATTRIBUTES);
ObjAttr.ObjectName = &UnicodeName;
ObjAttr.Attributes = OBJ_CASE_INSENSITIVE;
Status = NtCreateFile( &File,
GENERIC_WRITE | GENERIC_ALL | STANDARD_RIGHTS_ALL,
&ObjAttr,
&IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_OPEN,
FILE_OPEN_FOR_BACKUP_INTENT,
NULL,
0 );
if (!NT_SUCCESS(Status)) {
printf( "Error opening file %s %x\n", argv[1], Status );
return;
}
printf( "\nUsing file:%s", argv[1] );
FsTestDeleteOid( File );
CloseHandle( File );
return;
}