Пример #1
0
        internal CommonNetworkRelativeLink(byte[] bytes, int offset)
        {
            CommonNetworkRelativeLinkSize = BitConverter.ToUInt32(bytes, offset);

            if (CommonNetworkRelativeLinkSize >= 0x14)
            {
                CommonNetworkRelativeLinkFlags = (COMMON_NETWORK_RELATIVE_LINK_FLAGS)BitConverter.ToUInt32(bytes, offset + 0x04);

                #region NetName
                NetNameOffset = BitConverter.ToInt32(bytes, offset + 0x08);
                NetName       = Encoding.Default.GetString(bytes, offset + NetNameOffset, (int)CommonNetworkRelativeLinkSize - (int)NetNameOffset).Split('\0')[0];
                #endregion NetName

                #region DeviceName
                DeviceNameOffset = BitConverter.ToUInt32(bytes, offset + 0x0C);

                if (!((CommonNetworkRelativeLinkFlags & COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidDevice) == COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidDevice))
                {
                    throw new Exception("Invalid DeviceNameOffset value");
                }

                DeviceName = Encoding.Default.GetString(bytes, offset + (int)DeviceNameOffset, (int)CommonNetworkRelativeLinkSize - (int)DeviceNameOffset).Split('\0')[0];
                #endregion DeviceName

                #region NetworkProviderType
                if ((CommonNetworkRelativeLinkFlags & COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidNetType) == COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidNetType)
                {
                    NetworkProviderType = (NETWORK_PROVIDER_TYPE)BitConverter.ToUInt32(bytes, offset + 0x10);
                }
                #endregion NetworkProviderType

                if (NetNameOffset > 0x14)
                {
                    #region NetNameUnicode
                    NetNameOffsetUnicode = BitConverter.ToUInt32(bytes, offset + 0x14);
                    NetNameUnicode       = Encoding.Unicode.GetString(bytes, offset + (int)NetNameOffsetUnicode, (int)CommonNetworkRelativeLinkSize - (int)NetNameOffsetUnicode).Split('\0')[0];
                    #endregion NetNameUnicode

                    #region DeviceNameUnicode
                    DeviceNameOffsetUnicode = BitConverter.ToUInt32(bytes, offset + 0x18);
                    DeviceNameUnicode       = Encoding.Unicode.GetString(bytes, offset + (int)DeviceNameOffsetUnicode, (int)CommonNetworkRelativeLinkSize - (int)DeviceNameOffsetUnicode).Split('\0')[0];
                    #endregion DeviceNameUnicode
                }

                offset += (int)CommonNetworkRelativeLinkSize;
            }
            else
            {
                throw new Exception("Invalid CommonNetworkRelativeLink Object");
            }
        }
Пример #2
0
        internal CommonNetworkRelativeLink(byte[] bytes, int offset)
        {
            CommonNetworkRelativeLinkSize = BitConverter.ToUInt32(bytes, offset);

            if (CommonNetworkRelativeLinkSize >= 0x14)
            {
                CommonNetworkRelativeLinkFlags = (COMMON_NETWORK_RELATIVE_LINK_FLAGS)BitConverter.ToUInt32(bytes, offset + 0x04);

                #region NetName
                NetNameOffset = BitConverter.ToUInt32(bytes, offset + 0x08);
                NetName = Encoding.Default.GetString(bytes, offset + (int)NetNameOffset, (int)CommonNetworkRelativeLinkSize - (int)NetNameOffset).Split('\0')[0];
                #endregion NetName

                #region DeviceName
                DeviceNameOffset = BitConverter.ToUInt32(bytes, offset + 0x0C);

                if(!((CommonNetworkRelativeLinkFlags & COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidDevice) == COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidDevice))
                {
                    throw new Exception("Invalid DeviceNameOffset value");
                }

                DeviceName = Encoding.Default.GetString(bytes, offset + (int)DeviceNameOffset, (int)CommonNetworkRelativeLinkSize - (int)DeviceNameOffset).Split('\0')[0];
                #endregion DeviceName

                #region NetworkProviderType
                if ((CommonNetworkRelativeLinkFlags & COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidNetType) == COMMON_NETWORK_RELATIVE_LINK_FLAGS.ValidNetType)
                {
                    NetworkProviderType = (NETWORK_PROVIDER_TYPE)BitConverter.ToUInt32(bytes, offset + 0x10);
                }
                #endregion NetworkProviderType

                if (NetNameOffset > 0x14)
                {
                    #region NetNameUnicode
                    NetNameOffsetUnicode = BitConverter.ToUInt32(bytes, offset + 0x14);
                    NetNameUnicode = Encoding.Unicode.GetString(bytes, offset + (int)NetNameOffsetUnicode, (int)CommonNetworkRelativeLinkSize - (int)NetNameOffsetUnicode).Split('\0')[0];
                    #endregion NetNameUnicode

                    #region DeviceNameUnicode
                    DeviceNameOffsetUnicode = BitConverter.ToUInt32(bytes, offset + 0x18);
                    DeviceNameUnicode = Encoding.Unicode.GetString(bytes, offset + (int)DeviceNameOffsetUnicode, (int)CommonNetworkRelativeLinkSize - (int)DeviceNameOffsetUnicode).Split('\0')[0];
                    #endregion DeviceNameUnicode
                }

                offset += (int)CommonNetworkRelativeLinkSize;
            }
            else
            {
                throw new Exception("Invalid CommonNetworkRelativeLink Object");
            }
        }