public PointField()
 {
     name = "";
     offset = 0;
     datatype = 0;
     count = 0;
 }
Exemple #2
0
        public PgHdr pPgHdr = new PgHdr();  // Pointer to Actual Page Header

        public void Clear()
        {
            this.iKey = 0;
            this.pNext = null;
            this.pCache = null;
            this.pPgHdr.ClearState();
        }
Exemple #3
0
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     data = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(data).Length;
     return (curIndex - startIndex);
 }
      public u32 iMaxKey;               /* Largest key seen since xTruncate() */


      public void Clear()
      {
        nRecyclable = 0;
        nPage = 0;
        nHash = 0;
        apHash = null;
        iMaxKey = 0;
      }
Exemple #5
0
 public void Subtract()
 {
     unchecked
     {
         var complement = (DoubleWord)(-InputB);
         Output = (DoubleWord)InputA - InputB;
     }
 }
 public RegionOfInterest()
 {
     x_offset = 0;
     y_offset = 0;
     height = 0;
     width = 0;
     do_rectify = false;
 }
Exemple #7
0
 public TrackerState()
 {
     header = new std_msgs.Header();
     ActiveTracks = 0;
     TotalTracks = 0;
     Tracks = new List<person_tracker.TrackedPerson>();
     TrackerType = 0;
     TrackerName = "";
 }
Exemple #8
0
 public Image()
 {
     header = new std_msgs.Header();
     height = 0;
     width = 0;
     encoding = "";
     is_bigendian = 0;
     step = 0;
     data = new List<System.Byte>();
 }
        /// <summary>Initializes a new instance of the Abstract1 class.</summary>
        protected Abstract1(
			System.UInt32 identity,
			System.Int32 abstract1Field1,
			System.Int32 abstract1Field2,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.abstract1Field1 = abstract1Field1;
            this.abstract1Field2 = abstract1Field2;
        }
        /// <summary>Initializes a new instance of the A class.</summary>
        protected A(
			System.UInt32 identity,
			System.Int32 field1,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.field1 = field1;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
 internal RC btreeSetHasContent(Pgno pgno)
 {
     var rc = RC.OK;
     if (this.HasContent == null)
     {
         Debug.Assert(pgno <= this.Pages);
         this.HasContent = new BitArray(this.Pages);
     }
     if (rc == RC.OK && pgno <= this.HasContent.Length)
         rc = this.HasContent.Set(pgno);
     return rc;
 }
Exemple #12
0
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     seq = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(seq).Length;
     curIndex += stamp.Deserialize(serialized, curIndex);
     System.UInt32 frame_id_len = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(frame_id_len).Length;
     frame_id = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)frame_id_len);
     curIndex += (int)frame_id_len;
     return (curIndex - startIndex);
 }
 public PointCloud2()
 {
     header = new std_msgs.Header();
     height = 0;
     width = 0;
     fields = new List<sensor_msgs.PointField>();
     is_bigendian = false;
     point_step = 0;
     row_step = 0;
     data = new List<System.Byte>();
     is_dense = false;
 }
Exemple #14
0
		internal void Initialize(JulianDay currentDate, Span span, double viewportWidth)
		{
			m_Span = span;
			m_ViewportWidth = viewportWidth;
			m_CurrentDate = currentDate;

			RectangleGeometry rect = new RectangleGeometry();
			rect.Rect = new Rect(0, 0, m_ViewportWidth, base.ActualHeight);
			base.Clip = rect;

			InitializePanels();
		}
        /// <summary>Initializes a new instance of the Contact class.</summary>
        protected Contact(
			System.UInt32 identity,
			System.String name,
			System.String email,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.name = name;
            this.email = email;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the ReqAndHierL1 class.</summary>
        protected ReqAndHierL1(
			System.UInt32 identity,
			System.String l1Field1,
			System.String l1Field2,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.l1Field1 = l1Field1;
            this.l1Field2 = l1Field2;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
        /// <summary>Initializes a new instance of the Fruit class.</summary>
        protected Fruit(
			System.UInt32 identity,
			System.String color,
			System.Int32 skinThickness,
			ImmutableObjectGraph.Optional<bool> skipValidation = default(ImmutableObjectGraph.Optional<bool>))
        {
            this.identity = identity;
            this.color = color;
            this.skinThickness = skinThickness;
            if (!skipValidation.Value) {
                this.Validate();
            }
        }
Exemple #18
0
 public TrackedPerson()
 {
     header = new std_msgs.Header();
     Name = "";
     UID = 0;
     Pose = new geometry_msgs.Pose();
     Twist = new geometry_msgs.Twist();
     Skeleton = new person_tracker.SkeletonTrack();
     Hands = new List<person_tracker.HandTrack>();
     Confidence = 0.0f;
     TrackerType = 0;
     TrackerName = "";
 }
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     System.UInt32 label_len = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(label_len).Length;
     label = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)label_len);
     curIndex += (int)label_len;
     size = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(size).Length;
     stride = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(stride).Length;
     return (curIndex - startIndex);
 }
Exemple #20
0
 public CameraInfo()
 {
     header = new std_msgs.Header();
     height = 0;
     width = 0;
     distortion_model = "";
     D = new List<double>();
     K = new double[9];
     R = new double[9];
     P = new double[12];
     binning_x = 0;
     binning_y = 0;
     roi = new sensor_msgs.RegionOfInterest();
 }
Exemple #21
0
		internal string ToRelativeProfileText(JulianDay date)
		{
			ProfileCode profileCode = base.Value;
			if (profileCode < 0 || profileCode > Max)
				profileCode = 0;
			JulianDay birthDate = 0;
			double lifeExpectancy = 0;
			Profile profile = App.Model.ProfileHolder.Profile;
			if (profileCode == ProfileCode.MeBirth)
			{
				birthDate = profile.Me.BirthDate;
				lifeExpectancy = profile.Me.LifeExpectancy;
			}
			else
			if (profileCode == ProfileCode.SpouseBirth)
			{
				if (profile.IncludeSpouse)
				{
					birthDate = profile.Spouse.BirthDate;
					lifeExpectancy = profile.Spouse.LifeExpectancy;
				}
			}
			else
			if (profileCode >= ProfileCode.DependentMin && profileCode <= ProfileCode.DependentMax)
			{
				int dependent = (profileCode - ProfileCode.DependentMin) / ProfileCode.Range;
				Person person = (profile.IncludeDependents && dependent < profile.Dependents.Count ? profile.Dependents[dependent] : null);
				if (person != null)
				{
					birthDate = person.BirthDate;
					lifeExpectancy = person.LifeExpectancy;
				}
			}

			if (birthDate == 0)
				return null;

			int daysAlive = (int)date - (int)birthDate;
			if (daysAlive < 0)
				return null;

//j			if (daysAlive > JulianDate.YearsToDays(lifeExpectancy))
//j				return null;

			double age = JulianDate.DaysToYears((uint)daysAlive);
			profileCode += (int)age;

			ProfileDate pjd = new ProfileDate() { ProfileCode = profileCode, JulianDay = date };
			return pjd.GetTextFromProfile();
		}
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     x_offset = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(x_offset).Length;
     y_offset = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(y_offset).Length;
     height = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(height).Length;
     width = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(width).Length;
     do_rectify = Convert.ToBoolean(serialized[curIndex]);
     curIndex++;
     return (curIndex - startIndex);
 }
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     System.UInt32 dim_len = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(dim_len).Length;
     for (int i = 0; i < (int)dim_len; i++)
     {
         std_msgs.MultiArrayDimension element = new std_msgs.MultiArrayDimension();
         curIndex += element.Deserialize(serialized, curIndex);
         dim.Add(element);
     }
     data_offset = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(data_offset).Length;
     return (curIndex - startIndex);
 }
 public override int Deserialize(System.Byte[] serialized, int startIndex)
 {
     int curIndex = startIndex;
     System.UInt32 name_len = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(name_len).Length;
     name = System.Text.Encoding.UTF8.GetString(serialized, curIndex, (int)name_len);
     curIndex += (int)name_len;
     offset = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(offset).Length;
     datatype = serialized[curIndex];
     curIndex++;
     count = BitConverter.ToUInt32(serialized, curIndex);
     curIndex += BitConverter.GetBytes(count).Length;
     return (curIndex - startIndex);
 }
 internal Win32Resource(
     byte[] data,
     DWORD codePage,
     DWORD languageId,
     int id,
     string name,
     int typeId,
     string typeName)
 {
     this.data = data;
     this.codePage = codePage;
     this.languageId = languageId;
     this.id = id;
     this.name = name;
     this.typeId = typeId;
     this.typeName = typeName;
 }
Exemple #26
0
 internal Win32Resource(
     byte[] data,
     DWORD codePage,
     DWORD languageId,
     int id,
     string name,
     int typeId,
     string typeName)
 {
     _data = data;
     _codePage = codePage;
     _languageId = languageId;
     _id = id;
     _name = name;
     _typeId = typeId;
     _typeName = typeName;
 }
Exemple #27
0
 public void ClearState()
 {
     this.Data = null;
     this.Extra = null;
     this.Dirtys = null;
     this.ID = 0;
     this.Pager = null;
     #if DEBUG
     this.PageHash = 0;
     #endif
     this.Flags = 0;
     this.Refs = 0;
     this.CacheAllocated = false;
     this.Cache = null;
     this.DirtyNext = null;
     this.DirtyPrev = null;
     this.PgHdr1 = null;
 }
Exemple #28
0
			public void Clear()
			{
				sqlite3_free(ref this.pData);
				this.pData = null;
				this.pExtra = null;
				this.pDirty = null;
				this.pgno = 0;
				this.pPager = null;
#if SQLITE_CHECK_PAGES
this.pageHash=0;
#endif
				this.flags = 0;
				this.nRef = 0;
				this.CacheAllocated = false;
				this.pCache = null;
				this.pDirtyNext = null;
				this.pDirtyPrev = null;
				this.pPgHdr1 = null;
			}
Exemple #29
0
        public uint[] OverflowIDs; // Cache of overflow page locations

        #endif

        #region Methods

        // was:sqlite3BtreeCursorZero
        public void Zero()
        {
            Next = null;
            Prev = null;
            KeyInfo = null;
            RootID = 0;
            _cachedRowID = 0;
            Info = new MemPage.CellInfo();
            Writeable = false;
            AtLast = false;
            ValidNKey = false;
            State = 0;
            Key = null;
            NKey = 0;
            SkipNext = 0;
            #if !SQLITE_OMIT_INCRBLOB
            IsIncrblob = false;
            OverflowIDs = null;
            #endif
            PageID = 0;
        }
Exemple #30
0
        ///* *************************************
        //*  Dependencies
        //***************************************/
        //#include "mem.h"
        //#include "error_private.h"       /* ERR_*, ERROR */
        //#define FSE_STATIC_LINKING_ONLY  /* FSE_MIN_TABLELOG */
        //#include "fse.h"
        //#define HUF_STATIC_LINKING_ONLY  /* HUF_TABLELOG_ABSOLUTEMAX */
        //#include "huf.h"


        ///*===   Version   ===*/
        //unsigned VersionNumber(void) { return FSE_VERSION_NUMBER; }


        ///*===   Error Management   ===*/
        //unsigned IsError(size_t code) { return ERR_isError(code); }
        // char* GetErrorName(size_t code) { return ERR_getErrorName(code); }

        //unsigned IsError(size_t code) { return ERR_isError(code); }
        // char* GetErrorName(size_t code) { return ERR_getErrorName(code); }


        /*-**************************************************************
        *  FSE NCount encoding-decoding
        ****************************************************************/
        public static size_t ReadNCount(short[] normalizedCounter, uint *maxSVPtr, uint *tableLogPtr, void *headerBuffer, size_t hbSize)
        {
            BYTE *istart = (BYTE *)headerBuffer;
            BYTE *iend   = istart + hbSize;
            BYTE *ip     = istart;
            int   nbBits;
            int   remaining;
            int   threshold;
            U32   bitStream;
            int   bitCount;
            uint  charnum   = 0;
            int   previous0 = 0;

            if (hbSize < 4)
            {
                return(ERROR(Error.srcSize_wrong));
            }
            bitStream = MEM_readLE32(ip);
            nbBits    = (int)(bitStream & 0xF) + Fse.FSE_MIN_TABLELOG;            /* extract tableLog */
            if (nbBits > Fse.FSE_TABLELOG_ABSOLUTE_MAX)
            {
                return(ERROR(Error.tableLog_tooLarge));
            }
            bitStream >>= 4;
            bitCount    = 4;
            *tableLogPtr = (size_t)nbBits;
            remaining = (1 << nbBits) + 1;
            threshold = 1 << nbBits;
            nbBits++;

            while ((remaining > 1) & (charnum <= *maxSVPtr))
            {
                if (previous0 != 0)
                {
                    uint n0 = charnum;
                    while ((bitStream & 0xFFFF) == 0xFFFF)
                    {
                        n0 += 24;
                        if (ip < iend - 5)
                        {
                            ip       += 2;
                            bitStream = MEM_readLE32(ip) >> bitCount;
                        }
                        else
                        {
                            bitStream >>= 16;
                            bitCount   += 16;
                        }
                    }
                    while ((bitStream & 3) == 3)
                    {
                        n0         += 3;
                        bitStream >>= 2;
                        bitCount   += 2;
                    }
                    n0       += bitStream & 3;
                    bitCount += 2;
                    if (n0 > *maxSVPtr)
                    {
                        return(ERROR(Error.maxSymbolValue_tooSmall));
                    }
                    while (charnum < n0)
                    {
                        normalizedCounter[charnum++] = 0;
                    }
                    if ((ip <= iend - 7) || (ip + (bitCount >> 3) <= iend - 4))
                    {
                        ip       += bitCount >> 3;
                        bitCount &= 7;
                        bitStream = MEM_readLE32(ip) >> bitCount;
                    }
                    else
                    {
                        bitStream >>= 2;
                    }
                }
                {
                    int max = (2 * threshold - 1) - remaining;
                    int count;

                    if ((bitStream & (threshold - 1)) < (U32)max)
                    {
                        count     = (int)bitStream & (threshold - 1);
                        bitCount += nbBits - 1;
                    }
                    else
                    {
                        count = (int)bitStream & (2 * threshold - 1);
                        if (count >= threshold)
                        {
                            count -= max;
                        }
                        bitCount += nbBits;
                    }

                    count--;                                 /* extra accuracy */
                    remaining -= count < 0 ? -count : count; /* -1 means +1 */
                    normalizedCounter[charnum++] = (short)count;
                    previous0 = count == 0 ? 1 : 0;
                    while (remaining < threshold)
                    {
                        nbBits--;
                        threshold >>= 1;
                    }

                    if ((ip <= iend - 7) || (ip + (bitCount >> 3) <= iend - 4))
                    {
                        ip       += bitCount >> 3;
                        bitCount &= 7;
                    }
                    else
                    {
                        bitCount -= (int)(8 * (iend - 4 - ip));
                        ip        = iend - 4;
                    }
                    bitStream = MEM_readLE32(ip) >> (bitCount & 31);
                }
            }               /* while ((remaining>1) & (charnum<=*maxSVPtr)) */
            if (remaining != 1)
            {
                return(ERROR(Error.corruption_detected));
            }
            if (bitCount > 32)
            {
                return(ERROR(Error.corruption_detected));
            }
            *maxSVPtr = charnum - 1;

            ip += (bitCount + 7) >> 3;
            return((size_t)(ip - istart));
        }
Exemple #31
0
 public void GetInfo([XmlElement("NewEnable", Namespace = "")] out boolean Enable, [XmlElement("NewLinkStatus", Namespace = "")] out string LinkStatus, [XmlElement("NewLinkType", Namespace = "")] out string LinkType, [XmlElement("NewDestinationAddress", Namespace = "")] out string DestinationAddress, [XmlElement("NewATMEncapsulation", Namespace = "")] out string ATMEncapsulation, [XmlElement("NewAutoConfig", Namespace = "")] out boolean AutoConfig, [XmlElement("NewATMQoS", Namespace = "")] out string ATMQoS, [XmlElement("NewATMPeakCellRate", Namespace = "")] out ui4 ATMPeakCellRate, [XmlElement("NewATMSustainableCellRate", Namespace = "")] out ui4 ATMSustainableCellRate)
 {
     object[] results = this.Invoke("GetInfo", new object[] {  });
     Enable                 = (boolean)results[0];
     LinkStatus             = (string)results[1];
     LinkType               = (string)results[2];
     DestinationAddress     = (string)results[3];
     ATMEncapsulation       = (string)results[4];
     AutoConfig             = (boolean)results[5];
     ATMQoS                 = (string)results[6];
     ATMPeakCellRate        = (ui4)results[7];
     ATMSustainableCellRate = (ui4)results[8];
 }
Exemple #32
0
 public DataDirectory(RVA rva, uint size)
 {
     this.VirtualAddress = rva;
     this.Size           = size;
 }
Exemple #33
0
 /// <summary>
 /// Initializes new instance of SessionFlags class
 /// </summary>
 /// <param name="flags">Bit flags that define the type of session</param>
 protected internal SessionFlags(NativeULong flags)
 {
     _flags = flags;
 }
        /*
        ** the following macros help to manipulate instructions
        */

        public static OpCode GET_OPCODE(Instruction i)
        {
            return((OpCode)((i >> POS_OP) & MASK1(SIZE_OP, 0)));
        }
Exemple #35
0
 public void GetStatistics([XmlElement("NewATMTransmittedBlocks", Namespace = "")] out ui4 ATMTransmittedBlocks, [XmlElement("NewATMReceivedBlocks", Namespace = "")] out ui4 ATMReceivedBlocks, [XmlElement("NewAAL5CRCErrors", Namespace = "")] out ui4 AAL5CRCErrors, [XmlElement("NewATMCRCErrors", Namespace = "")] out ui4 ATMCRCErrors)
 {
     object[] results = this.Invoke("GetStatistics", new object[] {  });
     ATMTransmittedBlocks = (ui4)results[0];
     ATMReceivedBlocks    = (ui4)results[1];
     AAL5CRCErrors        = (ui4)results[2];
     ATMCRCErrors         = (ui4)results[3];
 }
Exemple #36
0
 /* macro to trim extra bits */
 private static lua_Unsigned trim(b_uint x)
 {
     return((x) & ALLONES);
 }
Exemple #37
0
        private static Signature GetSignatureFromCatalog(string filename)
        {
            if (Signature.CatalogApiAvailable.HasValue && !Signature.CatalogApiAvailable.Value)
            {
                // Signature.CatalogApiAvailable would be set to false the first time it is detected that
                // WTGetSignatureInfo API does not exist on the platform, or if the API is not functional on the target platform.
                // Just return from the function instead of revalidating.
                return(null);
            }

            Signature signature = null;

            Utils.CheckArgForNullOrEmpty(filename, "fileName");
            SecuritySupport.CheckIfFileExists(filename);

            try
            {
                using (FileStream stream = File.OpenRead(filename))
                {
                    NativeMethods.SIGNATURE_INFO sigInfo = new NativeMethods.SIGNATURE_INFO();
                    sigInfo.cbSize = (uint)Marshal.SizeOf(sigInfo);

                    IntPtr ppCertContext = IntPtr.Zero;
                    IntPtr phStateData   = IntPtr.Zero;

                    try
                    {
                        int hresult = NativeMethods.WTGetSignatureInfo(filename, stream.SafeFileHandle.DangerousGetHandle(),
                                                                       NativeMethods.SIGNATURE_INFO_FLAGS.SIF_CATALOG_SIGNED |
                                                                       NativeMethods.SIGNATURE_INFO_FLAGS.SIF_CATALOG_FIRST |
                                                                       NativeMethods.SIGNATURE_INFO_FLAGS.SIF_AUTHENTICODE_SIGNED |
                                                                       NativeMethods.SIGNATURE_INFO_FLAGS.SIF_BASE_VERIFICATION |
                                                                       NativeMethods.SIGNATURE_INFO_FLAGS.SIF_CHECK_OS_BINARY,
                                                                       ref sigInfo, ref ppCertContext, ref phStateData);

                        if (Utils.Succeeded(hresult))
                        {
                            DWORD error = GetErrorFromSignatureState(sigInfo.nSignatureState);

                            X509Certificate2 cert = null;

                            if (ppCertContext != IntPtr.Zero)
                            {
                                cert = new X509Certificate2(ppCertContext);

                                // Get the time stamper certificate if available
                                TryGetProviderSigner(phStateData, out IntPtr pProvSigner, out X509Certificate2 timestamperCert);
                                if (timestamperCert != null)
                                {
                                    signature = new Signature(filename, error, cert, timestamperCert);
                                }
                                else
                                {
                                    signature = new Signature(filename, error, cert);
                                }

                                switch (sigInfo.nSignatureType)
                                {
                                case NativeMethods.SIGNATURE_INFO_TYPE.SIT_AUTHENTICODE: signature.SignatureType = SignatureType.Authenticode; break;

                                case NativeMethods.SIGNATURE_INFO_TYPE.SIT_CATALOG: signature.SignatureType = SignatureType.Catalog; break;
                                }

                                if (sigInfo.fOSBinary == 1)
                                {
                                    signature.IsOSBinary = true;
                                }
                            }
                            else
                            {
                                signature = new Signature(filename, error);
                            }

                            if (!Signature.CatalogApiAvailable.HasValue)
                            {
                                string productFile = Path.Combine(Utils.DefaultPowerShellAppBase, "Modules\\PSDiagnostics\\PSDiagnostics.psm1");
                                if (signature.Status != SignatureStatus.Valid)
                                {
                                    if (string.Equals(filename, productFile, StringComparison.OrdinalIgnoreCase))
                                    {
                                        Signature.CatalogApiAvailable = false;
                                    }
                                    else
                                    {
                                        // ProductFile has to be Catalog signed. Hence validating
                                        // to see if the Catalog API is functional using the ProductFile.
                                        Signature productFileSignature = GetSignatureFromCatalog(productFile);
                                        Signature.CatalogApiAvailable = (productFileSignature != null && productFileSignature.Status == SignatureStatus.Valid);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // If calling NativeMethods.WTGetSignatureInfo failed (returned a non-zero value), we still want to set Signature.CatalogApiAvailable to false.
                            Signature.CatalogApiAvailable = false;
                        }
                    }
                    finally
                    {
                        if (phStateData != IntPtr.Zero)
                        {
                            NativeMethods.FreeWVTStateData(phStateData);
                        }

                        if (ppCertContext != IntPtr.Zero)
                        {
                            NativeMethods.CertFreeCertificateContext(ppCertContext);
                        }
                    }
                }
            }
            catch (TypeLoadException)
            {
                // If we don't have WTGetSignatureInfo, don't return a Signature.
                Signature.CatalogApiAvailable = false;
                return(null);
            }

            return(signature);
        }
Exemple #38
0
        /*! ReadStats() :
         *  Read compact Huffman tree, saved by WriteCTable().
         *  `huffWeight` is destination buffer.
         *  `rankStats` is assumed to be a table of at least HUF_TABLELOG_MAX U32.
         *  @return : size read from `src` , or an error Code .
         *  Note : Needed by ReadCTable() and HUF_readDTableX?() .
         */
        public static size_t ReadStats(BYTE *huffWeight, size_t hwSize, U32 *rankStats, U32 *nbSymbolsPtr, U32 *tableLogPtr, void *src, size_t srcSize)
        {
            U32    weightTotal;
            BYTE * ip = (BYTE *)src;
            size_t iSize;
            size_t oSize;

            if (srcSize == 0)
            {
                return(ERROR(Error.srcSize_wrong));
            }
            iSize = ip[0];
            /* memset(huffWeight, 0, hwSize);   *//* is not necessary, even though some analyzer complain ... */

            if (iSize >= 128)
            {              /* special header */
                oSize = iSize - 127;
                iSize = ((oSize + 1) / 2);
                if (iSize + 1 > srcSize)
                {
                    return(ERROR(Error.srcSize_wrong));
                }
                if (oSize >= hwSize)
                {
                    return(ERROR(Error.corruption_detected));
                }
                ip += 1;
                {
                    U32 n;
                    for (n = 0; n < oSize; n += 2)
                    {
                        huffWeight[n]     = (BYTE)(ip[n / 2] >> 4);
                        huffWeight[n + 1] = (BYTE)(ip[n / 2] & 15);
                    }
                }
            }
            else
            {                                                                                 /* header compressed with FSE (normal case) */
                FSE_DTable *fseWorkspace = stackalloc FSE_DTable[Fse.FSE_DTABLE_SIZE_U32(6)]; /* 6 is max possible tableLog for HUF header (maybe even 5, to be tested) */
                if (iSize + 1 > srcSize)
                {
                    return(ERROR(Error.srcSize_wrong));
                }
                oSize = FseDecompress.FSE_decompress_wksp(huffWeight, hwSize - 1, ip + 1, iSize, fseWorkspace, 6);                   /* max (hwSize-1) values decoded, as last one is implied */
                if (IsError(oSize))
                {
                    return(oSize);
                }
            }

            /* collect weight stats */
            memset(rankStats, 0, (Huf.HUF_TABLELOG_MAX + 1) * sizeof(U32));
            weightTotal = 0;
            {
                U32 n; for (n = 0; n < oSize; n++)
                {
                    if (huffWeight[n] >= Huf.HUF_TABLELOG_MAX)
                    {
                        return(ERROR(Error.corruption_detected));
                    }
                    rankStats[huffWeight[n]]++;
                    weightTotal += ((U32)1 << huffWeight[n]) >> 1;
                }
            }
            if (weightTotal == 0)
            {
                return(ERROR(Error.corruption_detected));
            }

            /* get last non-null symbol weight (implied, total must be 2^n) */
            {
                U32 tableLog = BitStream.BIT_highbit32(weightTotal) + 1;
                if (tableLog > Huf.HUF_TABLELOG_MAX)
                {
                    return(ERROR(Error.corruption_detected));
                }
                *tableLogPtr = tableLog;
                /* determine last weight */
                {
                    U32 total      = (U32)1 << (int)tableLog;
                    U32 rest       = total - weightTotal;
                    U32 verif      = (U32)1 << (int)BitStream.BIT_highbit32(rest);
                    U32 lastWeight = BitStream.BIT_highbit32(rest) + 1;
                    if (verif != rest)
                    {
                        return(ERROR(Error.corruption_detected));                                      /* last value must be a clean power of 2 */
                    }
                    huffWeight[oSize] = (BYTE)lastWeight;
                    rankStats[lastWeight]++;
                }
            }

            /* check tree construction validity */
            if ((rankStats[1] < 2) || ((rankStats[1] & 1) != 0))
            {
                return(ERROR(Error.corruption_detected));                                                               /* by construction : at least 2 elts of rank 1, must be even */
            }
            /* results */
            *nbSymbolsPtr = (U32)(oSize + 1);
            return(iSize + 1);
        }
Exemple #39
0
        public void LAYRchunk()
        {
            ID chunkId     = f.ReadID4();
            U4 chunkLength = f.ReadU4();

            Debug.WriteLine(f.Type.ToString() + "::" + chunkId.ToString() + " " + chunkLength + " bytes");

            f.Push(chunkLength);

            switch (chunkId.value)
            {
            //  LWOB, LWLO, LWO2
            case ID.PNTS: pointList(); break;

            //  LWOB, LWLO
            case ID.CRVS: oldCurveList(); break;

            case ID.PCHS: oldPatchList(); break;

            case ID.SRFS: readSurfaceList(); break;

            //  LWO2
            case ID.VMAP: vertexMapping_ID4_U2_S0_d(); break;

            case ID.VMAD: vertexMappingD_ID4_U2_S0_d(); break;

            case ID.VMPA: vertexMapParameter_I4_I4(); break;

            case ID.TAGS: tags_d(); break;

            case ID.CLIP: clip_U4_sc(); break;

            case ID.PTAG: polygonTags_ID4_d(); break;

            case ID.ENVL: envelope_U4_sc(); break;

            case ID.BBOX: boundingBox_VEC12_VEC12(); break;

            case ID.DESC: descriptionLine_S0(); break;

            case ID.TEXT: comments_S0(); break;

            case ID.ICON: thumbnail_U2_U2_d(); break;

            case ID.POLS: if (f.Type.value == ID.LWO2)
                {
                    polygonList();
                }
                else
                {
                    oldPolygonList();
                } break;

            case ID.SURF: if (f.Type.value == ID.LWO2)
                {
                    surf_S0_S0_sc();
                }
                else
                {
                    readSurface_sc();
                } break;

            case ID.LAYR: if (f.Type.value == ID.LWO2)
                {
                    layer_U2_U2_VEC12_S0_U2();
                }
                else
                {
                    layer_U2_U2_S0();
                } break;

            default:        Debug.WriteLine("Unknown chunk " + chunkId); break;
            }

            f.Pop(true);
        }
Exemple #40
0
 /// <summary>
 /// Initializes new instance of MechanismFlags class
 /// </summary>
 /// <param name="flags">Bits flags specifying mechanism capabilities</param>
 protected internal MechanismFlags(NativeULong flags)
 {
     _flags = flags;
 }
 public static void SET_OPCODE(ref Instruction i, OpCode opcode)
 {
     i = (Instruction)(i & MASK0(SIZE_OP, POS_OP)) | (((uint)opcode << POS_OP) & MASK1(SIZE_OP, POS_OP));
 }
 public static void SET_OPCODE(ref Instruction i, Instruction o)
 {
     i = (Instruction)(i & MASK0(SIZE_OP, POS_OP)) | ((o << POS_OP) & MASK1(SIZE_OP, POS_OP));
 }
Exemple #43
0
 public Object GetObject(ObjectId_t id)
 {
     return(_objects[id]);
 }
Exemple #44
0
 public void GetStatistics(out ui4 ATMTransmittedBlocks, out ui4 ATMReceivedBlocks, out ui4 AAL5CRCErrors, out ui4 ATMCRCErrors)
 {
     ((wandsllinkconfig1)SoapHttpClientProtocol).GetStatistics(out ATMTransmittedBlocks, out ATMReceivedBlocks, out AAL5CRCErrors, out ATMCRCErrors);
 }
Exemple #45
0
 //! get a new event id for the target tick
 private EventId_t GetEventId(Tick_t targetTick)
 {
     return((targetTick << 32) + _nextEventIdInc++);
 }
        /// <summary>
        /// Constructor for class Signature
        ///
        /// Call this ctor when creating an invalid signature object
        /// </summary>
        ///
        /// <param name="filePath"> this signature is found in this file </param>
        ///
        /// <param name="error"> win32 error code </param>
        ///
        /// <returns> constructed object </returns>
        ///
        /// <remarks>  </remarks>
        ///
        internal Signature(string filePath, DWORD error)
        {
            Utils.CheckArgForNullOrEmpty(filePath, "filePath");

            Init(filePath, null, error, null);
        }
Exemple #47
0
 //! schedule a event to be executed at a target tick
 public EventId_t ScheduleEvent(Tick_t tick, Event ev)
 {
     ev.Id = GetEventId(tick);
     _events.Add(ev.Id, ev);
     return(ev.Id);
 }
 public static int GETARG_Ax(Instruction i)
 {
     return(getarg(i, POS_Ax, SIZE_Ax));
 }
Exemple #49
0
 static int sqlite3OsFileControl(sqlite3_file id, u32 op, ref sqlite3_int64 pArg)
 {
     return(id.pMethods.xFileControl(id, (int)op, ref pArg));
 }
 public static int GETARG_sBx(Instruction i)
 {
     return(GETARG_Bx(i) - MAXARG_sBx);
 }
        public i32 i32(BitBufferReader <FibonacciDecoding> b, u8 numberOfBits)
        {
            u32 value = b.u32(numberOfBits);

            return(decode(value));
        }
Exemple #52
0
 public void GetInfo(out boolean Enable, out string LinkStatus, out string LinkType, out string DestinationAddress, out string ATMEncapsulation, out boolean AutoConfig, out string ATMQoS, out ui4 ATMPeakCellRate, out ui4 ATMSustainableCellRate)
 {
     ((wandsllinkconfig1)SoapHttpClientProtocol).GetInfo(out Enable, out LinkStatus, out LinkType, out DestinationAddress, out ATMEncapsulation, out AutoConfig, out ATMQoS, out ATMPeakCellRate, out ATMSustainableCellRate);
 }
 //FIXME:???
 public static int getarg(Instruction i, int pos, int size)
 {
     return((int)(((i) >> pos) & MASK1(size, 0)));
 }
Exemple #54
0
        internal static Signature SignFile(SigningOption option,
                                           string fileName,
                                           X509Certificate2 certificate,
                                           string timeStampServerUrl,
                                           string hashAlgorithm)
        {
            bool      result    = false;
            Signature signature = null;
            IntPtr    pSignInfo = IntPtr.Zero;
            DWORD     error     = 0;
            string    hashOid   = null;

            Utils.CheckArgForNullOrEmpty(fileName, "fileName");
            Utils.CheckArgForNull(certificate, "certificate");

            // If given, TimeStamp server URLs must begin with http://
            if (!string.IsNullOrEmpty(timeStampServerUrl))
            {
                if ((timeStampServerUrl.Length <= 7) ||
                    (timeStampServerUrl.IndexOf("http://", StringComparison.OrdinalIgnoreCase) != 0))
                {
                    throw PSTraceSource.NewArgumentException(
                              "certificate",
                              Authenticode.TimeStampUrlRequired);
                }
            }

            // Validate that the hash algorithm is valid
            if (!string.IsNullOrEmpty(hashAlgorithm))
            {
                IntPtr intptrAlgorithm = Marshal.StringToHGlobalUni(hashAlgorithm);

                IntPtr oidPtr = NativeMethods.CryptFindOIDInfo(NativeConstants.CRYPT_OID_INFO_NAME_KEY,
                                                               intptrAlgorithm,
                                                               0);

                // If we couldn't find an OID for the hash
                // algorithm, it was invalid.
                if (oidPtr == IntPtr.Zero)
                {
                    throw PSTraceSource.NewArgumentException(
                              "certificate",
                              Authenticode.InvalidHashAlgorithm);
                }
                else
                {
                    NativeMethods.CRYPT_OID_INFO oidInfo =
                        Marshal.PtrToStructure <NativeMethods.CRYPT_OID_INFO>(oidPtr);

                    hashOid = oidInfo.pszOID;
                }
            }

            if (!SecuritySupport.CertIsGoodForSigning(certificate))
            {
                throw PSTraceSource.NewArgumentException(
                          "certificate",
                          Authenticode.CertNotGoodForSigning);
            }

            SecuritySupport.CheckIfFileExists(fileName);
            //SecurityUtils.CheckIfFileSmallerThan4Bytes(fileName);

            try
            {
                // CryptUI is not documented either way, but does not
                // support empty strings for the timestamp server URL.
                // It expects null, only.  Instead, it randomly AVs if you
                // try.
                string timeStampServerUrlForCryptUI = null;
                if (!string.IsNullOrEmpty(timeStampServerUrl))
                {
                    timeStampServerUrlForCryptUI = timeStampServerUrl;
                }

                //
                // first initialize the struct to pass to
                // CryptUIWizDigitalSign() function
                //
                NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_INFO si = NativeMethods.InitSignInfoStruct(fileName,
                                                                                                  certificate,
                                                                                                  timeStampServerUrlForCryptUI,
                                                                                                  hashOid,
                                                                                                  option);

                pSignInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(si));
                Marshal.StructureToPtr(si, pSignInfo, false);

                //
                // sign the file
                //
                // The GetLastWin32Error of this is checked, but PreSharp doesn't seem to be
                // able to see that.
#pragma warning disable 56523
                result = NativeMethods.CryptUIWizDigitalSign(
                    (DWORD)NativeMethods.CryptUIFlags.CRYPTUI_WIZ_NO_UI,
                    IntPtr.Zero,
                    IntPtr.Zero,
                    pSignInfo,
                    IntPtr.Zero);
#pragma warning enable 56523

                if (si.pSignExtInfo != null)
                {
                    Marshal.DestroyStructure <NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_EXTENDED_INFO>(si.pSignExtInfo);
                    Marshal.FreeCoTaskMem(si.pSignExtInfo);
                }

                if (!result)
                {
                    error = GetLastWin32Error();

                    //
                    // ISSUE-2004/05/08-kumarp : there seems to be a bug
                    // in CryptUIWizDigitalSign().
                    // It returns 80004005 or 80070001
                    // but it signs the file correctly. Mask this error
                    // till we figure out this odd behavior.
                    //
                    if ((error == 0x80004005) ||
                        (error == 0x80070001) ||

                        // CryptUIWizDigitalSign introduced a breaking change in Win8 to return this
                        // error code (ERROR_INTERNET_NAME_NOT_RESOLVED) when you provide an invalid
                        // timestamp server. It used to be 0x80070001.
                        // Also masking this out so that we don't introduce a breaking change ourselves.
                        (error == 0x80072EE7)
                        )
                    {
                        result = true;
                    }
                    else
                    {
                        if (error == Win32Errors.NTE_BAD_ALGID)
                        {
                            throw PSTraceSource.NewArgumentException(
                                      "certificate",
                                      Authenticode.InvalidHashAlgorithm);
                        }

                        s_tracer.TraceError("CryptUIWizDigitalSign: failed: {0:x}",
                                            error);
                    }
                }

                if (result)
                {
                    signature = GetSignature(fileName, null);
                }
                else
                {
                    signature = new Signature(fileName, (DWORD)error);
                }
            }
            finally
            {
                Marshal.DestroyStructure <NativeMethods.CRYPTUI_WIZ_DIGITAL_SIGN_INFO>(pSignInfo);
                Marshal.FreeCoTaskMem(pSignInfo);
            }

            return(signature);
        }
 public static int GETARG_B(Instruction i)
 {
     return(getarg(i, POS_B, SIZE_B));
 }
 public static int GETARG_C(Instruction i)
 {
     return(getarg(i, POS_C, SIZE_C));
 }
        private static string GetSignatureStatusMessage(SignatureStatus status,
                                                        DWORD error,
                                                        string filePath)
        {
            string message        = null;
            string resourceString = null;
            string arg            = null;

            switch (status)
            {
            case SignatureStatus.Valid:
                resourceString = MshSignature.MshSignature_Valid;
                break;

            case SignatureStatus.UnknownError:
                int            intError = SecuritySupport.GetIntFromDWORD(error);
                Win32Exception e        = new Win32Exception(intError);
                message = e.Message;
                break;

            case SignatureStatus.Incompatible:
                if (error == Win32Errors.NTE_BAD_ALGID)
                {
                    resourceString = MshSignature.MshSignature_Incompatible_HashAlgorithm;
                }
                else
                {
                    resourceString = MshSignature.MshSignature_Incompatible;
                }
                arg = filePath;
                break;

            case SignatureStatus.NotSigned:
                resourceString = MshSignature.MshSignature_NotSigned;
                arg            = filePath;
                break;

            case SignatureStatus.HashMismatch:
                resourceString = MshSignature.MshSignature_HashMismatch;
                arg            = filePath;
                break;

            case SignatureStatus.NotTrusted:
                resourceString = MshSignature.MshSignature_NotTrusted;
                arg            = filePath;
                break;

            case SignatureStatus.NotSupportedFileFormat:
                resourceString = MshSignature.MshSignature_NotSupportedFileFormat;
                arg            = System.IO.Path.GetExtension(filePath);

                if (String.IsNullOrEmpty(arg))
                {
                    resourceString = MshSignature.MshSignature_NotSupportedFileFormat_NoExtension;
                    arg            = null;
                }
                break;
            }

            if (message == null)
            {
                if (arg == null)
                {
                    message = resourceString;
                }
                else
                {
                    message = StringUtil.Format(resourceString, arg);
                }
            }

            return(message);
        }
 public i32 decode(u32 value) => Coder.ZigZag.Decode(value);
Exemple #59
0
		static extern GtkWidgetPointer gtk_spin_button_new (GtkAdjustmentPointer adjustment, gdouble climb_rate, guint digits);
 static int MIN(int x, u32 y)
 {
     return((x < y) ? x : (int)y);
 }