예제 #1
0
        /// <summary>
        /// Method to create an object from a set of object attributes.
        /// </summary>
        /// <param name="obj_attributes">The object attributes to create/open from.</param>
        /// <returns>The newly created object.</returns>
        protected override object CreateObject(ObjectAttributes obj_attributes)
        {
            using (NtFile file = (NtFile)base.CreateObject(obj_attributes))
            {
                if (LinkRoot == null && ResolveLinkName)
                {
                    LinkName = PSUtils.ResolveWin32Path(SessionState, LinkName);
                }
                if (LinkFlags == 0)
                {
                    file.CreateHardlink(LinkName, LinkRoot, ReplaceIfExists);
                }
                else
                {
                    if (ReplaceIfExists)
                    {
                        LinkFlags |= FileRenameInformationExFlags.ReplaceIfExists;
                    }
                    file.CreateHardlinkEx(LinkName, LinkRoot, LinkFlags);
                }
            }

            return(null);
        }