Пример #1
0
 public static void Information(object message)
 {
     foreach (var m in SplitMessage(message))
     {
         PluginLog.LogInformation($"{m}");
     }
 }
Пример #2
0
 public static void Information(object message, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerName = "", [CallerLineNumber] int lineNumber = -1)
 {
     foreach (var m in SplitMessage(message))
     {
         PluginLog.LogInformation($"[{callerPath.Substring(_subStrIndex)}::{callerName}:{lineNumber}] {message}");
     }
 }
Пример #3
0
        private void DeleteFile(FileInfo file)
        {
            try
            {
                if (file.Extension != ".json")
                {
                    throw new InvalidOperationException("File must be json!");
                }

                file.Delete();
                PluginLog.LogInformation($"Deleted file {file.FullName}");
            }
            catch (Exception e)
            {
                QoLBar.PrintError($"Failed to delete: {e.Message}");
            }
        }
Пример #4
0
        private void BackupFile(FileInfo file, string name = "", bool overwrite = false)
        {
            try
            {
                if (file.Extension != ".json")
                {
                    throw new InvalidOperationException("File must be json!");
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss");
                }

                var path = Config.GetPluginBackupPath() + $"\\{name}.json";
                file.CopyTo(path, overwrite);
                PluginLog.LogInformation($"Saved file to {path}");
            }
            catch (Exception e)
            {
                QoLBar.PrintError($"Failed to save: {e.Message}");
            }
        }
Пример #5
0
        public static void Init(DalamudPluginInterface pluginInterface)
        {
            if (pluginInterface == null)
            {
                throw new Exception("Error in \"MemoryHandler.Init()\": A null plugin interface was passed!");
            }

            //	Save this off.
            mPluginInterface = pluginInterface;

            //	Get Function Pointers, etc.
            try
            {
                IntPtr fpGetUISAVESectionAddress = mPluginInterface.TargetModuleScanner.ScanText("40 53 48 83 EC 20 48 8B 0D ?? ?? ?? ?? 0F B7 DA");
                if (fpGetUISAVESectionAddress != IntPtr.Zero)
                {
                    mdGetUISAVESectionAddress = Marshal.GetDelegateForFunctionPointer <GetConfigSectionDelegate>(fpGetUISAVESectionAddress);
                }

                //	Write this address to log to help with digging around in memory if we need to.
                if (mdGetUISAVESectionAddress != null)
                {
                    PluginLog.LogInformation($"FMARKER.DAT address: 0x{mdGetUISAVESectionAddress.Invoke( IntPtr.Zero, mFMARKERDATIndex ).ToString( "X" )}");
                }

                IntPtr fpGetPresetAddressForSlot = mPluginInterface.TargetModuleScanner.ScanText("4C 8B C9 85 D2 78 0A 83 FA 08 73 05");
                if (fpGetPresetAddressForSlot != IntPtr.Zero)
                {
                    mdGetPresetAddressForSlot = Marshal.GetDelegateForFunctionPointer <GetPresetAddressForSlotDelegate>(fpGetPresetAddressForSlot);
                }

                //*****TODO: Determine actual proper sig.*****
                IntPtr fpGetCurrentContentFinderLinkType = mPluginInterface.TargetModuleScanner.ScanText("48 83 EC 28 48 8B 05 ?? ?? ?? ?? 48 85 C0 0F 84 A8 00 00 00 83 B8 ?? 2F 00 00 06 0F 85 9B 00 00 00");
                if (fpGetCurrentContentFinderLinkType != IntPtr.Zero)
                {
                    mdGetCurrentContentFinderLinkType = Marshal.GetDelegateForFunctionPointer <GetCurrentContentFinderLinkTypeDelegate>(fpGetCurrentContentFinderLinkType);
                }

                IntPtr fpDirectPlacePreset = mPluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 84 C0 0F 94 C0 EB 19");
                if (fpDirectPlacePreset != IntPtr.Zero)
                {
                    mdDirectPlacePreset = Marshal.GetDelegateForFunctionPointer <DirectPlacePresetDelegate>(fpDirectPlacePreset);
                }

                IntPtr fpGetCurrentWaymarkData = mPluginInterface.TargetModuleScanner.ScanText("48 89 ?? ?? ?? 57 48 83 ?? ?? 48 8B ?? 48 8B ?? 33 D2 48 8B");
                if (fpGetCurrentWaymarkData != IntPtr.Zero)
                {
                    mdGetCurrentWaymarkData = Marshal.GetDelegateForFunctionPointer <GetCurrentWaymarkDataDelegate>(fpGetCurrentWaymarkData);
                }

                mpWaymarksObj = mPluginInterface.TargetModuleScanner.GetStaticAddressFromSig("41 80 F9 08 7C BB 48 8D ?? ?? ?? 48 8D ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 84 C0 0F 94 C0 EB 19", 11);

                //	Write this address to log to help with digging around in memory if we need to.
                PluginLog.LogInformation($"Waymarks object address: 0x{mpWaymarksObj.ToString( "X" )}");

                //*****TODO:	Ideally we would check the size of the FMARKER.DAT section against the expected number of presets and the struct size, and
                //				warn the user if it doesn't all line up (or maybe only if it's not divisible?), but it doesn't appear to store the size of
                //				the config section like it does in UISAVE.DAT, so this may not be feasible.  We could consider checking the difference between
                //				the pointer to this section and the next section, but that seems a bit unreliable.*****
            }
            catch (Exception e)
            {
                throw new Exception($"Error in \"MemoryHandler.Init()\" while searching for required function signatures; this probably means that the plugin needs to be updated due to changes in Final Fantasy XIV.  Raw exception as follows:\r\n{e}");
            }
        }