mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-05 21:15:39 -05:00
Reformat project
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
Standard: c++20
|
||||
BreakBeforeBraces: Attach
|
||||
LineEnding: LF
|
||||
ColumnLimit: 100
|
||||
AlignAfterOpenBracket: BlockIndent
|
||||
IndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
NamespaceIndentation: All
|
||||
UseTab: Never
|
||||
PointerAlignment: Left
|
||||
SortIncludes: true
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
FixNamespaceComments: false
|
||||
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
BinPackParameters: OnePerLine
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
BinPackArguments: false
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
66
.idea/codeStyles/Project.xml
generated
66
.idea/codeStyles/Project.xml
generated
@@ -1,5 +1,6 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<option name="AUTODETECT_INDENTS" value="false" />
|
||||
<Markdown>
|
||||
<option name="MAX_LINES_AROUND_HEADER" value="0" />
|
||||
<option name="MAX_LINES_AROUND_BLOCK_ELEMENTS" value="0" />
|
||||
@@ -17,19 +18,72 @@
|
||||
<option name="SPACE_BETWEEN_ADJACENT_BRACKETS" value="true" />
|
||||
</Objective-C>
|
||||
<RiderCodeStyleSettings>
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CppIncludeDirective/SortIncludeDirectives/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CppPreferForwardDeclaration/PreferForwardDeclarations/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CppIncludeDirective/UseRelativePaths/@EntryValue" value="Never" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/CVQualifiersOrder/@EntryValue" value="VolatileConst" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/SortDefinitions/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInIfStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInForStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInWhileStatement/@EntryValue" value="Required" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/EXPORT_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/REQUIRES_EXPRESSION_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="END_OF_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/EMPTY_BLOCK_STYLE/@EntryValue" value="TOGETHER" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="1" type="long" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="1" type="long" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_EMBEDDED_STATEMENT_STYLE/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FUNCTION_DEFINITION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TOPLEVEL_FUNCTION_DEFINITION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FUNCTION_DECLARATION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TOPLEVEL_FUNCTION_DECLARATION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_BEFORE_DEREF_IN_TRAILING_RETURN_TYPES/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_DEREF_IN_TRAILING_RETURN_TYPES/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_BEFORE_FUNCTION_TRY_BLOCK/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COMMA_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_LIMIT/@EntryValue" value="100" type="long" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BRACED_INIT_LIST_STYLE/@EntryValue" value="CHOP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BASE_CLAUSE_STYLE/@EntryValue" value="CHOP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_CTOR_INITIALIZER_STYLE/@EntryValue" value="CHOP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="CHOP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="CHOP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_STATEMENT_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/USE_CONTINUOUS_LINE_INDENT_IN_EXPRESSION_BRACES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINKAGE_SPECIFICATION_INDENTATION/@EntryValue" value="All" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION_BRACES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OUTDENT_COMMAS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_ENUM_INITIALIZERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_BITFIELD_SIZES/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" />
|
||||
</RiderCodeStyleSettings>
|
||||
<clangFormatSettings>
|
||||
<option name="ENABLED" value="true" />
|
||||
</clangFormatSettings>
|
||||
<editorconfig>
|
||||
<option name="ENABLED" value="false" />
|
||||
</editorconfig>
|
||||
<files>
|
||||
<extensions>
|
||||
<pair source="cpp" header="hpp" fileNamingConvention="SNAKE_CASE" />
|
||||
<pair source="c" header="h" fileNamingConvention="NONE" />
|
||||
<pair source="cu" header="cuh" fileNamingConvention="NONE" />
|
||||
<pair source="c" header="h" fileNamingConvention="SNAKE_CASE" />
|
||||
</extensions>
|
||||
</files>
|
||||
<codeStyleSettings language="CMake">
|
||||
|
||||
6
.idea/dictionaries/project.xml
generated
6
.idea/dictionaries/project.xml
generated
@@ -2,13 +2,19 @@
|
||||
<dictionary name="project">
|
||||
<words>
|
||||
<w>abcdefghijklmnopqrstuvwxyz</w>
|
||||
<w>acidicoala</w>
|
||||
<w>ajaxgetdlclist</w>
|
||||
<w>indicies</w>
|
||||
<w>inlinentd</w>
|
||||
<w>isteamapps</w>
|
||||
<w>isteamclient</w>
|
||||
<w>isteaminventory</w>
|
||||
<w>isteamuser</w>
|
||||
<w>koalabox</w>
|
||||
<w>koality</w>
|
||||
<w>koaloader</w>
|
||||
<w>polyhook</w>
|
||||
<w>simplecpp</w>
|
||||
<w>steamapps</w>
|
||||
<w>wstr</w>
|
||||
</words>
|
||||
|
||||
@@ -72,6 +72,8 @@ add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES} ${VERSION_RESOURCE})
|
||||
# but manually setting the MSVC compiler option fixes this issue.
|
||||
target_compile_options(SmokeAPI PRIVATE /std:c++latest)
|
||||
|
||||
target_include_directories(SmokeAPI PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
|
||||
|
||||
configure_linker_exports(
|
||||
TARGET SmokeAPI
|
||||
HEADER_NAME "linker_exports_for_steam_api"
|
||||
@@ -93,7 +95,6 @@ configure_output_name(${STEAMAPI_DLL})
|
||||
configure_include_directories()
|
||||
|
||||
target_link_libraries(SmokeAPI PRIVATE KoalaBox)
|
||||
target_precompile_headers(SmokeAPI REUSE_FROM KoalaBox)
|
||||
|
||||
set(B_PRODUCTION_MODE ON)
|
||||
CPMAddPackage("gh:batterycenter/embed@1.2.19")
|
||||
|
||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: e749d5c90c...e0bae7adac
@@ -262,7 +262,7 @@ config::: `Debug` or `Release`
|
||||
For example:
|
||||
|
||||
----
|
||||
.\build.ps1 32 Debug
|
||||
.\build.ps1 64 Release
|
||||
----
|
||||
|
||||
== 📚 Open-Source libraries
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
This directory contains dummy headers used by the `simplecpp` preprocessor
|
||||
@@ -5,7 +5,11 @@
|
||||
#include "smoke_api/globals.hpp"
|
||||
|
||||
// TODO: Detour in hook mode
|
||||
DLL_EXPORT(bool) SteamAPI_RestartAppIfNecessary(const uint32_t unOwnAppID) {
|
||||
DLL_EXPORT(bool) SteamAPI_RestartAppIfNecessary
|
||||
(
|
||||
const uint32_t unOwnAppID
|
||||
)
|
||||
{
|
||||
if(smoke_api::config::instance.override_app_id != 0) {
|
||||
LOG_DEBUG("{} -> {}. Preventing app restart", unOwnAppID, __func__);
|
||||
return false;
|
||||
@@ -14,7 +18,10 @@ DLL_EXPORT(bool) SteamAPI_RestartAppIfNecessary(const uint32_t unOwnAppID) {
|
||||
return ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_RestartAppIfNecessary)(unOwnAppID);
|
||||
}
|
||||
|
||||
DLL_EXPORT(void) SteamAPI_Shutdown() {
|
||||
DLL_EXPORT(void) SteamAPI_Shutdown
|
||||
(
|
||||
)
|
||||
{
|
||||
LOG_INFO("{} -> Game requested shutdown", __func__);
|
||||
|
||||
ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_Shutdown)();
|
||||
|
||||
@@ -11,11 +11,18 @@
|
||||
|
||||
// ISteamApps
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp(void* self, AppId_t dlcID) {
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp
|
||||
(
|
||||
void *self, AppId_t dlcID
|
||||
)
|
||||
{
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::IsDlcUnlocked(
|
||||
__func__, app_id, dlcID, [&] {
|
||||
__func__,
|
||||
app_id,
|
||||
dlcID,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsSubscribedApp)
|
||||
|
||||
return SteamAPI_ISteamApps_BIsSubscribedApp_o(self, dlcID);
|
||||
@@ -27,11 +34,18 @@ DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp(void* self, AppId_t dlcID)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled(void* self, AppId_t dlcID) {
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled
|
||||
(
|
||||
void *self, AppId_t dlcID
|
||||
)
|
||||
{
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::IsDlcUnlocked(
|
||||
__func__, app_id, dlcID, [&] {
|
||||
__func__,
|
||||
app_id,
|
||||
dlcID,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsDlcInstalled)
|
||||
|
||||
return SteamAPI_ISteamApps_BIsDlcInstalled_o(self, dlcID);
|
||||
@@ -43,11 +57,17 @@ DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled(void* self, AppId_t dlcID)
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount(void* self) {
|
||||
DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount
|
||||
(
|
||||
void* self
|
||||
)
|
||||
{
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::GetDLCCount(
|
||||
__func__, app_id, [&] {
|
||||
__func__,
|
||||
app_id,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_GetDLCCount)
|
||||
|
||||
return SteamAPI_ISteamApps_GetDLCCount_o(self);
|
||||
@@ -59,22 +79,40 @@ DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount(void* self) {
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex
|
||||
(
|
||||
|
||||
void *self,
|
||||
|
||||
int iDLC,
|
||||
AppId_t*pDlcID,
|
||||
|
||||
bool *pbAvailable,
|
||||
|
||||
char *pchName,
|
||||
|
||||
int cchNameBufferSize
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::GetDLCDataByIndex(
|
||||
__func__, app_id, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize,
|
||||
__func__,
|
||||
app_id,
|
||||
iDLC,
|
||||
pDlcID,
|
||||
pbAvailable,
|
||||
pchName,
|
||||
cchNameBufferSize,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BGetDLCDataByIndex)
|
||||
return SteamAPI_ISteamApps_BGetDLCDataByIndex_o(
|
||||
self, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize
|
||||
self,
|
||||
iDLC,
|
||||
pDlcID,
|
||||
pbAvailable,
|
||||
pchName,
|
||||
cchNameBufferSize
|
||||
);
|
||||
},
|
||||
[&](AppId_t dlc_id) {
|
||||
@@ -89,17 +127,28 @@ DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex(
|
||||
|
||||
// ISteamClient
|
||||
|
||||
DLL_EXPORT(void*) SteamAPI_ISteamClient_GetISteamGenericInterface(
|
||||
DLL_EXPORT(void*) SteamAPI_ISteamClient_GetISteamGenericInterface
|
||||
(
|
||||
|
||||
void *self,
|
||||
HSteamUser hSteamUser,
|
||||
HSteamPipe hSteamPipe,
|
||||
|
||||
const char* pchVersion
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__, pchVersion, [&] {
|
||||
__func__,
|
||||
pchVersion,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamClient_GetISteamGenericInterface)
|
||||
return SteamAPI_ISteamClient_GetISteamGenericInterface_o(self, hSteamUser, hSteamPipe, pchVersion);
|
||||
return SteamAPI_ISteamClient_GetISteamGenericInterface_o(
|
||||
self,
|
||||
hSteamUser,
|
||||
hSteamPipe,
|
||||
pchVersion
|
||||
);
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
@@ -115,7 +164,9 @@ DLL_EXPORT(EResult) SteamAPI_ISteamInventory_GetResultStatus(
|
||||
SteamInventoryResult_t resultHandle
|
||||
) {
|
||||
return steam_inventory::GetResultStatus(
|
||||
__func__, resultHandle, [&] {
|
||||
__func__,
|
||||
resultHandle,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetResultStatus)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetResultStatus_o(self, resultHandle);
|
||||
@@ -123,80 +174,138 @@ DLL_EXPORT(EResult) SteamAPI_ISteamInventory_GetResultStatus(
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs
|
||||
(
|
||||
|
||||
|
||||
void *self,
|
||||
SteamItemDef_t*pItemDefIDs,
|
||||
uint32_t*punItemDefIDsArraySize
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::GetItemDefinitionIDs(
|
||||
__func__, pItemDefIDs, punItemDefIDsArraySize, [&] {
|
||||
__func__,
|
||||
pItemDefIDs,
|
||||
punItemDefIDsArraySize,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetItemDefinitionIDs)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(self, pItemDefIDs, punItemDefIDsArraySize);
|
||||
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(
|
||||
self,
|
||||
pItemDefIDs,
|
||||
punItemDefIDsArraySize
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItems(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItems
|
||||
(
|
||||
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t resultHandle,
|
||||
SteamItemDetails_t*pOutItemsArray,
|
||||
uint32_t*punOutItemsArraySize
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::GetResultItems(
|
||||
__func__, resultHandle, pOutItemsArray, punOutItemsArraySize,
|
||||
__func__,
|
||||
resultHandle,
|
||||
pOutItemsArray,
|
||||
punOutItemsArraySize,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetResultItems)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetResultItems_o(self, resultHandle, pOutItemsArray, punOutItemsArraySize);
|
||||
return SteamAPI_ISteamInventory_GetResultItems_o(
|
||||
self,
|
||||
resultHandle,
|
||||
pOutItemsArray,
|
||||
punOutItemsArraySize
|
||||
);
|
||||
},
|
||||
[&](SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize) {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetItemDefinitionIDs)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(self, pItemDefIDs, punItemDefIDsArraySize);
|
||||
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(
|
||||
self,
|
||||
pItemDefIDs,
|
||||
punItemDefIDsArraySize
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty
|
||||
(
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t resultHandle,
|
||||
uint32_t unItemIndex,
|
||||
|
||||
const char *pchPropertyName,
|
||||
|
||||
char *pchValueBuffer,
|
||||
uint32_t*punValueBufferSizeOut
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::GetResultItemProperty(
|
||||
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&] {
|
||||
__func__,
|
||||
resultHandle,
|
||||
unItemIndex,
|
||||
pchPropertyName,
|
||||
pchValueBuffer,
|
||||
punValueBufferSizeOut,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetResultItemProperty)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetResultItemProperty_o(
|
||||
self, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
|
||||
self,
|
||||
resultHandle,
|
||||
unItemIndex,
|
||||
pchPropertyName,
|
||||
pchValueBuffer,
|
||||
punValueBufferSizeOut
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID
|
||||
(
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t resultHandle,
|
||||
CSteamID steamIDExpected
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::CheckResultSteamID(
|
||||
__func__, resultHandle, steamIDExpected, [&] {
|
||||
__func__,
|
||||
resultHandle,
|
||||
steamIDExpected,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_CheckResultSteamID)
|
||||
|
||||
return SteamAPI_ISteamInventory_CheckResultSteamID_o(self, resultHandle, steamIDExpected);
|
||||
return SteamAPI_ISteamInventory_CheckResultSteamID_o(
|
||||
self,
|
||||
resultHandle,
|
||||
steamIDExpected
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems
|
||||
(
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t*pResultHandle
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::GetAllItems(
|
||||
__func__, pResultHandle, [&] {
|
||||
__func__,
|
||||
pResultHandle,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetAllItems)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetAllItems_o(self, pResultHandle);
|
||||
@@ -204,32 +313,58 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems(
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemsByID(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemsByID
|
||||
(
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t*pResultHandle,
|
||||
|
||||
const SteamItemInstanceID_t *pInstanceIDs,
|
||||
uint32_t unCountInstanceIDs
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::GetItemsByID(
|
||||
__func__, pResultHandle, pInstanceIDs, unCountInstanceIDs, [&] {
|
||||
__func__,
|
||||
pResultHandle,
|
||||
pInstanceIDs,
|
||||
unCountInstanceIDs,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_GetItemsByID)
|
||||
|
||||
return SteamAPI_ISteamInventory_GetItemsByID_o(self, pResultHandle, pInstanceIDs, unCountInstanceIDs);
|
||||
return SteamAPI_ISteamInventory_GetItemsByID_o(
|
||||
self,
|
||||
pResultHandle,
|
||||
pInstanceIDs,
|
||||
unCountInstanceIDs
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_SerializeResult(
|
||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_SerializeResult
|
||||
(
|
||||
|
||||
void *self,
|
||||
SteamInventoryResult_t resultHandle,
|
||||
|
||||
void *pOutBuffer,
|
||||
uint32_t*punOutBufferSize
|
||||
) {
|
||||
)
|
||||
{
|
||||
return steam_inventory::SerializeResult(
|
||||
__func__, resultHandle, pOutBuffer, punOutBufferSize, [&] {
|
||||
__func__,
|
||||
resultHandle,
|
||||
pOutBuffer,
|
||||
punOutBufferSize,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamInventory_SerializeResult)
|
||||
|
||||
return SteamAPI_ISteamInventory_SerializeResult_o(self, resultHandle, pOutBuffer, punOutBufferSize);
|
||||
return SteamAPI_ISteamInventory_SerializeResult_o(
|
||||
self,
|
||||
resultHandle,
|
||||
pOutBuffer,
|
||||
punOutBufferSize
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -244,7 +379,10 @@ DLL_EXPORT(EUserHasLicenseForAppResult) SteamAPI_ISteamUser_UserHasLicenseForApp
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_user::UserHasLicenseForApp(
|
||||
__func__, app_id, dlcID, [&] {
|
||||
__func__,
|
||||
app_id,
|
||||
dlcID,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamUser_UserHasLicenseForApp)
|
||||
|
||||
return SteamAPI_ISteamUser_UserHasLicenseForApp_o(self, steamID, dlcID);
|
||||
@@ -254,5 +392,4 @@ DLL_EXPORT(EUserHasLicenseForAppResult) SteamAPI_ISteamUser_UserHasLicenseForApp
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return k_EUserHasLicenseResultDoesNotHaveLicense;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,18 +4,37 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
#include "steam_interface/steam_client.hpp"
|
||||
|
||||
DLL_EXPORT(void*) SteamInternal_FindOrCreateUserInterface(HSteamUser hSteamUser, const char* version) {
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
DLL_EXPORT(void*) SteamInternal_FindOrCreateUserInterface
|
||||
(
|
||||
HSteamUser hSteamUser
|
||||
,
|
||||
const char* version
|
||||
)
|
||||
{
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamInternal_FindOrCreateUserInterface)
|
||||
|
||||
return SteamInternal_FindOrCreateUserInterface_o(hSteamUser, version);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(void*) SteamInternal_CreateInterface(const char* version) {
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
DLL_EXPORT(void*) SteamInternal_CreateInterface
|
||||
(
|
||||
|
||||
const char* version
|
||||
)
|
||||
{
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamInternal_CreateInterface)
|
||||
|
||||
return SteamInternal_CreateInterface_o(version);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -10,19 +10,24 @@
|
||||
#include "steam_interface/steam_client.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* Searches the `.rdata` section of the original dll for the full interface version string
|
||||
* Results are cached for performance.
|
||||
*/
|
||||
std::string
|
||||
get_versioned_interface(const std::string& version_prefix, const std::string& fallback) {
|
||||
std::string get_versioned_interface(
|
||||
const std::string& version_prefix,
|
||||
const std::string& fallback
|
||||
) {
|
||||
static std::map<std::string, std::string> version_map;
|
||||
|
||||
if (not version_map.contains(version_prefix)) {
|
||||
if(not
|
||||
version_map.contains(version_prefix)
|
||||
)
|
||||
{
|
||||
try {
|
||||
const std::string rdata = koalabox::win_util::get_pe_section_data_or_throw(
|
||||
globals::steamapi_module, ".rdata"
|
||||
globals::steamapi_module,
|
||||
".rdata"
|
||||
);
|
||||
|
||||
const std::regex regex(version_prefix + "\\d{3}");
|
||||
@@ -49,42 +54,70 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
DLL_EXPORT(void*) SteamClient() {
|
||||
DLL_EXPORT(void*) SteamClient
|
||||
(
|
||||
)
|
||||
{
|
||||
static auto version = get_versioned_interface(STEAM_CLIENT, "006");
|
||||
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamClient)
|
||||
|
||||
return SteamClient_o();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(void*) SteamApps() {
|
||||
DLL_EXPORT(void*) SteamApps
|
||||
(
|
||||
)
|
||||
{
|
||||
static auto version = get_versioned_interface(STEAM_APPS, "002");
|
||||
|
||||
return steam_client::GetGenericInterface(__func__, version, [&]() {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&]() {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamApps)
|
||||
|
||||
return SteamApps_o();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(void*) SteamUser() {
|
||||
DLL_EXPORT(void*) SteamUser
|
||||
(
|
||||
)
|
||||
{
|
||||
static auto version = get_versioned_interface(STEAM_USER, "012");
|
||||
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamUser)
|
||||
|
||||
return SteamUser_o();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
DLL_EXPORT(void*) SteamInventory() {
|
||||
DLL_EXPORT(void*) SteamInventory
|
||||
(
|
||||
)
|
||||
{
|
||||
static auto version = get_versioned_interface(STEAM_INVENTORY, "001");
|
||||
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_FUNCTION_STEAMAPI(SteamInventory)
|
||||
|
||||
return SteamInventory_o();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -5,9 +5,13 @@
|
||||
#include "steam_interface/steam_client.hpp"
|
||||
|
||||
C_DECL(void*) CreateInterface(const char* interface_string, int* out_result) {
|
||||
return steam_client::GetGenericInterface(__func__, interface_string, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
interface_string,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(CreateInterface)
|
||||
|
||||
return CreateInterface_o(interface_string, out_result);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "linker_exports_for_version.h"
|
||||
|
||||
EXTERN_C [[maybe_unused]] BOOL WINAPI
|
||||
|
||||
DllMain(const HMODULE module_handle, const DWORD reason, LPVOID) {
|
||||
if(reason == DLL_PROCESS_ATTACH) {
|
||||
smoke_api::init(module_handle);
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
#include <koalabox/http_client.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
|
||||
#include "smoke_api/types.hpp"
|
||||
#include "smoke_api/api.hpp"
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace api {
|
||||
|
||||
struct SteamResponse {
|
||||
uint32_t success = 0;
|
||||
std::vector<DLC> dlcs;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(
|
||||
SteamResponse, success, dlcs
|
||||
SteamResponse,
|
||||
success,
|
||||
dlcs
|
||||
) // NOLINT(misc-const-correctness)
|
||||
};
|
||||
|
||||
std::optional<std::vector<DLC>> fetch_dlcs_from_github(AppId_t app_id) noexcept {
|
||||
try {
|
||||
const auto* url = "https://raw.githubusercontent.com/acidicoala/public-entitlements/"
|
||||
"main/steam/v2/dlc.json";
|
||||
constexpr auto url = "https://raw.githubusercontent.com/"
|
||||
"acidicoala/public-entitlements/main/steam/v2/dlc.json";
|
||||
const auto json = koalabox::http_client::get_json(url);
|
||||
const auto response = json.get<AppDlcNameMap>();
|
||||
|
||||
return DLC::get_dlcs_from_apps(response, app_id);
|
||||
} catch(const nlohmann::json::exception& e) {
|
||||
LOG_ERROR("Failed to fetch dlc list from GitHub: {}", e.what());
|
||||
LOG_ERROR("Failed to fetch DLC list from GitHub: {}", e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
@@ -37,17 +38,16 @@ namespace api {
|
||||
fmt::format("https://store.steampowered.com/dlc/{}/ajaxgetdlclist", app_id);
|
||||
const auto json = koalabox::http_client::get_json(url);
|
||||
|
||||
const auto response = json.get<SteamResponse>();
|
||||
const auto [success, dlcs] = json.get<SteamResponse>();
|
||||
|
||||
if (response.success != 1) {
|
||||
if(success != 1) {
|
||||
throw std::runtime_error("Web API responded with 'success' != 1");
|
||||
}
|
||||
|
||||
return response.dlcs;
|
||||
return dlcs;
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("Failed to fetch dlc list from Steam: {}", e.what());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace api {
|
||||
|
||||
std::optional<std::vector<DLC>> fetch_dlcs_from_github(AppId_t app_id) noexcept;
|
||||
|
||||
std::optional<std::vector<DLC>> fetch_dlcs_from_steam(AppId_t app_id) noexcept;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
constexpr auto KEY_APPS = "apps";
|
||||
|
||||
namespace {
|
||||
|
||||
AppDlcNameMap get_cached_apps() noexcept {
|
||||
try {
|
||||
return koalabox::cache::get(KEY_APPS).get<AppDlcNameMap>();
|
||||
@@ -15,11 +14,9 @@ namespace {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace smoke_api::cache {
|
||||
|
||||
std::vector<DLC> get_dlcs(AppId_t app_id) noexcept {
|
||||
try {
|
||||
LOG_DEBUG("Reading cached DLC IDs for the app: {}", app_id);
|
||||
@@ -49,5 +46,4 @@ namespace smoke_api::cache {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,9 +3,7 @@
|
||||
#include "types.hpp"
|
||||
|
||||
namespace smoke_api::cache {
|
||||
|
||||
std::vector<DLC> get_dlcs(AppId_t app_id) noexcept;
|
||||
|
||||
bool save_dlcs(AppId_t app_id, const std::vector<DLC>& dlcs) noexcept;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
namespace smoke_api::config {
|
||||
namespace kb = koalabox;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
Config instance; // NOLINT(cert-err58-cpp)
|
||||
|
||||
@@ -16,7 +15,9 @@ namespace smoke_api::config {
|
||||
}
|
||||
|
||||
bool is_dlc_unlocked(
|
||||
AppId_t app_id, AppId_t dlc_id, const std::function<bool()>& original_function
|
||||
AppId_t app_id,
|
||||
AppId_t dlc_id,
|
||||
const std::function<bool()>& original_function
|
||||
) {
|
||||
auto status = instance.default_app_status;
|
||||
|
||||
@@ -31,6 +32,7 @@ namespace smoke_api::config {
|
||||
}
|
||||
|
||||
bool is_unlocked;
|
||||
|
||||
switch(status) {
|
||||
case AppStatus::UNLOCKED:
|
||||
is_unlocked = true;
|
||||
@@ -56,7 +58,10 @@ namespace smoke_api::config {
|
||||
return is_unlocked;
|
||||
}
|
||||
|
||||
DLL_EXPORT(void) ReloadConfig() {
|
||||
DLL_EXPORT(void) ReloadConfig
|
||||
(
|
||||
)
|
||||
{
|
||||
LOG_INFO("Reloading config");
|
||||
|
||||
instance = kb::config::parse<Config>();
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace smoke_api::config {
|
||||
|
||||
enum class AppStatus {
|
||||
UNDEFINED,
|
||||
ORIGINAL,
|
||||
@@ -11,12 +10,17 @@ namespace smoke_api::config {
|
||||
LOCKED,
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(AppStatus, {
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(
|
||||
AppStatus,
|
||||
// @formatter:off
|
||||
{
|
||||
{AppStatus::UNDEFINED, nullptr},
|
||||
{AppStatus::ORIGINAL, "original"},
|
||||
{AppStatus::UNLOCKED, "unlocked"},
|
||||
{AppStatus::LOCKED, "locked"},
|
||||
})
|
||||
}
|
||||
// @formatter:on
|
||||
)
|
||||
|
||||
struct Config {
|
||||
uint32_t $version = 2;
|
||||
@@ -30,7 +34,8 @@ namespace smoke_api::config {
|
||||
std::vector<uint32_t> extra_inventory_items;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
|
||||
Config, // NOLINT(misc-const-correctness)
|
||||
Config,
|
||||
// NOLINT(misc-const-correctness)
|
||||
$version,
|
||||
logging,
|
||||
default_app_status,
|
||||
@@ -47,7 +52,13 @@ namespace smoke_api::config {
|
||||
|
||||
std::vector<DLC> get_extra_dlcs(AppId_t app_id);
|
||||
|
||||
bool is_dlc_unlocked(uint32_t app_id, uint32_t dlc_id, const std::function<bool()>& original_function);
|
||||
bool is_dlc_unlocked(
|
||||
uint32_t app_id,
|
||||
uint32_t dlc_id,
|
||||
const std::function<bool()>& original_function
|
||||
);
|
||||
|
||||
DLL_EXPORT(void) ReloadConfig();
|
||||
DLL_EXPORT(void) ReloadConfig
|
||||
(
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
namespace globals {
|
||||
|
||||
HMODULE steamapi_module = nullptr;
|
||||
HMODULE steamclient_module = nullptr;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace globals {
|
||||
|
||||
extern HMODULE steamclient_module;
|
||||
extern HMODULE steamapi_module;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
#include "smoke_api/smoke_api.hpp"
|
||||
#include "exports/steamclient.hpp"
|
||||
#include "smoke_api/config.hpp"
|
||||
#include "smoke_api/globals.hpp"
|
||||
#include "smoke_api/smoke_api.hpp"
|
||||
|
||||
// Hooking steam_api has shown itself to be less desirable than steamclient
|
||||
// for the reasons outlined below:
|
||||
@@ -64,15 +64,19 @@ namespace {
|
||||
|
||||
kb::hook::init(true);
|
||||
|
||||
kb::dll_monitor::init_listener(STEAMCLIENT_DLL, [](const HMODULE& library) {
|
||||
kb::dll_monitor::init_listener(
|
||||
STEAMCLIENT_DLL,
|
||||
[](const HMODULE& library) {
|
||||
globals::steamclient_module = library;
|
||||
|
||||
DETOUR_STEAMCLIENT(CreateInterface)
|
||||
|
||||
kb::dll_monitor::shutdown_listener();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
namespace smoke_api {
|
||||
void init(const HMODULE module_handle) {
|
||||
// FIXME: IMPORTANT! Non ascii paths in directories will result in init errors
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace smoke_api {
|
||||
|
||||
void init(HMODULE module_handle);
|
||||
|
||||
void shutdown();
|
||||
|
||||
}
|
||||
|
||||
@@ -71,9 +71,6 @@ constexpr auto STEAM_CLIENT = "SteamClient";
|
||||
constexpr auto STEAM_USER = "SteamUser";
|
||||
constexpr auto STEAM_INVENTORY = "STEAMINVENTORY_INTERFACE_V";
|
||||
|
||||
// TODO: Delete
|
||||
constexpr auto CLIENT_ENGINE = "CLIENTENGINE_INTERFACE_VERSION";
|
||||
|
||||
using AppId_t = uint32_t;
|
||||
using SteamInventoryResult_t = uint32_t;
|
||||
using SteamItemInstanceID_t = uint64_t;
|
||||
@@ -121,8 +118,8 @@ class DLC {
|
||||
public:
|
||||
explicit DLC() = default;
|
||||
|
||||
explicit DLC(std::string appid, std::string name)
|
||||
: appid{std::move(appid)}, name{std::move(name)} {}
|
||||
explicit DLC(std::string appid, std::string name) : appid{std::move(appid)},
|
||||
name{std::move(name)} {}
|
||||
|
||||
[[nodiscard]] std::string get_id_str() const {
|
||||
return appid;
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <koalabox/logger.hpp>
|
||||
#include <koalabox/util.hpp>
|
||||
|
||||
#include "steam_interface/steam_apps.hpp"
|
||||
#include "smoke_api/api.hpp"
|
||||
#include "smoke_api/cache.hpp"
|
||||
#include "smoke_api/config.hpp"
|
||||
#include "smoke_api/types.hpp"
|
||||
#include "steam_interface/steam_apps.hpp"
|
||||
|
||||
namespace {
|
||||
/// Steamworks may max GetDLCCount value at 64, depending on how much unowned DLCs the user has.
|
||||
@@ -46,7 +46,10 @@ namespace {
|
||||
// by aggregating results from all the sources into a single set.
|
||||
std::vector<DLC> aggregated_dlcs;
|
||||
|
||||
const auto append_dlcs = [&](const std::vector<DLC>& dlc_list, const std::string& source_name) {
|
||||
const auto append_dlcs = [&](
|
||||
const std::vector<DLC>& dlc_list,
|
||||
const std::string& source_name
|
||||
) {
|
||||
LOG_DEBUG("App ID {} has {} DLCs defined in {}", app_id, dlc_list.size(), source_name);
|
||||
// Append DLCs to aggregated DLCs
|
||||
std::ranges::copy(dlc_list, std::back_inserter(aggregated_dlcs));
|
||||
@@ -78,7 +81,6 @@ namespace {
|
||||
}
|
||||
|
||||
namespace steam_apps {
|
||||
|
||||
bool IsDlcUnlocked(
|
||||
const std::string& function_name,
|
||||
AppId_t app_id,
|
||||
@@ -86,9 +88,19 @@ namespace steam_apps {
|
||||
const std::function<bool()>& original_function
|
||||
) {
|
||||
try {
|
||||
const auto unlocked = smoke_api::config::is_dlc_unlocked(app_id, dlc_id, original_function);
|
||||
const auto unlocked = smoke_api::config::is_dlc_unlocked(
|
||||
app_id,
|
||||
dlc_id,
|
||||
original_function
|
||||
);
|
||||
|
||||
LOG_INFO("{} -> {}DLC ID: {:>8}, Unlocked: {}", function_name, get_app_id_log(app_id), dlc_id, unlocked);
|
||||
LOG_INFO(
|
||||
"{} -> {}DLC ID: {:>8}, Unlocked: {}",
|
||||
function_name,
|
||||
get_app_id_log(app_id),
|
||||
dlc_id,
|
||||
unlocked
|
||||
);
|
||||
|
||||
return unlocked;
|
||||
} catch(const std::exception& e) {
|
||||
@@ -97,7 +109,11 @@ namespace steam_apps {
|
||||
}
|
||||
}
|
||||
|
||||
int GetDLCCount(const std::string& function_name, const AppId_t app_id, const std::function<int()>& original_function) {
|
||||
int GetDLCCount(
|
||||
const std::string& function_name,
|
||||
const AppId_t app_id,
|
||||
const std::function<int()>& original_function
|
||||
) {
|
||||
try {
|
||||
const auto total_count = [&](int count) {
|
||||
LOG_INFO("{} -> Responding with DLC count: {}", function_name, count);
|
||||
@@ -115,7 +131,10 @@ namespace steam_apps {
|
||||
return total_count(original_count);
|
||||
}
|
||||
|
||||
LOG_DEBUG("Game has {} or more DLCs. Fetching DLCs from remote sources.", original_count);
|
||||
LOG_DEBUG(
|
||||
"Game has {} or more DLCs. Fetching DLCs from remote sources.",
|
||||
original_count
|
||||
);
|
||||
|
||||
fetch_and_cache_dlcs(app_id);
|
||||
|
||||
@@ -143,7 +162,13 @@ namespace steam_apps {
|
||||
const auto print_dlc_info = [&](const std::string& tag) {
|
||||
LOG_INFO(
|
||||
R"({} -> [{:^12}] {}index: {:>3}, DLC ID: {:>8}, available: {:5}, name: "{}")",
|
||||
function_name, tag, get_app_id_log(app_id), iDLC, *pDlcId, *pbAvailable, pchName
|
||||
function_name,
|
||||
tag,
|
||||
get_app_id_log(app_id),
|
||||
iDLC,
|
||||
*pDlcId,
|
||||
*pbAvailable,
|
||||
pchName
|
||||
);
|
||||
};
|
||||
|
||||
@@ -151,7 +176,9 @@ namespace steam_apps {
|
||||
// Fill the output pointers
|
||||
*pDlcId = dlc.get_id();
|
||||
*pbAvailable = smoke_api::config::is_dlc_unlocked(
|
||||
app_id, *pDlcId, [&]() {
|
||||
app_id,
|
||||
*pDlcId,
|
||||
[&]() {
|
||||
return is_originally_unlocked(*pDlcId);
|
||||
}
|
||||
);
|
||||
@@ -178,7 +205,11 @@ namespace steam_apps {
|
||||
|
||||
if(success) {
|
||||
*pbAvailable = smoke_api::config::is_dlc_unlocked(
|
||||
app_id, *pDlcId, [&]() { return *pbAvailable; }
|
||||
app_id,
|
||||
*pDlcId,
|
||||
[&]() {
|
||||
return *pbAvailable;
|
||||
}
|
||||
);
|
||||
print_dlc_info("original");
|
||||
} else {
|
||||
@@ -191,5 +222,4 @@ namespace steam_apps {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace steam_apps {
|
||||
|
||||
bool IsDlcUnlocked(
|
||||
const std::string& function_name,
|
||||
AppId_t app_id,
|
||||
@@ -26,7 +25,7 @@ namespace steam_apps {
|
||||
char* pchName,
|
||||
int cchNameBufferSize,
|
||||
const std::function<bool()>& original_function,
|
||||
const std::function<bool(AppId_t)>& is_originally_unlocked // Aux function to resolve original dlc status
|
||||
const std::function<bool(AppId_t)>& is_originally_unlocked
|
||||
// Aux function to resolve original dlc status
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "steam_interface/steam_interface.hpp"
|
||||
|
||||
namespace steam_client {
|
||||
|
||||
void* GetGenericInterface(
|
||||
const std::string& function_name,
|
||||
const std::string& interface_version,
|
||||
@@ -18,5 +17,4 @@ namespace steam_client {
|
||||
|
||||
return interface;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace steam_client {
|
||||
|
||||
void* GetGenericInterface(
|
||||
const std::string& function_name,
|
||||
const std::string& interface_version,
|
||||
const std::function<void*()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,20 +2,17 @@
|
||||
#include <set>
|
||||
|
||||
#include <battery/embed.hpp>
|
||||
#include <polyhook2/Misc.hpp>
|
||||
|
||||
#include <koalabox/hook.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
#include <koalabox/util.hpp>
|
||||
#include <koalabox/win_util.hpp>
|
||||
|
||||
#include "build_config.h"
|
||||
|
||||
#include "steam_interface/steam_interface.hpp"
|
||||
#include "exports/steamclient.hpp"
|
||||
#include "virtuals/steam_api_virtuals.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
struct interface_entry {
|
||||
// function_name must match the function identifier to be able to call original functions
|
||||
std::string function_name; // e.g. "ISteamClient_GetISteamApps"
|
||||
@@ -29,7 +26,6 @@ namespace {
|
||||
};
|
||||
|
||||
std::map<std::string, interface_data> get_virtual_hook_map() {
|
||||
|
||||
#define ENTRY(INTERFACE, FUNC) \
|
||||
{ \
|
||||
#FUNC, { \
|
||||
@@ -38,41 +34,44 @@ namespace {
|
||||
}
|
||||
|
||||
return {
|
||||
{STEAM_CLIENT,
|
||||
{
|
||||
STEAM_CLIENT,
|
||||
interface_data{
|
||||
.fallback_version = "SteamClient021",
|
||||
.entry_map =
|
||||
{
|
||||
.entry_map = {
|
||||
ENTRY(ISteamClient, GetISteamApps),
|
||||
ENTRY(ISteamClient, GetISteamUser),
|
||||
ENTRY(ISteamClient, GetISteamGenericInterface),
|
||||
ENTRY(ISteamClient, GetISteamInventory),
|
||||
}
|
||||
}},
|
||||
{STEAM_APPS,
|
||||
}
|
||||
},
|
||||
{
|
||||
STEAM_APPS,
|
||||
interface_data{
|
||||
.fallback_version = "STEAMAPPS_INTERFACE_VERSION008",
|
||||
.entry_map =
|
||||
{
|
||||
.entry_map = {
|
||||
ENTRY(ISteamApps, BIsSubscribedApp),
|
||||
ENTRY(ISteamApps, BIsDlcInstalled),
|
||||
ENTRY(ISteamApps, GetDLCCount),
|
||||
ENTRY(ISteamApps, BGetDLCDataByIndex),
|
||||
}
|
||||
}},
|
||||
{STEAM_USER,
|
||||
}
|
||||
},
|
||||
{
|
||||
STEAM_USER,
|
||||
interface_data{
|
||||
.fallback_version = "SteamUser023",
|
||||
.entry_map =
|
||||
{
|
||||
.entry_map = {
|
||||
ENTRY(ISteamUser, UserHasLicenseForApp),
|
||||
}
|
||||
}},
|
||||
{STEAM_INVENTORY,
|
||||
}
|
||||
},
|
||||
{
|
||||
STEAM_INVENTORY,
|
||||
interface_data{
|
||||
.fallback_version = "STEAMINVENTORY_INTERFACE_V003",
|
||||
.entry_map =
|
||||
{
|
||||
.entry_map = {
|
||||
ENTRY(ISteamInventory, GetResultStatus),
|
||||
ENTRY(ISteamInventory, GetResultItems),
|
||||
ENTRY(ISteamInventory, CheckResultSteamID),
|
||||
@@ -81,7 +80,8 @@ namespace {
|
||||
ENTRY(ISteamInventory, SerializeResult),
|
||||
ENTRY(ISteamInventory, GetItemDefinitionIDs),
|
||||
}
|
||||
}},
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace {
|
||||
}
|
||||
|
||||
const nlohmann::json& find_lookup(
|
||||
const std::string& interface_version, //
|
||||
const std::string& interface_version,
|
||||
const std::string& fallback_version
|
||||
) {
|
||||
static const auto lookup = read_interface_lookup();
|
||||
@@ -137,7 +137,10 @@ namespace steam_interface {
|
||||
for(const auto& [function, entry] : data.entry_map) {
|
||||
if(lookup.contains(function)) {
|
||||
kb::hook::swap_virtual_func(
|
||||
interface, entry.function_name, lookup[function], entry.function_address
|
||||
interface,
|
||||
entry.function_name,
|
||||
lookup[function],
|
||||
entry.function_address
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -149,93 +152,17 @@ namespace steam_interface {
|
||||
processed_interfaces.insert(interface);
|
||||
}
|
||||
|
||||
HSteamPipe get_steam_pipe_or_throw() {
|
||||
// TODO: Is there a more elegant way of getting steam pipe?
|
||||
|
||||
const auto& steam_api_module = koalabox::win_util::get_module_handle_or_throw(STEAMAPI_DLL);
|
||||
void* GetHSteamPipe_address;
|
||||
try {
|
||||
GetHSteamPipe_address = (void*)koalabox::win_util::get_proc_address_or_throw(
|
||||
steam_api_module, "SteamAPI_GetHSteamPipe"
|
||||
);
|
||||
} catch (...) {
|
||||
GetHSteamPipe_address = (void*)koalabox::win_util::get_proc_address_or_throw(
|
||||
steam_api_module, "GetHSteamPipe"
|
||||
);
|
||||
}
|
||||
typedef HSteamPipe(__cdecl * GetHSteamPipe_t)();
|
||||
const auto GetHSteamPipe_o = (GetHSteamPipe_t)GetHSteamPipe_address;
|
||||
return GetHSteamPipe_o();
|
||||
}
|
||||
|
||||
template <typename F> F get_virtual_function(void* interface, int ordinal) {
|
||||
auto* v_table = (void***)interface;
|
||||
return (F)(*v_table)[ordinal];
|
||||
}
|
||||
|
||||
template <typename F, typename... Args>
|
||||
auto call_virtual_function(void* interface, F function, Args... args) {
|
||||
#ifdef _WIN64
|
||||
void* RCX = interface;
|
||||
#else
|
||||
void* ECX = interface;
|
||||
void* EDX = nullptr;
|
||||
#endif
|
||||
|
||||
return function(ARGS(args...));
|
||||
}
|
||||
|
||||
// TODO: Test if this actually works!!!
|
||||
AppId_t get_app_id_or_throw() {
|
||||
TCHAR buffer[32];
|
||||
GetEnvironmentVariable(TEXT("SteamAppId"), buffer, sizeof(buffer));
|
||||
|
||||
return std::stoi(buffer);
|
||||
const auto app_id_str = kb::win_util::get_env_var("SteamAppId");
|
||||
return std::stoi(app_id_str);
|
||||
}
|
||||
|
||||
AppId_t get_app_id() {
|
||||
try {
|
||||
return get_app_id_or_throw();
|
||||
} catch (...) {
|
||||
LOG_ERROR("Failed to get app id");
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("Failed to get app id: {}", e.what());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*// Get CreateInterface
|
||||
const auto& steam_client_module =
|
||||
koalabox::win_util::get_module_handle_or_throw(STEAMCLIENT_DLL);
|
||||
auto* CreateInterface_address = (void*)koalabox::win_util::get_proc_address_or_throw(
|
||||
steam_client_module, "CreateInterface"
|
||||
);
|
||||
auto* CreateInterface_o = PLH::FnCast(CreateInterface_address, CreateInterface);
|
||||
|
||||
// Get ISteamClient
|
||||
int result;
|
||||
auto* i_steam_client = CreateInterface_o("SteamClient006", &result);
|
||||
if (i_steam_client == nullptr) {
|
||||
throw koalabox::util::exception(
|
||||
"Failed to obtain SteamClient006 interface. Result: {}", result
|
||||
);
|
||||
}
|
||||
|
||||
// Get GetISteamUtils
|
||||
typedef void***(__fastcall * GetISteamUtils_t)(
|
||||
PARAMS(HSteamPipe hSteamPipe, const char* version)
|
||||
);
|
||||
const auto steam_utils_ordinal = steam_client_ordinal_map["ISteamClient_GetISteamUtils"][6];
|
||||
const auto GetISteamUtils_o =
|
||||
get_virtual_function<GetISteamUtils_t>(i_steam_client, steam_utils_ordinal);
|
||||
|
||||
// Get ISteamUtils
|
||||
const auto steam_pipe = get_steam_pipe_or_throw();
|
||||
auto* i_steam_utils =
|
||||
call_virtual_function(i_steam_client, GetISteamUtils_o, steam_pipe, "SteamUtils002");
|
||||
|
||||
// Get GetAppID
|
||||
typedef uint32_t(__fastcall * GetAppID_t)(PARAMS());
|
||||
const auto get_app_id_ordinal = steam_utils_ordinal_map["ISteamUtils_GetAppID"][2];
|
||||
const auto GetAppID_o = get_virtual_function<GetAppID_t>(i_steam_utils, get_app_id_ordinal);
|
||||
|
||||
return call_virtual_function(i_steam_utils, GetAppID_o);*/
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,9 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace steam_interface {
|
||||
|
||||
void hook_virtuals(void* interface, const std::string& version_string);
|
||||
|
||||
AppId_t get_app_id_or_throw();
|
||||
|
||||
AppId_t get_app_id();
|
||||
|
||||
void hook_virtuals(void* interface, const std::string& version_string);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "steam_interface/steam_inventory.hpp"
|
||||
|
||||
namespace steam_inventory {
|
||||
|
||||
EResult GetResultStatus(
|
||||
const std::string& function_name,
|
||||
const SteamInventoryResult_t resultHandle,
|
||||
@@ -13,7 +12,10 @@ namespace steam_inventory {
|
||||
const auto status = original_function();
|
||||
|
||||
LOG_DEBUG(
|
||||
"{} -> handle: {}, status: {}", function_name, resultHandle, static_cast<int>(status)
|
||||
"{} -> handle: {}, status: {}",
|
||||
function_name,
|
||||
resultHandle,
|
||||
static_cast<int>(status)
|
||||
);
|
||||
|
||||
return status;
|
||||
@@ -68,13 +70,16 @@ namespace steam_inventory {
|
||||
static std::vector<SteamItemDef_t> auto_inventory_items;
|
||||
if(smoke_api::config::instance.auto_inject_inventory) {
|
||||
static std::once_flag inventory_inject_flag;
|
||||
std::call_once(inventory_inject_flag, [&] {
|
||||
std::call_once(
|
||||
inventory_inject_flag,
|
||||
[&] {
|
||||
uint32_t count = 0;
|
||||
if(get_item_definition_ids(nullptr, &count)) {
|
||||
auto_inventory_items.resize(count);
|
||||
get_item_definition_ids(auto_inventory_items.data(), &count);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const auto auto_injected_count = auto_inventory_items.size();
|
||||
@@ -151,7 +156,9 @@ namespace steam_inventory {
|
||||
}
|
||||
|
||||
LOG_DEBUG(
|
||||
"{}, Buffer: '{}'", common_info, std::string(pchValueBuffer, *punValueBufferSizeOut - 1)
|
||||
"{}, Buffer: '{}'",
|
||||
common_info,
|
||||
std::string(pchValueBuffer, *punValueBufferSizeOut - 1)
|
||||
);
|
||||
|
||||
return success;
|
||||
@@ -203,7 +210,10 @@ namespace steam_inventory {
|
||||
LOG_DEBUG("{} -> Handle: {}, Buffer: '{}'", function_name, resultHandle, buffer);
|
||||
} else {
|
||||
LOG_DEBUG(
|
||||
"{} -> Handle: {}, Size: '{}'", function_name, resultHandle, *punOutBufferSize
|
||||
"{} -> Handle: {}, Size: '{}'",
|
||||
function_name,
|
||||
resultHandle,
|
||||
*punOutBufferSize
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace steam_inventory {
|
||||
|
||||
EResult GetResultStatus(
|
||||
const std::string& function_name,
|
||||
SteamInventoryResult_t resultHandle,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "steam_interface/steam_user.hpp"
|
||||
|
||||
namespace steam_user {
|
||||
|
||||
EUserHasLicenseForAppResult UserHasLicenseForApp(
|
||||
const std::string& function_name,
|
||||
AppId_t appId,
|
||||
@@ -18,14 +17,18 @@ namespace steam_user {
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto has_license = smoke_api::config::is_dlc_unlocked(appId, dlcId, [&]() {
|
||||
const auto has_license = smoke_api::config::is_dlc_unlocked(
|
||||
appId,
|
||||
dlcId,
|
||||
[&]() {
|
||||
return result == k_EUserHasLicenseResultHasLicense;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
LOG_INFO("{} -> App ID: {:>8}, HasLicense: {}", function_name, dlcId, has_license);
|
||||
|
||||
return has_license ? k_EUserHasLicenseResultHasLicense
|
||||
return has_license
|
||||
? k_EUserHasLicenseResultHasLicense
|
||||
: k_EUserHasLicenseResultDoesNotHaveLicense;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,12 +3,10 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
namespace steam_user {
|
||||
|
||||
EUserHasLicenseForAppResult UserHasLicenseForApp(
|
||||
const std::string& function_name,
|
||||
AppId_t appId,
|
||||
AppId_t dlcId,
|
||||
const std::function<EUserHasLicenseForAppResult()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
@@ -9,10 +9,15 @@
|
||||
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t dlc_id)) {
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id, [&] {
|
||||
return steam_apps::IsDlcUnlocked(
|
||||
__func__,
|
||||
app_id,
|
||||
dlc_id,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BIsSubscribedApp)
|
||||
return ISteamApps_BIsSubscribedApp_o(ARGS(dlc_id));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
|
||||
@@ -23,10 +28,15 @@ VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t dlc_id)) {
|
||||
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t dlc_id)) {
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id, [&] {
|
||||
return steam_apps::IsDlcUnlocked(
|
||||
__func__,
|
||||
app_id,
|
||||
dlc_id,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BIsDlcInstalled)
|
||||
return ISteamApps_BIsDlcInstalled_o(ARGS(dlc_id));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
|
||||
@@ -37,10 +47,14 @@ VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t dlc_id)) {
|
||||
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) {
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_apps::GetDLCCount(__func__, app_id, [&] {
|
||||
return steam_apps::GetDLCCount(
|
||||
__func__,
|
||||
app_id,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_GetDLCCount)
|
||||
return ISteamApps_GetDLCCount_o(ARGS());
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
|
||||
@@ -48,9 +62,14 @@ VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) {
|
||||
}
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamApps_BGetDLCDataByIndex(
|
||||
PARAMS(int iDLC, AppId_t* p_dlc_id, bool* pbAvailable, char* pchName, int cchNameBufferSize)
|
||||
VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
|
||||
PARAMS(
|
||||
int iDLC,
|
||||
AppId_t* p_dlc_id,
|
||||
bool* pbAvailable,
|
||||
char* pchName,
|
||||
int cchNameBufferSize
|
||||
)
|
||||
) {
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
@@ -68,7 +87,9 @@ ISteamApps_BGetDLCDataByIndex(
|
||||
ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize)
|
||||
);
|
||||
},
|
||||
[&](AppId_t dlc_id) { return ISteamApps_BIsDlcInstalled(ARGS(dlc_id)); }
|
||||
[&](AppId_t dlc_id) {
|
||||
return ISteamApps_BIsDlcInstalled(ARGS(dlc_id));
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
|
||||
@@ -4,62 +4,101 @@
|
||||
#include "steam_interface/steam_client.hpp"
|
||||
#include "virtuals/steam_api_virtuals.hpp"
|
||||
|
||||
VIRTUAL(void*)
|
||||
ISteamClient_GetISteamApps(PARAMS(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* version)
|
||||
VIRTUAL(void*) ISteamClient_GetISteamApps
|
||||
|
||||
(
|
||||
PARAMS(
|
||||
HSteamUser hSteamUser,
|
||||
HSteamPipe hSteamPipe,
|
||||
const char* version
|
||||
)
|
||||
) {
|
||||
try {
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamApps)
|
||||
return ISteamClient_GetISteamApps_o(ARGS(hSteamUser, hSteamPipe, version));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
VIRTUAL(void*)
|
||||
ISteamClient_GetISteamUser(PARAMS(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* version)
|
||||
VIRTUAL(void*) ISteamClient_GetISteamUser
|
||||
|
||||
(
|
||||
PARAMS(
|
||||
HSteamUser hSteamUser,
|
||||
HSteamPipe hSteamPipe,
|
||||
const char* version
|
||||
)
|
||||
) {
|
||||
try {
|
||||
return steam_client::GetGenericInterface(__func__, version, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
version,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamUser)
|
||||
|
||||
return ISteamClient_GetISteamUser_o(ARGS(hSteamUser, hSteamPipe, version));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
VIRTUAL(void*)
|
||||
ISteamClient_GetISteamGenericInterface(
|
||||
PARAMS(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion)
|
||||
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface
|
||||
|
||||
(
|
||||
PARAMS(
|
||||
HSteamUser hSteamUser,
|
||||
HSteamPipe hSteamPipe,
|
||||
const char* pchVersion
|
||||
)
|
||||
) {
|
||||
try {
|
||||
return steam_client::GetGenericInterface(__func__, pchVersion, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
pchVersion,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamGenericInterface)
|
||||
|
||||
return ISteamClient_GetISteamGenericInterface_o(ARGS(hSteamUser, hSteamPipe, pchVersion)
|
||||
return ISteamClient_GetISteamGenericInterface_o(
|
||||
ARGS(hSteamUser, hSteamPipe, pchVersion)
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
VIRTUAL(void*)
|
||||
ISteamClient_GetISteamInventory(
|
||||
PARAMS(HSteamUser hSteamUser, HSteamPipe hSteamPipe, const char* pchVersion)
|
||||
VIRTUAL(void*) ISteamClient_GetISteamInventory
|
||||
|
||||
(
|
||||
PARAMS(
|
||||
HSteamUser hSteamUser,
|
||||
HSteamPipe hSteamPipe,
|
||||
const char* pchVersion
|
||||
)
|
||||
) {
|
||||
try {
|
||||
return steam_client::GetGenericInterface(__func__, pchVersion, [&] {
|
||||
return steam_client::GetGenericInterface(
|
||||
__func__,
|
||||
pchVersion,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamInventory)
|
||||
|
||||
return ISteamClient_GetISteamInventory_o(ARGS(hSteamUser, hSteamPipe, pchVersion));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return nullptr;
|
||||
|
||||
@@ -4,19 +4,24 @@
|
||||
#include "virtuals/steam_api_virtuals.hpp"
|
||||
|
||||
VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(SteamInventoryResult_t resultHandle)) {
|
||||
return steam_inventory::GetResultStatus(__func__, resultHandle, [&] {
|
||||
return steam_inventory::GetResultStatus(
|
||||
__func__,
|
||||
resultHandle,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_GetResultStatus)
|
||||
|
||||
return ISteamInventory_GetResultStatus_o(ARGS(resultHandle));
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetResultItems(PARAMS(
|
||||
VIRTUAL(bool) ISteamInventory_GetResultItems(
|
||||
PARAMS(
|
||||
SteamInventoryResult_t resultHandle,
|
||||
SteamItemDetails_t* pOutItemsArray,
|
||||
uint32_t* punOutItemsArraySize
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
return steam_inventory::GetResultItems(
|
||||
__func__,
|
||||
resultHandle,
|
||||
@@ -32,20 +37,22 @@ ISteamInventory_GetResultItems(PARAMS(
|
||||
[&](SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize) {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_GetItemDefinitionIDs)
|
||||
|
||||
return ISteamInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, punItemDefIDsArraySize)
|
||||
return ISteamInventory_GetItemDefinitionIDs_o(
|
||||
ARGS(pItemDefIDs, punItemDefIDsArraySize)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetResultItemProperty(PARAMS(
|
||||
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
||||
PARAMS(
|
||||
SteamInventoryResult_t resultHandle,
|
||||
uint32_t unItemIndex,
|
||||
const char* pchPropertyName,
|
||||
char* pchValueBuffer,
|
||||
uint32_t* punValueBufferSizeOut
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
return steam_inventory::GetResultItemProperty(
|
||||
__func__,
|
||||
resultHandle,
|
||||
@@ -56,38 +63,55 @@ ISteamInventory_GetResultItemProperty(PARAMS(
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_GetResultItemProperty)
|
||||
|
||||
return ISteamInventory_GetResultItemProperty_o(ARGS(
|
||||
resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
|
||||
));
|
||||
return ISteamInventory_GetResultItemProperty_o(
|
||||
ARGS(
|
||||
resultHandle,
|
||||
unItemIndex,
|
||||
pchPropertyName,
|
||||
pchValueBuffer,
|
||||
punValueBufferSizeOut
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_CheckResultSteamID(
|
||||
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(
|
||||
PARAMS(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected)
|
||||
) {
|
||||
return steam_inventory::CheckResultSteamID(__func__, resultHandle, steamIDExpected, [&] {
|
||||
return steam_inventory::CheckResultSteamID(
|
||||
__func__,
|
||||
resultHandle,
|
||||
steamIDExpected,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_CheckResultSteamID)
|
||||
|
||||
return ISteamInventory_CheckResultSteamID_o(ARGS(resultHandle, steamIDExpected));
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t* pResultHandle)) {
|
||||
return steam_inventory::GetAllItems(__func__, pResultHandle, [&] {
|
||||
VIRTUAL(bool) ISteamInventory_GetAllItems(
|
||||
PARAMS(SteamInventoryResult_t*pResultHandle)
|
||||
) {
|
||||
return steam_inventory::GetAllItems(
|
||||
__func__,
|
||||
pResultHandle,
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_GetAllItems)
|
||||
|
||||
return ISteamInventory_GetAllItems_o(ARGS(pResultHandle));
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetItemsByID(PARAMS(
|
||||
VIRTUAL(bool) ISteamInventory_GetItemsByID(
|
||||
PARAMS(
|
||||
SteamInventoryResult_t* pResultHandle,
|
||||
const SteamItemInstanceID_t* pInstanceIDs,
|
||||
uint32_t unCountInstanceIDs
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
return steam_inventory::GetItemsByID(
|
||||
__func__,
|
||||
pResultHandle,
|
||||
@@ -103,8 +127,7 @@ ISteamInventory_GetItemsByID(PARAMS(
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_SerializeResult(
|
||||
VIRTUAL(bool) ISteamInventory_SerializeResult(
|
||||
PARAMS(SteamInventoryResult_t resultHandle, void* pOutBuffer, uint32_t* punOutBufferSize)
|
||||
) {
|
||||
return steam_inventory::SerializeResult(
|
||||
@@ -122,9 +145,11 @@ ISteamInventory_SerializeResult(
|
||||
);
|
||||
}
|
||||
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetItemDefinitionIDs(
|
||||
PARAMS(SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize)
|
||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(
|
||||
PARAMS(
|
||||
SteamItemDef_t*pItemDefIDs,
|
||||
uint32_t* punItemDefIDsArraySize
|
||||
)
|
||||
) {
|
||||
return steam_inventory::GetItemDefinitionIDs(
|
||||
__func__,
|
||||
@@ -133,7 +158,8 @@ ISteamInventory_GetItemDefinitionIDs(
|
||||
[&] {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamInventory_GetItemDefinitionIDs)
|
||||
|
||||
return ISteamInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, punItemDefIDsArraySize)
|
||||
return ISteamInventory_GetItemDefinitionIDs_o(
|
||||
ARGS(pItemDefIDs, punItemDefIDsArraySize)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -5,15 +5,21 @@
|
||||
#include "steam_interface/steam_user.hpp"
|
||||
#include "virtuals/steam_api_virtuals.hpp"
|
||||
|
||||
VIRTUAL(EUserHasLicenseForAppResult)
|
||||
ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID steamID, AppId_t dlc_id)) {
|
||||
VIRTUAL (EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
|
||||
PARAMS(CSteamID steamID, AppId_t dlc_id)
|
||||
) {
|
||||
try {
|
||||
static const auto app_id = steam_interface::get_app_id();
|
||||
return steam_user::UserHasLicenseForApp(__func__, app_id, dlc_id, [&]() {
|
||||
return steam_user::UserHasLicenseForApp(
|
||||
__func__,
|
||||
app_id,
|
||||
dlc_id,
|
||||
[&]() {
|
||||
GET_ORIGINAL_HOOKED_FUNCTION(ISteamUser_UserHasLicenseForApp)
|
||||
|
||||
return ISteamUser_UserHasLicenseForApp_o(ARGS(steamID, dlc_id));
|
||||
});
|
||||
}
|
||||
);
|
||||
} catch(const std::exception& e) {
|
||||
LOG_ERROR("{} -> Error: {}", __func__, e.what());
|
||||
return k_EUserHasLicenseResultDoesNotHaveLicense;
|
||||
|
||||
@@ -3,32 +3,62 @@
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
// ISteamApps
|
||||
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t));
|
||||
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t));
|
||||
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS());
|
||||
VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(PARAMS(int, AppId_t*, bool*, char*, int));
|
||||
VIRTUAL(bool) ISteamApps_BIsSubscribedApp
|
||||
(PARAMS
|
||||
(AppId_t)
|
||||
);
|
||||
VIRTUAL(bool) ISteamApps_BIsDlcInstalled
|
||||
(PARAMS
|
||||
(AppId_t)
|
||||
);
|
||||
VIRTUAL(int) ISteamApps_GetDLCCount
|
||||
(PARAMS());
|
||||
VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex
|
||||
(PARAMS(int, AppId_t*, bool*, char*, int));
|
||||
|
||||
// ISteamClient
|
||||
VIRTUAL(void*) ISteamClient_GetISteamApps(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamUser(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamInventory(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamApps
|
||||
(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamUser
|
||||
(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface
|
||||
(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamInventory
|
||||
(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
|
||||
// ISteamInventory
|
||||
VIRTUAL (EResult) ISteamInventory_GetResultStatus(PARAMS(SteamInventoryResult_t));
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetResultItems(PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*));
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetResultItemProperty(
|
||||
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*)
|
||||
VIRTUAL(bool) ISteamInventory_GetResultItems
|
||||
(
|
||||
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*) // @formatter:off
|
||||
); // @formatter:on
|
||||
|
||||
VIRTUAL(bool) ISteamInventory_GetResultItemProperty
|
||||
(
|
||||
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*) // @formatter:off
|
||||
); // @formatter:on
|
||||
VIRTUAL(bool) ISteamInventory_GetAllItems
|
||||
(PARAMS(SteamInventoryResult_t*));
|
||||
VIRTUAL(bool) ISteamInventory_GetItemsByID
|
||||
(
|
||||
PARAMS(
|
||||
SteamInventoryResult_t*,
|
||||
const SteamItemInstanceID_t*,
|
||||
uint32_t
|
||||
)
|
||||
);
|
||||
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
|
||||
VIRTUAL(bool)
|
||||
ISteamInventory_GetItemsByID(PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t)
|
||||
VIRTUAL(bool) ISteamInventory_SerializeResult
|
||||
(PARAMS(SteamInventoryResult_t, void*, uint32_t*));
|
||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs
|
||||
(PARAMS(SteamItemDef_t*, uint32_t*));
|
||||
VIRTUAL(bool) ISteamInventory_CheckResultSteamID
|
||||
(
|
||||
PARAMS
|
||||
(SteamInventoryResult_t
|
||||
,
|
||||
CSteamID
|
||||
)
|
||||
);
|
||||
VIRTUAL(bool) ISteamInventory_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t*));
|
||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*));
|
||||
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
|
||||
|
||||
// ISteamUser
|
||||
VIRTUAL (EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID, AppId_t));
|
||||
@@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
project(smoke-api-tools LANGUAGES CXX)
|
||||
|
||||
### C++ preprocessor library
|
||||
|
||||
CPMAddPackage("gh:danmar/simplecpp#1.5.2")
|
||||
target_include_directories(simplecpp_obj INTERFACE ${simplecpp_SOURCE_DIR})
|
||||
|
||||
### Thread pool library
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -34,5 +29,4 @@ add_executable(steamworks_parser steamworks_parser.cpp)
|
||||
target_link_libraries(steamworks_parser PRIVATE
|
||||
KoalaBox
|
||||
BS_thread_pool
|
||||
simplecpp_obj
|
||||
)
|
||||
|
||||
@@ -41,7 +41,9 @@ namespace {
|
||||
}
|
||||
|
||||
void unzip_sdk(const fs::path& zip_file_path, const fs::path& unzip_dir) {
|
||||
kb::zip::extract_files(zip_file_path, [&](const std::string& name, const bool) {
|
||||
kb::zip::extract_files(
|
||||
zip_file_path,
|
||||
[&](const std::string& name, const bool) {
|
||||
if(name.starts_with("sdk/public/steam/") && name.ends_with(".h")) {
|
||||
return unzip_dir / "headers/steam" / fs::path(name).filename();
|
||||
}
|
||||
@@ -52,7 +54,8 @@ namespace {
|
||||
}
|
||||
|
||||
return fs::path();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void download_sdk(const fs::path& steamworks_dir, const std::string_view& version) {
|
||||
@@ -74,7 +77,6 @@ namespace {
|
||||
|
||||
fs::remove(zip_file_path);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
#include <BS_thread_pool.hpp>
|
||||
#include <cpp-tree-sitter.h>
|
||||
#undef ERROR // Workaround for the ERROR enum defined in simplecpp
|
||||
#include <simplecpp.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <koalabox/io.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
@@ -35,7 +35,9 @@ namespace {
|
||||
nlohmann::ordered_json current_lookup = {};
|
||||
std::string interface_version;
|
||||
|
||||
kb::parser::walk(root, [&](const auto& current_node) {
|
||||
kb::parser::walk(
|
||||
root,
|
||||
[&](const auto& current_node) {
|
||||
const auto current_type = current_node.getType();
|
||||
const auto current_value = current_node.getSourceRange(source);
|
||||
const auto current_sexpr = current_node.getSExpr();
|
||||
@@ -44,7 +46,9 @@ namespace {
|
||||
std::string interface_name;
|
||||
[[maybe_unused]] int vt_idx = 0;
|
||||
|
||||
kb::parser::walk(current_node, [&](const ts::Node& class_node) {
|
||||
kb::parser::walk(
|
||||
current_node,
|
||||
[&](const ts::Node& class_node) {
|
||||
const auto type = class_node.getType();
|
||||
const auto value = class_node.getSourceRange(source);
|
||||
|
||||
@@ -57,9 +61,13 @@ namespace {
|
||||
|
||||
if(type == "field_declaration" && value.starts_with("virtual ")) {
|
||||
if(value.starts_with("virtual ")) {
|
||||
kb::parser::walk(class_node, [&](const ts::Node& decl_node) {
|
||||
kb::parser::walk(
|
||||
class_node,
|
||||
[&](const ts::Node& decl_node) {
|
||||
if(decl_node.getType() == "field_identifier") {
|
||||
const auto function_name = decl_node.getSourceRange(source);
|
||||
const auto function_name = decl_node.getSourceRange(
|
||||
source
|
||||
);
|
||||
|
||||
// Note: This doesn't take into account overloaded functions.
|
||||
// However, so far this project hasn't had any need to hook such
|
||||
@@ -69,16 +77,20 @@ namespace {
|
||||
return kb::parser::visit_result::Stop;
|
||||
}
|
||||
return kb::parser::visit_result::Continue;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return kb::parser::visit_result::SkipChildren;
|
||||
}
|
||||
|
||||
return kb::parser::visit_result::Continue;
|
||||
});
|
||||
}
|
||||
);
|
||||
} else if(current_type == "preproc_def") {
|
||||
kb::parser::walk(current_node, [&](const ts::Node& preproc_node) {
|
||||
kb::parser::walk(
|
||||
current_node,
|
||||
[&](const ts::Node& preproc_node) {
|
||||
if(preproc_node.getType() == "identifier") {
|
||||
const auto identifier = preproc_node.getSourceRange(source);
|
||||
|
||||
@@ -97,70 +109,27 @@ namespace {
|
||||
}
|
||||
|
||||
return kb::parser::visit_result::Continue;
|
||||
});
|
||||
}
|
||||
);
|
||||
} else if(current_type == "translation_unit" || current_type == "preproc_ifdef") {
|
||||
return kb::parser::visit_result::Continue;
|
||||
}
|
||||
|
||||
return kb::parser::visit_result::SkipChildren;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Save the findings
|
||||
static std::mutex mutex;
|
||||
if (not interface_version.empty()) {
|
||||
const std::lock_guard lock(mutex);
|
||||
static std::mutex section;
|
||||
if(not
|
||||
interface_version.empty()
|
||||
)
|
||||
{
|
||||
const std::lock_guard lock(section);
|
||||
lookup[interface_version] = current_lookup;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns out that preprocessing headers using a proper C++ preprocessor
|
||||
* significantly complicates AST parsing down the line.
|
||||
* To make matters worse, it also removes macro definitions with interface version string.
|
||||
* Hence, this function should not be used in practice.
|
||||
* It remains here for reference purposes only.
|
||||
*/
|
||||
[[maybe_unused]] std::string preprocess_header(const fs::path& header_path) {
|
||||
auto files = std::vector<std::string>();
|
||||
|
||||
static simplecpp::DUI dui{};
|
||||
dui.removeComments = true;
|
||||
// For stdlib headers
|
||||
dui.includePaths.emplace_back("dummy/");
|
||||
// For headers includes via "steam/*" path
|
||||
dui.includePaths.emplace_back(header_path.parent_path().parent_path().string());
|
||||
dui.defines.emplace_back("VALVE_CALLBACK_PACK_LARGE");
|
||||
|
||||
simplecpp::OutputList output_list;
|
||||
simplecpp::TokenList raw_token_list(header_path.string(), files, &output_list);
|
||||
raw_token_list.removeComments();
|
||||
|
||||
simplecpp::FileDataCache cache;
|
||||
simplecpp::TokenList output_token_list(files);
|
||||
simplecpp::preprocess(output_token_list, raw_token_list, files, cache, dui, &output_list);
|
||||
simplecpp::cleanup(cache);
|
||||
|
||||
for (const simplecpp::Output& output : output_list) {
|
||||
if (output.type == simplecpp::Output::MISSING_HEADER) {
|
||||
LOG_WARN(
|
||||
"Place missing empty header at: " + fs::absolute(fs::path("dummy")).string()
|
||||
);
|
||||
}
|
||||
|
||||
const auto msg = std::format(
|
||||
"msg = {}, line={}, col={}, type = {}",
|
||||
output.msg,
|
||||
output.location.line,
|
||||
output.location.col,
|
||||
static_cast<int>(output.type)
|
||||
);
|
||||
|
||||
throw std::runtime_error(msg);
|
||||
}
|
||||
|
||||
return output_token_list.stringify();
|
||||
}
|
||||
|
||||
/**
|
||||
* Certain Steam macros break C++ AST parser, if left unprocessed.
|
||||
* This function does that in a very naive manner. Stupid, but works.
|
||||
@@ -175,8 +144,11 @@ namespace {
|
||||
return processed_contents;
|
||||
}
|
||||
|
||||
void
|
||||
parse_sdk(const fs::path& sdk_path, nlohmann::ordered_json& lookup, BS::thread_pool<>& pool) {
|
||||
void parse_sdk(
|
||||
const fs::path& sdk_path,
|
||||
nlohmann::ordered_json& lookup,
|
||||
BS::thread_pool<>& pool
|
||||
) {
|
||||
const auto headers_dir = sdk_path / "headers\\steam";
|
||||
|
||||
if(not fs::exists(headers_dir)) {
|
||||
@@ -189,7 +161,8 @@ namespace {
|
||||
// Go over each file in headers directory
|
||||
for(const auto& entry : fs::directory_iterator(headers_dir)) {
|
||||
if(const auto& header_path = entry.path(); header_path.extension() == ".h") {
|
||||
const auto task = pool.submit_task([&, header_path] {
|
||||
const auto task = pool.submit_task(
|
||||
[&, header_path] {
|
||||
try {
|
||||
LOG_DEBUG("Parsing header: {}", header_path.string());
|
||||
|
||||
@@ -199,13 +172,15 @@ namespace {
|
||||
LOG_CRITICAL(e.what());
|
||||
exit(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void generate_lookup_json(
|
||||
const fs::path& steamworks_dir, //
|
||||
const fs::path& steamworks_dir,
|
||||
//
|
||||
const std::set<std::string>& sdk_filter
|
||||
) {
|
||||
nlohmann::ordered_json lookup;
|
||||
@@ -218,12 +193,21 @@ namespace {
|
||||
|
||||
// Go over each steamworks sdk version
|
||||
for(const auto& entry : fs::directory_iterator(steamworks_dir)) {
|
||||
if (not entry.is_directory()) {
|
||||
if(not
|
||||
entry.is_directory()
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (not sdk_filter.empty() and
|
||||
not sdk_filter.contains(entry.path().filename().string())) {
|
||||
if(not
|
||||
sdk_filter.empty()
|
||||
and
|
||||
not sdk_filter
|
||||
.
|
||||
contains(entry.path().filename().string())
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user