Skip to content

Commit

Permalink
Add MemoryPatch::WarheadEXE::FixHInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
ccomrade committed Feb 18, 2024
1 parent a8e85be commit 37e62ee
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
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 a 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

0 comments on commit 37e62ee

Please sign in to comment.