コード例 #1
0
        /// <summary>
        /// Attempts to allocate the memory to store the text to be supplied to FASM assembler.
        /// </summary>
        private void AllocateText(int textSize, int retryCount)
        {
            var allocationProperties = _bufferHelper.Allocate(textSize, 1, Int32.MaxValue, retryCount);

            _textAddress = allocationProperties.MemoryAddress;
            _textSize    = allocationProperties.Size;

            if (_textAddress == IntPtr.Zero)
            {
                throw new FasmWrapperException("Failed to allocate text memory for Assembler.");
            }
        }
コード例 #2
0
        private void AllocateFree()
        {
            for (int x = 0; x < 20; x++)
            {
                // Commit
                var buf    = _bufferHelper.Allocate(4096);
                var extBuf = _externalBufferHelper.Allocate(4096);

                // Write something to start of buffers to test allocation.
                var bufMem    = new Sources.Memory();
                var extBufMem = new ExternalMemory(_externalBufferHelper.Process);

                bufMem.Write(buf.MemoryAddress, 5);
                extBufMem.Write(extBuf.MemoryAddress, 5);

                // Release
                _bufferHelper.Free(buf.MemoryAddress);
                _externalBufferHelper.Free(extBuf.MemoryAddress);
            }
        }