Files
Plugins/PluginCache/K4sh/Modules/ManofMedan/Dependencies/Scripts/ManOfMedan.lua

215 lines
6.7 KiB
Lua

require(GlobalDependencys:GetDependency("StandardBase"):GetPackageName())
--ControlVars
bFixEnabled = true
bAspect = true
bFOV = true
--GAME VARS
fDefaultFOV = 0
fAspectRatio = 0
fAdditionalFOV = 0
--PROCESS VARS
Process_FriendlyName = Module:GetFriendlyName()
Process_WindowName = "Man of Medan "
Process_ClassName = "UnrealWindow"
Process_EXEName = "*"
--INJECTION BEHAVIOUR
InjectDelay = 500
WriteInterval = 500
SearchInterval = 1000
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","FOV fine adjustment",15,70,210,17)
DefaultControls.AddFixedFOVSlider("FOVSlider","FOVSlider_Changed",55,100,125,35,0,70,0,1)
FOVSlider:SetTickFrequency(5)
FOVSlider:SetLabel1Text("+0")
FOVSlider:SetLabel2Text("+70")
DefaultControls.AddFixToggle("CKFOVFix_Enable","FOV fix","CKFOVFix_Changed",255,101,180,14)
DefaultControls.AddFixToggle("CKARatioFix_Enable","Aspect Ratio fix","CKARatioFix_Changed",255,121,180,14)
end
function Configure_SignatureScan()
local tAddress = HackTool:AddAddress("FOV")
if HackTool:SignatureScan("E8 ?? ?? ?? ?? F3 0F 59 ?? ?? ?? ?? ?? EB ?? 0F",tAddress,PAGE_EXECUTE_READ,0x05,Process_EXEName) == 0 then
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
else
print( tAddress:GetInfo(TYPE_ADDRESS) )
--ManOfMedan-Win64-Shipping.exe+22059DD: 33 C9 - xor ecx,ecx
--ManOfMedan-Win64-Shipping.exe+22059DF: 89 4C 24 20 - mov [rsp+20],ecx
--ManOfMedan-Win64-Shipping.exe+22059E3: F3 41 0F 10 B0 8C 03 00 00 - movss xmm6,[r8+0000038C]
--ManOfMedan-Win64-Shipping.exe+22059EC: 0F 57 C0 - xorps xmm0,xmm0
--ManOfMedan-Win64-Shipping.exe+22059EF: 0F 2F F0 - comiss xmm6,xmm0
end
local tAddress = HackTool:AddAddress("AspectFix1")
if HackTool:SignatureScan("76 ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? F3 0F 11 ?? ?? ?? ?? ?? F3 0F 11 ?? ?? ?? ?? ?? 0F",tAddress,PAGE_EXECUTE_READ,0x0E,Process_EXEName) == 0 then
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
else
print( tAddress:GetInfo(TYPE_ADDRESS) )
--ManOfMedan-Win64-Shipping.exe+1CBBBCC: F3 0F 10 83 90 08 00 00 - movss xmm0,[rbx+00000890]
--ManOfMedan-Win64-Shipping.exe+1CBBBD4: F3 0F 5E C1 - divss xmm0,xmm1
--ManOfMedan-Win64-Shipping.exe+1CBBBD8: F3 0F 11 83 98 08 00 00 - movss [rbx+00000898],xmm0
--ManOfMedan-Win64-Shipping.exe+1CBBBE0: F3 0F 11 83 68 02 00 00 - movss [rbx+00000268],xmm0
--ManOfMedan-Win64-Shipping.exe+1CBBBE8: 0F 28 74 24 20 - movaps xmm6,[rsp+20]
end
local tAddress = HackTool:AddAddress("AspectFix2")
if HackTool:SignatureScan("76 ?? F3 0F ?? ?? ?? ?? ?? ?? F3 0F ?? ?? F3 0F 59 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? F3 0F 59 ?? ?? ?? ?? ?? EB",tAddress,PAGE_EXECUTE_READ,0x0E,Process_EXEName) == 0 then
return ErrorOccurred(string.format(SigScanError,tAddress:GetName()))
else
print( tAddress:GetInfo(TYPE_ADDRESS) )
--ManOfMedan-Win64-Shipping.exe+1CBBB91: F3 0F 10 05 2F 93 43 02 - movss xmm0,[ManOfMedan-Win64-Shipping.exe+40F4EC8]
--ManOfMedan-Win64-Shipping.exe+1CBBB99: F3 0F 5E C1 - divss xmm0,xmm1
--ManOfMedan-Win64-Shipping.exe+1CBBB9D: F3 0F 59 83 90 08 00 00 - mulss xmm0,[rbx+00000890]
--ManOfMedan-Win64-Shipping.exe+1CBBBA5: E8 6B E8 30 01 - call ManOfMedan-Win64-Shipping.exe+2FCA415
--ManOfMedan-Win64-Shipping.exe+1CBBBAA: F3 0F 59 05 E2 9A 43 02 - mulss xmm0,[ManOfMedan-Win64-Shipping.exe+40F5694]
end
return true
end
function Periodic()
local Variables = HackTool:GetAllocation("Variables")
if Variables and Variables["FOVIn"] and Variables["AdditionalFOV"] and bFOV then
fFOVIn = Variables["FOVIn"]:ReadFloat()
fFOVOut = Variables["FOVOut"]:ReadFloat()
PluginViewport:AppendStatusMessage( string.format("\r\n===== Fix informations =====\r\nFOV In: %0.f, FOV Out : %.0f", fFOVIn, fFOVOut))
end
end
function Enable_Inject()
local Variables = HackTool:AllocateMemory("Variables",0)
Variables:PushFloat("AspectRatio")
Variables:PushFloat("FOVIn")
Variables:PushFloat("FOVOut")
Variables:PushFloat("AdditionalFOV")
Variables:Allocate()
Variables["FOVIn"]:WriteFloat(fDefaultFOV)
Variables["AdditionalFOV"]:WriteFloat(fAdditionalFOV)
ResolutionChanged()
asm = [[
(codecave:jmp)FOV,FOV_cc:
%originalcode%
;cmp r15,8 ; will only affect in game FOV
;jne exit
movss [(allocation)Variables->FOVIn],$$1 $ctx=1
addss $$1,[(allocation)Variables->AdditionalFOV] $ctx=1
movss [(allocation)Variables->FOVOut],$$1 $ctx=1
;exit:
jmp %returnaddress%
%end%
(codecave:jmp)AspectFix1,AspectFix1_cc:
movss $$2,[(allocation)Variables->AspectRatio] $ctx=1
%originalcode%
jmp %returnaddress%
%end%
; following code will compensate widers aspect ratios for FOV
(codecave:jmp)AspectFix2,AspectFix2_cc:
movss xmm15,[$$2+4] $ctx=1
mulss xmm15,[(allocation)Variables->AspectRatio]
movss $$1,xmm15 $ctx=1
;mulss $$1,xmm15 $ctx=1
jmp %returnaddress%
%end%
]]
if HackTool:CompileAssembly(asm,"Fixes") == nil then
return ErrorOccurred("Assembly compilation failed...")
else
Toggle_CodeCave("AspectFix1_cc",bAspect)
Toggle_CodeCave("AspectFix2_cc",bAspect)
Toggle_CodeCave("FOV_cc",bFOV)
end
Write_FOV()
end
function CKFOVFix_Changed(Sender)
bFOV = Toggle_CheckFix(Sender)
Toggle_CodeCave("FOV_cc",bFOV)
ForceUpdate()
end
function CKARatioFix_Changed(Sender)
bAspect = Toggle_CheckFix(Sender)
Toggle_CodeCave("AspectFix1_cc",bAspect)
Toggle_CodeCave("AspectFix2_cc",bAspect)
ForceUpdate()
end
function FOVSlider_Changed(Sender)
fAdditionalFOV = Sender:GetPosition()
lblFOVSlider.Caption:SetCaption( string.format("%.0f",fAdditionalFOV) )
if bFOV then
Write_FOV()
end
ForceUpdate()
end
function Write_FOV()
local Variables = HackTool:GetAllocation("Variables")
if Variables and Variables["AdditionalFOV"] then
Variables["AdditionalFOV"]:WriteFloat(fAdditionalFOV)
end
end
function ResolutionChanged()
local fAspectRatio = DisplayInfo:GetAspectRatio()
local Variables = HackTool:GetAllocation("Variables")
if Variables then
Variables["AspectRatio"]:WriteFloat(fAspectRatio)
end
end
function Disable_Inject()
CleanUp()
end
function Init()
Init_BaseControls()
Init_Controls()
end
function DeInit()
DisableFix()
end