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)); }
public void Dispose() { if (IsEnabled) { Disable(); } ReadSqpackHook.Dispose(); GetResourceSyncHook.Dispose(); GetResourceAsyncHook.Dispose(); }
public void DisableHooks() { if (!HooksEnabled) { return; } HooksEnabled = false; ReadSqPackHook.Disable(); GetResourceSyncHook.Disable(); GetResourceAsyncHook.Disable(); }
public void EnableHooks() { if (HooksEnabled) { return; } HooksEnabled = true; ReadSqPackHook.Enable(); GetResourceSyncHook.Enable(); GetResourceAsyncHook.Enable(); }
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);
public void Disable() { if (!IsEnabled) { return; } IsEnabled = false; ReadSqpackHook.Disable(); GetResourceSyncHook.Disable(); GetResourceAsyncHook.Disable(); }
// ====================== public void Enable() { IsEnabled = true; ReadSqpackHook.Activate(); GetResourceSyncHook.Activate(); GetResourceAsyncHook.Activate(); ReadSqpackHook.Enable(); GetResourceSyncHook.Enable(); GetResourceAsyncHook.Enable(); }
public void Enable() { if (IsEnabled) { return; } ReadSqpackHook.Enable(); GetResourceSyncHook.Enable(); GetResourceAsyncHook.Enable(); IsEnabled = true; }
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)); }
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; }