[WIP] Koalageddon mode

master
acidicoala 2 years ago
parent 53d28ee65d
commit ec10445710
No known key found for this signature in database
GPG Key ID: D24C6065B49C645B

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.22)
project(SmokeAPI VERSION 1.0.2)
project(SmokeAPI VERSION 1.0.3)
include(KoalaBox/cmake/KoalaBox.cmake)
@ -66,7 +66,6 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 4)
src/steamclient_virtuals/client_apps.cpp
src/steamclient_virtuals/client_inventory.cpp
src/steamclient_virtuals/client_user.cpp
src/steamclient_virtuals/client_utils.cpp
)
endif ()

@ -30,24 +30,20 @@ DLL_EXPORT(void) Log_Interface(const char* interface_name, const char* function_
#define HOOK(FUNC, ORDINAL) hook_function(FUNC, #FUNC, ORDINAL);
if (compound_name == "IClientAppManager::IsAppDlcInstalled") {
if (util::strings_are_equal(interface_name, "IClientAppManager")) {
HOOK(IClientAppManager_IsAppDlcInstalled, 8)
} else if (compound_name == "IClientApps::GetDLCCount") {
} else if (util::strings_are_equal(interface_name, "IClientApps")) {
HOOK(IClientApps_GetDLCCount, 8)
} else if (compound_name == "IClientApps::BGetDLCDataByIndex") {
HOOK(IClientApps_BGetDLCDataByIndex, 9)
} else if (compound_name == "IClientUser::IsSubscribedApp") {
HOOK(IClientUser_IsSubscribedApp, 0xB5)
} else if (util::strings_are_equal(interface_name, "IClientInventory")) {
if (util::strings_are_equal(function_name, "GetResultItems")) {
auto* function_address = interface_address[0x2]; // TODO: Un-hardcode
logger->debug("{} -> {}::{} @ {}", __func__, interface_name, function_name, function_address);
}
} else if (util::strings_are_equal(interface_name, "IClientUtils")) {
if (util::strings_are_equal(function_name, "GetAppID")) {
auto* function_address = interface_address[0x12]; // TODO: Un-hardcode
logger->debug("{} -> {}::{} @ {}", __func__, interface_name, function_name, function_address);
}
HOOK(IClientInventory_GetResultStatus, 0)
HOOK(IClientInventory_GetResultItems, 2)
HOOK(IClientInventory_GetResultItemProperty, 3)
HOOK(IClientInventory_CheckResultSteamID, 5)
HOOK(IClientInventory_GetAllItems, 8)
HOOK(IClientInventory_GetItemsByID, 9)
HOOK(IClientInventory_SerializeResult, 6)
HOOK(IClientInventory_GetItemDefinitionIDs, 19)
}
GET_ORIGINAL_FUNCTION(Log_Interface)

@ -107,7 +107,6 @@ namespace smoke_api {
DETOUR(SteamAPI_ISteamInventory_GetAllItems)
DETOUR(SteamAPI_ISteamInventory_GetItemsByID)
DETOUR(SteamAPI_ISteamInventory_GetItemDefinitionIDs)
DETOUR(SteamAPI_ISteamInventory_GetItemDefinitionProperty)
});
}
} else {

@ -107,7 +107,7 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut
uint32_t* punValueBufferSizeOut
) {
return steam_inventory::GetResultItemProperty(
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
@ -180,21 +180,3 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(self, pItemDefIDs, punItemDefIDsArraySize);
});
}
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionProperty(
ISteamInventory* self,
SteamItemDef_t iDefinition,
const char* pchPropertyName,
char* pchValueBuffer,
uint32_t* punValueBufferSizeOut
) {
return steam_inventory::GetItemDefinitionProperty(
__func__, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamInventory_GetItemDefinitionProperty)
return SteamAPI_ISteamInventory_GetItemDefinitionProperty_o(
self, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
);
}
);
}

@ -40,7 +40,7 @@ VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut
uint32_t * punValueBufferSizeOut
)
) {
return steam_inventory::GetResultItemProperty(
@ -115,27 +115,3 @@ VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(
return ISteamInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, punItemDefIDsArraySize));
});
}
VIRTUAL(bool) ISteamInventory_GetItemDefinitionProperty(
PARAMS(
SteamItemDef_t iDefinition,
const char* pchPropertyName,
char* pchValueBuffer,
uint32_t * punValueBufferSizeOut
)
) {
return steam_inventory::GetItemDefinitionProperty(
__func__, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamInventory_GetItemDefinitionProperty)
return ISteamInventory_GetItemDefinitionProperty_o(
ARGS(
iDefinition,
pchPropertyName,
pchValueBuffer,
punValueBufferSizeOut
)
);
}
);
}

@ -75,7 +75,6 @@ namespace steam_functions {
{"ISteamInventory_GetItemsByID", {{1, 6}, {2, 7}}},
{"ISteamInventory_SerializeResult", {{1, 7}, {2, 8}}},
{"ISteamInventory_GetItemDefinitionIDs", {{1, 20}, {2, 21}}},
{"ISteamInventory_GetItemDefinitionProperty", {{1, 21}, {2, 22}}},
};
int extract_version_number(
@ -189,7 +188,6 @@ namespace steam_functions {
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemsByID)
HOOK_STEAM_INVENTORY(ISteamInventory_SerializeResult)
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemDefinitionIDs)
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemDefinitionProperty)
if (version_number >= 2) {
HOOK_STEAM_INVENTORY(ISteamInventory_GetResultItemProperty)

@ -74,13 +74,12 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSte
VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(uint32_t));
VIRTUAL(bool) ISteamInventory_GetResultItems(PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*));
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, const uint32_t*)
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, 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_GetItemDefinitionProperty(PARAMS(SteamItemDef_t, const char*, char*, uint32_t*));
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
// API
@ -105,7 +104,7 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItems(
ISteamInventory*, SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*
);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
ISteamInventory*, SteamInventoryResult_t, uint32_t, const char*, char*, const uint32_t*
ISteamInventory*, SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*
);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID(ISteamInventory*, SteamInventoryResult_t, CSteamID);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems(ISteamInventory*, SteamInventoryResult_t*);
@ -114,11 +113,8 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemsByID(
);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_SerializeResult(ISteamInventory*, SteamInventoryResult_t, void*, uint32_t*);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(ISteamInventory*, SteamItemDef_t*, uint32_t*);
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionProperty(
ISteamInventory*, SteamItemDef_t, const char*, char*, uint32_t*
);
// koalageddon
// Koalageddon mode
DLL_EXPORT(HCoroutine) Coroutine_Create(void* callback_address, struct CoroutineData* data);
DLL_EXPORT(void) Log_Interface(const char* interface_name, const char* function_name);
@ -133,6 +129,21 @@ VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(PARAMS(AppId_t, AppId_t));
// IClientUser
VIRTUAL(bool) IClientUser_IsSubscribedApp(PARAMS(AppId_t));
// IClientInventory
VIRTUAL(EResult) IClientInventory_GetResultStatus(PARAMS(SteamInventoryResult_t));
VIRTUAL(bool) IClientInventory_GetResultItems(
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t, uint32_t *)
);
//////
VIRTUAL(bool) IClientInventory_GetResultItemProperty(
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t, uint32_t*)
);
VIRTUAL(bool) IClientInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
VIRTUAL(bool) IClientInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
VIRTUAL(bool) IClientInventory_GetItemsByID(PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t));
VIRTUAL(bool) IClientInventory_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t, uint32_t *));
VIRTUAL(bool) IClientInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t, uint32_t *));
namespace steam_functions {
using namespace koalabox;

@ -157,7 +157,7 @@ namespace steam_apps {
logger->debug("{} -> App ID: {}", function_name, app_id);
}
// Compute count only once
// Compute count only once // FIXME: This doesn't work in Koalageddon mode
static int total_count = [&]() {
original_dlc_count = original_function();
logger->debug("{} -> Original DLC count: {}", function_name, original_dlc_count);

@ -64,7 +64,7 @@ namespace steam_inventory {
uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut,
uint32_t* punValueBufferSizeOut,
const std::function<bool()>& original_function
);
@ -97,14 +97,6 @@ namespace steam_inventory {
const std::function<bool()>& original_function
);
bool GetItemDefinitionProperty(
const String& function_name,
SteamItemDef_t iDefinition,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut,
const std::function<bool()>& original_function
);
bool CheckResultSteamID(
const String& function_name,

@ -119,7 +119,7 @@ namespace steam_inventory {
uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut,
uint32_t* punValueBufferSizeOut,
const std::function<bool()>& original_function
) {
const auto common_info = fmt::format(
@ -210,37 +210,13 @@ namespace steam_inventory {
if (pItemDefIDs) { // Definitions were copied
for (int i = 0; i < *punItemDefIDsArraySize; i++) {
const auto& def = pItemDefIDs[i];
logger->debug(" Index: {}, ID: {}", i, def);
logger->debug(" Index: {}, ID: {}", i, def);
}
}
return success;
}
bool GetItemDefinitionProperty(
const String& function_name,
SteamItemDef_t iDefinition,
const char* pchPropertyName,
char* pchValueBuffer,
const uint32_t* punValueBufferSizeOut,
const std::function<bool()>& original_function
) {
const auto common_info = fmt::format(
"{} -> Definition ID: {}, Name: '{}'", function_name, iDefinition, pchPropertyName
);
const auto success = original_function();
if (!success) {
logger->warn("{}, Result is false", common_info);
return false;
}
logger->debug("{}, Buffer: '{}'", common_info, String(pchValueBuffer, *punValueBufferSizeOut - 1));
return success;
}
bool CheckResultSteamID(
const String& function_name,
SteamInventoryResult_t resultHandle,

@ -0,0 +1,135 @@
#include <smoke_api/smoke_api.hpp>
#include <steam_impl/steam_impl.hpp>
using namespace smoke_api;
VIRTUAL(EResult) IClientInventory_GetResultStatus(PARAMS(SteamInventoryResult_t resultHandle)) {
return steam_inventory::GetResultStatus(__func__, resultHandle, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultStatus)
return IClientInventory_GetResultStatus_o(ARGS(resultHandle));
});
}
VIRTUAL(bool) IClientInventory_GetResultItems(
PARAMS(
SteamInventoryResult_t resultHandle,
SteamItemDetails_t* pOutItemsArray, // 1st pass: null, 2nd pass: ptr to out array
uint32_t item_count, // 1st pass: 0, 2nd pass: array size
uint32_t * punOutItemsArraySize // 1st pass: ptr to out array size, 2nd pass: ptr to 0
)
) {
return steam_inventory::GetResultItems(
__func__, resultHandle, pOutItemsArray, punOutItemsArraySize,
[&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultItems)
*punOutItemsArraySize = item_count;
return IClientInventory_GetResultItems_o(
ARGS(resultHandle, pOutItemsArray, item_count, punOutItemsArraySize)
);
},
[&](SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize) {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemDefinitionIDs)
return IClientInventory_GetItemDefinitionIDs_o(
ARGS(pItemDefIDs, *punItemDefIDsArraySize, punItemDefIDsArraySize)
);
}
);
}
// TODO: Verify this function [ ] signature, in-game [ ]
VIRTUAL(bool) IClientInventory_GetResultItemProperty(
PARAMS(
SteamInventoryResult_t resultHandle,
uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
uint32_t item_count,
uint32_t * punValueBufferSizeOut
)
) {
return steam_inventory::GetResultItemProperty(
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultItemProperty)
*punValueBufferSizeOut = item_count;
return IClientInventory_GetResultItemProperty_o(
ARGS(resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, item_count, punValueBufferSizeOut)
);
}
);
}
// TODO: Verify this function [x] signature, in-game [ ]
VIRTUAL(bool) IClientInventory_CheckResultSteamID(
PARAMS(
SteamInventoryResult_t resultHandle,
CSteamID steamIDExpected
)
) {
return steam_inventory::CheckResultSteamID(__func__, resultHandle, steamIDExpected, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_CheckResultSteamID)
return IClientInventory_CheckResultSteamID_o(ARGS(resultHandle, steamIDExpected));
});
}
// TODO: Verify this function [x] signature, in-game [ ]
VIRTUAL(bool) IClientInventory_GetAllItems(PARAMS(SteamInventoryResult_t* pResultHandle)) {
return steam_inventory::GetAllItems(__func__, pResultHandle, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetAllItems)
return IClientInventory_GetAllItems_o(ARGS(pResultHandle));
});
}
// TODO: Verify this function [x] signature, in-game [ ]
VIRTUAL(bool) IClientInventory_GetItemsByID(
PARAMS(
SteamInventoryResult_t* pResultHandle,
const SteamItemInstanceID_t* pInstanceIDs,
uint32_t unCountInstanceIDs
)
) {
return steam_inventory::GetItemsByID(__func__, pResultHandle, pInstanceIDs, unCountInstanceIDs, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemsByID)
return IClientInventory_GetItemsByID_o(ARGS(pResultHandle, pInstanceIDs, unCountInstanceIDs));
});
}
// TODO: Verify this function [x] signature, in-game [ ]
VIRTUAL(bool) IClientInventory_SerializeResult(
PARAMS(
SteamInventoryResult_t resultHandle,
void* pOutBuffer,
uint32_t buffer_size,
uint32_t * punOutBufferSize
)
) {
return steam_inventory::SerializeResult(__func__, resultHandle, pOutBuffer, punOutBufferSize, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_SerializeResult)
*punOutBufferSize = buffer_size;
return IClientInventory_SerializeResult_o(ARGS(resultHandle, pOutBuffer, buffer_size, punOutBufferSize));
});
}
VIRTUAL(bool) IClientInventory_GetItemDefinitionIDs(
PARAMS(
SteamItemDef_t* pItemDefIDs, // 1st pass: null, 2nd pass: ptr to out array
uint32_t item_count, // 1st pass: 0, 2nd pass: array size
uint32_t * p_array_size // 1st pass: ptr to out array size, 2nd pass: ptr to 0
)
) {
return steam_inventory::GetItemDefinitionIDs(__func__, pItemDefIDs, p_array_size, [&]() {
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemDefinitionIDs)
*p_array_size = item_count;
return IClientInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, item_count, p_array_size));
});
}
Loading…
Cancel
Save