private static unsafe byte *toByteArray(UnitSettings data)
        {
            int               dataSize = 4168;
            IntPtr            ptr      = Marshal.AllocHGlobal(dataSize);
            byte *            bytes    = (byte *)ptr;
            UnsafeWriteBuffer wb       = new UnsafeWriteBuffer(bytes);

            wb.writeData(data);
            return(bytes);
        }
        private static unsafe void run(TranslationStructure *settings)
        {
            unsafe {
                // Move to unmanaged memory

                //int dataSize = Marshal.SizeOf<EUDSettings>(settings);

                int               dataSize = 1024; // Stupid but works
                IntPtr            ptr      = Marshal.AllocHGlobal(dataSize);
                byte *            data     = (byte *)ptr;
                UnsafeWriteBuffer wb       = new UnsafeWriteBuffer(data);
                wb.writeByte(settings->action);
                wb.writeBytePtr(settings->inputFilePath);
                wb.writeBytePtr(settings->outputFilePath);

                wb.writeBytePtr(settings->stringData);
                wb.writeInt(settings->stringDataLength);

                wb.writeInt(settings->useCondition);
                wb.writeByte(settings->repack);

                wb.writeByte(settings->result);

                // Process
                IntPtr ms = (IntPtr)data;
                Process(ms);

                UnsafeReadBuffer rb = new UnsafeReadBuffer(data);
                settings->action = (byte)rb.readByte();

                settings->inputFilePath  = rb.readBytePtr();
                settings->outputFilePath = rb.readBytePtr();

                settings->stringData       = rb.readBytePtr();
                settings->stringDataLength = rb.readInt();

                settings->useCondition = rb.readInt();
                settings->repack       = (byte)rb.readByte();

                settings->result = (byte)rb.readByte();

                Marshal.FreeHGlobal(ptr);
            }
        }
        private static unsafe byte *toByteArray(int[] data, String[] strArr, int *outLength, String encoding)
        {
            int dataSize = 4; // Size of array

            byte *[] strPtrs        = new byte *[strArr.Length];
            int[]    strPtrsLengths = new int[strArr.Length];

            for (int i = 0; i < strArr.Length; i++)
            {
                int   len  = 0; // Total length of encoded data, without null delimiter
                byte *strR = toByteArray(strArr[i], &len, encoding);
                strPtrs[i]        = strR;
                strPtrsLengths[i] = len;
                dataSize         += len + 4 + 4; // Size of string, ID of string and length of length
            }

            IntPtr ptr = Marshal.AllocHGlobal(dataSize);

            if (outLength != null)
            {
                *outLength = dataSize;
            }

            byte *            bytes = (byte *)ptr;
            UnsafeWriteBuffer wb    = new UnsafeWriteBuffer(bytes);

            wb.writeInt(strArr.Length);
            for (int i = 0; i < strArr.Length; i++)
            {
                byte *str = strPtrs[i];
                int   len = strPtrsLengths[i];
                wb.writeInt(data[i]);
                wb.writeInt(len);
                for (int o = 0; o < len; o++)
                {
                    wb.writeByte(str[o]);
                }
                killByteArray(str);
            }

            return(bytes);
        }
        private static unsafe void run(EUDSettings *settings)
        {
            unsafe
            {
                // Move to unmanaged memory

                //int dataSize = Marshal.SizeOf<EUDSettings>(settings);

                int               dataSize = 1024; // Stupid but works
                IntPtr            ptr      = Marshal.AllocHGlobal(dataSize);
                byte *            data     = (byte *)ptr;
                UnsafeWriteBuffer wb       = new UnsafeWriteBuffer(data);
                wb.writeByte(settings->action);
                wb.writeBool(settings->addTouchRevive);
                wb.writeBool(settings->useDefaultGunShot);
                wb.writeBool(settings->useDefaultBackgroundMusic);
                wb.writeBool(settings->enableVisor);
                wb.writeBool(settings->enableBarrier);
                wb.writeBool(settings->addLeaderboard);
                wb.writeBool(settings->addTimeLock);

                wb.writeBool(settings->useSanctuaryColors);

                wb.writeBool(settings->recalculateHPAndDamage);
                wb.writeBool(settings->muteUnits);

                wb.writeBytePtr(settings->GunShotWavFilePath);
                wb.writeBytePtr(settings->VisorUsageFilePath);
                wb.writeBytePtr(settings->BackgroundWavFilePath);

                wb.writeBytePtr(settings->TimeLockMessage);
                wb.writeBytePtr(settings->TimeLockFrom);
                wb.writeBytePtr(settings->TimeLockTo);
                wb.writeBytePtr(settings->inputFilePath);
                wb.writeBytePtr(settings->outputFilePath);

                wb.writeShort(settings->EMPDamage);

                wb.writeInt(settings->result);
                wb.writeBytePtr(settings->preferredUnitSettings);
                wb.writeBytePtr(settings->ignoreArmors);

                wb.writeBytePtr(settings->mapName);
                wb.writeBytePtr(settings->description);
                wb.writeBytePtr(settings->objectives);
                wb.writeBool(settings->useObjectives);

                // Process
                IntPtr ms = (IntPtr)data;
                Process(ms);

                UnsafeReadBuffer rb = new UnsafeReadBuffer(data);
                settings->action                    = (byte)rb.readByte();
                settings->addTouchRevive            = rb.readBool();
                settings->useDefaultGunShot         = rb.readBool();
                settings->useDefaultBackgroundMusic = rb.readBool();
                settings->enableVisor               = rb.readBool();
                settings->enableBarrier             = rb.readBool();
                settings->addLeaderboard            = rb.readBool();
                settings->addTimeLock               = rb.readBool();
                settings->useSanctuaryColors        = rb.readBool();
                settings->recalculateHPAndDamage    = rb.readBool();
                settings->muteUnits                 = rb.readBool();

                settings->GunShotWavFilePath    = rb.readBytePtr();
                settings->VisorUsageFilePath    = rb.readBytePtr();
                settings->BackgroundWavFilePath = rb.readBytePtr();

                settings->TimeLockMessage       = rb.readBytePtr();
                settings->TimeLockFrom          = rb.readBytePtr();
                settings->TimeLockTo            = rb.readBytePtr();
                settings->inputFilePath         = rb.readBytePtr();
                settings->outputFilePath        = rb.readBytePtr();
                settings->EMPDamage             = (short)rb.readShort();
                settings->result                = rb.readInt();
                settings->preferredUnitSettings = rb.readBytePtr();
                settings->ignoreArmors          = rb.readBytePtr();

                settings->mapName       = rb.readBytePtr();
                settings->description   = rb.readBytePtr();
                settings->objectives    = rb.readBytePtr();
                settings->useObjectives = rb.readBool();

                Marshal.FreeHGlobal(ptr);
            }
        }