a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/* $Id$ */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/** @file
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * IPRT - NtSetInformationFile wrapper.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/*
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Copyright (C) 2009-2011 Oracle Corporation
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * available from http://www.virtualbox.org. This file is free software;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * General Public License (GPL) as published by the Free Software
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * The contents of this file may alternatively be used under the terms
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * of the Common Development and Distribution License Version 1.0
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * VirtualBox OSE distribution, in which case the provisions of the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * CDDL are applicable instead of those of the GPL.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * You may elect to license modified versions of this file under the
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * terms and conditions of either the GPL or the CDDL or both.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/*******************************************************************************
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync* Header Files *
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync*******************************************************************************/
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/* APIs used here require DDK headers. */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync#include <wdm.h>
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/* Declare ntdll exports. */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncextern "C"
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync{
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncNTSYSAPI ULONG NTAPI RtlNtStatusToDosError (IN NTSTATUS Status);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncNTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE FileHandle,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync OUT PIO_STATUS_BLOCK IoStatusBlock,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync IN PVOID FileInformation,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync IN ULONG Length,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync IN FILE_INFORMATION_CLASS FileInformationClass);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync}
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync/** Windows/NT worker.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * @todo rename to rtFileWinSetAttributes */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsyncint rtFileNativeSetAttributes(HANDLE hFile, ULONG fAttributes)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync{
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync IO_STATUS_BLOCK IoStatusBlock;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync memset(&IoStatusBlock, 0, sizeof(IoStatusBlock));
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync /*
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * Members that are set 0 will not be modified on the file object.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * See http://msdn.microsoft.com/en-us/library/aa491634.aspx (the struct docs)
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync * for details.
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync FILE_BASIC_INFORMATION Info;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync memset(&Info, 0, sizeof(Info));
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync Info.FileAttributes = fAttributes;
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync /** @todo resolve dynamically to avoid dragging in NtDll? */
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync NTSTATUS Status = NtSetInformationFile(hFile,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync &IoStatusBlock,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync &Info,
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync sizeof(Info),
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync FileBasicInformation);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync return RtlNtStatusToDosError(Status);
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync}
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync
a3f3701cea1ba388e7c877955252bb7375eedebdvboxsync