280 lines
8.7 KiB
Lua
280 lines
8.7 KiB
Lua
require(GlobalDependencys:GetDependency("StandardBase"):GetPackageName())
|
|
|
|
--GAME VARS
|
|
fDefaultFOV = 85
|
|
fAdditionalFOV = 0
|
|
fAspectRatio = DisplayInfo:GetWidth() / DisplayInfo:GetHeight()
|
|
fAspectRatio169 = 1.59
|
|
|
|
--ControlVars
|
|
bFixEnabled = true
|
|
bFOV = true
|
|
bAspect = true
|
|
bDOF = true
|
|
bFringe = true
|
|
|
|
--PROCESS VARS
|
|
Process_FriendlyName = Module:GetFriendlyName()
|
|
Process_WindowName = "*"
|
|
Process_ClassName = "*"
|
|
Process_EXEName = "TheSinkingCityRemastered-Win64-Shipping.exe"
|
|
|
|
--INJECTION BEHAVIOUR
|
|
InjectDelay = 500
|
|
WriteInterval = 100
|
|
SearchInterval = 100
|
|
SuspendThread = true
|
|
|
|
--Name Manual/Auto/Hybrid Steam/Origin/Any IncludeFile:Configure;Enable;Periodic;Disable;
|
|
SupportedVersions = {
|
|
{"Automatically Detect", "Hybrid", "Any", "Configure_SignatureScan;Enable_Inject;Periodic;Disable_Inject;"},
|
|
}
|
|
|
|
function Init_Controls()
|
|
|
|
DefaultControls.AddHeader("Header_FixesEnableDisable","Individual Fixes",245,70,210,17)
|
|
|
|
DefaultControls.AddHeader("Header_FOV","In game FOV fine adjustment",15,70,210,17)
|
|
DefaultControls.AddFixedFOVSlider("FOVSlider","FOVSlider_Changed",55,100,125,35,0,70,0,1)
|
|
FOVSlider:SetTickFrequency(10)
|
|
|
|
DefaultControls.AddFixToggle("CKFOVFix_Enable","FOV fix","CKFOVFix_Changed",255,101,180,14)
|
|
DefaultControls.AddFixToggle("CKASPECTFix_Enable","Aspect ratio fix","CKASPECTFix_Changed",255,121,180,14)
|
|
DefaultControls.AddFixToggle("CKDOFFix_Enable","Depth of field fix","CKDOFFix_Changed",255,141,180,14)
|
|
DefaultControls.AddFixToggle("CKFRINGEFix_Enable","Chromatic aberrations fix","CKFRINGEFix_Changed",255,161,180,14)
|
|
|
|
end
|
|
|
|
function Configure_SignatureScan()
|
|
|
|
local tAddress = HackTool:AddAddress("FOV")
|
|
|
|
if HackTool:SignatureScan("EB ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? ?? 8B 83 ?? ?? ?? ?? 89 ?? ?? 0F B6 8B",tAddress,PAGE_EXECUTE_READ,0x0a,Process_EXEName) == 0 then
|
|
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
|
|
else
|
|
print( tAddress:GetInfo(TYPE_ADDRESS) )
|
|
local Aspect = HackTool:AddAddress("ASPECT", tAddress)
|
|
Aspect:OffsetAddress(0x05)
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC364 - F3 0F 58 83 30 02 00 00 - addss xmm0,[rbx+00000230]
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC36C - EB 08 - jmp "TheSinkingCityRemastered-Win64-Shipping.exe"+33AC376
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC36E - F3 0F 10 83 30 02 00 00 - movss xmm0,[rbx+00000230]
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC376 - F3 0F 11 47 30 - movss [rdi+30],xmm0
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC37B - 8B 83 4C 02 00 00 - mov eax,[rbx+0000024C]
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC381 - 89 47 54 - mov [rdi+54],eax
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+33AC384 - 0F B6 8B 51 02 00 00 - movzx ecx,byte ptr [rbx+00000251]
|
|
end
|
|
|
|
local tAddress = HackTool:AddAddress("DOF")
|
|
|
|
if HackTool:SignatureScan("8B ?? ?? 48 ?? ?? E8 ?? ?? ?? ?? 0F ?? ?? 48 6B ?? ?? 48 8D",tAddress,PAGE_EXECUTE_READ,0x0,Process_EXEName) == 0 then
|
|
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
|
|
else
|
|
print( tAddress:GetInfo(TYPE_ADDRESS) )
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+247A9C2 - 75 05 - jne "TheSinkingCityRemastered-Win64-Shipping.exe"+247A9C9
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+247A9C4 - BF 04 00 00 00 - mov edi,00000004
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+247A9C9 - 8B 3C 37 - mov edi,[rdi+rsi]
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+247A9CC - 48 8B CB - mov rcx,rbx
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+247A9CF - E8 7C E6 66 01 - call "TheSinkingCityRemastered-Win64-Shipping.exe"+3AE9050
|
|
end
|
|
|
|
local tAddress = HackTool:AddAddress("FRINGE")
|
|
|
|
if HackTool:SignatureScan("48 8B ?? ?? ?? ?? ?? 44 ?? ?? 7F ?? 44 89 ?? ?? ?? ?? ?? 43",tAddress,PAGE_EXECUTE_READ,0x0a,Process_EXEName) == 0 then
|
|
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
|
|
else
|
|
print( tAddress:GetInfo(TYPE_ADDRESS) )
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+3AE5002 - 48 8B 05 D7 92 56 04 - mov rax,["TheSinkingCityRemastered-Win64-Shipping.exe"+804E2E0]
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+3AE5009 - 44 39 38 - cmp [rax],r15d
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+3AE500C - 7F 07 - jg "TheSinkingCityRemastered-Win64-Shipping.exe"+3AE5015
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+3AE500E - 44 89 BB 2C 1F 00 00 - mov [rbx+00001F2C],r15d
|
|
--TheSinkingCityRemastered-Win64-Shipping.exe+3AE5015 - 43 8B 04 26 - mov eax,[r14+r12]
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
function Enable_Inject()
|
|
local Variables = HackTool:AllocateMemory("Variables",0)
|
|
Variables:PushFloat("FOVIn")
|
|
Variables:PushFloat("FOVOut")
|
|
Variables:PushFloat("CompensatedFOV")
|
|
Variables:PushFloat("AdditionalFOV")
|
|
Variables:PushFloat("ScreenRatio")
|
|
Variables:PushByte("ASPECTCHECKED")
|
|
|
|
Variables:Allocate()
|
|
Variables["FOVIn"]:WriteFloat(fDefaultFOV)
|
|
Variables["FOVOut"]:WriteFloat(fDefaultFOV)
|
|
Variables["AdditionalFOV"]:WriteFloat(fAdditionalFOV)
|
|
Variables["ScreenRatio"]:WriteFloat(fAspectRatio)
|
|
|
|
FOVCalculator = HackTool:InjectFOVCalculator("FOVCalculator")
|
|
|
|
ResolutionChanged()
|
|
|
|
local asm = [[
|
|
|
|
(codecave:jmp)FOV,FOV_cc:
|
|
$$0 [(allocation)Variables->FOVIn],$$2 $ctx=1
|
|
cmp byte ptr [(allocation)Variables->ASPECTCHECKED],1
|
|
jne normalFOV
|
|
fld dword [(allocation)Variables->FOVIn]
|
|
call (allocation)FOVCalculator
|
|
fstp dword ptr [(allocation)Variables->CompensatedFOV]
|
|
$$0 $$2,[(allocation)Variables->CompensatedFOV] $ctx=1
|
|
normalFOV:
|
|
addss $$2,[(allocation)Variables->AdditionalFOV] $ctx=1
|
|
$$0 [(allocation)Variables->FOVOut],$$2 $ctx=1
|
|
%originalcode%
|
|
jmp %returnaddress%
|
|
%end%
|
|
|
|
(codecave:jmp)ASPECT,ASPECT_cc:
|
|
$$0 $$1,[(allocation)Variables->ScreenRatio] $ctx=1
|
|
jmp %returnaddress%
|
|
%end%
|
|
|
|
(codecave)DOF,DOF_cc:
|
|
xor $$1,$$1 $ctx=1
|
|
nop
|
|
%end%
|
|
|
|
(codecave)FRINGE,FRINGE_cc:
|
|
nop
|
|
nop
|
|
%end%
|
|
|
|
]]
|
|
|
|
if HackTool:CompileAssembly(asm,"Fixes") == nil then
|
|
return ErrorOccurred("Assembly compilation failed...")
|
|
else
|
|
if Variables and Variables["ASPECTCHECKED"] and bAspect then
|
|
Variables["ASPECTCHECKED"]:WriteByte(1)
|
|
end
|
|
Toggle_CodeCave("FOV_cc",(bFOV or bAspect))
|
|
Toggle_CodeCave("ASPECT_cc",bAspect)
|
|
Toggle_CodeCave("DOF_cc",bDOF)
|
|
Toggle_CodeCave("FRINGE_cc",bFringe)
|
|
end
|
|
|
|
Write_FOV()
|
|
|
|
end
|
|
|
|
function Periodic()
|
|
|
|
local Variables = HackTool:GetAllocation("Variables")
|
|
|
|
if Variables and Variables["FOVIn"] and Variables["AdditionalFOV"] then
|
|
local fFOVIn = Variables["FOVIn"]:ReadFloat()
|
|
local fFOVOut = Variables["FOVOut"]:ReadFloat()
|
|
local fFOVCompensated = Variables["CompensatedFOV"]:ReadFloat()
|
|
|
|
PluginViewport:AppendStatusMessage( string.format("\r\n===== Fix informations =====\r\nFOV In: %.2f, Compensated : %.2f, Out : %.2f", fFOVIn, fFOVCompensated, fFOVOut))
|
|
end
|
|
|
|
end
|
|
|
|
function FOVSlider_Changed(Sender)
|
|
|
|
fAdditionalFOV = Sender:GetPosition() - 20
|
|
lblFOVSlider.Caption:SetCaption( string.format("World FOV: %.0f",fAdditionalFOV) )
|
|
|
|
Write_FOV()
|
|
ForceUpdate()
|
|
|
|
end
|
|
|
|
function Write_FOV()
|
|
|
|
local Variables = HackTool:GetAllocation("Variables")
|
|
if Variables and Variables["AdditionalFOV"] then
|
|
if bFOV == true then
|
|
Variables["AdditionalFOV"]:WriteFloat(fAdditionalFOV)
|
|
else
|
|
Variables["AdditionalFOV"]:WriteFloat(0)
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function Disable_Inject()
|
|
|
|
CleanUp()
|
|
|
|
end
|
|
|
|
function CKFOVFix_Changed(Sender)
|
|
|
|
bFOV = Toggle_CheckFix(Sender)
|
|
local fFOV = (bFOV or bAspect)
|
|
Write_FOV()
|
|
Toggle_CodeCave("FOV_cc",fFOV)
|
|
ForceUpdate()
|
|
|
|
end
|
|
|
|
function CKASPECTFix_Changed(Sender)
|
|
|
|
bAspect = Toggle_CheckFix(Sender)
|
|
Toggle_CodeCave("ASPECT_cc",bAspect)
|
|
local Variables = HackTool:GetAllocation("Variables")
|
|
if Variables and Variables["ASPECTCHECKED"] then
|
|
if bAspect then
|
|
Toggle_CodeCave("FOV_cc",bAspect)
|
|
Variables["ASPECTCHECKED"]:WriteByte(1)
|
|
else
|
|
Variables["ASPECTCHECKED"]:WriteByte(0)
|
|
Variables["CompensatedFOV"]:WriteFloat(0)
|
|
end
|
|
end
|
|
ForceUpdate()
|
|
|
|
end
|
|
|
|
function CKDOFFix_Changed(Sender)
|
|
|
|
bDOF = Toggle_CheckFix(Sender)
|
|
Toggle_CodeCave("DOF_cc",bDOF)
|
|
ForceUpdate()
|
|
|
|
end
|
|
|
|
function CKFRINGEFix_Changed(Sender)
|
|
|
|
bFringe = Toggle_CheckFix(Sender)
|
|
Toggle_CodeCave("FRINGE_cc",bFringe)
|
|
ForceUpdate()
|
|
|
|
end
|
|
|
|
function ResolutionChanged()
|
|
|
|
SyncDisplayDetection()
|
|
|
|
local CurrentAspectRatio = DisplayInfo:GetAspectRatio()
|
|
local AspectDevisional = CurrentAspectRatio / fAspectRatio169
|
|
|
|
if CurrentAspectRatio < 1.78 then
|
|
AspectDevisional = 1.0
|
|
end
|
|
|
|
UpdateFOVCalculator("FOVCalculator",AspectDevisional,0.0)
|
|
|
|
end
|
|
|
|
function Init()
|
|
|
|
Init_BaseControls()
|
|
Init_Controls()
|
|
|
|
end
|
|
|
|
function DeInit()
|
|
|
|
DisableFix()
|
|
|
|
end
|