コード例 #1
0
        private unsafe void SetGameModeTextCallStackBase(string textString)
        {
            var data = stackalloc int[1];

            var len       = NativeUtils.GetByteCount(textString);
            var textBytes = stackalloc byte[len];

            NativeUtils.GetBytes(textString, textBytes, len);


            data[0] = NativeUtils.BytePointerToInt(textBytes);

            Interop.FastNativeInvoke(new IntPtr(9999), "s", data);
        }
コード例 #2
0
        private unsafe void SetGameModeTextCallStackBase(string textString)
        {
            // prototype to inspect IL code for developing code generator
            var data = stackalloc int[1];

            var len       = NativeUtils.GetByteCount(textString);
            var textBytes = stackalloc byte[len];

            NativeUtils.GetBytes(textString, textBytes, len);


            data[0] = NativeUtils.BytePointerToInt(textBytes);

            Interop.FastNativeInvoke(new IntPtr(9999), "s", data);
        }
コード例 #3
0
        private unsafe void SetGameModeTextCall(IntPtr nativeSetGameModeText, string textString)
        {
            // concept test with string parameters
            Span <int> data = stackalloc int[16];

            var         textSpan  = GetStringEncodingAndLength(textString, out var enc, out var len);
            Span <byte> textBytes = stackalloc byte[len];

            textBytes[len - 1] = 0;
            enc.GetBytes(textSpan, textBytes);

            fixed(int *dataPtr = &data.GetPinnableReference())
            fixed(byte *textPtr = &textBytes.GetPinnableReference())
            {
                data[0] = NativeUtils.BytePointerToInt(textPtr);
                Interop.FastNativeInvoke(nativeSetGameModeText, "s", dataPtr);
            }
        }