Пример #1
0
        public static int Init(IntPtr nativeHandlesPtr, int nativeHandlesLength, IGameManager gameManager)
        {
            GameManager = gameManager;

            if (nativeHandlesPtr == IntPtr.Zero)
            {
                Console.WriteLine("Received NULL bootstrap structure");
                return(1);
            }

            int expectedLength = Marshal.SizeOf(typeof(NativeHandles));

            if (nativeHandlesLength < expectedLength)
            {
                Console.WriteLine($"Received bootstrap structure too small - actual={nativeHandlesLength}, expected={expectedLength}");
                return(1);
            }

            if (nativeHandlesLength > expectedLength)
            {
                Console.WriteLine($"WARNING: Received bootstrap structure bigger than expected - actual={nativeHandlesLength}, expected={expectedLength}");
                Console.WriteLine("         This usually means that native code version is ahead of the managed code");
            }

            NativeFunctions = Marshal.PtrToStructure <NativeHandles>(nativeHandlesPtr);
            RegisterHandles();
            RegisterNativeEventHandles();
            return(0);
        }