public Model() { var processes = Process.GetProcessesByName("JustCause3"); if (processes.Length == 0) { MessageBox.Show("Failed to find JustCause3.exe process", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(0); } _handle = Natives.OpenProcess( (uint)Natives.ProcessAccessFlags.VMOperation | (uint)Natives.ProcessAccessFlags.VMRead | (uint)Natives.ProcessAccessFlags.VMWrite, false, processes[0].Id); if (_handle == IntPtr.Zero) { MessageBox.Show("Failed to open a handle to JustCause3.exe process", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(0); } _originalCallBytes = Natives.ReadBytes(_handle, _setFovCall, 5); PatchSetFov(true); }
private void PatchFov(float newFov) { var cameraManager = Natives.ReadIntPtr(_handle, _cameraManagerPtr); var currentCamera = Natives.ReadIntPtr(_handle, cameraManager + CurrentCameraOffset); // Update the flags to indicate an FOV change has occurred var flags = Natives.ReadBytes(_handle, currentCamera + CameraFlagsOffset, 1); flags[0] |= 0x10; Natives.WriteBytes(_handle, currentCamera + CameraFlagsOffset, flags); // Update the actual FOV values Natives.WriteFloat(_handle, currentCamera + FovOffset1, newFov); Natives.WriteFloat(_handle, currentCamera + FovOffset2, newFov); }