예제 #1
0
            public unsafe XoshiroImpl()
            {
#if WINDOWS
                ulong *ptr = stackalloc ulong[4];
#elif EFI
                EfiImpl byteGen = new();
                //TODO Use stackalloc?
                byte[] bPtr = new byte[4 * sizeof(ulong)];
#endif
                do
                {
                    //TODO Add this function as soon as having reference type static fields is possible, this would avoid reinitialising EfiImpl or
                    //at least not using LocateHandle/OpenProtocol every time in order to access EFI_RNG_PROTOCOL.GetBytes
#if WINDOWS
                    Interop.GetRandomBytes((byte *)ptr, 4 * sizeof(ulong));
#elif EFI
                    byteGen.NextBytes(bPtr);
                    ulong[] ptr = Unsafe.As <ulong[]>(bPtr);
#endif
                    _s0 = ptr[0];
                    _s1 = ptr[1];
                    _s2 = ptr[2];
                    _s3 = ptr[3];
#if EFI
                    ptr.Free();
#endif
                }while ((_s0 | _s1 | _s2 | _s3) == 0); // at least one value must be non-zero

#if EFI
                bPtr.Free();
                byteGen.Free();
#endif
            }
예제 #2
0
        private void GrowStackTrace()
        {
            IntPtr[] newArray = new IntPtr[_corDbgStackTrace.Length * 2];
            for (int i = 0; i < _corDbgStackTrace.Length; i++)
            {
                newArray[i] = _corDbgStackTrace[i];
            }

            _corDbgStackTrace.Free();

            _corDbgStackTrace = newArray;
        }