コード例 #1
0
ファイル: Program.cs プロジェクト: conankzhang/fez
        private static int Main()
        {
            string executableName = Program.GetExecutableName();

            try
            {
                SOP.ResultCodes resultCodes1 = SOP.SOP_RemoveProfile("FEZ");
                SOP.ResultCodes resultCodes2 = SOP.SOP_SetProfile("FEZ", executableName);
                if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FEZ")))
                {
                    Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FEZ"));
                }
                using (FileStream fileStream = File.Open(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FEZ\\Debug Log.txt", FileMode.Append))
                {
                    using (StreamWriter streamWriter = new StreamWriter((Stream)fileStream))
                    {
                        streamWriter.WriteLine("({0}) [{1}] {2}", (object)DateTime.Now.ToString("HH:mm:ss.fff"), (object)"Optimus Fix", (object)string.Concat(new object[4]
                        {
                            (object)"SOP_Remove returned ",
                            (object)resultCodes1,
                            (object)" for ",
                            (object)executableName
                        }));
                        streamWriter.WriteLine("({0}) [{1}] {2}", (object)DateTime.Now.ToString("HH:mm:ss.fff"), (object)"Optimus Fix", (object)string.Concat(new object[4]
                        {
                            (object)"SOP_Set returned ",
                            (object)resultCodes2,
                            (object)" for ",
                            (object)executableName
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                using (FileStream fileStream = File.Open(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\FEZ\\Debug Log.txt", FileMode.Append))
                {
                    using (StreamWriter streamWriter = new StreamWriter((Stream)fileStream))
                        streamWriter.WriteLine("({0}) [{1}] {2}", (object)DateTime.Now.ToString("HH:mm:ss.fff"), (object)"Optimus Fix", (object)string.Concat(new object[4]
                        {
                            (object)"SOP raised exception : ",
                            (object)ex,
                            (object)" for ",
                            (object)executableName
                        }));
                }
            }
            return(0);
        }
コード例 #2
0
ファイル: SOP.cs プロジェクト: conankzhang/fez
        public static unsafe SOP.ResultCodes SOP_SetProfile(string profileName, string applicationName)
        {
            SOP.ResultCodes resultCodes = SOP.ResultCodes.NoChange;
            int             num         = 0;
            IntPtr          session;

            if (!SOP.GetProcs() || SOP.CheckForError(SOP.Initialize()) || (SOP.CheckForError(SOP.CreateSession(out session)) || SOP.CheckForError(SOP.LoadSettings(session))))
            {
                return(SOP.ResultCodes.Error);
            }
            ushort[] unicodeString1 = SOP.GetUnicodeString(profileName);
            ushort[] unicodeString2 = SOP.GetUnicodeString(applicationName);
            IntPtr   profile;
            int      status = SOP.FindProfileByName(session, profileName, out profile);

            if (status == -163)
            {
                SOP.Profile profileInfo = new SOP.Profile();
                profileInfo.version      = 69652U;
                profileInfo.isPredefined = 0U;
                for (int index = 0; index < 2048; ++index)
                {
                    // ISSUE: reference to a compiler-generated field
                    (&profileInfo.profileName.FixedElementField)[index] = unicodeString1[index];
                }

                fixed(uint *numPtr = new uint[32])
                {
                    profileInfo.gpuSupport = numPtr;
                    *profileInfo.gpuSupport = 1U;
                }

                if (SOP.CheckForError(SOP.CreateProfile(session, ref profileInfo, out profile)))
                {
                    return(SOP.ResultCodes.Error);
                }
                if (SOP.CheckForError(SOP.SetSetting(session, profile, ref new SOP.Setting()
                {
                    version = 77856U,
                    settingID = 284810369U,
                    u32CurrentValue = 17U
                })))
                {
                    return(SOP.ResultCodes.Error);
                }
            }
            else if (SOP.CheckForError(status))
            {
                return(SOP.ResultCodes.Error);
            }
            SOP.Profile profileInfo1 = new SOP.Profile();
            profileInfo1.version = 69652U;
            if (SOP.CheckForError(SOP.GetProfileInfo(session, profile, ref profileInfo1)))
            {
                return(SOP.ResultCodes.Error);
            }
            SOP.Application application = new SOP.Application();
            if (!SOP.ContainsApplication(session, profile, profileInfo1, SOP.GetUnicodeString(applicationName.ToLower(CultureInfo.InvariantCulture)), out application))
            {
                application.version      = 147464U;
                application.isPredefined = 0U;
                for (int index = 0; index < 2048; ++index)
                {
                    // ISSUE: reference to a compiler-generated field
                    (&application.appName.FixedElementField)[index] = unicodeString2[index];
                }
                if (SOP.CheckForError(SOP.CreateApplication(session, profile, ref application)) || SOP.CheckForError(SOP.SaveSettings(session)))
                {
                    return(SOP.ResultCodes.Error);
                }
                resultCodes = SOP.ResultCodes.Change;
            }
            num = SOP.DestroySession(session);
            return(resultCodes);
        }