示例#1
0
        private unsafe void *CallOriginalHandler(
            bool isSync,
            IntPtr pFileManager,
            uint *pCategoryId,
            char *pResourceType,
            uint *pResourceHash,
            char *pPath,
            void *pUnknown,
            bool isUnknown
            )
        {
            if (isSync)
            {
                if (GetResourceSyncHook == null)
                {
                    PluginLog.Error("[GetResourceHandler] GetResourceSync is null.");
                    return(null);
                }

                return(GetResourceSyncHook.OriginalFunction(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown));
            }

            if (GetResourceAsyncHook == null)
            {
                PluginLog.Error("[GetResourceHandler] GetResourceAsync is null.");
                return(null);
            }

            return(GetResourceAsyncHook.OriginalFunction(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown));
        }
示例#2
0
        public void Dispose()
        {
            if (IsEnabled)
            {
                Disable();
            }

            ReadSqpackHook.Dispose();
            GetResourceSyncHook.Dispose();
            GetResourceAsyncHook.Dispose();
        }
示例#3
0
    public void DisableHooks()
    {
        if (!HooksEnabled)
        {
            return;
        }

        HooksEnabled = false;
        ReadSqPackHook.Disable();
        GetResourceSyncHook.Disable();
        GetResourceAsyncHook.Disable();
    }
示例#4
0
    public void EnableHooks()
    {
        if (HooksEnabled)
        {
            return;
        }

        HooksEnabled = true;
        ReadSqPackHook.Enable();
        GetResourceSyncHook.Enable();
        GetResourceAsyncHook.Enable();
    }
示例#5
0
 private unsafe void *CallOriginalHandler(
     bool isSync,
     IntPtr pFileManager,
     uint *pCategoryId,
     char *pResourceType,
     uint *pResourceHash,
     char *pPath,
     void *pUnknown,
     bool isUnknown
     ) => isSync
     ? GetResourceSyncHook.OriginalFunction(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown)
     : GetResourceAsyncHook.OriginalFunction(pFileManager, pCategoryId, pResourceType, pResourceHash, pPath, pUnknown, isUnknown);
示例#6
0
        public void Disable()
        {
            if (!IsEnabled)
            {
                return;
            }
            IsEnabled = false;

            ReadSqpackHook.Disable();
            GetResourceSyncHook.Disable();
            GetResourceAsyncHook.Disable();
        }
示例#7
0
        // ======================

        public void Enable()
        {
            IsEnabled = true;

            ReadSqpackHook.Activate();
            GetResourceSyncHook.Activate();
            GetResourceAsyncHook.Activate();

            ReadSqpackHook.Enable();
            GetResourceSyncHook.Enable();
            GetResourceAsyncHook.Enable();
        }
示例#8
0
        public void Enable()
        {
            if (IsEnabled)
            {
                return;
            }

            ReadSqpackHook.Enable();
            GetResourceSyncHook.Enable();
            GetResourceAsyncHook.Enable();

            IsEnabled = true;
        }
示例#9
0
        private unsafe void *GetResourceHandler(bool isSync, IntPtr pFileManager, uint *pCategoryId,
                                                char *pResourceType, uint *pResourceHash, char *pPath, void *pUnknown, bool isUnknown)
        {
            var gameFsPath = Marshal.PtrToStringAnsi(new IntPtr(pPath));

            if (LogAllFiles)
            {
                PluginLog.Log("[ReadSqPack] {0}", gameFsPath);
            }

            var candidate = Plugin.ModManager.GetCandidateForGameFile(gameFsPath);

            // path must be < 260 because statically defined array length :(
            if (candidate == null || candidate.FullName.Length >= 260 || !candidate.Exists)
            {
                return(isSync
                    ? GetResourceSyncHook.Original(pFileManager, pCategoryId, pResourceType,
                                                   pResourceHash, pPath, pUnknown)
                    : GetResourceAsyncHook.Original(pFileManager, pCategoryId, pResourceType,
                                                    pResourceHash, pPath, pUnknown, isUnknown));
            }

            var cleanPath = candidate.FullName.Replace('\\', '/');
            var asciiPath = Encoding.ASCII.GetBytes(cleanPath);

            var bPath = stackalloc byte[asciiPath.Length + 1];

            Marshal.Copy(asciiPath, 0, new IntPtr(bPath), asciiPath.Length);
            pPath = ( char * )bPath;

            Crc32.Init();
            Crc32.Update(asciiPath);
            *pResourceHash = Crc32.Checksum;

            return(isSync
                ? GetResourceSyncHook.Original(pFileManager, pCategoryId, pResourceType,
                                               pResourceHash, pPath, pUnknown)
                : GetResourceAsyncHook.Original(pFileManager, pCategoryId, pResourceType,
                                                pResourceHash, pPath, pUnknown, isUnknown));
        }
示例#10
0
        public void Enable()
        {
            if (IsEnabled)
            {
                return;
            }

            if (ReadSqpackHook == null || GetResourceSyncHook == null || GetResourceAsyncHook == null)
            {
                PluginLog.Error("[GetResourceHandler] Could not activate hooks because at least one was not set.");
                return;
            }

            ReadSqpackHook.Activate();
            GetResourceSyncHook.Activate();
            GetResourceAsyncHook.Activate();

            ReadSqpackHook.Enable();
            GetResourceSyncHook.Enable();
            GetResourceAsyncHook.Enable();

            IsEnabled = true;
        }