public unsafe byte ReadSqpackHandler(IntPtr pFileHandler, SeFileDescriptor *pFileDesc, int priority, bool isSync) { var gameFsPath = Marshal.PtrToStringAnsi(new IntPtr(pFileDesc->ResourceHandle->FileName)); var isRooted = Path.IsPathRooted(gameFsPath); if (gameFsPath == null || gameFsPath.Length >= 260 || !isRooted) { return(ReadSqpackHook.Original(pFileHandler, pFileDesc, priority, isSync)); } #if DEBUG PluginLog.Log("loading modded file: {GameFsPath}", gameFsPath); #endif pFileDesc->FileMode = FileMode.LoadUnpackedResource; var utfPath = Encoding.Unicode.GetBytes(gameFsPath); Marshal.Copy(utfPath, 0, new IntPtr(&pFileDesc->UtfFileName), utfPath.Length); var fd = stackalloc byte[0x20 + utfPath.Length + 0x16]; Marshal.Copy(utfPath, 0, new IntPtr(fd + 0x21), utfPath.Length); pFileDesc->FileDescriptor = fd; return(ReadFile(pFileHandler, pFileDesc, priority, isSync)); }
public void Dispose() { if (IsEnabled) { Disable(); } ReadSqpackHook.Dispose(); GetResourceSyncHook.Dispose(); GetResourceAsyncHook.Dispose(); }
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; }
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; }