Skip to content
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
3 changes: 0 additions & 3 deletions FactionFixLoader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@
<None Include="LICENSE" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Text Include="licenses\CoHModSDK.txt" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\resource.rc" />
</ItemGroup>
Expand Down
42 changes: 17 additions & 25 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
FactionFixLoader - A wrapper mod for the FactionFix.dll
Copyright (C) 2025 Tosox
All rights reserved.
MIT License

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Copyright (c) 2025 - 2026 Tosox

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

-------------------------------------------------------------------------------
This mod includes code from the CoHModSDK project by Tosox, licensed under the BSD 2-Clause License.
See licenses/CoHModSDK.txt for details.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
114 changes: 109 additions & 5 deletions lib/CoHModSDK/include/CoHModSDK.hpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,140 @@
/**
* CoHModSDK - The lightweight modding SDK for Company of Heroes
* Copyright (c) 2026 Tosox
*
* This project is licensed under the Creative Commons
* Attribution-NonCommercial-NoDerivatives 4.0 International License
* (CC BY-NC-ND 4.0) with additional permissions.
*
* Independent mods using this project only through its public interfaces
* are not required to use CC BY-NC-ND 4.0.
*
* See the repository root LICENSE file for the full license text and
* additional permissions.
*/

#pragma once

#include <Windows.h>
#include <cstddef>
#include <cstdint>

extern "C" {
// Called once when ModSDK loads the mod
/**
* @brief Called once when the SDK loads the mod DLL.
*
* Perform any early setup required for the mod here (e.g., install hooks, patch memory).
*/
__declspec(dllexport) void OnSDKLoad();

// Called when the game is starting (after mod load)
/**
* @brief Called when the game is starting (after all mods have been loaded).
*
* Use this to initialize features that require the game to be fully running.
*/
__declspec(dllexport) void OnGameStart();

// Called when the game is shutting down
/**
* @brief Called when the game is shutting down.
*
* Use this to clean up any hooks, memory patches, or resources before unloading.
*/
__declspec(dllexport) void OnGameShutdown();

// Mod metadata
/**
* @brief Returns the display name of the mod.
*
* @return const char* - Name of the mod.
*/
__declspec(dllexport) const char* GetModName();

/**
* @brief Returns the version string of the mod.
*
* @return const char* - Version of the mod.
*/
__declspec(dllexport) const char* GetModVersion();

/**
* @brief Returns the author name(s) of the mod.
*
* @return const char* - Author or team name.
*/
__declspec(dllexport) const char* GetModAuthor();
}

namespace ModSDK {
namespace Memory {
std::uintptr_t FindPattern(const char* moduleName, const char* signature, bool reportError = true);
/**
* @brief Returns a handle to the module that contains the original game code.
*
* @return HMODULE - Handle to `WW2Mod.original.dll` with fallback to `WW2Mod.dll`.
*/
HMODULE GetGameModuleHandle();

/**
* @brief Scans a module for a byte pattern signature.
*
* Use `GetGameModuleHandle()` when you want to scan the original game module.
*
* @param moduleHandle Handle to the module to scan.
* @param signature Pattern string (e.g., "48 8B ?? ?? ?? ?? ?? 48 8B").
* @param reportError Whether to show an error if the pattern is not found.
* @return std::uintptr_t Address where the pattern was found or 0 if not found.
*/
std::uintptr_t FindPattern(HMODULE moduleHandle, const char* signature, bool reportError = true);

/**
* @brief Patches memory by copying bytes to a destination address.
*
* Automatically changes memory protection to allow writing.
*
* @param destination Target address to patch.
* @param source Bytes to write.
* @param size Number of bytes to copy.
*/
void PatchMemory(void* destination, const void* source, std::size_t size);
}

namespace Hooks {
/**
* @brief Creates a hook from a target function to a detour function.
*
* @param targetFunction Pointer to the function to hook.
* @param detourFunction Pointer to the custom function (your detour).
* @param originalFunction Out parameter; will store the pointer to call original later.
* @return true if the hook was created successfully, false otherwise.
*/
bool CreateHook(void* targetFunction, void* detourFunction, void** originalFunction);

/**
* @brief Enables an individual installed hook.
*
* @param targetFunction Pointer to the function where a hook was created.
* @return true if successfully enabled, false otherwise.
*/
bool EnableHook(void* targetFunction);

/**
* @brief Enables all hooks created by the SDK.
*
* @return true if successful, false otherwise.
*/
bool EnableAllHooks();

/**
* @brief Disables an individual hook.
*
* @param targetFunction Pointer to the hooked function.
* @return true if successfully disabled, false otherwise.
*/
bool DisableHook(void* targetFunction);

/**
* @brief Disables all active hooks created by the SDK.
*
* @return true if successful, false otherwise.
*/
bool DisableAllHooks();
}
}
Binary file modified lib/CoHModSDK/lib/x86/CoHModSDK.lib
Binary file not shown.
110 changes: 0 additions & 110 deletions licenses/CoHModSDK.txt

This file was deleted.

10 changes: 5 additions & 5 deletions res/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,1,0,0
PRODUCTVERSION 0,1,0,0
FILEVERSION 0,1,1,0
PRODUCTVERSION 0,1,1,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Tosox"
VALUE "FileDescription", "A wrapper mod for the FactionFix.dll"
VALUE "FileVersion", "0.1.0.0"
VALUE "FileVersion", "0.1.1.0"
VALUE "InternalName", "FactionFixLoader"
VALUE "LegalCopyright", "Copyright © 2025"
VALUE "LegalCopyright", "Copyright © 2026"
VALUE "OriginalFilename", "FactionFixLoader.dll"
VALUE "ProductName", "FactionFixLoader"
VALUE "ProductVersion", "0.1.0.0"
VALUE "ProductVersion", "0.1.1.0"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
}

__declspec(dllexport) const char* GetModVersion() {
return "1.0.0";
return "1.1.0";
}

__declspec(dllexport) const char* GetModAuthor() {
Expand Down
Loading