From cb07ebd437da2a48904cabdf50fa361c715f85c9 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 22 Mar 2024 10:17:29 +0100 Subject: [PATCH] Add warning when using legacy api function without calling WUPSBackend_InitLibrary --- source/api.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/api.cpp b/source/api.cpp index 46ec767..a1b2ce0 100644 --- a/source/api.cpp +++ b/source/api.cpp @@ -178,38 +178,53 @@ PluginBackendApiErrorType WUPSBackend_GetSectionMemoryAddresses(plugin_container return reinterpret_cast(sWUPSGetSectionMemoryAddresses)(handle, textAddress, dataAddress); } +#define PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED() \ + do { \ + if (sWUPSAPIVersion == WUPS_BACKEND_MODULE_API_VERSION_ERROR) { DEBUG_FUNCTION_LINE_WARN("libwupsbackend is not initialized, please make sure to call WUPSBackend_InitLibrary"); } \ + } while (0) + + PluginBackendApiErrorType WUPSBackend_LoadAndLinkByDataHandle(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSLoadAndLinkByDataHandle(plugin_data_handle_list, plugin_data_handle_list_size); } PluginBackendApiErrorType WUPSBackend_DeletePluginData(const plugin_data_handle *plugin_data_handle_list, uint32_t plugin_data_handle_list_size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSDeletePluginData(plugin_data_handle_list, plugin_data_handle_list_size); } PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByPath(plugin_data_handle *output, const char *path) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSLoadPluginAsDataByPath(output, path); } PluginBackendApiErrorType WUPSBackend_LoadPluginAsDataByBuffer(plugin_data_handle *output, char *buffer, size_t size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSLoadPluginAsDataByBuffer(output, buffer, size); } PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByPath(plugin_information *output, const char *path) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSGetPluginMetaInformationByPath(output, path); } PluginBackendApiErrorType WUPSBackend_GetPluginMetaInformationByBuffer(plugin_information *output, char *buffer, size_t size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSGetPluginMetaInformationByBuffer(output, buffer, size); } PluginBackendApiErrorType WUPSBackend_GetPluginDataForContainerHandles(const plugin_container_handle *plugin_container_handle_list, const plugin_data_handle *plugin_data_list, uint32_t buffer_size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSGetPluginDataForContainerHandles(plugin_container_handle_list, plugin_data_list, buffer_size); } PluginBackendApiErrorType WUPSBackend_GetMetaInformation(const plugin_container_handle *plugin_container_handle_list, plugin_information *plugin_information_list, uint32_t buffer_size) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSGetMetaInformation(plugin_container_handle_list, plugin_information_list, buffer_size); } PluginBackendApiErrorType WUPSBackend_GetLoadedPlugins(const plugin_container_handle *io_handles, uint32_t buffer_size, uint32_t *outSize, uint32_t *plugin_information_version) { + PRINT_WARNING_FOR_LEGACY_FUNCTION_WHEN_NOT_INITIALIZED(); return WUPSGetLoadedPlugins(io_handles, buffer_size, outSize, plugin_information_version); }