示例#1
0
        /// <summary>
        /// imageHelper Constructor passing in width and height and whether we want to tilt the feature
        /// </summary>
        /// <param name="pWidth"></param>
        /// <param name="pHeight"></param>
        /// <param name="pComputeTilted"></param>
        protected ImageHelper(int pWidth, int pHeight, bool pComputeTilted)
        {
            // figure out the width and height for each
            this.iWidth = pWidth;
            this.iHeight = pHeight;

            this.nWidth = pWidth + 1;
            this.nHeight = pHeight + 1;

            this.tWidth = pWidth + 2;
            this.tHeight = pHeight + 2;

            // grab the image and create a GCHandle pointer to the memory for that image
            this.integralImage = new int[nHeight, nWidth];
            this.intPointer = GCHandle.Alloc(integralImage, GCHandleType.Pinned);
            this.intImage = (int*)intPointer.AddrOfPinnedObject().ToPointer();

            this.squaredIntImage = new int[nHeight, nWidth];
            this.squaredPointer = GCHandle.Alloc(squaredIntImage, GCHandleType.Pinned);
            this.squaredImage = (int*)squaredPointer.AddrOfPinnedObject().ToPointer();

            if (pComputeTilted)
            {
                this.tiltedIntImage = new int[tHeight, tWidth];
                this.tiltedPointer = GCHandle.Alloc(tiltedIntImage, GCHandleType.Pinned);
                this.tiltedImage = (int*)tiltedPointer.AddrOfPinnedObject().ToPointer();
            }
        }
 internal unsafe DBCSCodePageEncoding(SerializationInfo info, StreamingContext context) : base(0)
 {
     this.mapBytesToUnicode = null;
     this.mapUnicodeToBytes = null;
     this.mapCodePageCached = null;
     throw new ArgumentNullException("this");
 }
示例#3
0
 void testError()
 {
     unsafe
     {
         int*[] ptrArray = new int*[10];
     }
 }
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="model">The model the successors are computed for.</param>
		/// <param name="capacity">The maximum number of successors that can be cached.</param>
		/// <param name="formulas">The formulas that should be checked for all successor states.</param>
		public ActivationMinimalTransitionSetBuilder(RuntimeModel model, long capacity, params Func<bool>[] formulas)
		{
			Requires.NotNull(model, nameof(model));
			Requires.NotNull(formulas, nameof(formulas));
			Requires.That(formulas.Length < 32, "At most 32 formulas are supported.");
			Requires.That(capacity <= (1 << 30), nameof(capacity), $"Maximum supported capacity is {1 << 30}.");

			_stateVectorSize = model.StateVectorSize;
			_formulas = formulas;

			_transitionBuffer.Resize(capacity * sizeof(CandidateTransition), zeroMemory: false);
			_transitions = (CandidateTransition*)_transitionBuffer.Pointer;

			_targetStateBuffer.Resize(capacity * model.StateVectorSize, zeroMemory: true);
			_targetStateMemory = _targetStateBuffer.Pointer;

			_lookupBuffer.Resize(capacity * sizeof(int), zeroMemory: false);
			_faultsBuffer.Resize(capacity * sizeof(FaultSetInfo), zeroMemory: false);
			_hashedStateBuffer.Resize(capacity * _stateVectorSize, zeroMemory: false);

			_successors = new List<uint>();
			_capacity = capacity;

			_lookup = (int*)_lookupBuffer.Pointer;
			_faults = (FaultSetInfo*)_faultsBuffer.Pointer;
			_hashedStateMemory = _hashedStateBuffer.Pointer;

			for (var i = 0; i < capacity; ++i)
				_lookup[i] = -1;
		}
示例#5
0
        /// <summary>
        /// Initialize a new GridBitmap with the given dimensions and color range.
        /// </summary>
        /// <param name="x">The width of the bitmap (in pixels)</param>
        /// <param name="y">The height of the bitmap (in pixels)</param>
        /// <param name="colors">An array containing RGB values indicating how states should be colored. Array size
        /// should correspond to the number of states; a cell in state i will be colored with the RGB value in colors[i].
        /// If a color for a given state is undefined, undefinedColor will be used.</param>
        public GridBitmap(int x, int y, uint defaultState, int[] colors)
        {
            gridSizeX = x;
            gridSizeY = y;
            colorList = colors;

            numPixels = (uint)(gridSizeX * gridSizeY);
            numBytes = numPixels * 4;
            int stride = (gridSizeX * format.BitsPerPixel + 7) / 8;

            // Make a memory mapping for the bitmap
            map = CreateFileMapping(INVALID_HANDLE_VALUE, IntPtr.Zero, PAGE_READWRITE, 0, numBytes, null);

            // Initialize a blank bitmap (using the color specified for the default state)
            unsafe {
                vptr = (int*)MapViewOfFile(map, FILE_MAP_ALL_ACCESS, 0, 0, numBytes).ToPointer();
                Parallel.For(0, gridSizeY, j => {
                    int rowStart = j * gridSizeX;
                    for (int i = 0; i < gridSizeX; i++) vptr[rowStart+i] = colors[defaultState];
                });
            }

            // Create a bitmap source using the memory map
            bmpSource = (InteropBitmap)Imaging.CreateBitmapSourceFromMemorySection(map, gridSizeX, gridSizeY, format, stride, 0);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryMappedTexture32bpp"/> class.
 /// </summary>
 /// <param name="size">The total size of the texture.</param>
 public MemoryMappedTexture32bpp(Size2 size)
 {
     m_pointer = Marshal.AllocHGlobal(size.Width * size.Height * 4);
     m_pointerNative = (int*)m_pointer.ToPointer();
     m_size = size;
     m_countInts = m_size.Width * m_size.Height;
 }
示例#7
0
        public override void BeginRender(Object sender, EventArgs e, Dictionary<String, UInt32> map)
        {
            if (map == null)
                return;

            size = (int*)map["watchedn"];
            from = (int*)map["watchedStart"];
            to = (int*)map["watchedGoal"];

            if (size != (int*)0)
            {
                if (isInitialized == false)
                {
                    isInitialized = true;
                    oldSize = *size;
                    oldFrom = *from;
                    oldTo = *to;
                    Initialize();

                    //MoveItem(pole1, pole3);
                    //MoveItem(pole1, pole2);
                    //MoveItem(pole3, pole2);
                    MoveItem(poleMap[oldFrom.ToString()], poleMap[oldTo.ToString()]);
                }
                if ((*from != oldFrom || *to != oldTo) && poleMap[(*from).ToString()].Count > 0 && poleMap[(*to).ToString()].Count < oldSize)
                {
                    oldFrom = *from;
                    oldTo = *to;
                    MoveItem(poleMap[oldFrom.ToString()], poleMap[oldTo.ToString()]);
                }
            }
        }
        /// <summary>
        ///   Constructs a new Integral image of the given size.
        /// </summary>
        /// 
        protected IntegralImage2(int width, int height, bool computeTilted)
        {
            this.width = width;
            this.height = height;

            this.nWidth = width + 1;
            this.nHeight = height + 1;

            this.tWidth = width + 2;
            this.tHeight = height + 2;

            this.nSumImage = new int[nHeight, nWidth];
            this.nSumHandle = GCHandle.Alloc(nSumImage, GCHandleType.Pinned);
            this.nSum = (int*)nSumHandle.AddrOfPinnedObject().ToPointer();

            this.sSumImage = new int[nHeight, nWidth];
            this.sSumHandle = GCHandle.Alloc(sSumImage, GCHandleType.Pinned);
            this.sSum = (int*)sSumHandle.AddrOfPinnedObject().ToPointer();

            if (computeTilted)
            {
                this.tSumImage = new int[tHeight, tWidth];
                this.tSumHandle = GCHandle.Alloc(tSumImage, GCHandleType.Pinned);
                this.tSum = (int*)tSumHandle.AddrOfPinnedObject().ToPointer();
            }
        }
示例#9
0
        public VertexBuffer(int vertexCapacity, int indexCapacity)
        {
            declarations = new List<VertexDeclaration>();

            int tmp;
            GL.GenVertexArrays(1, out tmp);
            VertexArrayObject = tmp;
            GL.BindVertexArray(VertexArrayObject);

            GL.GenBuffers(1, out tmp);
            VertexDataBufferObject = tmp;

            GL.GenBuffers(1, out tmp);
            IndexDataBufferObject = tmp;

            UsageMode = BufferUsageHint.DynamicDraw;

            vertexDataLength = vertexCapacity;
            indexDataLength = indexCapacity;

            _indexDataPointer = Marshal.AllocHGlobal(indexDataLength * sizeof(int));
            IndexData = (int*)_indexDataPointer.ToPointer();

            _vertexDataPointer = Marshal.AllocHGlobal(vertexDataLength * sizeof(float));
            VertexData = (float*)_vertexDataPointer.ToPointer();

            voffset = 0;
            ioffset = 0;
            stride = 0;
        }
示例#10
0
 static unsafe void Main(string[] args) {
     int[] i = new int[] { 10 };
     fixed (int* p = i) {
         int*[] q = new int*[] { p };
         *q[0] = 5;
         Console.WriteLine(*q[0]);
     }
 }
示例#11
0
文件: Axis.cs 项目: HaKDMoDz/InVision
        /// <summary>
        /// Initializes the specified descriptor.
        /// </summary>
        /// <param name="descriptor">The descriptor.</param>
        protected void Initialize(AxisDescriptor descriptor)
        {
            Initialize(descriptor.Base);

            _abs = descriptor.Abs;
            _rel = descriptor.Rel;
            _absOnly = descriptor.AbsOnly;
        }
示例#12
0
 public AtomicInt(byte* ptr)
 {
     if (((long)ptr & 3) != 0)
     {
         throw new ArgumentException("The address should be aligned to 4 byte boundary");
     }
     _ptr = (int*)ptr;
 }
示例#13
0
文件: Matrix.cs 项目: Farouq/semclone
    public Matrix(int size)
    {
        if (!_validSizes.Contains(size)) throw new ArgumentOutOfRangeException("size");
        _size = size;
        _data = new int[size * size];

        _dataPtrHandle = GCHandle.Alloc(_data, GCHandleType.Pinned);
        _dataPtr = (int*)_dataPtrHandle.AddrOfPinnedObject().ToPointer();
    }
        private int* _tail; //save first data byte offset index

        public LoopMemoryStream(byte* dataArea, int length)
        {
            _dataArea = dataArea;
            _totalLen = length - PREHEAD;

            _head = (int*) _dataArea;
            _tail = (int*) _dataArea + 1;

            _start = dataArea + PREHEAD;
            _end = dataArea + length;
        }
示例#15
0
		/// <summary>
		///   Initializes a new instance.
		/// </summary>
		/// <param name="capacity">The maximum number of states that can be stored on the stack.</param>
		public StateStack(long capacity)
		{
			Requires.InRange(capacity, nameof(capacity), 1024, Int32.MaxValue);

			_framesBuffer.Resize(capacity * sizeof(Frame), zeroMemory: false);
			_statesBuffer.Resize(capacity * sizeof(int), zeroMemory: false);

			_frames = (Frame*)_framesBuffer.Pointer;
			_states = (int*)_statesBuffer.Pointer;
			_capacity = capacity;
		}
示例#16
0
 public unsafe override int Solve()
 {
     _capacity = _knapsack.Capacity;
       _idx = 0;
       _sumCost = 0;
       _sumWeight = 0;
       fixed (int* itemsPtr = &_knapsack.ItemValues[0])
       {
     items = itemsPtr;
     return RecursiveKnapsackRec();
       }
 }
示例#17
0
        internal ImageExports(MappedImage mappedImage)
        {
            _mappedImage = mappedImage;
            _dataDirectory = mappedImage.GetDataEntry(ImageDataEntry.Export);
            _exportDirectory = mappedImage.GetExportDirectory();

            if (_exportDirectory != null)
            {
                _addressTable = (int*)mappedImage.RvaToVa(_exportDirectory->AddressOfFunctions);
                _namePointerTable = (int*)mappedImage.RvaToVa(_exportDirectory->AddressOfNames);
                _ordinalTable = (short*)mappedImage.RvaToVa(_exportDirectory->AddressOfNameOrdinals);
            }
        }
        public MMFMessageQueue(string mmfName, int size)
        {
            _mmfName = mmfName;
            _size = size;
            _realSize = _size - sizeof(int*) * 3;

            _shm = GetOrCreateMMFView();
            _lck = (int*)_shm;
            _ms = new LoopMemoryStream((byte*)_shm + sizeof(int*), _size - sizeof(int*));
            //_ms.ClearData();//打开的同时清理

            _head = _ms.Head;
            _tail = _ms.Tail;
        }
示例#19
0
        public unsafe override int Solve()
        {
            SumAll();
              _max = _sumAllWeights*2 + 1;
              _weights = new int[_size + 1, _sumAllCosts + 1];
              FillInf();

              fixed (int* itemsPtr = &_knapsack.ItemValues[0])
              {
            _items = itemsPtr;
            MainLoop();
              }

              return ReadSolution();
        }
        public unsafe void PointerNonGeneric()
        {
            {
                var e1 = Emit.NewDynamicMethod(typeof(IntPtr), new [] { typeof(int*[]), typeof(int) });
                e1.LoadArgument(0);
                e1.LoadArgument(1);
                e1.LoadElement(typeof(int*));
                e1.Return();

                var x = new int*[] { (int*)123 };

                var d1 = e1.CreateDelegate<Func<int*[], int, IntPtr>>();

                var y = (int*)d1(x, 0);

                Assert.IsTrue(x[0] == y);
            }
        }
示例#21
0
        public unsafe override int Solve()
        {
            SumFullCost();
              CalculateBits();
              int[] fptasItems = MakeFPTASItems();
              SumAll(fptasItems);
              _max = _sumAllWeights * 2 + 1;
              _weights = new int[_size + 1, _sumAllCosts + 1];
              FillInf();

              fixed (int* itemsPtr = &fptasItems[0])
              {
            _items = itemsPtr;
            MainLoop();
              }

              return ReadSolution();
        }
示例#22
0
 public unsafe override int Solve()
 {
     _capacity = _knapsack.Capacity;
       _idx = 0;
       _sumCost = 0;
       _sumWeight = 0;
       _currMaxCost = 0;
       fixed (int* itemsPtr = &_knapsack.ItemValues[0])
       {
     _items = itemsPtr;
     int[] postSums = new int[_size];
     fixed (int* postSumsPtr = &postSums[0])
     {
       _postCostSums = postSumsPtr;
       CalculatePostCostSums();
       return RecursiveKnapsackRec();
     }
       }
 }
示例#23
0
		void Setup(int size)
		{
			bool init = size != -1;

			mmva = mmf.CreateViewAccessor();
			byte* tempPtr = null;
			mmva.SafeMemoryMappedViewHandle.AcquirePointer(ref tempPtr);
			mmvaPtr = tempPtr;

			//setup management area
			head = (int*)mmvaPtr;
			tail = (int*)mmvaPtr + 1;
			int* bufsizeptr = (int*)mmvaPtr + 2;
			begin = mmvaPtr + 12;

			if (init)
				*bufsizeptr = bufsize = size - 12;
			else bufsize = *bufsizeptr;
		}
示例#24
0
        private unsafe UOHooks(int pId, IntPtr sharedMemory, OnUOMessage handler)
        {
            ProcessId = pId;
            FileVersionInfo v = Process.GetProcessById(pId).MainModule.FileVersionInfo;
            Version = new Version(v.FileMajorPart, v.FileMinorPart, v.FileBuildPart, v.FilePrivatePart);

            dataIn = (byte*)sharedMemory.ToPointer();
            dataOut = dataIn + BufferSize;

            msgIn = (int*)(dataOut + BufferSize);
            msgOut = msgIn + 4;

            uint[] packetTable = new uint[0x100];
            fixed (uint* p = packetTable)
                memcpy(p, dataIn, packetTable.Length * sizeof(uint));
            PacketTable = packetTable;

            sentIn = new IntPtr(msgIn[0]);
            handledIn = new IntPtr(msgIn[1]);
            sentOut = new IntPtr(msgIn[2]);
            handledOut = new IntPtr(msgIn[3]);

            new Thread(MessagePump) { IsBackground = true }.Start(handler);
        }
 private void CloseBitmapData()
 {
     if (bmpData != null)
     {
         bmp.UnlockBits(bmpData);
         bmpData = null;
         scan0 = null;
     }
 }
            private void OpenBitmapData()
            {
                if (bmpData == null)
                {
                    bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
                        ImageLockMode.ReadOnly, bmp.PixelFormat);

                    // Use unsafe mode for fast access to the bitmapdata. We use a int* 
                    // pointer for faster access as the image format is 32-bit (althouth if
                    // the pointer is not 32-bit aligned it might take two read operations).
                    scan0 = (int*)bmpData.Scan0.ToPointer();
                }
            }
示例#27
0
		public void Init ()
		{
			if (inited)
				return;

			lock (initLock){
				if (inited)
					return;
				inited = true;
				
				/* This should not happen any more, since it is checked for in Console */
				if (!ConsoleDriver.IsConsole)
					throw new IOException ("Not a tty.");
				
				ConsoleDriver.SetEcho (false);
				
				string endString = null;
				keypadXmit = reader.Get (TermInfoStrings.KeypadXmit);
				keypadLocal = reader.Get (TermInfoStrings.KeypadLocal);
				if (keypadXmit != null) {
					WriteConsole (keypadXmit); // Needed to get the arrows working
					if (keypadLocal != null)
						endString += keypadLocal;
				}
				
				origPair = reader.Get (TermInfoStrings.OrigPair);
				origColors = reader.Get (TermInfoStrings.OrigColors);
				setfgcolor = reader.Get (TermInfoStrings.SetAForeground);
				setbgcolor = reader.Get (TermInfoStrings.SetABackground);
				maxColors = reader.Get (TermInfoNumbers.MaxColors);
				maxColors = Math.Max (Math.Min (maxColors, 16), 1);
				
				string resetColors = (origColors == null) ? origPair : origColors;
				if (resetColors != null)
					endString += resetColors;
				
				unsafe {
					if (!ConsoleDriver.TtySetup (keypadXmit, endString, out control_characters, out native_terminal_size)){
						control_characters = new byte [17];
						native_terminal_size = null;
						//throw new IOException ("Error initializing terminal.");
					}
				}
				
				stdin = new StreamReader (Console.OpenStandardInput (0), Console.InputEncoding);
				clear = reader.Get (TermInfoStrings.ClearScreen);
				bell = reader.Get (TermInfoStrings.Bell);
				if (clear == null) {
					clear = reader.Get (TermInfoStrings.CursorHome);
					clear += reader.Get (TermInfoStrings.ClrEos);
				}
				
				csrVisible = reader.Get (TermInfoStrings.CursorNormal);
				if (csrVisible == null)
					csrVisible = reader.Get (TermInfoStrings.CursorVisible);
				
				csrInvisible = reader.Get (TermInfoStrings.CursorInvisible);
				if (term == "cygwin" || term == "linux" || (term != null && term.StartsWith ("xterm")) ||
				    term == "rxvt" || term == "dtterm") {
					titleFormat = "\x1b]0;{0}\x7"; // icon + window title
				} else if (term == "iris-ansi") {
					titleFormat = "\x1bP1.y{0}\x1b\\"; // not tested
				} else if (term == "sun-cmd") {
					titleFormat = "\x1b]l{0}\x1b\\"; // not tested
				}
				
				cursorAddress = reader.Get (TermInfoStrings.CursorAddress);
				
				GetCursorPosition ();
#if DEBUG
				logger.WriteLine ("noGetPosition: {0} left: {1} top: {2}", noGetPosition, cursorLeft, cursorTop);
				logger.Flush ();
#endif
				if (noGetPosition) {
					WriteConsole (clear);
					cursorLeft = 0;
					cursorTop = 0;
				}
			}
		}
示例#28
0
		static Normalization ()
		{
			IntPtr p1, p2, p3, p4, p5, p6;
			lock (forLock) {
				load_normalization_resource (out p1, out p2, out p3, out p4, out p5, out p6);
				props = (byte*) p1;
				mappedChars = (int*) p2;
				charMapIndex = (short*) p3;
				helperIndex = (short*) p4;
				mapIdxToComposite = (ushort*) p5;
				combiningClass = (byte*) p6;
			}

			isReady = true;
		}
 [System.Security.SecuritySafeCritical]  // auto-generated
 private unsafe void Dispose(bool disposing)
 {
     if (_store != null) {
         _resCache = null;
         if (disposing) {
             // Close the stream in a thread-safe way.  This fix means 
             // that we may call Close n times, but that's safe.
             BinaryReader copyOfStore = _store;
             _store = null;
             if (copyOfStore != null)
                 copyOfStore.Close();
         }
         _store = null;
         _namePositions = null;
         _nameHashes = null;
         _ums = null;
         _namePositionsPtr = null;
         _nameHashesPtr = null;
     }
 }
        [System.Security.SecurityCritical]  // auto-generated
        private void _ReadResources()
        {
            // Read ResourceManager header
            // Check for magic number
            int magicNum = _store.ReadInt32();
            if (magicNum != ResourceManager.MagicNumber)
                throw new ArgumentException(Environment.GetResourceString("Resources_StreamNotValid"));
            // Assuming this is ResourceManager header V1 or greater, hopefully
            // after the version number there is a number of bytes to skip
            // to bypass the rest of the ResMgr header. For V2 or greater, we
            // use this to skip to the end of the header
            int resMgrHeaderVersion = _store.ReadInt32();
            int numBytesToSkip = _store.ReadInt32();
            if (numBytesToSkip < 0 || resMgrHeaderVersion < 0) {
                throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
            }
            if (resMgrHeaderVersion > 1) {
                BCLDebug.Log("RESMGRFILEFORMAT", LogLevel.Status, "ReadResources: Unexpected ResMgr header version: {0}  Skipping ahead {1} bytes.", resMgrHeaderVersion, numBytesToSkip);
                _store.BaseStream.Seek(numBytesToSkip, SeekOrigin.Current);
            }
            else {
                BCLDebug.Log("RESMGRFILEFORMAT", "ReadResources: Parsing ResMgr header v1.");
                // We don't care about numBytesToSkip; read the rest of the header

                // Read in type name for a suitable ResourceReader
                // Note ResourceWriter & InternalResGen use different Strings.
                String readerType = _store.ReadString();
                AssemblyName mscorlib = new AssemblyName(ResourceManager.MscorlibName);

                if (!ResourceManager.CompareNames(readerType, ResourceManager.ResReaderTypeName, mscorlib))
                    throw new NotSupportedException(Environment.GetResourceString("NotSupported_WrongResourceReader_Type", readerType));

                // Skip over type name for a suitable ResourceSet
                SkipString();
            }

            // Read RuntimeResourceSet header
            // Do file version check
            int version = _store.ReadInt32();
            if (version != RuntimeResourceSet.Version && version != 1)
                throw new ArgumentException(Environment.GetResourceString("Arg_ResourceFileUnsupportedVersion", RuntimeResourceSet.Version, version));
            _version = version;

#if RESOURCE_FILE_FORMAT_DEBUG
            // Look for ***DEBUG*** to see if this is a debuggable file.
            long oldPos = _store.BaseStream.Position;
            _debug = false;
            try {
                String debugString = _store.ReadString();
                _debug = String.Equals("***DEBUG***", debugString);
            }
            catch(IOException) {
            }
            catch(OutOfMemoryException) {
            }
            if (_debug) {
                Console.WriteLine("ResourceReader is looking at a debuggable .resources file, version {0}", _version);
            }
            else {
                _store.BaseStream.Position = oldPos;
            }
#endif

            _numResources = _store.ReadInt32();
            if (_numResources < 0) {
                throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
            }
            BCLDebug.Log("RESMGRFILEFORMAT", "ReadResources: Expecting " + _numResources + " resources.");
#if _DEBUG      
            if (ResourceManager.DEBUG >= 4)
                Console.WriteLine("ResourceReader::ReadResources - Reading in "+_numResources+" resources");
#endif

            // Read type positions into type positions array.
            // But delay initialize the type table.
            int numTypes = _store.ReadInt32();
            if (numTypes < 0) {
                throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
            }
            _typeTable = new RuntimeType[numTypes];
            _typeNamePositions = new int[numTypes];
            for (int i=0; i<numTypes; i++) {
                _typeNamePositions[i] = (int) _store.BaseStream.Position;

                // Skip over the Strings in the file.  Don't create types.
                SkipString();
            }

#if _DEBUG
                if (ResourceManager.DEBUG >= 5)
                    Console.WriteLine("ResourceReader::ReadResources - Reading in "+numTypes+" type table entries");
#endif

            // Prepare to read in the array of name hashes
            //  Note that the name hashes array is aligned to 8 bytes so 
            //  we can use pointers into it on 64 bit machines. (4 bytes 
            //  may be sufficient, but let's plan for the future)
            //  Skip over alignment stuff.  All public .resources files
            //  should be aligned   No need to verify the byte values.
            long pos = _store.BaseStream.Position;
            int alignBytes = ((int)pos) & 7;
            if (alignBytes != 0) {
                for (int i = 0; i < 8 - alignBytes; i++) {
                    _store.ReadByte();
                }
            }

            // Read in the array of name hashes
#if RESOURCE_FILE_FORMAT_DEBUG
                //  Skip over "HASHES->"
                if (_debug) {
                    _store.BaseStream.Position += 8;
                }
#endif

            if (_ums == null) {
                _nameHashes = new int[_numResources];
                for (int i = 0; i < _numResources; i++) {
                    _nameHashes[i] = _store.ReadInt32();
                }
            }
            else {
                int seekPos = unchecked(4 * _numResources);
                if (seekPos < 0) {
                    throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
                }
                unsafe {
                    _nameHashesPtr = (int*)_ums.PositionPointer;
                    // Skip over the array of nameHashes.
                    _ums.Seek(seekPos, SeekOrigin.Current);
                    // get the position pointer once more to check that the whole table is within the stream
                    byte* junk = _ums.PositionPointer;
                }
            }

            // Read in the array of relative positions for all the names.
#if RESOURCE_FILE_FORMAT_DEBUG
            // Skip over "POS---->"
            if (_debug) {
                _store.BaseStream.Position += 8;
            }
#endif
            if (_ums == null) {
                _namePositions = new int[_numResources];
                for (int i = 0; i < _numResources; i++) {
                    int namePosition = _store.ReadInt32();
                    if (namePosition < 0) {
                        throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
                    }

                    _namePositions[i] = namePosition;
                }
            }
            else {
                int seekPos = unchecked(4 * _numResources);
                if (seekPos < 0) {
                    throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
                }
                unsafe {
                    _namePositionsPtr = (int*)_ums.PositionPointer;
                    // Skip over the array of namePositions.
                    _ums.Seek(seekPos, SeekOrigin.Current);
                    // get the position pointer once more to check that the whole table is within the stream
                    byte* junk = _ums.PositionPointer;
                }
            }

            // Read location of data section.
            _dataSectionOffset = _store.ReadInt32();
            if (_dataSectionOffset < 0) {
                throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
            }

            // Store current location as start of name section
            _nameSectionOffset = _store.BaseStream.Position;

            // _nameSectionOffset should be <= _dataSectionOffset; if not, it's corrupt
            if (_dataSectionOffset < _nameSectionOffset) {
                throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"));
            }

            BCLDebug.Log("RESMGRFILEFORMAT", String.Format(CultureInfo.InvariantCulture, "ReadResources: _nameOffset = 0x{0:x}  _dataOffset = 0x{1:x}", _nameSectionOffset, _dataSectionOffset));
        }
示例#31
0
 public int GetRange([NativeTypeName("long")] int Property, [NativeTypeName("long *")] int *pMin, [NativeTypeName("long *")] int *pMax, [NativeTypeName("long *")] int *pSteppingDelta, [NativeTypeName("long *")] int *pDefault, [NativeTypeName("long *")] int *pCapsFlags)
 {
     return(((delegate * unmanaged <IAMCameraControl *, int, int *, int *, int *, int *, int *, int>)(lpVtbl[3]))((IAMCameraControl *)Unsafe.AsPointer(ref this), Property, pMin, pMax, pSteppingDelta, pDefault, pCapsFlags));
 }