public static EnlistmentHandle Create(
            EnlistmentAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            ResourceManagerHandle resourceManagerHandle,
            TransactionHandle transactionHandle,
            EnlistmentOptions createOptions,
            NotificationMask notificationMask,
            IntPtr enlistmentKey
            )
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                Win32.NtCreateEnlistment(
                    out handle,
                    access,
                    resourceManagerHandle,
                    transactionHandle,
                    ref oa,
                    createOptions,
                    notificationMask,
                    enlistmentKey
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return(new EnlistmentHandle(handle, true));
        }
Пример #2
0
        public DirectoryHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, DirectoryAccess access)
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if (KProcessHacker.Instance != null)
                {
                    handle = KProcessHacker.Instance.KphOpenDirectoryObject(access, oa).ToIntPtr();
                }
                else
                {
                    if ((status = Win32.NtOpenDirectoryObject(out handle, access, ref oa)) >= NtStatus.Error)
                    {
                        Win32.Throw(status);
                    }
                }
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #3
0
        public TransactionHandle(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            Guid unitOfWorkGuid,
            TmHandle tmHandle,
            TransactionAccess access
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if ((status = Win32.NtOpenTransaction(
                         out handle,
                         access,
                         ref oa,
                         ref unitOfWorkGuid,
                         tmHandle ?? IntPtr.Zero
                         )) >= NtStatus.Error)
                {
                    Win32.ThrowLastError(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #4
0
        public TransactionHandle(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            Guid unitOfWorkGuid,
            TmHandle tmHandle,
            TransactionAccess access
            )
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                Win32.NtOpenTransaction(
                    out handle,
                    access,
                    ref oa,
                    ref unitOfWorkGuid,
                    tmHandle ?? IntPtr.Zero
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #5
0
        public static PortHandle Create(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            int maxConnectionInfoLength,
            int maxMessageLength,
            int maxPoolUsage
            )
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                Win32.NtCreatePort(
                    out handle,
                    ref oa,
                    maxConnectionInfoLength,
                    maxMessageLength,
                    maxPoolUsage
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return(new PortHandle(handle, true));
        }
Пример #6
0
        public LegacyBBeBObject CreateLegacyTextObject()
        {
            m_PageBuffer.putTag(TagId.EndPage);

            byte[]      output = m_PageBuffer.GetBuffer();
            ObjectFlags flags  = 0;
            int         len    = (int)m_PageBuffer.Position;

            if (len > k_MinUncompressedLen)
            {
                // Allocate a buffer to compress into
                output = new byte[len];

                // Stash uncompressed size
                ByteBuffer.PackInt(output, 0, len);

                // Deflate text
                ICSharpCode.SharpZipLib.Zip.Compression.Deflater compresser =
                    new ICSharpCode.SharpZipLib.Zip.Compression.Deflater();
                compresser.SetInput(m_PageBuffer.GetBuffer(), 0, len);
                compresser.Finish();
                len   = compresser.Deflate(output, 4, output.Length - 4) + 4;
                flags = ObjectFlags.COMPRESSED;
            }

            return(new LegacyBBeBObject(m_Book, ObjectType.Text, flags, output, len));
        }
Пример #7
0
        public static PortHandle CreateWaitable(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            int maxConnectionInfoLength,
            int maxMessageLength,
            int maxPoolUsage
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if ((status = Win32.NtCreateWaitablePort(
                         out handle,
                         ref oa,
                         maxConnectionInfoLength,
                         maxMessageLength,
                         maxPoolUsage
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new PortHandle(handle, true));
        }
Пример #8
0
        private NJS_OBJECT(byte[] file, int address, uint imageBase, ModelFormat format, NJS_OBJECT parent, Dictionary <int, string> labels, Dictionary <int, Attach> attaches)
        {
            if (labels.ContainsKey(address))
            {
                Name = labels[address];
            }
            else
            {
                Name = "object_" + address.ToString("X8");
            }
            ObjectFlags flags = (ObjectFlags)ByteConverter.ToInt32(file, address);

            RotateZYX = (flags & ObjectFlags.RotateZYX) == ObjectFlags.RotateZYX;
            Animate   = (flags & ObjectFlags.NoAnimate) == 0;
            Morph     = (flags & ObjectFlags.NoMorph) == 0;
            int tmpaddr = ByteConverter.ToInt32(file, address + 4);

            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                if (attaches != null && attaches.ContainsKey(tmpaddr))
                {
                    Attach = attaches[tmpaddr];
                }
                else
                {
                    Attach = Attach.Load(file, tmpaddr, imageBase, format, labels);
                    attaches.Add(tmpaddr, Attach);
                }
            }
            Position = new Vertex(file, address + 8);
            Rotation = new Rotation(file, address + 0x14);
            Scale    = new Vertex(file, address + 0x20);
            Parent   = parent;
            children = new List <NJS_OBJECT>();
            Children = new ReadOnlyCollection <NJS_OBJECT>(children);
            NJS_OBJECT child = null;

            tmpaddr = ByteConverter.ToInt32(file, address + 0x2C);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                child   = new NJS_OBJECT(file, tmpaddr, imageBase, format, this, labels, attaches);
            }
            while (child != null)
            {
                children.Add(child);
                child = child.Sibling;
            }
            tmpaddr = ByteConverter.ToInt32(file, address + 0x30);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                Sibling = new NJS_OBJECT(file, tmpaddr, imageBase, format, parent, labels, attaches);
            }

            //Assimp.AssimpContext context = new AssimpContext();
            //Scene scene = context.ImportFile("F:\\untitled.obj", PostProcessSteps.Triangulate);
            //AssimpLoad(scene, scene.RootNode);
        }
Пример #9
0
        public static KeyHandle Create(
            KeyAccess access,
            string name,
            ObjectFlags objectFlags,
            KeyHandle rootDirectory,
            RegOptions createOptions,
            out KeyCreationDisposition creationDisposition
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if ((status = Win32.NtCreateKey(
                         out handle,
                         access,
                         ref oa,
                         0,
                         IntPtr.Zero,
                         createOptions,
                         out creationDisposition
                         )) >= NtStatus.Error)
                {
                    Win32.ThrowLastError(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new KeyHandle(handle, true));
        }
Пример #10
0
        public static MailslotHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            int quota,
            int maxMessageSize,
            long readTimeout,
            FileCreateOptions createOptions
            )
        {
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock    isb;
            IntPtr           handle;

            try
            {
                Win32.NtCreateMailslotFile(
                    out handle,
                    access,
                    ref oa,
                    out isb,
                    createOptions,
                    quota,
                    maxMessageSize,
                    ref readTimeout
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return(new MailslotHandle(handle, true));
        }
Пример #11
0
        public TmHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory, TmAccess access)
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if ((status = Win32.NtOpenTransactionManager(
                         out handle,
                         access,
                         ref oa,
                         IntPtr.Zero,
                         IntPtr.Zero,
                         0
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #12
0
        public static ThreadHandle Create(
            ThreadAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            ProcessHandle processHandle,
            out ClientId clientId,
            ref Context threadContext,
            ref InitialTeb initialTeb,
            bool createSuspended
            )
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                Win32.NtCreateThread(
                    out handle,
                    access,
                    ref oa,
                    processHandle,
                    out clientId,
                    ref threadContext,
                    ref initialTeb,
                    createSuspended
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return(new ThreadHandle(handle, true));
        }
Пример #13
0
        public bool TryGetLength(object value, out uint length, string scenario = default, string @case = default)
        {
            ObjectFlags flag   = value == null ? ObjectFlags.IsNull : ObjectFlags.None;
            bool        result = BinarySerializer.TryGetLength(flag, out length);

            switch (flag)
            {
            case ObjectFlags.None:
                IEnumerable <object> _value = (IEnumerable <object>)value;
                Type type  = value.GetType().GenericTypeArguments[0];
                int  count = Enumerable.Count(_value);
                result = BinarySerializer.TryGetLength(count, out length);
                for (int i0 = 0; i0 < count; i0++)
                {
                    result &= BinarySerializer.TryGetLength(type, Enumerable.ElementAt(_value, i0), out uint _length, scenario, @case);
                    length += _length;
                }
                break;

            default:
            case ObjectFlags.IsNull:

                break;
            }
            return(result);
        }
Пример #14
0
        public int Deserialize()
        {
            // TODO: Handle dependencies
            // 2nd pass after this to resolve names etc?
            _ClassIndex = Data.ReadInt32();
            ClassName = CurrentPCC.GetClassName(_ClassIndex);
            _SuperIndex = Data.ReadInt32();
            _OuterIndex = Data.ReadInt32();

            _ObjectNameRef = Data.ReadNameRef();
            ObjectName = CurrentPCC.GetName(_ObjectNameRef);
            if (_ObjectNameRef.ModNumber > -1)
                ObjectName += "_" + _ObjectNameRef.ModNumber; // TODO: correct?
            _ArchetypeIndex = Data.ReadInt32();
            ObjectFlags = (ObjectFlags)Data.ReadUInt64();

            Size = Data.ReadUInt32();
            FileOffset = Data.ReadUInt32();
            ExportFlags = (ExportFlags)Data.ReadUInt32();

            // TODO: save / figure these out!
            var netObjectCount = Data.ReadInt32(); // Skip netObjectCount
            Data.ReadRawData(netObjectCount * 4); // Skip netObjects

            Data.ReadRawData(16); // Skip package GUID's
            Data.ReadRawData(4); // Skip package flags

            return (int)SizeInBytes + 4 * netObjectCount;
        }
        /// <summary>
        /// Create the binary from the buffer
        /// </summary>
        /// <param name="binary">The binary</param>
        /// <param name="offset">The offset in the binary</param>
        public override void GetBinaryForm(byte[] binary, int offset)
        {
            int len = Size;

            binary[offset++] = (byte)this.AceType;
            binary[offset++] = (byte)this.AceFlags;
            DtypUtility.WriteUInt16ToByteArray((ushort)len, binary, offset); offset     += 2;
            DtypUtility.WriteInt32ToByteArray(_AccessMask, binary, offset); offset      += 4;
            DtypUtility.WriteInt32ToByteArray((int)ObjectFlags, binary, offset); offset += 4;

            if (ObjectFlags.HasFlag(_ObjectAceFlags.ObjectAceTypePresent))
            {
                DtypUtility.WriteGuid(ObjectType, binary, offset);
                offset += 16;
            }
            if (ObjectFlags.HasFlag(_ObjectAceFlags.InheritedObjectAceTypePresent))
            {
                DtypUtility.WriteGuid(InheritedObjectType, binary, offset);
                offset += 16;
            }

            _SecurityIdentifier.GetBinaryForm(binary, offset);
            offset += _SecurityIdentifier.Size;

            if (this.applicationData != null)
            {
                Array.Copy(this.applicationData, 0, binary, offset, this.applicationData.Length);
                offset += this.applicationData.Length;
            }
        }
Пример #16
0
        public int Deserialize()
        {
            // TODO: Handle dependencies
            // 2nd pass after this to resolve names etc?
            _ClassIndex = Data.ReadInt32();
            ClassName   = CurrentPCC.GetClassName(_ClassIndex);
            _SuperIndex = Data.ReadInt32();
            _OuterIndex = Data.ReadInt32();

            _ObjectNameRef = Data.ReadNameRef();
            ObjectName     = CurrentPCC.GetName(_ObjectNameRef);
            if (_ObjectNameRef.ModNumber > -1)
            {
                ObjectName += "_" + _ObjectNameRef.ModNumber; // TODO: correct?
            }
            _ArchetypeIndex = Data.ReadInt32();
            ObjectFlags     = (ObjectFlags)Data.ReadUInt64();

            Size        = Data.ReadUInt32();
            FileOffset  = Data.ReadUInt32();
            ExportFlags = (ExportFlags)Data.ReadUInt32();

            // TODO: save / figure these out!
            var netObjectCount = Data.ReadInt32(); // Skip netObjectCount

            Data.ReadRawData(netObjectCount * 4);  // Skip netObjects

            Data.ReadRawData(16);                  // Skip package GUID's
            Data.ReadRawData(4);                   // Skip package flags

            return((int)SizeInBytes + 4 * netObjectCount);
        }
Пример #17
0
        public static TmHandle Create(
            TmAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            string logFileName,
            TmOptions createOptions
            )
        {
            ObjectAttributes oa             = new ObjectAttributes(name, objectFlags, rootDirectory);
            UnicodeString    logFileNameStr = new UnicodeString(logFileName);
            IntPtr           handle;

            try
            {
                Win32.NtCreateTransactionManager(
                    out handle,
                    access,
                    ref oa,
                    ref logFileNameStr,
                    createOptions,
                    0
                    ).ThrowIf();
            }
            finally
            {
                logFileNameStr.Dispose();
                oa.Dispose();
            }

            return(new TmHandle(handle, true));
        }
Пример #18
0
        public bool TrySerialize(BinaryWriter writer, object value, string scenario = default, string @case = default)
        {
            bool        result   = true;
            ObjectFlags flag     = ObjectFlags.None;
            TypeInfo    typeInfo = value?.GetType().GetTypeInfo();

            if (typeInfo == null)
            {
                flag    = ObjectFlags.IsNull;
                result &= BinarySerializer.TrySerialize(writer, flag);
            }
            else if (!typeInfo.IsValueType)
            {
                result &= BinarySerializer.TrySerialize(writer, flag);
            }
            switch (flag)
            {
            case ObjectFlags.None:
                IEnumerable <FieldInfo>    fields     = typeInfo.DeclaredFields.Where(x => FieldSearcher(x, scenario, @case));
                IEnumerable <PropertyInfo> properties = typeInfo.DeclaredProperties.Where(x => PropertySearcher(x, scenario, @case));
                uint count = (uint)(fields.Count() + properties.Count());
                result &= BinarySerializer.TrySerialize(writer, count);
                foreach (FieldInfo fi in fields)
                {
                    SerializationScenarioAttribute attr = fi.GetCustomAttributes <SerializationScenarioAttribute>().FirstOrDefault(x => x.Scenario == scenario && x.Case == @case);
                    if (attr != null)
                    {
                        ISerializationScenario wrapper = BinarySerializer.Scenarios.Find(x => x.Name == scenario);
                        MethodInfo             method  = wrapper.GetType().GetTypeInfo().GetDeclaredMethod("Wrap").MakeGenericMethod(fi.FieldType, attr.WrappedType);
                        object field = method.Invoke(wrapper, new object[] { fi.GetValue(value), @case });
                        result &= BinarySerializer.TrySerialize(writer, attr.WrappedType, field);
                    }
                    else
                    {
                        result &= BinarySerializer.TrySerialize(writer, fi.FieldType, fi.GetValue(value));
                    }
                }
                foreach (PropertyInfo pi in properties)
                {
                    SerializationScenarioAttribute attr = pi.GetCustomAttributes <SerializationScenarioAttribute>().FirstOrDefault(x => x.Scenario == scenario && x.Case == @case);
                    if (attr != null)
                    {
                        ISerializationScenario wrapper = BinarySerializer.Scenarios.Find(x => x.Name == scenario);
                        MethodInfo             method  = wrapper.GetType().GetTypeInfo().GetDeclaredMethod("Wrap").MakeGenericMethod(pi.PropertyType, attr.WrappedType);
                        object field = method.Invoke(wrapper, new object[] { pi.GetValue(value), @case });
                        result &= BinarySerializer.TrySerialize(writer, attr.WrappedType, field);
                    }
                    else
                    {
                        result &= BinarySerializer.TrySerialize(writer, pi.PropertyType, pi.GetValue(value));
                    }
                }
                break;

            default:
            case ObjectFlags.IsNull:
                break;
            }
            return(result);
        }
Пример #19
0
        public static MailslotHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            int quota,
            int maxMessageSize,
            long readTimeout,
            FileCreateOptions createOptions
            )
        {
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock isb;
            IntPtr handle;

            try
            {
                Win32.NtCreateMailslotFile(
                    out handle,
                    access,
                    ref oa,
                    out isb,
                    createOptions,
                    quota,
                    maxMessageSize,
                    ref readTimeout
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            return new MailslotHandle(handle, true);
        }
        public EnlistmentHandle(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            ResourceManagerHandle resourceManagerHandle,
            Guid guid,
            EnlistmentAccess access
            )
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                Win32.NtOpenEnlistment(
                    out handle,
                    access,
                    resourceManagerHandle,
                    ref guid,
                    ref oa
                    ).ThrowIf();
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #21
0
        public static TokenHandle Create(
            TokenAccess access,
            ObjectFlags objectFlags,
            TokenHandle existingTokenHandle,
            TokenType tokenType,
            Sid user,
            Sid[] groups,
            PrivilegeSet privileges,
            Sid owner,
            Sid primaryGroup
            )
        {
            var statistics = existingTokenHandle.GetStatistics();

            return(Create(
                       access,
                       null,
                       objectFlags,
                       null,
                       tokenType,
                       statistics.AuthenticationId,
                       statistics.ExpirationTime,
                       user,
                       groups,
                       privileges,
                       owner,
                       primaryGroup,
                       null,
                       _phTokenSource
                       ));
        }
Пример #22
0
        public ResourceManagerHandle(
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            TmHandle tmHandle,
            Guid guid,
            ResourceManagerAccess access
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if ((status = Win32.NtOpenResourceManager(
                         out handle,
                         access,
                         tmHandle,
                         ref guid,
                         ref oa
                         )) >= NtStatus.Error)
                {
                    Win32.ThrowLastError(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            this.Handle = handle;
        }
Пример #23
0
        public const uint MODERATOR = 0xFF0078FF; // kinda blue (0, 120, 255)
#endif

        /// <summary>
        /// Returns a 32bit color based on ObjectFlags.
        /// </summary>
        /// <param name="Flags"></param>
        /// <returns></returns>
        public static uint GetColorFor(ObjectFlags Flags)
        {
#if !VANILLA
            // use default namecolor or override with magic item color
            uint color = (Flags.IsMagicItem) ? MAGIC : Flags.NameColor;

            // openmeridian has a name-color transferred from server in flags
            // however it has opacity set to 0, so we make it full opaque here.
            color |= 0xFF000000;

            // lots of kod objects have black as color
            // which is turned into white as a workaround here
            return(color != 0xFF000000 ? color : 0xFFFFFFFF);
#else
            if (Flags.Player == ObjectFlags.PlayerType.SuperDM)
            {
                return(SUPERDM);
            }

            else if (Flags.Player == ObjectFlags.PlayerType.EventChar)
            {
                return(EVENTCHAR);
            }

            else if (Flags.Player == ObjectFlags.PlayerType.Creator)
            {
                return(CREATOR);
            }

            else if (Flags.Player == ObjectFlags.PlayerType.DM)
            {
                return(DM);
            }

            else if (Flags.Drawing == ObjectFlags.DrawingType.Invisible)
            {
                return(NORMAL);
            }

            else if (Flags.Drawing == ObjectFlags.DrawingType.Black)
            {
                return(BLACK);
            }

            else if (Flags.Player == ObjectFlags.PlayerType.Killer)
            {
                return(KILLER);
            }

            else if (Flags.Player == ObjectFlags.PlayerType.Outlaw)
            {
                return(OUTLAW);
            }

            else
            {
                return(NORMAL);
            }
#endif
        }
Пример #24
0
        public override string ToString()
        {
            StringBuilder ret = new StringBuilder();

            ret.AppendLine(string.Format("{0} (Id = {1})", this.GetType().Name, this.ID));

            ByteArrayTag refTable    = RefTableTag;
            MemoryStream tableStream = new MemoryStream(refTable.Value);
            BinaryReader tableReader = new BinaryReader(tableStream);

            ObjectFlags infoType = Flags;

            uint dwNumRectObjIds, i;

            switch (infoType)
            {
            case ObjectFlags.PAGE_LAYOUT:
                ret.AppendLine("   Flags: PAGE_LAYOUT");
                dwNumRectObjIds = tableReader.ReadUInt32();
                ret.AppendLine("   " + dwNumRectObjIds + " Rectangle object(s)");
                ret.AppendLine("   ------------------------------");
                for (i = 0; i < dwNumRectObjIds; i++)
                {
                    ret.AppendLine(string.Format("   [{0}] ID: {1}",
                                                 i, tableReader.ReadUInt32()));
                    byte[] data = tableReader.ReadBytes(16);
                }
                long bytesLeft = tableReader.BaseStream.Length - tableReader.BaseStream.Position;
                if (bytesLeft != 0)
                {
                    ret.AppendLine("  Left: " + bytesLeft + " bytes");
                }
                break;

            case ObjectFlags.PAGE_NUMBERS:
                ret.AppendLine("   Flags: PAGE_NUMBERS");
                dwNumRectObjIds = tableReader.ReadUInt32();
                ret.AppendLine("   " + dwNumRectObjIds + " Page object(s)");
                ret.AppendLine("   ------------------------------");
                for (i = 0; i < dwNumRectObjIds; i++)
                {
                    ret.AppendLine(string.Format("   [{0}] ID = {1}, Count = {2}",
                                                 i, tableReader.ReadUInt32(), tableReader.ReadUInt16()));
                }
                break;

            default:
                ret.AppendLine("   Flags: Unknown=" + infoType.ToString());
                while (tableReader.BaseStream.Position < tableReader.BaseStream.Length)
                {
                    uint id = tableReader.ReadUInt16();
                    ret.Append(id);
                    ret.Append(",");
                }
                break;
            }

            return(ret.ToString());
        }
Пример #25
0
        public LegacyBBeBObject(LegacyBBeB book, ObjectType aType, ObjectFlags aDataFlags, byte[] data, long dataLen)
        {
            m_Id    = book.GetNextObjId();
            m_eType = aType;
            book.AddObject(this);

            AddStreamData(aDataFlags, data, dataLen);
        }
Пример #26
0
        public OnlinePlayer(uint ID, uint NameRID, string Name, ObjectFlags Flags)
            : base(ID)
        {
            this.nameRID = NameRID;
            this.name    = Name;

            this.flags.UpdateFromModel(Flags, false);
        }
Пример #27
0
        public LegacyBBeBObject(LegacyBBeB book, ObjectType aType, ObjectFlags aDataFlags, ByteBuffer data)
        {
            m_Id    = book.GetNextObjId();
            m_eType = aType;
            book.AddObject(this);

            AddStreamData(aDataFlags, data.GetBuffer(), data.Length);
        }
Пример #28
0
        public static NamedPipeHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            FileShareMode shareMode,
            FileCreationDisposition creationDisposition,
            FileCreateOptions createOptions,
            PipeType type,
            PipeType readMode,
            PipeCompletionMode completionMode,
            int maximumInstances,
            int inboundQuota,
            int outboundQuota,
            long defaultTimeout
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock    isb;
            IntPtr           handle;

            // If a timeout wasn't specified, use a default value.
            if (defaultTimeout == 0)
            {
                defaultTimeout = -50 * Win32.TimeMsTo100Ns; // 50 milliseconds
            }
            try
            {
                if ((status = Win32.NtCreateNamedPipeFile(
                         out handle,
                         access,
                         ref oa,
                         out isb,
                         shareMode,
                         creationDisposition,
                         createOptions,
                         type,
                         readMode,
                         completionMode,
                         maximumInstances,
                         inboundQuota,
                         outboundQuota,
                         ref defaultTimeout
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new NamedPipeHandle(handle, true));
        }
Пример #29
0
 public PackedNativeUnityEngineObject(string name, int instanceId, int size, int nativeTypeArrayIndex, UnityEngine.HideFlags hideFlags, ObjectFlags flags, long nativeObjectAddress)
 {
     m_Name                 = name;
     m_InstanceId           = instanceId;
     m_Size                 = size;
     m_NativeTypeArrayIndex = nativeTypeArrayIndex;
     m_HideFlags            = hideFlags;
     m_Flags                = flags;
     m_NativeObjectAddress  = nativeObjectAddress;
 }
Пример #30
0
        public static SectionHandle Create(
            SectionAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            long maximumSize,
            SectionAttributes sectionAttributes,
            MemoryProtection pageAttributes,
            FileHandle fileHandle
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            try
            {
                if (maximumSize != 0)
                {
                    if ((status = Win32.NtCreateSection(
                             out handle,
                             access,
                             ref oa,
                             ref maximumSize,
                             pageAttributes,
                             sectionAttributes,
                             fileHandle ?? IntPtr.Zero
                             )) >= NtStatus.Error)
                    {
                        Win32.Throw(status);
                    }
                }
                else
                {
                    if ((status = Win32.NtCreateSection(
                             out handle,
                             access,
                             ref oa,
                             IntPtr.Zero,
                             pageAttributes,
                             sectionAttributes,
                             fileHandle ?? IntPtr.Zero
                             )) >= NtStatus.Error)
                    {
                        Win32.Throw(status);
                    }
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new SectionHandle(handle, true));
        }
Пример #31
0
        public static TransactionHandle Create(
            TransactionAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            Guid unitOfWorkGuid,
            TmHandle tmHandle,
            TransactionOptions createOptions,
            long timeout,
            string description
            )
        {
            NtStatus         status;
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr           handle;

            if (unitOfWorkGuid == Guid.Empty)
            {
                unitOfWorkGuid = Guid.NewGuid();
            }

            try
            {
                UnicodeString descriptionStr = new UnicodeString(description);

                try
                {
                    if ((status = Win32.NtCreateTransaction(
                             out handle,
                             access,
                             ref oa,
                             ref unitOfWorkGuid,
                             tmHandle ?? IntPtr.Zero,
                             createOptions,
                             0,
                             0,
                             ref timeout,
                             ref descriptionStr
                             )) >= NtStatus.Error)
                    {
                        Win32.Throw(status);
                    }
                }
                finally
                {
                    descriptionStr.Dispose();
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new TransactionHandle(handle, true));
        }
Пример #32
0
        public static TokenHandle Create(
            TokenAccess access,
            string name,
            ObjectFlags objectFlags,
            DirectoryHandle rootDirectory,
            TokenType tokenType,
            Luid authenticationId,
            long expirationTime,
            Sid user,
            Sid[] groups,
            PrivilegeSet privileges,
            Sid owner,
            Sid primaryGroup,
            Acl defaultDacl,
            TokenSource source
            )
        {
            NtStatus          status;
            TokenUser         tokenUser         = new TokenUser(user);
            TokenGroups       tokenGroups       = new TokenGroups(groups);
            TokenPrivileges   tokenPrivileges   = new TokenPrivileges(privileges);
            TokenOwner        tokenOwner        = new TokenOwner(owner);
            TokenPrimaryGroup tokenPrimaryGroup = new TokenPrimaryGroup(primaryGroup);
            TokenDefaultDacl  tokenDefaultDacl  = new TokenDefaultDacl(defaultDacl);
            ObjectAttributes  oa = new ObjectAttributes(name, objectFlags, rootDirectory);
            IntPtr            handle;

            try
            {
                if ((status = Win32.NtCreateToken(
                         out handle,
                         access,
                         ref oa,
                         tokenType,
                         ref authenticationId,
                         ref expirationTime,
                         ref tokenUser,
                         ref tokenGroups,
                         ref tokenPrivileges,
                         ref tokenOwner,
                         ref tokenPrimaryGroup,
                         ref tokenDefaultDacl,
                         ref source
                         )) >= NtStatus.Error)
                {
                    Win32.Throw(status);
                }
            }
            finally
            {
                oa.Dispose();
            }

            return(new TokenHandle(handle, true));
        }
Пример #33
0
 public MailslotHandle(
     string fileName,
     ObjectFlags objectFlags,
     FileHandle rootDirectory,
     FileShareMode shareMode,
     FileCreateOptions openOptions,
     FileAccess access
     )
     : base(fileName, objectFlags, rootDirectory, shareMode, openOptions, access)
 {
 }
Пример #34
0
        public static NamedPipeHandle Create(
            FileAccess access,
            string fileName,
            ObjectFlags objectFlags,
            NativeHandle rootDirectory,
            FileShareMode shareMode,
            FileCreationDisposition creationDisposition,
            FileCreateOptions createOptions,
            PipeType type,
            PipeType readMode,
            PipeCompletionMode completionMode,
            int maximumInstances,
            int inboundQuota,
            int outboundQuota,
            long defaultTimeout
            )
        {
            NtStatus status;
            ObjectAttributes oa = new ObjectAttributes(fileName, objectFlags, rootDirectory);
            IoStatusBlock isb;
            IntPtr handle;

            // If a timeout wasn't specified, use a default value.
            if (defaultTimeout == 0)
                defaultTimeout = -50 * Win32.TimeMsTo100Ns; // 50 milliseconds

            try
            {
                if ((status = Win32.NtCreateNamedPipeFile(
                    out handle,
                    access,
                    ref oa,
                    out isb,
                    shareMode,
                    creationDisposition,
                    createOptions,
                    type,
                    readMode,
                    completionMode,
                    maximumInstances,
                    inboundQuota,
                    outboundQuota,
                    ref defaultTimeout
                    )) >= NtStatus.Error)
                    Win32.Throw(status);
            }
            finally
            {
                oa.Dispose();
            }

            return new NamedPipeHandle(handle, true);
        }
Пример #35
0
        public DriverHandle(string name, ObjectFlags objectFlags, DirectoryHandle rootDirectory)
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);

            try
            {
                this.Handle = KProcessHacker.Instance.KphOpenDriver(oa).ToIntPtr();
            }
            finally
            {
                oa.Dispose();
            }
        }
Пример #36
0
 /// <summary>
 /// Creates a new <see cref="IS_OBH"/> object.
 /// </summary>
 /// <param name="buffer">The packet data.</param>
 public IS_OBH(byte[] buffer) {
     PacketReader reader = new PacketReader(buffer);
     Size = reader.ReadByte();
     Type = (PacketType)reader.ReadByte();
     ReqI = reader.ReadByte();
     PLID = reader.ReadByte();
     SpClose = reader.ReadUInt16();
     Time = TimeSpan.FromMilliseconds(reader.ReadUInt16() * 10);
     C = new CarContOBJ(reader);
     X = reader.ReadInt16();
     Y = reader.ReadInt16();
     reader.Skip(2);
     Index = reader.ReadByte();
     OBHFlags = (ObjectFlags)reader.ReadByte();
 }
Пример #37
0
        public const uint MODERATOR = 0xFF0078FF; // kinda blue (0, 120, 255)
#endif

        /// <summary>
        /// Returns a 32bit color based on ObjectFlags.
        /// </summary>
        /// <param name="Flags"></param>
        /// <returns></returns>
        public static uint GetColorFor(ObjectFlags Flags)
        {
            if (Flags.Player == ObjectFlags.PlayerType.SuperDM)
                return SUPERDM;

            else if (Flags.Player == ObjectFlags.PlayerType.EventChar)
                return EVENTCHAR;
#if !VANILLA
            else if (Flags.Player == ObjectFlags.PlayerType.Moderator)
                return MODERATOR;

            else if (Flags.Player == ObjectFlags.PlayerType.Creator)
                return DAENKS;

            else if (Flags.IsMagicItem)
                return MAGIC;
#else
            else if (Flags.Player == ObjectFlags.PlayerType.Creator)
                return CREATOR;
#endif
            else if (Flags.Player == ObjectFlags.PlayerType.DM)
                return DM;

            else if (Flags.Drawing == ObjectFlags.DrawingType.Invisible)
                return NORMAL;

            else if (Flags.Drawing == ObjectFlags.DrawingType.Black)
                return BLACK;

            else if (Flags.Player == ObjectFlags.PlayerType.Killer)
                return KILLER;

            else if (Flags.Player == ObjectFlags.PlayerType.Outlaw)
                return OUTLAW;

            else
                return NORMAL;
        }
Пример #38
0
        public static NativeHandle OpenObject(int access, string name, ObjectFlags objectFlags, NativeHandle rootDirectory)
        {
            ObjectAttributes oa = new ObjectAttributes(name, objectFlags, rootDirectory);

            try
            {
                return new NativeHandle(KProcessHacker.Instance.KphOpenNamedObject(access, oa).ToIntPtr(), true);
            }
            finally
            {
                oa.Dispose();
            }
        }
Пример #39
0
		public bool ObjectFlagged (ObjectFlags flag)
		{
			return ((Flags.ObjectFlags & (byte)flag) == (byte)flag);
		}
Пример #40
0
		public void RemoveObjectFlag (ObjectFlags flag)
		{
			Flags.ObjectFlags &= ~(byte)flag;
		}
Пример #41
0
		public void SetObjectFlag (ObjectFlags flag)
		{
			Flags.ObjectFlags = Flags.ObjectFlags | (byte)flag;
		}
Пример #42
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Flags"></param>
 /// <param name="A"></param>
 /// <param name="R"></param>
 /// <param name="G"></param>
 /// <param name="B"></param>
 public static void GetColorComponentsFor(ObjectFlags Flags, out byte A, out byte R, out byte G, out byte B)
 {
     Util.GetIntegerBytes(GetColorFor(Flags), out A, out R, out G, out B);
 }