Skip to content

Commit

Permalink
Crysis Warhead + Mem + Helper: Try to adapt for NT 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
illusion0001 committed Jan 24, 2025
1 parent e12d4a4 commit 1deeabc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace Memory
uint8_t* wchar_Scan(void* module, const wchar_t* value);
uint8_t* u32_Scan(void* module, uint32_t value);
uint8_t* u64_Scan(void* module, uint64_t value);
#if !defined(WINXP)
std::string GetVersionString();
std::vector<int> string_to_ints(const std::string& s, char delimiter);
std::wstring GetVersionProductName();
#endif
}
9 changes: 9 additions & 0 deletions source/CrysisWarhead.Patches/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ string(REPLACE " " "_" ProjectId ${PROJECT_NAME})
project(${PROJECT_NAME})
include(win32)

ADD_DEFINITIONS(-DWINXP)

file(GLOB SOURCES
"*.cpp"
"*.h"
Expand All @@ -11,6 +13,13 @@ file(GLOB SOURCES
"../../include/*.hpp")
add_library(${PROJECT_NAME} SHARED ${SOURCES})

# static link c runtime for
# hopefully compatibility with nt 5.2 x64
set_property(TARGET ${PROJECT_NAME}
PROPERTY
MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>")

include(win32_install)

install(
Expand Down
3 changes: 3 additions & 0 deletions source/Shared/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ void SendInputWrapper(WORD inputKey)
#define str(s) #s
#define xstr(s) str(s)

#if !defined(WINXP)

static void CooldownDefault(const wchar_t* inifile)
{
HANDLE fd = CreateFile(inifile, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
Expand Down Expand Up @@ -470,3 +472,4 @@ void CheckScriptFile()
}
}
}
#endif
2 changes: 2 additions & 0 deletions source/Shared/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ namespace Memory
return nullptr;
}

#if !defined(WINXP)
std::string GetVersionString()
{
auto hInst = GetModuleHandle(NULL);
Expand Down Expand Up @@ -462,4 +463,5 @@ namespace Memory
VerQueryValue(buffer.data(), query, (LPVOID*)&p, &n_chars);
return std::wstring(p, p + n_chars);
}
#endif
}

0 comments on commit 1deeabc

Please sign in to comment.