Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Logitech G15 in Warhead launcher #40

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Fixed
- Fix startup crash of Warhead launcher when Logitech G15 keyboard is connected
([#39](https://github.com/ccomrade/c1-launcher/issues/39)).

## [v6] - 2024-02-15
### Added
- Crysis Editor (Sandbox 2) support.
Expand Down
2 changes: 2 additions & 0 deletions Code/Launcher/Game/GameLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ void GameLauncher::PatchEngine()
}

MemoryPatch::CryAction::AllowDX9ImmersiveMultiplayer(m_dlls.pEXE, m_dlls.gameBuild);

MemoryPatch::WarheadEXE::FixHInstance(m_dlls.pEXE, m_dlls.gameBuild);
}

if (m_dlls.pCryGame)
Expand Down
35 changes: 35 additions & 0 deletions Code/Launcher/MemoryPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3240,6 +3240,41 @@ void MemoryPatch::CryRenderNULL::DisableDebugRenderer(void* pCryRenderNULL, int
}
}

////////////////////////////////////////////////////////////////////////////////
// WarheadEXE
////////////////////////////////////////////////////////////////////////////////

/**
* Initializes the global hInstance pointer in the Warhead EXE.
*
* Normally, WinMain initializes it, but we load Warhead EXE as a DLL without executing its WinMain function.
* Only the Logitech G15 display interface uses it to obtain its bitmap resources from the EXE.
*
* Only game launcher needs this.
*/
void MemoryPatch::WarheadEXE::FixHInstance(void* pEXE, int gameBuild)
{
switch (gameBuild)
{
#ifdef BUILD_64BIT
case 710:
case 711:
{
*static_cast<void**>(ByteOffset(pEXE, 0x80BBE8)) = pEXE;
break;
}
#else
case 687:
case 710:
case 711:
{
// TODO: 32-bit Crysis Warhead
break;
}
#endif
}
}

////////////////////////////////////////////////////////////////////////////////
// Editor
////////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions Code/Launcher/MemoryPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ namespace MemoryPatch
void DisableDebugRenderer(void* pCryRenderNULL, int gameBuild);
}

namespace WarheadEXE
{
void FixHInstance(void* pEXE, int gameBuild);
}

namespace Editor
{
struct Version
Expand Down