Skip to content

Commit

Permalink
fix: Hopefully help prevent false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
shdwmtr committed Nov 10, 2024
1 parent 604f093 commit d448ab1
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ add_compile_definitions(
_CRT_SECURE_NO_WARNINGS
)

if (WIN32)
add_subdirectory(win32)
endif()

add_subdirectory(cli)

find_package(CURL REQUIRED) # used for web requests.
Expand Down Expand Up @@ -120,7 +124,7 @@ if (NOT APPLE)
endif()

if (WIN32)
set_target_properties(Millennium PROPERTIES OUTPUT_NAME "user32")
set_target_properties(Millennium PROPERTIES OUTPUT_NAME "millennium")
set_target_properties(Millennium PROPERTIES PREFIX "")
set_target_properties(Millennium PROPERTIES NO_EXPORT TRUE)
endif()
Expand Down
4 changes: 2 additions & 2 deletions scripts/version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#define VER_COMPANYNAME_STR "Steam Homebrew\0"
#define VER_FILEDESCRIPTION_STR "A plugin loader for the modern Steam Client\0"
#define VER_INTERNALNAME_STR "user32.dll\0"
#define VER_ORIGINALFILENAME_STR "user32.dll\0"
#define VER_INTERNALNAME_STR "millennium.dll\0"
#define VER_ORIGINALFILENAME_STR "millennium.dll\0"
#define VER_LEGALCOPYRIGHT_STR "Steam Homebrew 2024\0"
#define VER_LEGALTRADEMARKS1_STR "All Rights Reserved\0"
#define VER_LEGALTRADEMARKS2_STR "\0"
Expand Down
4 changes: 1 addition & 3 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ const static void EntryMain()

backendThread.join();
frontendThreads.join();

// std::this_thread::sleep_for(std::chrono::milliseconds(10000));
}

#ifdef _WIN32
Expand All @@ -98,7 +96,7 @@ int __stdcall DllMain(void*, unsigned long fdwReason, void*)
}
case DLL_PROCESS_DETACH:
{
Logger.PrintMessage(" MAIN ", "Shutting down Millennium...", COL_MAGENTA);
Logger.Log("Shutting down Millennium...");
std::exit(EXIT_SUCCESS);
g_threadTerminateFlag->flag.store(true);
Sockets::Shutdown();
Expand Down
25 changes: 25 additions & 0 deletions win32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.10)

# Set the project name
project(ShimDll)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if (WIN32 AND NOT GITHUB_ACTION_BUILD)
# debug output paths
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
set(LIBRARY_OUTPUT_DIRECTORY "C:/Program Files (x86)/Steam")
elseif(UNIX AND NOT GITHUB_ACTION_BUILD)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "$ENV{HOME}/.millennium/")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "$ENV{HOME}/.millennium/")
endif()

# Add the executable
add_library(ShimDll SHARED main.cc)

set_target_properties(ShimDll PROPERTIES OUTPUT_NAME "user32")
set_target_properties(ShimDll PROPERTIES PREFIX "")
set_target_properties(ShimDll PROPERTIES NO_EXPORT TRUE)

40 changes: 40 additions & 0 deletions win32/main.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <windows.h>

const void ShutdownShim(HINSTANCE hinstDLL)
{
// Unload current module
FreeLibraryAndExitThread(hinstDLL, 0);
}

const void LoadMillennium(HINSTANCE hinstDLL)
{
HMODULE hMillennium = LoadLibrary(TEXT("millennium.dll"));
if (hMillennium == nullptr) {
MessageBoxA(nullptr, "Failed to load millennium.dll", "Error", MB_ICONERROR);
return; // Exit with error code
}

CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)ShutdownShim, hinstDLL, 0, nullptr);
}

BOOL WINAPI DllMain(
HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved ) // reserved
{
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
{
LoadMillennium(hinstDLL);
break;
}
case DLL_PROCESS_DETACH:
{
// ShutdownShim();
break;
}
}

return true;
}

0 comments on commit d448ab1

Please sign in to comment.