Skip to content

Commit

Permalink
Merge pull request #7 from RussellJerome/development
Browse files Browse the repository at this point in the history
Merging Dev Branch Patch 2.0.1 to main
  • Loading branch information
RussellJerome authored Oct 25, 2021
2 parents 0447820 + d632c55 commit 1760f2b
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 137 deletions.
2 changes: 1 addition & 1 deletion ExampleMod/ExampleMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExampleMod : public Mod
ModVersion = "1.0.0"; // Mod Version
ModDescription = "HAHAHAHA MOD GO BURR"; // Mod Description
ModAuthors = "RussellJ"; // Mod Author
ModLoaderVersion = "2.0.0";
ModLoaderVersion = "2.0.1";

// Dont Touch The Internal Stuff
ModRef = this;
Expand Down
3 changes: 3 additions & 0 deletions Profiles/AdvancedExampleGame.profile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#UE4.22 changes the namepool weird, only set this to 1 if the game uses 4.22
#IsUsing4_22=0

#If you get any Direct X errors such as resizing, enable this to delay the hook and prevent most issues.
#DelayGUISpawn=1

#GName, GWorld, and GObject patterns with op code (EXAMPLE BELOW, FILL OUT PATTERNS YOURSELF IF NEEDED)
#[GInfo]

Expand Down
4 changes: 3 additions & 1 deletion Profiles/GGST-Win64-Shipping.profile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
UsesFNamePool=1

#Set to 1 (true) if the game engine version is 4.18 and up (this can vary)
IsUsingFChunkedFixedUObjectArray=1
IsUsingFChunkedFixedUObjectArray=1

DelayGUISpawn=1
Binary file modified UnrealEngineModLauncher/UnrealEngineModLauncher.aps
Binary file not shown.
8 changes: 4 additions & 4 deletions UnrealEngineModLauncher/UnrealEngineModLauncher.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ IDI_ICON1 ICON "u4mdl_logo_ZfM_icon.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,0,0
PRODUCTVERSION 2,0,0,0
FILEVERSION 2,0,1,0
PRODUCTVERSION 2,0,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "Mods Go Burr"
VALUE "FileVersion", "2.0.0.0"
VALUE "FileVersion", "2.0.1.0"
VALUE "InternalName", "UnrealLoader.exe"
VALUE "LegalCopyright", "Copyright (C) 2021"
VALUE "OriginalFilename", "UnrealEn.exe"
VALUE "ProductName", "Unreal Engine Mod Launcher"
VALUE "ProductVersion", "2.0.0.0"
VALUE "ProductVersion", "2.0.1.0"
END
END
BLOCK "VarFileInfo"
Expand Down
112 changes: 7 additions & 105 deletions UnrealEngineModLoader/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ namespace Hooks
}
ModActor->CallFunctionByNameWithArguments(L"PreBeginPlay", nullptr, NULL, true);

Log::Info("Sucessfully Loaded %s", str);
Log::Info("Sucessfully Loaded %s", str.c_str());
}
}
else
{
Log::Info("Could not locate ModActor for %s", str);
Log::Info("Could not locate ModActor for %s", str.c_str());
}
}
}
Expand Down Expand Up @@ -222,108 +222,6 @@ namespace Hooks
}
};

HRESULT hookResizeBuffers(IDXGISwapChain* pSwapChain, UINT BufferCount, UINT Width, UINT Height, DXGI_FORMAT NewFormat, UINT SwapChainFlags)
{
return LoaderUI::GetUI()->LoaderResizeBuffers(pSwapChain, BufferCount, Width, Height, NewFormat, SwapChainFlags);
}

HRESULT(*D3D11Present)(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
HRESULT __stdcall hookD3D11Present(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
LoaderUI::GetUI()->LoaderD3D11Present(pSwapChain, SyncInterval, Flags);
return D3D11Present(pSwapChain, SyncInterval, Flags);
}

DWORD __stdcall InitDX11Hook(LPVOID)
{
Log::Info("Setting up D3D11Present hook");

HMODULE hDXGIDLL = 0;
do
{
hDXGIDLL = GetModuleHandle(L"dxgi.dll");
Sleep(100);
} while (!hDXGIDLL);
Sleep(100);

IDXGISwapChain* pSwapChain;

WNDCLASSEXA wc = { sizeof(WNDCLASSEX), CS_CLASSDC, DefWindowProc, 0L, 0L, GetModuleHandleA(NULL), NULL, NULL, NULL, NULL, "DX", NULL };
RegisterClassExA(&wc);

HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL);

D3D_FEATURE_LEVEL requestedLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1 };
D3D_FEATURE_LEVEL obtainedLevel;
ID3D11Device* d3dDevice = nullptr;
ID3D11DeviceContext* d3dContext = nullptr;

DXGI_SWAP_CHAIN_DESC scd;
ZeroMemory(&scd, sizeof(scd));
scd.BufferCount = 1;
scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
scd.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;

scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
scd.OutputWindow = hWnd;
scd.SampleDesc.Count = 1;
scd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
scd.Windowed = ((GetWindowLongPtr(hWnd, GWL_STYLE) & WS_POPUP) != 0) ? false : true;

scd.BufferDesc.Width = 1;
scd.BufferDesc.Height = 1;
scd.BufferDesc.RefreshRate.Numerator = 0;
scd.BufferDesc.RefreshRate.Denominator = 1;

UINT createFlags = 0;
#ifdef _DEBUG
createFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

IDXGISwapChain* d3dSwapChain = 0;

if (FAILED(D3D11CreateDeviceAndSwapChain(
nullptr,
D3D_DRIVER_TYPE_HARDWARE,
nullptr,
createFlags,
requestedLevels,
sizeof(requestedLevels) / sizeof(D3D_FEATURE_LEVEL),
D3D11_SDK_VERSION,
&scd,
&pSwapChain,
&LoaderUI::GetUI()->pDevice,
&obtainedLevel,
&LoaderUI::GetUI()->pContext)))
{
Log::Error("Failed to create D3D device and swapchain");
return NULL;
}

LoaderUI::GetUI()->pSwapChainVtable = (DWORD_PTR*)pSwapChain;
LoaderUI::GetUI()->pSwapChainVtable = (DWORD_PTR*)LoaderUI::GetUI()->pSwapChainVtable[0];
LoaderUI::GetUI()->phookD3D11Present = (LoaderUI::D3D11PresentHook)LoaderUI::GetUI()->pSwapChainVtable[8];
MinHook::Add((DWORD64)LoaderUI::GetUI()->phookD3D11Present, &hookD3D11Present, &D3D11Present, "DX11-Present");
MinHook::Add((DWORD64)LoaderUI::GetUI()->pSwapChainVtable[13], &hookResizeBuffers, &LoaderUI::GetUI()->ResizeBuffers, "DX11-ResizeBuffers");

DWORD dPresentwOld;
DWORD dResizeOld;
VirtualProtect(LoaderUI::GetUI()->phookD3D11Present, 2, PAGE_EXECUTE_READWRITE, &dPresentwOld);
VirtualProtect((LPVOID)LoaderUI::GetUI()->pSwapChainVtable[13], 2, PAGE_EXECUTE_READWRITE, &dResizeOld);

while (true)
{
Sleep(10);
}

LoaderUI::GetUI()->pDevice->Release();
LoaderUI::GetUI()->pContext->Release();
pSwapChain->Release();
return NULL;
}

DWORD __stdcall InitHooks(LPVOID)
{
MinHook::Init();
Expand All @@ -332,7 +230,11 @@ namespace Hooks
Log::Info("ScanLoadedPaks Setup");
MinHook::Add(GameProfile::SelectedGameProfile.GameStateInit, &HookedFunctions::hookInitGameState, &HookedFunctions::origInitGameState, "AGameModeBase::InitGameState");
MinHook::Add(GameProfile::SelectedGameProfile.BeginPlay, &HookedFunctions::hookBeginPlay, &HookedFunctions::origBeginPlay, "AActor::BeginPlay");
CreateThread(NULL, 0, InitDX11Hook, NULL, 0, NULL);
LoaderUI::GetUI()->CreateUILogicThread();
if (!GameProfile::SelectedGameProfile.bDelayGUISpawn)
{
LoaderUI::HookDX();
}
return NULL;
}

Expand Down
Loading

0 comments on commit 1760f2b

Please sign in to comment.