diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 104763a4c6f..d73a8220c31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -180,6 +180,41 @@ jobs: name: "build${{ steps.vars.outputs.nwn_build }}.${{ steps.vars.outputs.nwn_build_revision }}.${{ steps.vars.outputs.nwn_build_postfix }}-HEAD" artifacts: "NWNX-EE.zip,NWScript.zip" + build-win: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v3 + - run: git config --system --add safe.directory /__w/unified/unified + + - name: Create Build Environment + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + shell: cmake -P {0} + run: | + set(ENV{PATH} "$ENV{GITHUB_WORKSPACE}:$ENV{PATH}") + execute_process( + COMMAND cmake + -S . + -B build + -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + execute_process( + COMMAND cmake --build build -j 4 + RESULT_VARIABLE result + ) + if (NOT result EQUAL 0) + message(FATAL_ERROR "Build failed") + endif() + docker: runs-on: ubuntu-20.04 if: github.event_name == 'push' diff --git a/CMakeLists.txt b/CMakeLists.txt index 801ff791fca..c0d85929c94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,94 +1,8 @@ cmake_minimum_required(VERSION 3.0.2) project(NWNX-Unified) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE RelWithDebInfo) -endif() - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) - -set(CMAKE_EXPORT_COMPILE_COMMANDS 1) - -# Includes the sanitizer package to facilitate debugging. -# If you want to build with this support (I suggest you do), you should pass in one or all of the following: -# -DSANITIZE_UNDEFINED=On -# -DSANITIZE_THREAD=On -# -DSANITIZE_MEMORY=On -# -DSANITIZE_ADDRESS=On -find_package(Sanitizers) - -execute_process(COMMAND git rev-parse --short HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE SHORT_HASH) -set(TARGET_NWN_BUILD 8193) -set(TARGET_NWN_BUILD_REVISION 35) -set(TARGET_NWN_BUILD_POSTFIX 40) -set(NWNX_BUILD_SHA ${SHORT_HASH}) -set(PLUGIN_PREFIX NWNX_) - -# Adds the provided shared library, then builds it with a NWNX_ prefix. -function(add_plugin target) - add_library(${target} MODULE ${ARGN}) - configure_plugin(${target}) -endfunction() - -function(configure_plugin target) - add_sanitizers(${target}) - target_link_libraries(${target} Core) - set_target_properties(${target} PROPERTIES PREFIX "${PLUGIN_PREFIX}") - target_include_directories(${target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") - target_compile_definitions(${target} PRIVATE "-DPLUGIN_NAME=\"${PLUGIN_PREFIX}${target}\"") -endfunction() - -# Sets the output directory for the built targets. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Binaries) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Binaries) - -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(WARNING_FLAGS_CXX "-Weverything -Wno-missing-braces -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded \ - -Wno-packed -Wno-old-style-cast -Wno-reserved-id-macro -Wno-format-nonliteral -Wno-format-security \ - -Wno-gnu-zero-variadic-macro-arguments -Wno-global-constructors -Wno-exit-time-destructors \ - -Wno-missing-prototypes -Wno-unused-function -Wno-weak-vtables -Wno-missing-noreturn \ - -Wno-non-virtual-dtor -Wno-double-promotion -Wno-covered-switch-default -Wno-unused-macros \ - -Wno-register -Wno-pmf-conversions") +if (MSVC) + include(windows.cmake) else() - set(WARNING_FLAGS_CXX "-Wall -Wextra -Wno-pmf-conversions") -endif() - -set(NWNX_STANDARD_FLAGS "-m64 -march=x86-64 -fdiagnostics-show-option -fno-omit-frame-pointer -fPIC -fno-strict-aliasing") - -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NWNX_STANDARD_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NWNX_STANDARD_FLAGS} ${WARNING_FLAGS_CXX} -std=c++17") - -add_definitions(-DNWNX_PLUGIN_PREFIX="${PLUGIN_PREFIX}") -add_definitions(-DNWNX_TARGET_NWN_BUILD=${TARGET_NWN_BUILD}) -add_definitions(-DNWNX_TARGET_NWN_BUILD_REVISION=${TARGET_NWN_BUILD_REVISION}) -add_definitions(-DNWNX_TARGET_NWN_BUILD_POSTFIX=${TARGET_NWN_BUILD_POSTFIX}) -add_definitions(-DNWNX_BUILD_SHA="${NWNX_BUILD_SHA}") - -# Provides the NWN API and other useful things as a static lib. -add_subdirectory(NWNXLib) - -# The core shared library. -add_subdirectory(Core) - -# The documentation generation. -add_subdirectory(docgen) - -# Detect every plugin and store it in plugins . . . -file(GLOB plugins Plugins/*/CMakeLists.txt) - -# Allow skipping certain plugins by putting their names in env. variable -foreach(skipped $ENV{NWNX_SKIP_PLUGINS}) - file(GLOB skip Plugins/${skipped}/CMakeLists.txt) - list(REMOVE_ITEM plugins ${skip} ) -endforeach(skipped) - -# . . . Then iterate over it. -foreach(plugin ${plugins}) - get_filename_component(pluginPath ${plugin} PATH) - add_subdirectory(${pluginPath}) -endforeach(plugin) - -# Allow specifying out of tree plugins by putting their paths in an env. variable -foreach(addplugin $ENV{NWNX_ADDITIONAL_PLUGINS}) - add_subdirectory(${addplugin} ${CMAKE_BINARY_DIR}/custom) -endforeach(addplugin) + include(linux.cmake) +endif () diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index f013617530d..0b22066bfd3 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -7,6 +7,25 @@ set_target_properties(Core PROPERTIES PREFIX "${PLUGIN_PREFIX}") target_compile_definitions(Core PRIVATE "-DPLUGIN_NAME=\"${PLUGIN_PREFIX}Core\"") target_link_libraries(Core NWNXLib) +if(MSVC) + file(DOWNLOAD https://nwn.beamdog.net/downloads/nwnee-dedicated-8193.35-40.zip nwserver.zip) + file(ARCHIVE_EXTRACT INPUT nwserver.zip DESTINATION "." PATTERNS "bin/win32/nwserver.exe") + + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/create_lib.bat + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create_lib.bat ARGS "bin/win32/nwserver.exe" + ) + + add_custom_target(NWServerLib DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib") + + add_dependencies(Core NWServerLib) + set_target_properties(Core PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + set_target_properties(Core PROPERTIES BUILD_SHARED_LIBS TRUE) + set_target_properties(Core PROPERTIES ENABLE_EXPORTS TRUE) + target_link_libraries(Core "${CMAKE_CURRENT_BINARY_DIR}/nwserver.lib") +endif () + # The name defined here will be ignored when loading plugins. add_definitions(-DNWNX_CORE_PLUGIN_NAME="${PLUGIN_PREFIX}Core") diff --git a/Core/NWNXCore.cpp b/Core/NWNXCore.cpp index 3aa4d262363..4ab39ccaf48 100644 --- a/Core/NWNXCore.cpp +++ b/Core/NWNXCore.cpp @@ -6,7 +6,6 @@ #include "API/CServerExoApp.hpp" #include "API/CNWSModule.hpp" #include "API/CExoLinkedListInternal.hpp" -#include "API/CExoLinkedListNode.hpp" #include "API/CExoResMan.hpp" #include "API/CExoBase.hpp" #include "API/CExoAliasList.hpp" @@ -16,11 +15,10 @@ #include #include -#include -#include #include -#include -#include +#include +#include +#include using namespace NWNXLib; using namespace NWNXLib::API; @@ -69,27 +67,6 @@ extern "C" void nwnx_signal_handler(int sig) } } -// Don't allow the -quite flag to close stdout/stderr, we print important info there. -extern "C" FILE *freopen64(const char *filename, const char *mode, FILE *stream) -{ - if ((stream == stdout || stream == stderr) && !strcmp(filename, "/dev/null")) - { - if (stream == stdout) - { - std::puts("NWNX overriding -quiet flag. Always keep an eye on stdout.\n" - "Server will continue in non-interactive mode, but with full output.\n"); - } - return stream; - } - - using Type = FILE*(*)(const char*,const char*,FILE*); - static Type real; - if (!real) - real = (Type)dlsym(RTLD_NEXT, "freopen64"); - return real(filename, mode, stream); -} - - namespace { void InitCrashHandlers() @@ -123,11 +100,21 @@ static NWNXCore s_core; NWNXCore* g_core = nullptr; // Used to access the core class in hook or event handlers. bool g_CoreShuttingDown = false; +#if WIN32 +extern "C" __declspec(dllexport) BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) +{ + return TRUE; +} +#endif + NWNXCore::NWNXCore() : m_ScriptChunkRecursion(0) { g_core = this; + // Initialize platform specific stuff (e.g. create windows console window). + Platform::Initialize(); + // NOTE: We should do the version check here, but the global in the binary hasn't been initialised yet at this point. // This will be fixed in a future release of NWNX:EE. For now, the version check will happen *too late* - we may // crash before the version check happens. @@ -300,59 +287,47 @@ void NWNXCore::InitialSetupPlugins() constexpr static const char* pluginPrefix = NWNX_PLUGIN_PREFIX; const std::string prefix = pluginPrefix; - char cwd[PATH_MAX]; - ASSERT(getcwd(cwd, sizeof(cwd)) != nullptr); - - const auto pluginDir = Config::Get("LOAD_PATH", cwd); + const auto pluginDir = Config::Get("LOAD_PATH", std::filesystem::current_path().string()); const bool skipAllPlugins = Config::Get("SKIP_ALL", false); LOG_INFO("Loading plugins from: %s", pluginDir); - std::vector files; - if (auto dir = opendir(pluginDir.c_str())) + std::vector files; + + for (const auto& entry : std::filesystem::directory_iterator(pluginDir)) { - while (auto entry = readdir(dir)) + if (entry.is_regular_file() || entry.is_symlink() || entry.is_other()) { - if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_REG || entry->d_type == DT_LNK) - { - files.emplace_back(entry->d_name); - } + files.emplace_back(entry.path()); } - closedir(dir); } + // Sort by file name, so at least plugins are loaded in deterministic order. std::sort(std::begin(files), std::end(files)); - for (auto& dynamicLibrary : files) + for (auto& libraryPath : files) { - const std::string& pluginName = dynamicLibrary; - const std::string pluginNameWithoutExtension = String::Basename(pluginName); + const std::string& extension = libraryPath.extension().string(); + const std::string& pluginName = libraryPath.stem().string(); - if (pluginNameWithoutExtension.compare(0, prefix.size(), prefix) != 0) + if (pluginName.compare(0, prefix.size(), prefix) != 0 || pluginName == "NWNX_Launcher" || (extension != Platform::PluginExtension())) { continue; // Not a plugin. } - if (pluginNameWithoutExtension == "NWNX_Experimental" && !Config::Get("LOAD_EXPERIMENTAL_PLUGIN", false)) + if (pluginName == "NWNX_Experimental" && !Config::Get("LOAD_EXPERIMENTAL_PLUGIN", false)) { continue; } - auto services = ConstructProxyServices(pluginNameWithoutExtension); - - // Always load core. - if (pluginNameWithoutExtension != NWNX_CORE_PLUGIN_NAME && Config::Get("SKIP", (bool)skipAllPlugins, pluginNameWithoutExtension)) - { - LOG_INFO("Skipping plugin %s due to configuration.", pluginNameWithoutExtension); - continue; - } - Plugin::Load(pluginDir + "/" + pluginName, std::move(services)); + auto services = ConstructProxyServices(pluginName); + Plugin::Load(pluginDir + Platform::PathSeparator() + pluginName, std::move(services)); } } void NWNXCore::InitialSetupResourceDirectories() { - auto nwnxResDirPath = Config::Get("NWNX_RESOURCE_DIRECTORY_PATH", Globals::ExoBase()->m_sUserDirectory.CStr() + std::string("/nwnx")); + auto nwnxResDirPath = Config::Get("NWNX_RESOURCE_DIRECTORY_PATH", Globals::ExoBase()->m_sUserDirectory.CStr() + std::string(Platform::PathSeparator() + "nwnx")); auto nwnxResDirPriority = Config::Get("NWNX_RESOURCE_DIRECTORY_PRIORITY", 70000000); std::unordered_map> resourceDirectories; diff --git a/Core/create_lib.bat b/Core/create_lib.bat new file mode 100644 index 00000000000..d5e614948db --- /dev/null +++ b/Core/create_lib.bat @@ -0,0 +1,11 @@ +@echo off + +dumpbin /exports %1 > nwserver.exports + +echo LIBRARY nwserver.exe > nwserver.def +echo EXPORTS >> nwserver.def +for /f "skip=19 tokens=1,4" %%A in (nwserver.exports) do if NOT "%%B" == "" (echo %%B @%%A >> nwserver.def) + +lib /def:nwserver.def /out:nwserver.lib /machine:x64 /name:nwserver.exe + +del nwserver.exports nwserver.def nwserver.exp diff --git a/Launcher/CMakeLists.txt b/Launcher/CMakeLists.txt new file mode 100644 index 00000000000..a9d6490a02e --- /dev/null +++ b/Launcher/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(Launcher WIN32 main.cpp) +target_link_libraries(Launcher PRIVATE detours) + +set_target_properties(Launcher PROPERTIES PREFIX "${PLUGIN_PREFIX}") diff --git a/Launcher/main.cpp b/Launcher/main.cpp new file mode 100644 index 00000000000..c141d990db9 --- /dev/null +++ b/Launcher/main.cpp @@ -0,0 +1,25 @@ +#include +#include +#include + +static const char exename[] = "nwserver.exe"; +static const char dllname[] = "NWNX_Core.dll"; + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +{ + static char cmd[4192]; + snprintf(cmd, sizeof(cmd), "%s %s", exename, lpCmdLine); + + STARTUPINFO si; + PROCESS_INFORMATION pi; + memset(&si, 0, sizeof(si)); + memset(&pi, 0, sizeof(pi)); + si.cb = sizeof(si); + + if(!DetourCreateProcessWithDll(NULL, cmd, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi, dllname, NULL)) + { + exit(GetLastError()); + } + + return 0; +} diff --git a/NWNXLib/API/API/ALL_CLASSES.hpp b/NWNXLib/API/API/ALL_CLASSES.hpp index fddd36f735d..6e4e25bbb4b 100644 --- a/NWNXLib/API/API/ALL_CLASSES.hpp +++ b/NWNXLib/API/API/ALL_CLASSES.hpp @@ -1,328 +1,328 @@ -struct CAppManager; -struct CBaseExoApp; -struct CExoApp; -struct CExoAliasList; -struct CExoFile; -struct CExoLinkedListNode; -struct CExoLinkedListInternal; -struct CExoString; -struct CExoLocString; -struct CExoDebug; -struct CExoTimers; -struct CExoIni; -struct CExoRand; -struct CExoIdentity; -struct CFileInfo; -struct CExoBase; -struct CExoCriticalSection; -struct CExoStringList; -struct ScriptParam; -struct CExoEncrypt; -struct CExoInputEventDesc; -struct CExoInputEvent; -struct CExoInputClass; -struct CExoInput; -struct RESID; -struct CResRef; -struct CRes; -struct RES_FIXED_HEADER; -struct CExoResMan; -struct TLK_FILE_HEADER; -struct STR_RES_HEADER_OLD; -struct STR_RES_HEADER; -struct STR_RES; -struct CTlkFile; -struct CTlkResFile; -struct CTlkTableToken; -struct CTlkTableTokenCustom; -struct CTlkTable; -struct CCallbackHandlerBase; -struct KeyFileData; -struct CExtendedServerInfo; -struct CNetLayerSessionInfo; -struct CNetLayer; -struct CNetLayerPlayerCDKeyInfo; -struct CNetLayerPlayerInfo; -struct CNWAmbientSound; -struct NWERFHEADER; -struct CERFFile; -struct CERFKey; -struct CERFRes; -struct CERFString; -struct SJournalEntry; -struct CWorldJournalEntry; -struct CNWNameGen; -struct StartupConfig; -struct Provider; -struct PlatformIntrinsicsProvider; -struct out_of_space_error; -struct StorageShard; -struct DestroyHelper; -struct StorageShardAllocParams; -struct CPathfindInfoIntraTileSuccessors; -struct CNWGridSearchPath; -struct CPathfindInformation; -struct EXO2DAHEADER; -struct CRes2DA; -struct EXOLTRHEADER; -struct CResLTR; -struct CResMDL; -struct CResTLK; -struct CScriptSourceFile; -struct CScriptCompilerIncludeFileStackEntry; -struct CScriptCompiler; -struct CVirtualMachineCmdImplementer; -struct StackElement; -struct CVirtualMachineStack; -struct CVirtualMachineScript; -struct CVirtualMachineFile; -struct CScriptLog; -struct CVirtualMachine; -struct SSubNetProfile; -struct CServerExoApp; -struct CServerOptionLookup; -struct CJoiningRestrictions; -struct CPlayOptions; -struct CResetOption; -struct CAutoSave; -struct CPersistantWorldOptions; -struct CServerNetOptions; -struct CServerInfo; -struct CWorldTimer; -struct CNWArea; -struct CNWDoorSurfaceMesh; -struct SNWItemFlags; -struct CNWItemProperty; -struct CNWBaseItem; -struct CNWBaseItemArray; -struct CNWItem; -struct CNWTile; -struct CNWTileData; -struct CNWTileSet; -struct CNWTilePathNode; -struct CNWTileSetManager; -struct CWalkHitInfo; -struct CNWTileSurfaceMeshHashTableEntry; -struct CNWTileSurfaceMeshSortSuccessors; -struct CNWTileSurfaceMeshLocalInfo; -struct CNWTileSurfaceMeshNodeVertex; -struct CNWTileSurfaceMeshNodeFace; -struct CNWTileSurfaceMeshAABBNode; -struct CNWTileSurfaceMesh; -struct CNWPlaceableSurfaceMesh; -struct CNWPlaceMeshManager; -struct BindUpdate; -struct Event; -struct CScriptLocation; -struct ObjectVisualTransformData; -struct MaterialShaderParam; -struct TextureReplaceInfo; -struct CFeatUseListEntry; -struct CEffectIconObject; -struct CNWCreatureStatsUpdate; -struct CNWSkill; -struct CNWSStats_Spell; -struct CNWSStats_SpellLikeAbility; -struct CNWSpell; -struct CNWSpellArray; -struct CNWRace; -struct CCombatInformationNode; -struct CCombatInformation; -struct CNWRules; -struct CachedRulesetEntry; -struct CResDWK; -struct CResPWK; -struct SETEntry; -struct SETSection; -struct CResSET; -struct CResWOK; -struct C2DA; -struct CTwoDimArrays; -struct CObjectLookupTable; -struct CObjectTableManager; -struct CGameObject; -struct CGameObjectArrayNode; -struct CGameObjectArray; -struct CNWClass_Feat; -struct CNWClass; -struct CNWClass_Skill; -struct CNWAnimBase; -struct CNWLevelStats; -struct CNWDomain; -struct CNWFeat; -struct CNWCCMessageData; -struct CNWVisibilityNode; -struct CNWActionNode; -struct CNWMessage; -struct CExoBaseInternal; -struct CExoDebugInternal; -struct CExoIniInternal; -struct EXOLOCSTRING; -struct CExoLocStringInternal; -struct CExoRandInternal; -struct CExoTimersInternal; -struct KEYFILE_HEADER; -struct KEYFILE_RESFILENAME; -struct KEYFILE_KEYENTRY_E1; -struct BIFFFILE_HEADER; -struct BIFFFILE_VARRESENTRY_V1; -struct BIFFFILE_VARRESENTRY_E1; -struct ENCAPSULATED_HEADER; -struct ENCAPSULATED_KEYLISTENTRY; -struct ENCAPSULATED_KEYLISTENTRY_E1; -struct ENCAPSULATED_RESLISTENTRY; -struct ENCAPSULATED_RESLISTENTRY_E1; -struct CKeyTableEntry; -struct CKeyTableInfo; -struct CExoKeyTable; -struct CExoPackedFile; -struct CExoResFile; -struct CExoEncapsulatedFile; -struct CExoResourceImageFile; -struct CNetLayerWindow; -struct CNetLayerInternal; -struct KXPacket; -struct IntendedConnectionData; -struct CScriptParseTreeNode; -struct CScriptParseTreeNodeBlock; -struct CScriptCompilerStackEntry; -struct CScriptCompilerKeyWordEntry; -struct CScriptCompilerIdentifierHashTableEntry; -struct CScriptCompilerIdListEntry; -struct CScriptCompilerVarStackEntry; -struct CScriptCompilerStructureEntry; -struct CScriptCompilerStructureFieldEntry; -struct CScriptCompilerSymbolTableEntry; -struct CVirtualMachineDebuggingContext; -struct CVirtualMachineDebugLoader; -struct CVirtualMachineDebuggerInstance; -struct CResNCS; -struct CResNDB; -struct CResNSS; -struct CFactionManager; -struct CMessagePlayer; -struct CMessageSysAdmin; -struct CNWSAmbientSound; -struct CNWSAnimBase; -struct NWAREAHEADER; -struct NWAREAEXPANSION; -struct CNWSAreaGridSuccessors; -struct CNWSAreaGridPoint; -struct CNWSAreaGridTransTableEntry; -struct CNWSAreaInterTileSuccessors; -struct CNWSArea; -struct CNWSBarter; -struct CNWSClient; -struct CNWSCombatRoundAction; -struct CNWSCombatAttackData; -struct CNWSCombatRound; -struct CNWSCreatureAppearanceInfo; -struct CNWSQuickbarButton; -struct CNWSSpellScriptData; -struct CNWSInvitationDetails; -struct CNWSPVPEntry; -struct CNWSCreRestorePolymorphData; -struct CNWSCreature; -struct CNWSCreatureStats_ClassInfo; -struct CNWSCreatureStats; -struct CNWSDialogPlayer; -struct CNWSDialogLinkEntry; -struct CNWSDialogLinkReply; -struct CNWSDialogEntry; -struct CNWSDialogReply; -struct CNWSDialogSpeaker; -struct CNWSDialog; -struct CNWSDoor; -struct CGameEffect; -struct CNWSEffectListHandler; -struct CEncounterListEntry; -struct CEncounterSpawnPoint; -struct CNWSEncounter; -struct CNWSExpressionNode; -struct CNWSExpressionList; -struct CNWSExpression; -struct CNWSForcedAction; -struct CNWSInventory; -struct CItemRepository; -struct CNWSItem; -struct CNWSJournal; -struct CNWSMessage; -struct NWMODULEHEADER; -struct NWMODULEENTRYINFO; -struct NWMODULEEXPANSION; -struct NWMODULECUTSCENE; -struct NWPLAYERLISTITEM; -struct NWPlayerCharacterListClass_st; -struct NWPlayerCharacterList_st; -struct CNWSTagNode; -struct CNWSModule; -struct CNWSObjectActionNode; -struct CNWSObjectEventHandler; -struct CLoopingVisualEffect; -struct CScriptTalent; -struct CNWSObject; -struct CNWSPersonalReputation; -struct CNWSFaction; -struct CNWSPlaceable; -struct CNWSPlayerJournalQuestUpdates; -struct CNWSPlayerJournalQuest; -struct CNWSPlayerStoreGUI; -struct CNWSPlayerCharSheetGUI; -struct CNWSPlayerContainerGUI; -struct CNWSPlayerInventoryGUI; -struct CNWSPlayer; -struct NuiState; -struct WindowState; -struct CNWSPlayerLUOInventoryItem; -struct CNWSPlayerLUOInventory; -struct CNWSPlayerLUOAppearanceInfo; -struct CSpell_Delete; -struct CSpell_Add; -struct CNWSPlayerLUOQuickbarItemButton; -struct CLastUpdateObject; -struct CNWSPlayerLastUpdateObject; -struct CLastUpdatePartyObject; -struct CNWSPlayerLUOSortedObjectList; -struct CNWSPlayerTURD; -struct CNWSPortal; -struct CNWSRules; -struct CScriptEvent; -struct CNWSSound; -struct CNWSSoundObject; -struct CNWSAreaOfEffectObject; -struct CStoreCustomer; -struct CNWSStore; -struct CNWSSysAdmin; -struct CNWSTile; -struct CNWSTileSet; -struct CNWSTransition; -struct CNWSTrigger; -struct CNWSUUID; -struct CNWSScriptVar; -struct CNWSScriptVarTable; -struct CNWSWaypoint; -struct SqlQueryEngineStructure; -struct CNWVirtualMachineCommands; -struct CResARE; -struct CResIFO; -struct CGameEffectApplierRemover; -struct CItemPropertyApplierRemover; -struct CServerAIList; -struct CServerAIEventNode; -struct CServerAIBodyBagInfo; -struct CServerAIMaster; -struct CServerExoAppInternal; -struct Vector; -struct CAurObjectVisualTransformData; -struct CStringFieldIDType; -struct CResGenericFileHeader; -struct CResStructHeader; -struct CResStructLookUp; -struct CResStruct; -struct CResStructInternal; -struct CResGFFFileHeader; -struct CResGFFStruct; -struct CResGFFField; -struct CResGFFLabel; -struct CResGFF; -struct NWVMachineUtils; +class CAppManager; +class CBaseExoApp; +class CExoApp; +class CExoAliasList; +class CExoFile; +class CExoLinkedListNode; +class CExoLinkedListInternal; +class CExoString; +class CExoLocString; +class CExoDebug; +class CExoTimers; +class CExoIni; +class CExoRand; +class CExoIdentity; +class CFileInfo; +class CExoBase; +class CExoCriticalSection; +class CExoStringList; +class ScriptParam; +class CExoEncrypt; +class CExoInputEventDesc; +class CExoInputEvent; +class CExoInputClass; +class CExoInput; +class RESID; +class CResRef; +class CRes; +class RES_FIXED_HEADER; +class CExoResMan; +class TLK_FILE_HEADER; +class STR_RES_HEADER_OLD; +class STR_RES_HEADER; +class STR_RES; +class CTlkFile; +class CTlkResFile; +class CTlkTableToken; +class CTlkTableTokenCustom; +class CTlkTable; +class CCallbackHandlerBase; +class KeyFileData; +class CExtendedServerInfo; +class CNetLayerSessionInfo; +class CNetLayer; +class CNetLayerPlayerCDKeyInfo; +class CNetLayerPlayerInfo; +class CNWAmbientSound; +class NWERFHEADER; +class CERFFile; +class CERFKey; +class CERFRes; +class CERFString; +class SJournalEntry; +class CWorldJournalEntry; +class CNWNameGen; +class StartupConfig; +class Provider; +class PlatformIntrinsicsProvider; +class out_of_space_error; +class StorageShard; +class DestroyHelper; +class StorageShardAllocParams; +class CPathfindInfoIntraTileSuccessors; +class CNWGridSearchPath; +class CPathfindInformation; +class EXO2DAHEADER; +class CRes2DA; +class EXOLTRHEADER; +class CResLTR; +class CResMDL; +class CResTLK; +class CScriptSourceFile; +class CScriptCompilerIncludeFileStackEntry; +class CScriptCompiler; +class CVirtualMachineCmdImplementer; +class StackElement; +class CVirtualMachineStack; +class CVirtualMachineScript; +class CVirtualMachineFile; +class CScriptLog; +class CVirtualMachine; +class SSubNetProfile; +class CServerExoApp; +class CServerOptionLookup; +class CJoiningRestrictions; +class CPlayOptions; +class CResetOption; +class CAutoSave; +class CPersistantWorldOptions; +class CServerNetOptions; +class CServerInfo; +class CWorldTimer; +class CNWArea; +class CNWDoorSurfaceMesh; +class SNWItemFlags; +class CNWItemProperty; +class CNWBaseItem; +class CNWBaseItemArray; +class CNWItem; +class CNWTile; +class CNWTileData; +class CNWTileSet; +class CNWTilePathNode; +class CNWTileSetManager; +class CWalkHitInfo; +class CNWTileSurfaceMeshHashTableEntry; +class CNWTileSurfaceMeshSortSuccessors; +class CNWTileSurfaceMeshLocalInfo; +class CNWTileSurfaceMeshNodeVertex; +class CNWTileSurfaceMeshNodeFace; +class CNWTileSurfaceMeshAABBNode; +class CNWTileSurfaceMesh; +class CNWPlaceableSurfaceMesh; +class CNWPlaceMeshManager; +class BindUpdate; +class Event; +class CScriptLocation; +class ObjectVisualTransformData; +class MaterialShaderParam; +class TextureReplaceInfo; +class CFeatUseListEntry; +class CEffectIconObject; +class CNWCreatureStatsUpdate; +class CNWSkill; +class CNWSStats_Spell; +class CNWSStats_SpellLikeAbility; +class CNWSpell; +class CNWSpellArray; +class CNWRace; +class CCombatInformationNode; +class CCombatInformation; +class CNWRules; +class CachedRulesetEntry; +class CResDWK; +class CResPWK; +class SETEntry; +class SETSection; +class CResSET; +class CResWOK; +class C2DA; +class CTwoDimArrays; +class CObjectLookupTable; +class CObjectTableManager; +class CGameObject; +class CGameObjectArrayNode; +class CGameObjectArray; +class CNWClass_Feat; +class CNWClass; +class CNWClass_Skill; +class CNWAnimBase; +class CNWLevelStats; +class CNWDomain; +class CNWFeat; +class CNWCCMessageData; +class CNWVisibilityNode; +class CNWActionNode; +class CNWMessage; +class CExoBaseInternal; +class CExoDebugInternal; +class CExoIniInternal; +class EXOLOCSTRING; +class CExoLocStringInternal; +class CExoRandInternal; +class CExoTimersInternal; +class KEYFILE_HEADER; +class KEYFILE_RESFILENAME; +class KEYFILE_KEYENTRY_E1; +class BIFFFILE_HEADER; +class BIFFFILE_VARRESENTRY_V1; +class BIFFFILE_VARRESENTRY_E1; +class ENCAPSULATED_HEADER; +class ENCAPSULATED_KEYLISTENTRY; +class ENCAPSULATED_KEYLISTENTRY_E1; +class ENCAPSULATED_RESLISTENTRY; +class ENCAPSULATED_RESLISTENTRY_E1; +class CKeyTableEntry; +class CKeyTableInfo; +class CExoKeyTable; +class CExoPackedFile; +class CExoResFile; +class CExoEncapsulatedFile; +class CExoResourceImageFile; +class CNetLayerWindow; +class CNetLayerInternal; +class KXPacket; +class IntendedConnectionData; +class CScriptParseTreeNode; +class CScriptParseTreeNodeBlock; +class CScriptCompilerStackEntry; +class CScriptCompilerKeyWordEntry; +class CScriptCompilerIdentifierHashTableEntry; +class CScriptCompilerIdListEntry; +class CScriptCompilerVarStackEntry; +class CScriptCompilerStructureEntry; +class CScriptCompilerStructureFieldEntry; +class CScriptCompilerSymbolTableEntry; +class CVirtualMachineDebuggingContext; +class CVirtualMachineDebugLoader; +class CVirtualMachineDebuggerInstance; +class CResNCS; +class CResNDB; +class CResNSS; +class CFactionManager; +class CMessagePlayer; +class CMessageSysAdmin; +class CNWSAmbientSound; +class CNWSAnimBase; +class NWAREAHEADER; +class NWAREAEXPANSION; +class CNWSAreaGridSuccessors; +class CNWSAreaGridPoint; +class CNWSAreaGridTransTableEntry; +class CNWSAreaInterTileSuccessors; +class CNWSArea; +class CNWSBarter; +class CNWSClient; +class CNWSCombatRoundAction; +class CNWSCombatAttackData; +class CNWSCombatRound; +class CNWSCreatureAppearanceInfo; +class CNWSQuickbarButton; +class CNWSSpellScriptData; +class CNWSInvitationDetails; +class CNWSPVPEntry; +class CNWSCreRestorePolymorphData; +class CNWSCreature; +class CNWSCreatureStats_ClassInfo; +class CNWSCreatureStats; +class CNWSDialogPlayer; +class CNWSDialogLinkEntry; +class CNWSDialogLinkReply; +class CNWSDialogEntry; +class CNWSDialogReply; +class CNWSDialogSpeaker; +class CNWSDialog; +class CNWSDoor; +class CGameEffect; +class CNWSEffectListHandler; +class CEncounterListEntry; +class CEncounterSpawnPoint; +class CNWSEncounter; +class CNWSExpressionNode; +class CNWSExpressionList; +class CNWSExpression; +class CNWSForcedAction; +class CNWSInventory; +class CItemRepository; +class CNWSItem; +class CNWSJournal; +class CNWSMessage; +class NWMODULEHEADER; +class NWMODULEENTRYINFO; +class NWMODULEEXPANSION; +class NWMODULECUTSCENE; +class NWPLAYERLISTITEM; +class NWPlayerCharacterListClass_st; +class NWPlayerCharacterList_st; +class CNWSTagNode; +class CNWSModule; +class CNWSObjectActionNode; +class CNWSObjectEventHandler; +class CLoopingVisualEffect; +class CScriptTalent; +class CNWSObject; +class CNWSPersonalReputation; +class CNWSFaction; +class CNWSPlaceable; +class CNWSPlayerJournalQuestUpdates; +class CNWSPlayerJournalQuest; +class CNWSPlayerStoreGUI; +class CNWSPlayerCharSheetGUI; +class CNWSPlayerContainerGUI; +class CNWSPlayerInventoryGUI; +class CNWSPlayer; +class NuiState; +class WindowState; +class CNWSPlayerLUOInventoryItem; +class CNWSPlayerLUOInventory; +class CNWSPlayerLUOAppearanceInfo; +class CSpell_Delete; +class CSpell_Add; +class CNWSPlayerLUOQuickbarItemButton; +class CLastUpdateObject; +class CNWSPlayerLastUpdateObject; +class CLastUpdatePartyObject; +class CNWSPlayerLUOSortedObjectList; +class CNWSPlayerTURD; +class CNWSPortal; +class CNWSRules; +class CScriptEvent; +class CNWSSound; +class CNWSSoundObject; +class CNWSAreaOfEffectObject; +class CStoreCustomer; +class CNWSStore; +class CNWSSysAdmin; +class CNWSTile; +class CNWSTileSet; +class CNWSTransition; +class CNWSTrigger; +class CNWSUUID; +class CNWSScriptVar; +class CNWSScriptVarTable; +class CNWSWaypoint; +class SqlQueryEngineStructure; +class CNWVirtualMachineCommands; +class CResARE; +class CResIFO; +class CGameEffectApplierRemover; +class CItemPropertyApplierRemover; +class CServerAIList; +class CServerAIEventNode; +class CServerAIBodyBagInfo; +class CServerAIMaster; +class CServerExoAppInternal; +class Vector; +class CAurObjectVisualTransformData; +class CStringFieldIDType; +class CResGenericFileHeader; +class CResStructHeader; +class CResStructLookUp; +class CResStruct; +class CResStructInternal; +class CResGFFFileHeader; +class CResGFFStruct; +class CResGFFField; +class CResGFFLabel; +class CResGFF; +class NWVMachineUtils; diff --git a/NWNXLib/API/API/BIFFFILE_HEADER.hpp b/NWNXLib/API/API/BIFFFILE_HEADER.hpp index 19417cc918c..b266d4a553d 100644 --- a/NWNXLib/API/API/BIFFFILE_HEADER.hpp +++ b/NWNXLib/API/API/BIFFFILE_HEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(BIFFFILE_HEADER) -struct BIFFFILE_HEADER +class BIFFFILE_HEADER { +public: uint32_t nFileType; uint32_t nFileVersion; uint32_t nNumVariableResources; diff --git a/NWNXLib/API/API/BIFFFILE_VARRESENTRY_E1.hpp b/NWNXLib/API/API/BIFFFILE_VARRESENTRY_E1.hpp index 5bdd05955e3..f1f858e22a6 100644 --- a/NWNXLib/API/API/BIFFFILE_VARRESENTRY_E1.hpp +++ b/NWNXLib/API/API/BIFFFILE_VARRESENTRY_E1.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(BIFFFILE_VARRESENTRY_E1) -struct BIFFFILE_VARRESENTRY_E1 +class BIFFFILE_VARRESENTRY_E1 { +public: uint32_t nID; uint32_t nOffset; uint32_t nSize; diff --git a/NWNXLib/API/API/BIFFFILE_VARRESENTRY_V1.hpp b/NWNXLib/API/API/BIFFFILE_VARRESENTRY_V1.hpp index 548278d50c5..b72872a21bc 100644 --- a/NWNXLib/API/API/BIFFFILE_VARRESENTRY_V1.hpp +++ b/NWNXLib/API/API/BIFFFILE_VARRESENTRY_V1.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(BIFFFILE_VARRESENTRY_V1) -struct BIFFFILE_VARRESENTRY_V1 +class BIFFFILE_VARRESENTRY_V1 { +public: uint32_t nID; uint32_t nOffset; uint32_t nSize; diff --git a/NWNXLib/API/API/C2DA.hpp b/NWNXLib/API/API/C2DA.hpp index 0667c2fd613..b79aef3a564 100644 --- a/NWNXLib/API/API/C2DA.hpp +++ b/NWNXLib/API/API/C2DA.hpp @@ -16,8 +16,9 @@ NWN_API_PROLOGUE(C2DA) typedef int BOOL; -struct C2DA : CResHelper +class C2DA : public CResHelper { +public: CExoString m_sDefaultValue; CExoString * m_pRowLabel; CExoString * m_pColumnLabel; diff --git a/NWNXLib/API/API/CAppManager.hpp b/NWNXLib/API/API/CAppManager.hpp index 544f372c744..9ea239dee60 100644 --- a/NWNXLib/API/API/CAppManager.hpp +++ b/NWNXLib/API/API/CAppManager.hpp @@ -9,18 +9,19 @@ NWN_API_PROLOGUE(CAppManager) #endif -struct CClientExoApp; -struct CNWReentrantServerStats; -struct CNWTileSetManager; -struct CObjectTableManager; -struct CServerExoApp; +class CClientExoApp; +class CNWReentrantServerStats; +class CNWTileSetManager; +class CObjectTableManager; +class CServerExoApp; typedef int BOOL; -struct CAppManager +class CAppManager { +public: CClientExoApp * m_pClientExoApp; CServerExoApp * m_pServerExoApp; CNWTileSetManager * m_pNWTileSetManager; @@ -42,8 +43,8 @@ struct CAppManager CObjectTableManager * GetObjectTableManager(uint32_t dwClientServer); void DoSaveGameScreenShot(CExoString & sFile); void ShowServerMem(); - void CreateServer(void ); - void DestroyServer(); + NWNX_IMPORT void CreateServer(void ); + NWNX_IMPORT void DestroyServer(); void SetDungeonMasterEXERunning(BOOL bDM); BOOL GetDungeonMasterEXERunning(); void DisplayScriptDebuggerPopup(); diff --git a/NWNXLib/API/API/CAurObjectVisualTransformData.hpp b/NWNXLib/API/API/CAurObjectVisualTransformData.hpp index 15facef9f2e..d270cd8d416 100644 --- a/NWNXLib/API/API/CAurObjectVisualTransformData.hpp +++ b/NWNXLib/API/API/CAurObjectVisualTransformData.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CAurObjectVisualTransformData) -struct CAurObjectVisualTransformData +class CAurObjectVisualTransformData { +public: LerpVector m_scale; LerpVector m_rotate; LerpVector m_translate; diff --git a/NWNXLib/API/API/CAutoSave.hpp b/NWNXLib/API/API/CAutoSave.hpp index 1b0714a35b8..09a643afe98 100644 --- a/NWNXLib/API/API/CAutoSave.hpp +++ b/NWNXLib/API/API/CAutoSave.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CAutoSave) typedef int BOOL; -struct CAutoSave +class CAutoSave { +public: BOOL bAtIntervals; BOOL bAtSavePoints; BOOL bOnPlayerChange; diff --git a/NWNXLib/API/API/CBaseExoApp.hpp b/NWNXLib/API/API/CBaseExoApp.hpp index 45ce0c11f66..837c763f0e2 100644 --- a/NWNXLib/API/API/CBaseExoApp.hpp +++ b/NWNXLib/API/API/CBaseExoApp.hpp @@ -15,9 +15,9 @@ NWN_API_PROLOGUE(CBaseExoApp) typedef int BOOL; -struct CBaseExoApp +class CBaseExoApp { - +public: virtual BOOL AdmitNetworkAddress(uint32_t nProtocol, CExoString sAddress); virtual BOOL AdmitPlayerName(CExoString sPlayerName); virtual BOOL SetNetworkAddressBan(uint32_t nProtocol, CExoString sAddress, BOOL bBanPlayer); diff --git a/NWNXLib/API/API/CCallbackHandlerBase.hpp b/NWNXLib/API/API/CCallbackHandlerBase.hpp index 9f2a1a18275..41e6bd3826d 100644 --- a/NWNXLib/API/API/CCallbackHandlerBase.hpp +++ b/NWNXLib/API/API/CCallbackHandlerBase.hpp @@ -11,9 +11,9 @@ NWN_API_PROLOGUE(CCallbackHandlerBase) -struct CCallbackHandlerBase +class CCallbackHandlerBase { - +public: #ifdef NWN_CLASS_EXTENSION_CCallbackHandlerBase diff --git a/NWNXLib/API/API/CCombatInformation.hpp b/NWNXLib/API/API/CCombatInformation.hpp index 08a67dbb128..71942950af7 100644 --- a/NWNXLib/API/API/CCombatInformation.hpp +++ b/NWNXLib/API/API/CCombatInformation.hpp @@ -9,17 +9,18 @@ NWN_API_PROLOGUE(CCombatInformation) #endif -struct CCombatInformationNode; -struct CResGFF; -struct CResStruct; +class CCombatInformationNode; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CCombatInformation +class CCombatInformation { +public: uint8_t m_nNumAttacks; char m_nOnHandAttackModifier; char m_nOnHandDamageModifier; diff --git a/NWNXLib/API/API/CCombatInformationNode.hpp b/NWNXLib/API/API/CCombatInformationNode.hpp index c521e341123..79e72a5f352 100644 --- a/NWNXLib/API/API/CCombatInformationNode.hpp +++ b/NWNXLib/API/API/CCombatInformationNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CCombatInformationNode) typedef int BOOL; -struct CCombatInformationNode +class CCombatInformationNode { +public: char m_nModifier; uint8_t m_nModifierType; uint8_t m_nWeaponWield; diff --git a/NWNXLib/API/API/CERFFile.hpp b/NWNXLib/API/API/CERFFile.hpp index b472cd56310..0f38fd820bc 100644 --- a/NWNXLib/API/API/CERFFile.hpp +++ b/NWNXLib/API/API/CERFFile.hpp @@ -12,17 +12,18 @@ NWN_API_PROLOGUE(CERFFile) #endif -struct CExoFile; -struct CExoString; -struct CRes; +class CExoFile; +class CExoString; +class CRes; typedef int BOOL; typedef uint16_t RESTYPE; -struct CERFFile +class CERFFile { +public: NWERFHEADER m_stHeader; CExoLinkedList m_lstStringList; CExoLinkedList m_lstKeyList; diff --git a/NWNXLib/API/API/CERFKey.hpp b/NWNXLib/API/API/CERFKey.hpp index f7645234429..f4d0a1eeb05 100644 --- a/NWNXLib/API/API/CERFKey.hpp +++ b/NWNXLib/API/API/CERFKey.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CERFKey) #endif -struct CExoFile; -struct CExoString; +class CExoFile; +class CExoString; typedef int BOOL; -struct CERFKey +class CERFKey { +public: char m_sName[16]; uint32_t m_nID; uint16_t m_nType; diff --git a/NWNXLib/API/API/CERFRes.hpp b/NWNXLib/API/API/CERFRes.hpp index c4a3848de3a..6560be331cc 100644 --- a/NWNXLib/API/API/CERFRes.hpp +++ b/NWNXLib/API/API/CERFRes.hpp @@ -7,14 +7,15 @@ NWN_API_PROLOGUE(CERFRes) #endif -struct CExoFile; +class CExoFile; typedef int BOOL; -struct CERFRes +class CERFRes { +public: uint32_t m_nOffset; uint32_t m_nSize; uint8_t * m_pData; diff --git a/NWNXLib/API/API/CERFString.hpp b/NWNXLib/API/API/CERFString.hpp index c4343000592..2a16e1dc27a 100644 --- a/NWNXLib/API/API/CERFString.hpp +++ b/NWNXLib/API/API/CERFString.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CERFString) #endif -struct CExoFile; +class CExoFile; typedef int BOOL; -struct CERFString +class CERFString { +public: uint32_t m_nLanguageID; uint32_t m_nSize; char * m_pText; diff --git a/NWNXLib/API/API/CEffectIconObject.hpp b/NWNXLib/API/API/CEffectIconObject.hpp index 302cd3b8ded..7206fb309ad 100644 --- a/NWNXLib/API/API/CEffectIconObject.hpp +++ b/NWNXLib/API/API/CEffectIconObject.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CEffectIconObject) typedef int BOOL; -struct CEffectIconObject +class CEffectIconObject { +public: uint8_t m_nIcon; BOOL m_bFlashing; BOOL m_nPlayerBar; diff --git a/NWNXLib/API/API/CEncounterListEntry.hpp b/NWNXLib/API/API/CEncounterListEntry.hpp index de923a736e4..45985689dec 100644 --- a/NWNXLib/API/API/CEncounterListEntry.hpp +++ b/NWNXLib/API/API/CEncounterListEntry.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CEncounterListEntry) typedef int BOOL; -struct CEncounterListEntry +class CEncounterListEntry { +public: CResRef m_cCreatureResRef; float m_fCR; float m_fCreaturePoints; diff --git a/NWNXLib/API/API/CEncounterSpawnPoint.hpp b/NWNXLib/API/API/CEncounterSpawnPoint.hpp index 2eae6a0c6d2..03567110cf4 100644 --- a/NWNXLib/API/API/CEncounterSpawnPoint.hpp +++ b/NWNXLib/API/API/CEncounterSpawnPoint.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CEncounterSpawnPoint) -struct CEncounterSpawnPoint +class CEncounterSpawnPoint { +public: Vector m_vPosition; float m_fOrientation; diff --git a/NWNXLib/API/API/CExoAliasList.hpp b/NWNXLib/API/API/CExoAliasList.hpp index 4168a588795..55e9256a7bc 100644 --- a/NWNXLib/API/API/CExoAliasList.hpp +++ b/NWNXLib/API/API/CExoAliasList.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CExoAliasList) #endif -struct CExoAliasListInternal; +class CExoAliasListInternal; typedef uint16_t RESTYPE; -struct CExoAliasList +class CExoAliasList { +public: CExoAliasListInternal * m_pcExoAliasListInternal; CExoAliasList(); diff --git a/NWNXLib/API/API/CExoArrayList.hpp b/NWNXLib/API/API/CExoArrayList.hpp index bd0e622a40c..90d482bf91e 100644 --- a/NWNXLib/API/API/CExoArrayList.hpp +++ b/NWNXLib/API/API/CExoArrayList.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CExoArrayList) typedef int BOOL; // NOTE: Manually implemented for now.. -template struct CExoArrayList +template class CExoArrayList { +public: T * element; int32_t num; int32_t array_size; diff --git a/NWNXLib/API/API/CExoBase.hpp b/NWNXLib/API/API/CExoBase.hpp index ed00ae986aa..02a58dd9cf8 100644 --- a/NWNXLib/API/API/CExoBase.hpp +++ b/NWNXLib/API/API/CExoBase.hpp @@ -10,22 +10,23 @@ NWN_API_PROLOGUE(CExoBase) #endif -struct CExoAliasList; -struct CExoBaseInternal; -struct CExoConfig; -struct CExoDebug; -struct CExoIdentity; -struct CExoIni; -struct CExoRand; -struct CExoTimers; +class CExoAliasList; +class CExoBaseInternal; +class CExoConfig; +class CExoDebug; +class CExoIdentity; +class CExoIni; +class CExoRand; +class CExoTimers; typedef int BOOL; typedef uint16_t RESTYPE; -struct CExoBase +class CExoBase { +public: CExoConfig * m_pcExoConfig; CExoIni * m_pcExoIni; CExoTimers * m_pcExoTimers; diff --git a/NWNXLib/API/API/CExoBaseInternal.hpp b/NWNXLib/API/API/CExoBaseInternal.hpp index ecbcedbd7e1..a265a63943e 100644 --- a/NWNXLib/API/API/CExoBaseInternal.hpp +++ b/NWNXLib/API/API/CExoBaseInternal.hpp @@ -16,8 +16,9 @@ typedef int BOOL; typedef uint16_t RESTYPE; -struct CExoBaseInternal +class CExoBaseInternal { +public: int32_t m_nResTypes; RESTYPE * m_pnResTypes; CExoString * m_psResTypeNames; diff --git a/NWNXLib/API/API/CExoCriticalSection.hpp b/NWNXLib/API/API/CExoCriticalSection.hpp index 52162b241ac..d7003e06c6f 100644 --- a/NWNXLib/API/API/CExoCriticalSection.hpp +++ b/NWNXLib/API/API/CExoCriticalSection.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CExoCriticalSection) #endif -struct CExoCriticalSectionInternal; +class CExoCriticalSectionInternal; -struct CExoCriticalSection +class CExoCriticalSection { +public: CExoCriticalSectionInternal * m_pcExoCriticalSectionInternal; CExoCriticalSection(); diff --git a/NWNXLib/API/API/CExoDebug.hpp b/NWNXLib/API/API/CExoDebug.hpp index ed596cf5b1a..949d5d6367f 100644 --- a/NWNXLib/API/API/CExoDebug.hpp +++ b/NWNXLib/API/API/CExoDebug.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CExoDebug) #endif -struct CExoDebugInternal; +class CExoDebugInternal; typedef int BOOL; -struct CExoDebug +class CExoDebug { +public: CExoString m_sLogString; CExoDebugInternal * m_pcExoDebugInternal; diff --git a/NWNXLib/API/API/CExoDebugInternal.hpp b/NWNXLib/API/API/CExoDebugInternal.hpp index ba2ba74a929..d3e64659f3f 100644 --- a/NWNXLib/API/API/CExoDebugInternal.hpp +++ b/NWNXLib/API/API/CExoDebugInternal.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CExoDebugInternal) #endif -struct CExoFile; +class CExoFile; typedef int BOOL; -struct CExoDebugInternal +class CExoDebugInternal { +public: BOOL m_bFilesOpen; CExoFile * m_pLogFile; CExoFile * m_pErrorFile; diff --git a/NWNXLib/API/API/CExoEncapsulatedFile.hpp b/NWNXLib/API/API/CExoEncapsulatedFile.hpp index ac00950e550..a52cc2e5ff0 100644 --- a/NWNXLib/API/API/CExoEncapsulatedFile.hpp +++ b/NWNXLib/API/API/CExoEncapsulatedFile.hpp @@ -10,15 +10,16 @@ NWN_API_PROLOGUE(CExoEncapsulatedFile) #endif -struct ENCAPSULATED_HEADER; -struct ENCAPSULATED_RESLISTENTRY_E1; +class ENCAPSULATED_HEADER; +class ENCAPSULATED_RESLISTENTRY_E1; typedef int BOOL; -struct CExoEncapsulatedFile : CExoPackedFile +class CExoEncapsulatedFile : public CExoPackedFile { +public: CExoLocString m_lsDescription; ENCAPSULATED_HEADER * m_pEncapsulatedHeader; ENCAPSULATED_RESLISTENTRY_E1 * m_pResListEntry; diff --git a/NWNXLib/API/API/CExoEncrypt.hpp b/NWNXLib/API/API/CExoEncrypt.hpp index ddcc10d0fc9..9ff260e82eb 100644 --- a/NWNXLib/API/API/CExoEncrypt.hpp +++ b/NWNXLib/API/API/CExoEncrypt.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CExoEncrypt) -struct CExoEncrypt +class CExoEncrypt { +public: uint32_t m_anI[2]; uint32_t m_aBuf[4]; uint8_t m_aIn[128]; diff --git a/NWNXLib/API/API/CExoFile.hpp b/NWNXLib/API/API/CExoFile.hpp index f8d7e7a5f62..110ac273229 100644 --- a/NWNXLib/API/API/CExoFile.hpp +++ b/NWNXLib/API/API/CExoFile.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CExoFile) #endif -struct CExoFileInternal; -struct CExoString; +class CExoFileInternal; +class CExoString; typedef int BOOL; typedef uint16_t RESTYPE; -struct CExoFile +class CExoFile { +public: CExoFileInternal * m_pcExoFileInternal; CExoFile(const CExoString & fileName, const CExoString & mode); diff --git a/NWNXLib/API/API/CExoIni.hpp b/NWNXLib/API/API/CExoIni.hpp index 9f575133539..88f0ce1cea0 100644 --- a/NWNXLib/API/API/CExoIni.hpp +++ b/NWNXLib/API/API/CExoIni.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CExoIni) #endif -struct CExoIniInternal; +class CExoIniInternal; typedef int BOOL; -struct CExoIni +class CExoIni { +public: CExoIniInternal * m_pcExoIniInternal; CExoIni(CExoString sUserDirectory); diff --git a/NWNXLib/API/API/CExoIniInternal.hpp b/NWNXLib/API/API/CExoIniInternal.hpp index ad8f3dda9b1..8091836f9c7 100644 --- a/NWNXLib/API/API/CExoIniInternal.hpp +++ b/NWNXLib/API/API/CExoIniInternal.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CExoIniInternal) typedef int BOOL; -struct CExoIniInternal +class CExoIniInternal { +public: CExoString * m_pFileNames; CExoIniInternal(CExoString sUserDirectory); diff --git a/NWNXLib/API/API/CExoInputClass.hpp b/NWNXLib/API/API/CExoInputClass.hpp index e7d41002eaa..89720cc5dd7 100644 --- a/NWNXLib/API/API/CExoInputClass.hpp +++ b/NWNXLib/API/API/CExoInputClass.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CExoInputClass) -struct CExoInputClass +class CExoInputClass { +public: CExoString m_Label; CExoLinkedList * m_pUnassignedInputEventDescList; CExoLinkedList * m_pInputEventDescList; diff --git a/NWNXLib/API/API/CExoInputEvent.hpp b/NWNXLib/API/API/CExoInputEvent.hpp index 3d2bebf8542..31261f3f5c0 100644 --- a/NWNXLib/API/API/CExoInputEvent.hpp +++ b/NWNXLib/API/API/CExoInputEvent.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CExoInputEvent) #endif -struct CExoInputEventDesc; +class CExoInputEventDesc; -struct CExoInputEvent +class CExoInputEvent { +public: uint32_t m_nValue; uint32_t m_nTimeStamp; uint32_t m_nSequenceNumber; diff --git a/NWNXLib/API/API/CExoInputEventDesc.hpp b/NWNXLib/API/API/CExoInputEventDesc.hpp index 991efd622c9..3f947630161 100644 --- a/NWNXLib/API/API/CExoInputEventDesc.hpp +++ b/NWNXLib/API/API/CExoInputEventDesc.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CExoInputEventDesc) -struct CExoInputEventDesc +class CExoInputEventDesc { +public: CExoString m_Label; uint32_t m_nID; int32_t m_nInputDeviceType; diff --git a/NWNXLib/API/API/CExoKeyTable.hpp b/NWNXLib/API/API/CExoKeyTable.hpp index 2a0ed4f993a..afe35108c71 100644 --- a/NWNXLib/API/API/CExoKeyTable.hpp +++ b/NWNXLib/API/API/CExoKeyTable.hpp @@ -11,19 +11,20 @@ NWN_API_PROLOGUE(CExoKeyTable) #endif -struct CExoPackedFile; -struct CExoStringList; -struct CKeyTableEntry; -struct CRes; -struct CResRef; +class CExoPackedFile; +class CExoStringList; +class CKeyTableEntry; +class CRes; +class CResRef; typedef int BOOL; typedef uint16_t RESTYPE; -struct CExoKeyTable +class CExoKeyTable { +public: BOOL m_bLoaded; BOOL m_bExcludeFromSearches; uint32_t m_nTableEntries; diff --git a/NWNXLib/API/API/CExoLinkedList.hpp b/NWNXLib/API/API/CExoLinkedList.hpp index c391793ae42..2de2ecb8375 100644 --- a/NWNXLib/API/API/CExoLinkedList.hpp +++ b/NWNXLib/API/API/CExoLinkedList.hpp @@ -14,8 +14,9 @@ typedef CExoLinkedListNode * CExoLinkedListPosition; // NOTE: Manually implemented for now.. -template struct CExoLinkedList +template class CExoLinkedList { +public: CExoLinkedListInternal * m_pcExoLinkedListInternal; CExoLinkedList() diff --git a/NWNXLib/API/API/CExoLinkedListInternal.hpp b/NWNXLib/API/API/CExoLinkedListInternal.hpp index e746aa8da8e..3d4754ebdd6 100644 --- a/NWNXLib/API/API/CExoLinkedListInternal.hpp +++ b/NWNXLib/API/API/CExoLinkedListInternal.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CExoLinkedListInternal) typedef CExoLinkedListNode * CExoLinkedListPosition; -struct CExoLinkedListInternal +class CExoLinkedListInternal { +public: CExoLinkedListPosition pHead; CExoLinkedListPosition pTail; uint32_t m_nCount; diff --git a/NWNXLib/API/API/CExoLinkedListNode.hpp b/NWNXLib/API/API/CExoLinkedListNode.hpp index 99ebbba0c97..377d01c4a0c 100644 --- a/NWNXLib/API/API/CExoLinkedListNode.hpp +++ b/NWNXLib/API/API/CExoLinkedListNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CExoLinkedListNode) typedef CExoLinkedListNode * CExoLinkedListPosition; -struct CExoLinkedListNode +class CExoLinkedListNode { +public: CExoLinkedListPosition pPrev; CExoLinkedListPosition pNext; void * pObject; diff --git a/NWNXLib/API/API/CExoLocString.hpp b/NWNXLib/API/API/CExoLocString.hpp index 25f28821bcb..f119215e03b 100644 --- a/NWNXLib/API/API/CExoLocString.hpp +++ b/NWNXLib/API/API/CExoLocString.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CExoLocString) #endif -struct CExoLocStringInternal; +class CExoLocStringInternal; typedef int BOOL; typedef uint32_t STRREF; -struct CExoLocString +class CExoLocString { +public: CExoLocStringInternal * m_pExoLocStringInternal; STRREF m_dwStringRef; diff --git a/NWNXLib/API/API/CExoLocStringInternal.hpp b/NWNXLib/API/API/CExoLocStringInternal.hpp index 30cce540bbe..e61c94c6fca 100644 --- a/NWNXLib/API/API/CExoLocStringInternal.hpp +++ b/NWNXLib/API/API/CExoLocStringInternal.hpp @@ -10,14 +10,15 @@ NWN_API_PROLOGUE(CExoLocStringInternal) #endif -struct CExoLocString; +class CExoLocString; typedef int BOOL; -struct CExoLocStringInternal +class CExoLocStringInternal { +public: CExoLinkedList m_lstString; uint32_t m_nStringCount; diff --git a/NWNXLib/API/API/CExoPackedFile.hpp b/NWNXLib/API/API/CExoPackedFile.hpp index f7abe64da14..9111c91801a 100644 --- a/NWNXLib/API/API/CExoPackedFile.hpp +++ b/NWNXLib/API/API/CExoPackedFile.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CExoPackedFile) #endif -struct CExoFile; +class CExoFile; typedef int BOOL; -struct CExoPackedFile +class CExoPackedFile { +public: CExoString m_sFileName; uint16_t m_wDrives; uint32_t m_nFileSize; diff --git a/NWNXLib/API/API/CExoRand.hpp b/NWNXLib/API/API/CExoRand.hpp index 8eeda6c5700..02c51c247c3 100644 --- a/NWNXLib/API/API/CExoRand.hpp +++ b/NWNXLib/API/API/CExoRand.hpp @@ -8,13 +8,14 @@ NWN_API_PROLOGUE(CExoRand) #endif -struct CExoRandInternal; +class CExoRandInternal; -struct CExoRand +class CExoRand { +public: CExoRandInternal * m_pcExoRandInternal; CExoRand(); diff --git a/NWNXLib/API/API/CExoRandInternal.hpp b/NWNXLib/API/API/CExoRandInternal.hpp index 715295af900..99ff97d16f4 100644 --- a/NWNXLib/API/API/CExoRandInternal.hpp +++ b/NWNXLib/API/API/CExoRandInternal.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CExoRandInternal) typedef int BOOL; -struct CExoRandInternal +class CExoRandInternal { +public: uint32_t m_s1; uint32_t m_s2; uint32_t m_s3; diff --git a/NWNXLib/API/API/CExoResFile.hpp b/NWNXLib/API/API/CExoResFile.hpp index 43258772fbe..2b74c6e05f3 100644 --- a/NWNXLib/API/API/CExoResFile.hpp +++ b/NWNXLib/API/API/CExoResFile.hpp @@ -9,8 +9,8 @@ NWN_API_PROLOGUE(CExoResFile) #endif -struct BIFFFILE_HEADER; -struct BIFFFILE_VARRESENTRY_E1; +class BIFFFILE_HEADER; +class BIFFFILE_VARRESENTRY_E1; typedef int BOOL; @@ -21,8 +21,9 @@ enum BIFFFILE_Version BIFFFILE_V1, BIFFFILE_E1 }; -struct CExoResFile : CExoPackedFile +class CExoResFile : public CExoPackedFile { +public: BIFFFILE_Version m_nVersion; BIFFFILE_HEADER * m_pBiffHeader; BIFFFILE_VARRESENTRY_E1 * m_pBiffVarResEntry; diff --git a/NWNXLib/API/API/CExoResMan.hpp b/NWNXLib/API/API/CExoResMan.hpp index f189911265a..fcb8083dbef 100644 --- a/NWNXLib/API/API/CExoResMan.hpp +++ b/NWNXLib/API/API/CExoResMan.hpp @@ -16,18 +16,19 @@ NWN_API_PROLOGUE(CExoResMan) #endif -struct CExoFile; -struct CExoKeyTable; -struct CExoKeyTable; -struct CExoStringList; -struct CKeyTableEntry; +class CExoFile; +class CExoKeyTable; +class CExoKeyTable; +class CExoStringList; +class CKeyTableEntry; typedef int BOOL; typedef uint16_t RESTYPE; -struct CExoResMan +class CExoResMan { +public: int64_t m_nTotalPhysicalMemory; int64_t m_nTotalAvailableMemory; int64_t m_nAvailableMemory; diff --git a/NWNXLib/API/API/CExoResourceImageFile.hpp b/NWNXLib/API/API/CExoResourceImageFile.hpp index 49cb47a56dc..cb7ee49eec0 100644 --- a/NWNXLib/API/API/CExoResourceImageFile.hpp +++ b/NWNXLib/API/API/CExoResourceImageFile.hpp @@ -10,15 +10,16 @@ NWN_API_PROLOGUE(CExoResourceImageFile) #endif -struct ENCAPSULATED_HEADER; -struct ENCAPSULATED_RESLISTENTRY; +class ENCAPSULATED_HEADER; +class ENCAPSULATED_RESLISTENTRY; typedef int BOOL; -struct CExoResourceImageFile : CExoPackedFile +class CExoResourceImageFile : public CExoPackedFile { +public: uint8_t * m_pResourceImage; CExoResourceImageFile(); diff --git a/NWNXLib/API/API/CExoString.hpp b/NWNXLib/API/API/CExoString.hpp index 546adfcdd84..c0f70b0b423 100644 --- a/NWNXLib/API/API/CExoString.hpp +++ b/NWNXLib/API/API/CExoString.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CExoString) #endif -struct CResRef; +class CResRef; typedef int BOOL; -struct CExoString +class CExoString { +public: char * m_sString; uint32_t m_nBufferLength; diff --git a/NWNXLib/API/API/CExoStringList.hpp b/NWNXLib/API/API/CExoStringList.hpp index 892d9d7fb90..ae7187e7285 100644 --- a/NWNXLib/API/API/CExoStringList.hpp +++ b/NWNXLib/API/API/CExoStringList.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CExoStringList) #endif -struct CExoString; +class CExoString; -struct CExoStringList +class CExoStringList { +public: CExoString * * m_pStrings; int32_t m_nCount; int32_t m_nDuplicates; diff --git a/NWNXLib/API/API/CExoTimers.hpp b/NWNXLib/API/API/CExoTimers.hpp index 6fa8d78d70c..9253685e09d 100644 --- a/NWNXLib/API/API/CExoTimers.hpp +++ b/NWNXLib/API/API/CExoTimers.hpp @@ -7,14 +7,15 @@ NWN_API_PROLOGUE(CExoTimers) #endif -struct CExoTimersInternal; +class CExoTimersInternal; typedef int BOOL; -struct CExoTimers +class CExoTimers { +public: CExoTimersInternal * m_pcExoTimersInternal; CExoTimers(); diff --git a/NWNXLib/API/API/CExoTimersInternal.hpp b/NWNXLib/API/API/CExoTimersInternal.hpp index eafc541eafb..0e252d19199 100644 --- a/NWNXLib/API/API/CExoTimersInternal.hpp +++ b/NWNXLib/API/API/CExoTimersInternal.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CExoTimersInternal) typedef int BOOL; -struct CExoTimersInternal +class CExoTimersInternal { +public: BOOL m_bQPCActive; BOOL m_bQPCAlgorithm2; uint64_t m_nQPFrequency; diff --git a/NWNXLib/API/API/CExtendedServerInfo.hpp b/NWNXLib/API/API/CExtendedServerInfo.hpp index 44712a8ef31..34d8ea2ef9f 100644 --- a/NWNXLib/API/API/CExtendedServerInfo.hpp +++ b/NWNXLib/API/API/CExtendedServerInfo.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CExtendedServerInfo) typedef int BOOL; -struct CExtendedServerInfo +class CExtendedServerInfo { +public: BOOL m_bPasswordRequired; uint8_t m_nMinLevel; uint8_t m_nMaxLevel; diff --git a/NWNXLib/API/API/CFactionManager.hpp b/NWNXLib/API/API/CFactionManager.hpp index b4cbfba0452..06be5894668 100644 --- a/NWNXLib/API/API/CFactionManager.hpp +++ b/NWNXLib/API/API/CFactionManager.hpp @@ -8,18 +8,19 @@ NWN_API_PROLOGUE(CFactionManager) #endif -struct CExoString; -struct CNWSFaction; -struct CNWSFaction; -struct CResGFF; -struct CResList; +class CExoString; +class CNWSFaction; +class CNWSFaction; +class CResGFF; +class CResList; typedef int BOOL; -struct CFactionManager +class CFactionManager { +public: CNWSFaction * m_pDefaultFactionDefender; CNWSFaction * m_pDefaultFactionCommoner; CNWSFaction * m_pDefaultFactionMerchant; diff --git a/NWNXLib/API/API/CFeatUseListEntry.hpp b/NWNXLib/API/API/CFeatUseListEntry.hpp index 4086fccb859..d52dd33a047 100644 --- a/NWNXLib/API/API/CFeatUseListEntry.hpp +++ b/NWNXLib/API/API/CFeatUseListEntry.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CFeatUseListEntry) -struct CFeatUseListEntry +class CFeatUseListEntry { +public: uint16_t m_nFeat; uint8_t m_nUsedToday; diff --git a/NWNXLib/API/API/CFileInfo.hpp b/NWNXLib/API/API/CFileInfo.hpp index cf48c64fd3f..5c1cc4e7cab 100644 --- a/NWNXLib/API/API/CFileInfo.hpp +++ b/NWNXLib/API/API/CFileInfo.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CFileInfo) -struct CFileInfo +class CFileInfo { +public: CExoString sFileName; uint16_t nYear; uint16_t nMonth; diff --git a/NWNXLib/API/API/CGameEffect.hpp b/NWNXLib/API/API/CGameEffect.hpp index 91cc2795309..a6dab1df203 100644 --- a/NWNXLib/API/API/CGameEffect.hpp +++ b/NWNXLib/API/API/CGameEffect.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CGameEffect) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CGameEffect +class CGameEffect { +public: uint64_t m_nID; uint16_t m_nType; uint16_t m_nSubType; diff --git a/NWNXLib/API/API/CGameEffectApplierRemover.hpp b/NWNXLib/API/API/CGameEffectApplierRemover.hpp index ffa8faa110b..b950b21d09e 100644 --- a/NWNXLib/API/API/CGameEffectApplierRemover.hpp +++ b/NWNXLib/API/API/CGameEffectApplierRemover.hpp @@ -7,16 +7,16 @@ NWN_API_PROLOGUE(CGameEffectApplierRemover) #endif -struct CGameEffect; -struct CNWSObject; +class CGameEffect; +class CNWSObject; typedef int BOOL; -struct CGameEffectApplierRemover +class CGameEffectApplierRemover { - +public: virtual ~CGameEffectApplierRemover(); virtual void InitializeEffects(); virtual int32_t OnEffectApplied(CNWSObject * object, CGameEffect * effect, BOOL bLoadingGame = false); diff --git a/NWNXLib/API/API/CGameObject.hpp b/NWNXLib/API/API/CGameObject.hpp index 12d9cf03c3d..f84955ee18a 100644 --- a/NWNXLib/API/API/CGameObject.hpp +++ b/NWNXLib/API/API/CGameObject.hpp @@ -13,39 +13,40 @@ NWN_API_PROLOGUE(CGameObject) #endif -struct CNWCArea; -struct CNWCAreaOfEffectObject; -struct CNWCCreature; -struct CNWCDoor; -struct CNWCItem; -struct CNWCModule; -struct CNWCObject; -struct CNWCPlaceable; -struct CNWCProjectile; -struct CNWCSoundObject; -struct CNWCStore; -struct CNWCTrigger; -struct CNWSArea; -struct CNWSAreaOfEffectObject; -struct CNWSCreature; -struct CNWSDoor; -struct CNWSEncounter; -struct CNWSItem; -struct CNWSModule; -struct CNWSObject; -struct CNWSPlaceable; -struct CNWSPlayerTURD; -struct CNWSSoundObject; -struct CNWSStore; -struct CNWSTrigger; -struct CNWSWaypoint; +class CNWCArea; +class CNWCAreaOfEffectObject; +class CNWCCreature; +class CNWCDoor; +class CNWCItem; +class CNWCModule; +class CNWCObject; +class CNWCPlaceable; +class CNWCProjectile; +class CNWCSoundObject; +class CNWCStore; +class CNWCTrigger; +class CNWSArea; +class CNWSAreaOfEffectObject; +class CNWSCreature; +class CNWSDoor; +class CNWSEncounter; +class CNWSItem; +class CNWSModule; +class CNWSObject; +class CNWSPlaceable; +class CNWSPlayerTURD; +class CNWSSoundObject; +class CNWSStore; +class CNWSTrigger; +class CNWSWaypoint; typedef uint32_t OBJECT_ID; -struct CGameObject : CCallbackHandlerBase +class CGameObject : public CCallbackHandlerBase { +public: OBJECT_ID m_idSelf; uint8_t m_nObjectType; void * m_pNwnxData; diff --git a/NWNXLib/API/API/CGameObjectArray.hpp b/NWNXLib/API/API/CGameObjectArray.hpp index d99bb242297..e09a84ff891 100644 --- a/NWNXLib/API/API/CGameObjectArray.hpp +++ b/NWNXLib/API/API/CGameObjectArray.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CGameObjectArray) #endif -struct CGameObject; -struct CGameObjectArrayNode; +class CGameObject; +class CGameObjectArrayNode; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CGameObjectArray +class CGameObjectArray { +public: CGameObjectArrayNode * * m_pArray; uint32_t m_nNextObjectArrayID[2]; uint32_t m_nNextCharArrayID[2]; diff --git a/NWNXLib/API/API/CGameObjectArrayNode.hpp b/NWNXLib/API/API/CGameObjectArrayNode.hpp index 8c8c7d36cfa..3d7417bfde4 100644 --- a/NWNXLib/API/API/CGameObjectArrayNode.hpp +++ b/NWNXLib/API/API/CGameObjectArrayNode.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CGameObjectArrayNode) #endif -struct CGameObject; +class CGameObject; -struct CGameObjectArrayNode +class CGameObjectArrayNode { +public: uint32_t m_objectId; CGameObject * m_objectPtr; CGameObjectArrayNode * m_nextNode; diff --git a/NWNXLib/API/API/CItemPropertyApplierRemover.hpp b/NWNXLib/API/API/CItemPropertyApplierRemover.hpp index 7d602fb7b38..da3819c3935 100644 --- a/NWNXLib/API/API/CItemPropertyApplierRemover.hpp +++ b/NWNXLib/API/API/CItemPropertyApplierRemover.hpp @@ -7,17 +7,17 @@ NWN_API_PROLOGUE(CItemPropertyApplierRemover) #endif -struct CNWItemProperty; -struct CNWSCreature; -struct CNWSItem; +class CNWItemProperty; +class CNWSCreature; +class CNWSItem; typedef int BOOL; -struct CItemPropertyApplierRemover +class CItemPropertyApplierRemover { - +public: virtual ~CItemPropertyApplierRemover(); virtual void InitializeItemProperties(); virtual int32_t OnItemPropertyApplied(CNWSItem * pItem, CNWItemProperty * pItemProperty, CNWSCreature * pTargetCreature, uint32_t nTargetInventorySlot, BOOL bLoadingGame); diff --git a/NWNXLib/API/API/CItemRepository.hpp b/NWNXLib/API/API/CItemRepository.hpp index 6b9c8c216d4..3dfe773067a 100644 --- a/NWNXLib/API/API/CItemRepository.hpp +++ b/NWNXLib/API/API/CItemRepository.hpp @@ -8,8 +8,8 @@ NWN_API_PROLOGUE(CItemRepository) #endif -struct CExoString; -struct CNWSItem; +class CExoString; +class CNWSItem; typedef int BOOL; @@ -17,8 +17,9 @@ typedef CExoLinkedListNode * CExoLinkedListPosition; typedef uint32_t OBJECT_ID; -struct CItemRepository +class CItemRepository { +public: uint8_t m_nWidth; uint8_t m_nHeight; uint32_t m_nBoundary; diff --git a/NWNXLib/API/API/CJoiningRestrictions.hpp b/NWNXLib/API/API/CJoiningRestrictions.hpp index c0176616cc8..4d2c3b68164 100644 --- a/NWNXLib/API/API/CJoiningRestrictions.hpp +++ b/NWNXLib/API/API/CJoiningRestrictions.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CJoiningRestrictions) typedef int BOOL; -struct CJoiningRestrictions +class CJoiningRestrictions { +public: BOOL bAllowLocal; BOOL bAllowServer; BOOL bAllowVault; diff --git a/NWNXLib/API/API/CKeyTableEntry.hpp b/NWNXLib/API/API/CKeyTableEntry.hpp index 2f5f60e5fe0..994acd101dc 100644 --- a/NWNXLib/API/API/CKeyTableEntry.hpp +++ b/NWNXLib/API/API/CKeyTableEntry.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CKeyTableEntry) #endif -struct CRes; +class CRes; typedef uint16_t RESTYPE; -struct CKeyTableEntry +class CKeyTableEntry { +public: CResRef m_cResRef; CRes * m_pRes; RESID m_nID; diff --git a/NWNXLib/API/API/CKeyTableInfo.hpp b/NWNXLib/API/API/CKeyTableInfo.hpp index e4cce161a00..99137d5492e 100644 --- a/NWNXLib/API/API/CKeyTableInfo.hpp +++ b/NWNXLib/API/API/CKeyTableInfo.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CKeyTableInfo) #endif -struct CExoFile; -struct KEYFILE_RESFILENAME; +class CExoFile; +class KEYFILE_RESFILENAME; -struct CKeyTableInfo +class CKeyTableInfo { +public: CExoString m_sName; CExoFile * m_pFile; KEYFILE_HEADER m_header; diff --git a/NWNXLib/API/API/CLastUpdateObject.hpp b/NWNXLib/API/API/CLastUpdateObject.hpp index b2b841a2189..7008dc8413f 100644 --- a/NWNXLib/API/API/CLastUpdateObject.hpp +++ b/NWNXLib/API/API/CLastUpdateObject.hpp @@ -16,9 +16,9 @@ NWN_API_PROLOGUE(CLastUpdateObject) #endif -struct CLoopingVisualEffect; -struct CNWSPlayerLUOQuickbarItemButton; -struct ObjectVisualTransformData; +class CLoopingVisualEffect; +class CNWSPlayerLUOQuickbarItemButton; +class ObjectVisualTransformData; typedef TextureReplaceInfo AnimationReplaceInfo; @@ -26,8 +26,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CLastUpdateObject +class CLastUpdateObject { +public: CNWSPlayerLUOAppearanceInfo m_cAppearance; BOOL m_bActive; uint8_t m_nObjectType; diff --git a/NWNXLib/API/API/CLastUpdatePartyObject.hpp b/NWNXLib/API/API/CLastUpdatePartyObject.hpp index 6a4938aa477..d8f5dfeb960 100644 --- a/NWNXLib/API/API/CLastUpdatePartyObject.hpp +++ b/NWNXLib/API/API/CLastUpdatePartyObject.hpp @@ -15,8 +15,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CLastUpdatePartyObject +class CLastUpdatePartyObject { +public: CResRef m_cPortrait; uint16_t m_nPortraitId; BOOL m_bActive; diff --git a/NWNXLib/API/API/CLoopingVisualEffect.hpp b/NWNXLib/API/API/CLoopingVisualEffect.hpp index 3abae6aa8d5..9aa3a0eaba7 100644 --- a/NWNXLib/API/API/CLoopingVisualEffect.hpp +++ b/NWNXLib/API/API/CLoopingVisualEffect.hpp @@ -14,8 +14,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CLoopingVisualEffect +class CLoopingVisualEffect { +public: uint16_t m_nId; OBJECT_ID m_oOriginator; uint8_t m_nBodyPart; diff --git a/NWNXLib/API/API/CNWActionNode.hpp b/NWNXLib/API/API/CNWActionNode.hpp index 0afb635b837..523ebb7535d 100644 --- a/NWNXLib/API/API/CNWActionNode.hpp +++ b/NWNXLib/API/API/CNWActionNode.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWActionNode) typedef uint32_t OBJECT_ID; -struct CNWActionNode +class CNWActionNode { +public: uint16_t nGroupId; uint16_t nActionId; uint16_t nSpecialAttackId; diff --git a/NWNXLib/API/API/CNWAmbientSound.hpp b/NWNXLib/API/API/CNWAmbientSound.hpp index 440203f6d22..31969d371ba 100644 --- a/NWNXLib/API/API/CNWAmbientSound.hpp +++ b/NWNXLib/API/API/CNWAmbientSound.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWAmbientSound) typedef int BOOL; -struct CNWAmbientSound +class CNWAmbientSound { +public: BOOL m_bMusicPlaying; int32_t m_nMusicDelay; int32_t m_nMusicDayTrack; diff --git a/NWNXLib/API/API/CNWArea.hpp b/NWNXLib/API/API/CNWArea.hpp index 1b3605059cd..ff37155150f 100644 --- a/NWNXLib/API/API/CNWArea.hpp +++ b/NWNXLib/API/API/CNWArea.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CNWArea) #endif -struct CGameObject; -struct CPathfindInformation; +class CGameObject; +class CPathfindInformation; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWArea +class CNWArea { +public: uint32_t m_nFlags; int32_t m_nWidth; int32_t m_nHeight; diff --git a/NWNXLib/API/API/CNWBaseItem.hpp b/NWNXLib/API/API/CNWBaseItem.hpp index 2334b3ea9ce..99d16be75dd 100644 --- a/NWNXLib/API/API/CNWBaseItem.hpp +++ b/NWNXLib/API/API/CNWBaseItem.hpp @@ -15,8 +15,9 @@ typedef int BOOL; typedef uint32_t STRREF; -struct CNWBaseItem +class CNWBaseItem { +public: uint32_t m_nName; uint32_t m_nEquipableSlots; uint8_t m_nWeaponWield; diff --git a/NWNXLib/API/API/CNWBaseItemArray.hpp b/NWNXLib/API/API/CNWBaseItemArray.hpp index e7ffc7b3744..4aee8c53889 100644 --- a/NWNXLib/API/API/CNWBaseItemArray.hpp +++ b/NWNXLib/API/API/CNWBaseItemArray.hpp @@ -7,14 +7,15 @@ NWN_API_PROLOGUE(CNWBaseItemArray) #endif -struct CNWBaseItem; +class CNWBaseItem; typedef int BOOL; -struct CNWBaseItemArray +class CNWBaseItemArray { +public: int32_t m_nNumBaseItems; CNWBaseItem * m_pBaseItems; diff --git a/NWNXLib/API/API/CNWCCMessageData.hpp b/NWNXLib/API/API/CNWCCMessageData.hpp index d554d4f010e..3d3991c43bd 100644 --- a/NWNXLib/API/API/CNWCCMessageData.hpp +++ b/NWNXLib/API/API/CNWCCMessageData.hpp @@ -9,15 +9,16 @@ NWN_API_PROLOGUE(CNWCCMessageData) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef uint32_t OBJECT_ID; -struct CNWCCMessageData +class CNWCCMessageData { +public: uint8_t m_nType; CExoArrayList m_nParamInteger; CExoArrayList m_nParamFloat; diff --git a/NWNXLib/API/API/CNWCSync.hpp b/NWNXLib/API/API/CNWCSync.hpp index 8fbdf49adfb..763ce60acb3 100644 --- a/NWNXLib/API/API/CNWCSync.hpp +++ b/NWNXLib/API/API/CNWCSync.hpp @@ -12,10 +12,13 @@ namespace NWSync { NWN_API_PROLOGUE(CNWCSync) #endif -struct CNWCSyncInternal; +class CNWCSyncInternal; -struct CNWCSync : InstanceLookup::List { - struct Progress { +class CNWCSync : public InstanceLookup::List +{ +public: + class Progress { + public: int m_currentState; CExoString m_currentStateMessage; int m_currentStatePercentage; diff --git a/NWNXLib/API/API/CNWClass.hpp b/NWNXLib/API/API/CNWClass.hpp index 24a434fffdd..c735e850244 100644 --- a/NWNXLib/API/API/CNWClass.hpp +++ b/NWNXLib/API/API/CNWClass.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CNWClass) #endif -struct CNWClass_Feat; -struct CNWClass_Skill; -struct CNWRules; +class CNWClass_Feat; +class CNWClass_Skill; +class CNWRules; typedef int BOOL; -struct CNWClass +class CNWClass { +public: uint32_t m_nName; uint32_t m_nShort; uint32_t m_nNameLower; diff --git a/NWNXLib/API/API/CNWClass_Feat.hpp b/NWNXLib/API/API/CNWClass_Feat.hpp index 44eabe2d7ad..4d6640867e8 100644 --- a/NWNXLib/API/API/CNWClass_Feat.hpp +++ b/NWNXLib/API/API/CNWClass_Feat.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWClass_Feat) typedef int BOOL; -struct CNWClass_Feat +class CNWClass_Feat { +public: uint16_t nFeat; uint8_t nLevelGranted; uint8_t nListType; diff --git a/NWNXLib/API/API/CNWClass_Skill.hpp b/NWNXLib/API/API/CNWClass_Skill.hpp index 4bf1125d97d..5ea30d8ecfd 100644 --- a/NWNXLib/API/API/CNWClass_Skill.hpp +++ b/NWNXLib/API/API/CNWClass_Skill.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWClass_Skill) typedef int BOOL; -struct CNWClass_Skill +class CNWClass_Skill { +public: uint16_t nSkill; BOOL bClassSkill; diff --git a/NWNXLib/API/API/CNWCreatureStatsUpdate.hpp b/NWNXLib/API/API/CNWCreatureStatsUpdate.hpp index b9d2e19d7ff..22b8fc7c9d7 100644 --- a/NWNXLib/API/API/CNWCreatureStatsUpdate.hpp +++ b/NWNXLib/API/API/CNWCreatureStatsUpdate.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CNWCreatureStatsUpdate) #endif -struct CCombatInformation; -struct CEffectIconObject; +class CCombatInformation; +class CEffectIconObject; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWCreatureStatsUpdate +class CNWCreatureStatsUpdate { +public: CExoArrayList m_lstFeats; CExoArrayList m_lstBonusFeats; OBJECT_ID m_oidFeatUpdated; diff --git a/NWNXLib/API/API/CNWDomain.hpp b/NWNXLib/API/API/CNWDomain.hpp index 3d4d5094f2f..1f900722edc 100644 --- a/NWNXLib/API/API/CNWDomain.hpp +++ b/NWNXLib/API/API/CNWDomain.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWDomain) typedef int BOOL; -struct CNWDomain +class CNWDomain { +public: int32_t m_nNameStrref; int32_t m_nDescriptionStrref; CResRef m_cIcon; diff --git a/NWNXLib/API/API/CNWDoorSurfaceMesh.hpp b/NWNXLib/API/API/CNWDoorSurfaceMesh.hpp index e266462718c..17d0dbecae7 100644 --- a/NWNXLib/API/API/CNWDoorSurfaceMesh.hpp +++ b/NWNXLib/API/API/CNWDoorSurfaceMesh.hpp @@ -16,8 +16,9 @@ NWN_API_PROLOGUE(CNWDoorSurfaceMesh) typedef int BOOL; -struct CNWDoorSurfaceMesh : CResHelper +class CNWDoorSurfaceMesh : public CResHelper { +public: int32_t m_pnVertices[3]; float * m_ppfVertices[3]; int32_t m_pnTriangles[3]; diff --git a/NWNXLib/API/API/CNWFeat.hpp b/NWNXLib/API/API/CNWFeat.hpp index 25e9b4c025f..345fceae668 100644 --- a/NWNXLib/API/API/CNWFeat.hpp +++ b/NWNXLib/API/API/CNWFeat.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWFeat) typedef int BOOL; -struct CNWFeat +class CNWFeat { +public: int32_t m_nNameStrref; int32_t m_nDescriptionStrref; int32_t m_nTalentCategory; diff --git a/NWNXLib/API/API/CNWGridSearchPath.hpp b/NWNXLib/API/API/CNWGridSearchPath.hpp index bd9d5f6cc17..c3739e41f40 100644 --- a/NWNXLib/API/API/CNWGridSearchPath.hpp +++ b/NWNXLib/API/API/CNWGridSearchPath.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWGridSearchPath) -struct CNWGridSearchPath +class CNWGridSearchPath { +public: int32_t nDistance; int32_t nSteps; int32_t nLength; diff --git a/NWNXLib/API/API/CNWItem.hpp b/NWNXLib/API/API/CNWItem.hpp index 2df5d3fd672..3b76bef5377 100644 --- a/NWNXLib/API/API/CNWItem.hpp +++ b/NWNXLib/API/API/CNWItem.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWItem) -struct CNWItem +class CNWItem { +public: uint8_t m_nLayeredTextureColors[6]; uint8_t * m_pLayeredTextureColorsPerPart[6]; uint32_t m_nBaseItem; diff --git a/NWNXLib/API/API/CNWItemProperty.hpp b/NWNXLib/API/API/CNWItemProperty.hpp index 0538d516cf3..20cd98299f9 100644 --- a/NWNXLib/API/API/CNWItemProperty.hpp +++ b/NWNXLib/API/API/CNWItemProperty.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWItemProperty) typedef int BOOL; -struct CNWItemProperty +class CNWItemProperty { +public: uint16_t m_nPropertyName; uint16_t m_nSubType; uint8_t m_nCostTable; diff --git a/NWNXLib/API/API/CNWLevelStats.hpp b/NWNXLib/API/API/CNWLevelStats.hpp index 287b5e52ba9..edb4d101740 100644 --- a/NWNXLib/API/API/CNWLevelStats.hpp +++ b/NWNXLib/API/API/CNWLevelStats.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWLevelStats) typedef int BOOL; -struct CNWLevelStats +class CNWLevelStats { +public: CExoArrayList m_pAddedKnownSpellList[10]; CExoArrayList m_pRemovedKnownSpellList[10]; CExoArrayList m_lstFeats; diff --git a/NWNXLib/API/API/CNWMessage.hpp b/NWNXLib/API/API/CNWMessage.hpp index 4f7c201970f..b8951528ec1 100644 --- a/NWNXLib/API/API/CNWMessage.hpp +++ b/NWNXLib/API/API/CNWMessage.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWMessage) typedef int BOOL; -struct CNWMessage +class CNWMessage { +public: uint8_t * m_pnWriteBuffer; uint32_t m_nWriteBufferSize; uint32_t m_nWriteBufferPtr; diff --git a/NWNXLib/API/API/CNWNameGen.hpp b/NWNXLib/API/API/CNWNameGen.hpp index 93d2a8eede0..dfb272bcc81 100644 --- a/NWNXLib/API/API/CNWNameGen.hpp +++ b/NWNXLib/API/API/CNWNameGen.hpp @@ -15,8 +15,9 @@ NWN_API_PROLOGUE(CNWNameGen) typedef int BOOL; -struct CNWNameGen : CResHelper +class CNWNameGen : public CResHelper { +public: BOOL m_bLoaded; uint16_t m_nTableRace; uint8_t m_nTableNameType; diff --git a/NWNXLib/API/API/CNWPlaceMeshManager.hpp b/NWNXLib/API/API/CNWPlaceMeshManager.hpp index 64c1072e0f0..daba842da58 100644 --- a/NWNXLib/API/API/CNWPlaceMeshManager.hpp +++ b/NWNXLib/API/API/CNWPlaceMeshManager.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CNWPlaceMeshManager) #endif -struct CNWPlaceableSurfaceMesh; +class CNWPlaceableSurfaceMesh; -struct CNWPlaceMeshManager +class CNWPlaceMeshManager { +public: int32_t m_nArraySize; CNWPlaceableSurfaceMesh * * m_pSurfaceMeshLoaded; diff --git a/NWNXLib/API/API/CNWPlaceableSurfaceMesh.hpp b/NWNXLib/API/API/CNWPlaceableSurfaceMesh.hpp index 3cef432ee3e..df2a3174a2e 100644 --- a/NWNXLib/API/API/CNWPlaceableSurfaceMesh.hpp +++ b/NWNXLib/API/API/CNWPlaceableSurfaceMesh.hpp @@ -16,8 +16,9 @@ NWN_API_PROLOGUE(CNWPlaceableSurfaceMesh) typedef int BOOL; -struct CNWPlaceableSurfaceMesh : CResHelper +class CNWPlaceableSurfaceMesh : public CResHelper { +public: Vector * m_pvVertices; int32_t * m_pnTriangles; int32_t m_nTriangles; diff --git a/NWNXLib/API/API/CNWRace.hpp b/NWNXLib/API/API/CNWRace.hpp index f03a0630828..37d9b73b57d 100644 --- a/NWNXLib/API/API/CNWRace.hpp +++ b/NWNXLib/API/API/CNWRace.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWRace) typedef int BOOL; -struct CNWRace +class CNWRace { +public: int32_t m_nNameStrref; int32_t m_nConverNameStrref; int32_t m_nConverNameLowerStrref; diff --git a/NWNXLib/API/API/CNWRules.hpp b/NWNXLib/API/API/CNWRules.hpp index 42bccadd9c4..629a61c90eb 100644 --- a/NWNXLib/API/API/CNWRules.hpp +++ b/NWNXLib/API/API/CNWRules.hpp @@ -12,21 +12,22 @@ NWN_API_PROLOGUE(CNWRules) #endif -struct CNWBaseItemArray; -struct CNWClass; -struct CNWDomain; -struct CNWFeat; -struct CNWRace; -struct CNWSkill; -struct CNWSpellArray; -struct CTwoDimArrays; +class CNWBaseItemArray; +class CNWClass; +class CNWDomain; +class CNWFeat; +class CNWRace; +class CNWSkill; +class CNWSpellArray; +class CTwoDimArrays; typedef int BOOL; -struct CNWRules +class CNWRules { +public: float m_fRangeTypes[5]; CNWBaseItemArray * m_pBaseItemArray; uint32_t m_nExperienceTable[40+1]; diff --git a/NWNXLib/API/API/CNWSAmbientSound.hpp b/NWNXLib/API/API/CNWSAmbientSound.hpp index 7b37cb1b303..43ea0508d85 100644 --- a/NWNXLib/API/API/CNWSAmbientSound.hpp +++ b/NWNXLib/API/API/CNWSAmbientSound.hpp @@ -9,17 +9,18 @@ NWN_API_PROLOGUE(CNWSAmbientSound) #endif -struct CNWSMessage; -struct CResGFF; -struct CResStruct; +class CNWSMessage; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSAmbientSound : CNWAmbientSound +class CNWSAmbientSound : public CNWAmbientSound { +public: OBJECT_ID m_nArea; CNWSAmbientSound(OBJECT_ID nArea); diff --git a/NWNXLib/API/API/CNWSArea.hpp b/NWNXLib/API/API/CNWSArea.hpp index d1436383496..5634f38f2c6 100644 --- a/NWNXLib/API/API/CNWSArea.hpp +++ b/NWNXLib/API/API/CNWSArea.hpp @@ -20,28 +20,29 @@ NWN_API_PROLOGUE(CNWSArea) #endif -struct CERFFile; -struct CGameEffect; -struct CGameObject; -struct CNWSAmbientSound; -struct CNWSAreaGridPoint; -struct CNWSAreaInterTileSuccessors; -struct CNWSCreature; -struct CNWSPlayer; -struct CNWSTile; -struct CNWTileSet; -struct CPathfindInformation; -struct CResGFF; -struct CResStruct; -struct NWAREAHEADER; +class CERFFile; +class CGameEffect; +class CGameObject; +class CNWSAmbientSound; +class CNWSAreaGridPoint; +class CNWSAreaInterTileSuccessors; +class CNWSCreature; +class CNWSPlayer; +class CNWSTile; +class CNWTileSet; +class CPathfindInformation; +class CResGFF; +class CResStruct; +class NWAREAHEADER; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSArea : CNWArea, CResHelper, CGameObject +class CNWSArea : public CNWArea, public CResHelper, public CGameObject { +public: int32_t m_nPlayersInArea; CExoArrayList m_pTrapList; int32_t m_nObjectByNameIndex; @@ -107,7 +108,7 @@ struct CNWSArea : CNWArea, CResHelper, CGameObject ~CNWSArea(); virtual CNWSArea * AsNWSArea(); virtual CNWSArea * NWAreaAsNWSArea(); - BOOL AddObjectToArea(OBJECT_ID id, BOOL bRunScripts = true); + NWNX_IMPORT BOOL AddObjectToArea(OBJECT_ID id, BOOL bRunScripts = true); BOOL AIUpdate(); Vector ComputeAwayVector(Vector vCurrentPosition, Vector vPositionToMoveAwayFrom, float fMoveAwayRange, CPathfindInformation * pPathInfo); int32_t ComputeBestCorner(float fX1, float fY1, float fX2, float fY2, float fX3, float fY3, float fPersonalSpace, float fCreatureHeight, float * fNewX1, float * fNewY1, float * fNewX2, float * fNewY2); @@ -190,6 +191,63 @@ struct CNWSArea : CNWArea, CResHelper, CGameObject BOOL LoadProperties(CResGFF * pRes, CResStruct * pStruct); void IncreaseAILevelPriority(); void DecreaseAILevelPriority(); + + inline void PublicSaveCreatures(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aCreatures, BOOL bSaveOIDs) + { + SaveCreatures(pRes, pTopLevelStruct, aCreatures, bSaveOIDs); + } + + inline void PublicSaveItems(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aItems, BOOL bSaveOIDs) + { + SaveItems(pRes, pTopLevelStruct, aItems, bSaveOIDs); + } + + inline void PublicSaveDoors(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aDoors, BOOL bSaveOIDs) + { + SaveDoors(pRes, pTopLevelStruct, aDoors, bSaveOIDs); + } + + inline void PublicSaveTriggers(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aTriggers, BOOL bSaveOIDs) + { + SaveTriggers(pRes, pTopLevelStruct, aTriggers, bSaveOIDs); + } + + inline void PublicSaveEncounters(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aEncounters, BOOL bSaveOIDs) + { + SaveEncounters(pRes, pTopLevelStruct, aEncounters, bSaveOIDs); + } + + inline void PublicSaveWaypoints(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aWaypoints, BOOL bSaveOIDs) + { + SaveWaypoints(pRes, pTopLevelStruct, aWaypoints, bSaveOIDs); + } + + inline void PublicSaveSounds(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aSounds, BOOL bSaveOIDs) + { + SaveSounds(pRes, pTopLevelStruct, aSounds, bSaveOIDs); + } + + inline void PublicSavePlaceables(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aPlaceables, BOOL bSaveOIDs) + { + SavePlaceables(pRes, pTopLevelStruct, aPlaceables, bSaveOIDs); + } + + inline void PublicSaveStores(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aStores, BOOL bSaveOIDs) + { + SaveStores(pRes, pTopLevelStruct, aStores, bSaveOIDs); + } + + inline void PublicSaveAreaEffects(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aStores, BOOL bSaveOIDs) + { + SaveAreaEffects(pRes, pTopLevelStruct, aStores, bSaveOIDs); + } + + inline void PublicSaveProperties(CResGFF * pRes, CResStruct * pTopLevelStruct) + { + SaveProperties(pRes, pTopLevelStruct); + } + +protected: void SaveCreatures(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aCreatures, BOOL bSaveOIDs); void SaveItems(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aItems, BOOL bSaveOIDs); void SaveDoors(CResGFF * pRes, CResStruct * pTopLevelStruct, CExoArrayList & aDoors, BOOL bSaveOIDs); diff --git a/NWNXLib/API/API/CNWSAreaGridPoint.hpp b/NWNXLib/API/API/CNWSAreaGridPoint.hpp index c50f2e65562..c5b1a9c8c8d 100644 --- a/NWNXLib/API/API/CNWSAreaGridPoint.hpp +++ b/NWNXLib/API/API/CNWSAreaGridPoint.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWSAreaGridPoint) -struct CNWSAreaGridPoint +class CNWSAreaGridPoint { +public: int32_t nX; int32_t nY; diff --git a/NWNXLib/API/API/CNWSAreaGridSuccessors.hpp b/NWNXLib/API/API/CNWSAreaGridSuccessors.hpp index 4ebbd94be94..d7082fa71b1 100644 --- a/NWNXLib/API/API/CNWSAreaGridSuccessors.hpp +++ b/NWNXLib/API/API/CNWSAreaGridSuccessors.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWSAreaGridSuccessors) -struct CNWSAreaGridSuccessors +class CNWSAreaGridSuccessors { +public: int32_t nStepSize; int32_t nX; int32_t nY; diff --git a/NWNXLib/API/API/CNWSAreaGridTransTableEntry.hpp b/NWNXLib/API/API/CNWSAreaGridTransTableEntry.hpp index 6223c7b8c25..5532dde5f55 100644 --- a/NWNXLib/API/API/CNWSAreaGridTransTableEntry.hpp +++ b/NWNXLib/API/API/CNWSAreaGridTransTableEntry.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWSAreaGridTransTableEntry) -struct CNWSAreaGridTransTableEntry +class CNWSAreaGridTransTableEntry { +public: int32_t nX; int32_t nY; int32_t nShortestPath; diff --git a/NWNXLib/API/API/CNWSAreaInterTileSuccessors.hpp b/NWNXLib/API/API/CNWSAreaInterTileSuccessors.hpp index bf703dbee69..9be315e9d7d 100644 --- a/NWNXLib/API/API/CNWSAreaInterTileSuccessors.hpp +++ b/NWNXLib/API/API/CNWSAreaInterTileSuccessors.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWSAreaInterTileSuccessors) -struct CNWSAreaInterTileSuccessors +class CNWSAreaInterTileSuccessors { +public: int32_t nTileGridX; int32_t nTileGridY; int32_t nTileRegion; diff --git a/NWNXLib/API/API/CNWSAreaOfEffectObject.hpp b/NWNXLib/API/API/CNWSAreaOfEffectObject.hpp index 6684d82d9af..55266827fcb 100644 --- a/NWNXLib/API/API/CNWSAreaOfEffectObject.hpp +++ b/NWNXLib/API/API/CNWSAreaOfEffectObject.hpp @@ -10,17 +10,18 @@ NWN_API_PROLOGUE(CNWSAreaOfEffectObject) #endif -struct CNWSArea; -struct CResGFF; -struct CResStruct; +class CNWSArea; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSAreaOfEffectObject : CNWSObject +class CNWSAreaOfEffectObject : public CNWSObject { +public: uint16_t m_nObjectArrayIndex; int32_t m_nAreaEffectId; uint8_t m_nShape; diff --git a/NWNXLib/API/API/CNWSBarter.hpp b/NWNXLib/API/API/CNWSBarter.hpp index 69d4286a775..7bc7d2037a4 100644 --- a/NWNXLib/API/API/CNWSBarter.hpp +++ b/NWNXLib/API/API/CNWSBarter.hpp @@ -7,17 +7,18 @@ NWN_API_PROLOGUE(CNWSBarter) #endif -struct CItemRepository; -struct CNWSCreature; -struct CNWSPlayerLUOInventory; +class CItemRepository; +class CNWSCreature; +class CNWSPlayerLUOInventory; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSBarter +class CNWSBarter { +public: CItemRepository * m_pBarterList; CNWSPlayerLUOInventory * m_pLastUpdate; CNWSPlayerLUOInventory * m_pOtherLastUpdate; diff --git a/NWNXLib/API/API/CNWSClient.hpp b/NWNXLib/API/API/CNWSClient.hpp index 5f6f1003c25..1319794f127 100644 --- a/NWNXLib/API/API/CNWSClient.hpp +++ b/NWNXLib/API/API/CNWSClient.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CNWSClient) #endif -struct CNWSPlayer; +class CNWSPlayer; -struct CNWSClient +class CNWSClient { +public: uint32_t m_nPlayerID; int32_t m_nLanguage; diff --git a/NWNXLib/API/API/CNWSCombatAttackData.hpp b/NWNXLib/API/API/CNWSCombatAttackData.hpp index de63addada3..9bedf4c9d1a 100644 --- a/NWNXLib/API/API/CNWSCombatAttackData.hpp +++ b/NWNXLib/API/API/CNWSCombatAttackData.hpp @@ -10,19 +10,20 @@ NWN_API_PROLOGUE(CNWSCombatAttackData) #endif -struct CGameEffect; -struct CNWCCMessageData; -struct CNWSSpellScriptData; -struct CResGFF; -struct CResStruct; +class CGameEffect; +class CNWCCMessageData; +class CNWSSpellScriptData; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSCombatAttackData +class CNWSCombatAttackData { +public: uint8_t m_nAttackGroup; uint16_t m_nAnimationLength; OBJECT_ID m_oidReactObject; diff --git a/NWNXLib/API/API/CNWSCombatRound.hpp b/NWNXLib/API/API/CNWSCombatRound.hpp index 82618f40c96..3d2440d8801 100644 --- a/NWNXLib/API/API/CNWSCombatRound.hpp +++ b/NWNXLib/API/API/CNWSCombatRound.hpp @@ -11,18 +11,19 @@ NWN_API_PROLOGUE(CNWSCombatRound) #endif -struct CNWSCreature; -struct CNWSItem; -struct CResGFF; -struct CResStruct; +class CNWSCreature; +class CNWSItem; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSCombatRound +class CNWSCombatRound { +public: CNWSCombatAttackData m_pcLastAttack[50]; CExoArrayList m_nSpecialAttacks; CExoArrayList m_nSpecialAttackIDs; diff --git a/NWNXLib/API/API/CNWSCombatRoundAction.hpp b/NWNXLib/API/API/CNWSCombatRoundAction.hpp index 4da0f213d31..de4e77f2412 100644 --- a/NWNXLib/API/API/CNWSCombatRoundAction.hpp +++ b/NWNXLib/API/API/CNWSCombatRoundAction.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CNWSCombatRoundAction) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSCombatRoundAction +class CNWSCombatRoundAction { +public: int32_t m_nActionTimer; uint16_t m_nAnimation; int32_t m_nAnimationTime; diff --git a/NWNXLib/API/API/CNWSCreRestorePolymorphData.hpp b/NWNXLib/API/API/CNWSCreRestorePolymorphData.hpp index 4715512dca6..881a465fd7f 100644 --- a/NWNXLib/API/API/CNWSCreRestorePolymorphData.hpp +++ b/NWNXLib/API/API/CNWSCreRestorePolymorphData.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CNWSCreRestorePolymorphData) #endif -struct CGameEffect; -struct CNWSItem; +class CGameEffect; +class CNWSItem; typedef int BOOL; -struct CNWSCreRestorePolymorphData +class CNWSCreRestorePolymorphData { +public: int32_t nCurrentHitPoints; int32_t nTemporaryHitPoints; CGameEffect * effect; diff --git a/NWNXLib/API/API/CNWSCreature.hpp b/NWNXLib/API/API/CNWSCreature.hpp index e761ac9968e..53ef2349da5 100644 --- a/NWNXLib/API/API/CNWSCreature.hpp +++ b/NWNXLib/API/API/CNWSCreature.hpp @@ -17,31 +17,31 @@ NWN_API_PROLOGUE(CNWSCreature) #endif -struct CEffectIconObject; -struct CGameEffect; -struct CGameEffect; -struct CItemRepository; -struct CNWCCMessageData; -struct CNWItemProperty; -struct CNWSArea; -struct CNWSBarter; -struct CNWSCombatAttackData; -struct CNWSCombatRound; -struct CNWSCreRestorePolymorphData; -struct CNWSCreatureStats; -struct CNWSFaction; -struct CNWSForcedAction; -struct CNWSInventory; -struct CNWSItem; -struct CNWSJournal; -struct CNWSObjectActionNode; -struct CNWSPlayer; -struct CNWSQuickbarButton; -struct CNWVisibilityNode; -struct CNWVisibilityNode; -struct CPathfindInformation; -struct CResGFF; -struct CResStruct; +class CEffectIconObject; +class CGameEffect; +class CGameEffect; +class CItemRepository; +class CNWCCMessageData; +class CNWItemProperty; +class CNWSArea; +class CNWSBarter; +class CNWSCombatAttackData; +class CNWSCombatRound; +class CNWSCreRestorePolymorphData; +class CNWSCreatureStats; +class CNWSFaction; +class CNWSForcedAction; +class CNWSInventory; +class CNWSItem; +class CNWSJournal; +class CNWSObjectActionNode; +class CNWSPlayer; +class CNWSQuickbarButton; +class CNWVisibilityNode; +class CNWVisibilityNode; +class CPathfindInformation; +class CResGFF; +class CResStruct; typedef int BOOL; @@ -49,8 +49,9 @@ typedef uint32_t OBJECT_ID; typedef uint32_t STRREF; -struct CNWSCreature : CNWSObject +class CNWSCreature : public CNWSObject { +public: BOOL m_bPonyRide; uint16_t m_nEquipArrayIndex; OBJECT_ID m_poidCntrSpellObjects[10]; diff --git a/NWNXLib/API/API/CNWSCreatureAppearanceInfo.hpp b/NWNXLib/API/API/CNWSCreatureAppearanceInfo.hpp index 9d636ec7c52..4cedba7fbdf 100644 --- a/NWNXLib/API/API/CNWSCreatureAppearanceInfo.hpp +++ b/NWNXLib/API/API/CNWSCreatureAppearanceInfo.hpp @@ -14,8 +14,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSCreatureAppearanceInfo +class CNWSCreatureAppearanceInfo { +public: OBJECT_ID m_oidLeftHandItem; OBJECT_ID m_oidRightHandItem; uint8_t m_nRightHandItemVFX; diff --git a/NWNXLib/API/API/CNWSCreatureStats.hpp b/NWNXLib/API/API/CNWSCreatureStats.hpp index 472d9aed899..46f173788ec 100644 --- a/NWNXLib/API/API/CNWSCreatureStats.hpp +++ b/NWNXLib/API/API/CNWSCreatureStats.hpp @@ -13,19 +13,19 @@ NWN_API_PROLOGUE(CNWSCreatureStats) #endif -struct CCombatInformation; -struct CFeatUseListEntry; -struct CNWClass; -struct CNWCreatureStatsUpdate; -struct CNWLevelStats; -struct CNWLevelStats; -struct CNWSCreature; -struct CNWSCreatureAppearanceInfo; -struct CNWSItem; -struct CNWSObject; -struct CNWSpell; -struct CResGFF; -struct CResStruct; +class CCombatInformation; +class CFeatUseListEntry; +class CNWClass; +class CNWCreatureStatsUpdate; +class CNWLevelStats; +class CNWLevelStats; +class CNWSCreature; +class CNWSCreatureAppearanceInfo; +class CNWSItem; +class CNWSObject; +class CNWSpell; +class CResGFF; +class CResStruct; typedef int BOOL; @@ -33,8 +33,9 @@ typedef uint32_t OBJECT_ID; typedef uint32_t STRREF; -struct CNWSCreatureStats +class CNWSCreatureStats { +public: CExoArrayList m_lstFeats; CExoArrayList m_lstFeatUses; CExoArrayList m_lstBonusFeats; diff --git a/NWNXLib/API/API/CNWSCreatureStats_ClassInfo.hpp b/NWNXLib/API/API/CNWSCreatureStats_ClassInfo.hpp index 93c18f5e13e..6c2247afca8 100644 --- a/NWNXLib/API/API/CNWSCreatureStats_ClassInfo.hpp +++ b/NWNXLib/API/API/CNWSCreatureStats_ClassInfo.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CNWSCreatureStats_ClassInfo) #endif -struct CNWSStats_Spell; -struct CNWSStats_Spell; +class CNWSStats_Spell; +class CNWSStats_Spell; typedef int BOOL; -struct CNWSCreatureStats_ClassInfo +class CNWSCreatureStats_ClassInfo { +public: CExoArrayList m_pKnownSpellList[10]; CExoArrayList m_pMemorizedSpellList[10]; uint32_t m_nBonusSpellsList[10]; diff --git a/NWNXLib/API/API/CNWSDialog.hpp b/NWNXLib/API/API/CNWSDialog.hpp index 82bb56ef0dc..1ee9c8d716b 100644 --- a/NWNXLib/API/API/CNWSDialog.hpp +++ b/NWNXLib/API/API/CNWSDialog.hpp @@ -13,22 +13,23 @@ NWN_API_PROLOGUE(CNWSDialog) #endif -struct CExoString; -struct CNWSDialogEntry; -struct CNWSDialogLinkEntry; -struct CNWSDialogReply; -struct CNWSDialogSpeaker; -struct CNWSObject; -struct CResGFF; -struct CResStruct; +class CExoString; +class CNWSDialogEntry; +class CNWSDialogLinkEntry; +class CNWSDialogReply; +class CNWSDialogSpeaker; +class CNWSObject; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSDialog +class CNWSDialog { +public: uint32_t m_nEntries; CNWSDialogEntry * m_pEntries; uint32_t m_nReplies; diff --git a/NWNXLib/API/API/CNWSDialogEntry.hpp b/NWNXLib/API/API/CNWSDialogEntry.hpp index eb18e9e7bb8..3a761e32015 100644 --- a/NWNXLib/API/API/CNWSDialogEntry.hpp +++ b/NWNXLib/API/API/CNWSDialogEntry.hpp @@ -11,13 +11,14 @@ NWN_API_PROLOGUE(CNWSDialogEntry) #endif -struct CNWSDialogLinkReply; +class CNWSDialogLinkReply; -struct CNWSDialogEntry +class CNWSDialogEntry { +public: CExoString m_sSpeaker; uint32_t m_nAnimation; uint8_t m_bAnimationLoop; diff --git a/NWNXLib/API/API/CNWSDialogLinkEntry.hpp b/NWNXLib/API/API/CNWSDialogLinkEntry.hpp index 03c090c2ef0..86afb620a43 100644 --- a/NWNXLib/API/API/CNWSDialogLinkEntry.hpp +++ b/NWNXLib/API/API/CNWSDialogLinkEntry.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWSDialogLinkEntry) -struct CNWSDialogLinkEntry +class CNWSDialogLinkEntry { +public: CResRef m_sActive; CExoArrayList m_lConditionParams; uint32_t m_nIndex; diff --git a/NWNXLib/API/API/CNWSDialogLinkReply.hpp b/NWNXLib/API/API/CNWSDialogLinkReply.hpp index d44744cbdcc..37de641072f 100644 --- a/NWNXLib/API/API/CNWSDialogLinkReply.hpp +++ b/NWNXLib/API/API/CNWSDialogLinkReply.hpp @@ -15,8 +15,9 @@ NWN_API_PROLOGUE(CNWSDialogLinkReply) typedef int BOOL; -struct CNWSDialogLinkReply +class CNWSDialogLinkReply { +public: CResRef m_sActive; CExoArrayList m_lConditionParams; uint32_t m_nIndex; diff --git a/NWNXLib/API/API/CNWSDialogPlayer.hpp b/NWNXLib/API/API/CNWSDialogPlayer.hpp index 22e060c4265..698f1c3e4a0 100644 --- a/NWNXLib/API/API/CNWSDialogPlayer.hpp +++ b/NWNXLib/API/API/CNWSDialogPlayer.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSDialogPlayer) typedef uint32_t OBJECT_ID; -struct CNWSDialogPlayer +class CNWSDialogPlayer { +public: uint32_t m_playerId; OBJECT_ID m_oidObject; uint8_t m_gender; diff --git a/NWNXLib/API/API/CNWSDialogReply.hpp b/NWNXLib/API/API/CNWSDialogReply.hpp index 2cd2ecc3f86..30d9b7f6a42 100644 --- a/NWNXLib/API/API/CNWSDialogReply.hpp +++ b/NWNXLib/API/API/CNWSDialogReply.hpp @@ -12,13 +12,14 @@ NWN_API_PROLOGUE(CNWSDialogReply) #endif -struct CNWSDialogLinkEntry; +class CNWSDialogLinkEntry; -struct CNWSDialogReply +class CNWSDialogReply { +public: uint32_t m_nAnimation; uint8_t m_bAnimationLoop; CExoLocString m_sText; diff --git a/NWNXLib/API/API/CNWSDialogSpeaker.hpp b/NWNXLib/API/API/CNWSDialogSpeaker.hpp index f092c96d3d5..588d6012dbc 100644 --- a/NWNXLib/API/API/CNWSDialogSpeaker.hpp +++ b/NWNXLib/API/API/CNWSDialogSpeaker.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWSDialogSpeaker) typedef uint32_t OBJECT_ID; -struct CNWSDialogSpeaker +class CNWSDialogSpeaker { +public: CExoString m_sSpeaker; OBJECT_ID m_id; diff --git a/NWNXLib/API/API/CNWSDoor.hpp b/NWNXLib/API/API/CNWSDoor.hpp index d04bead269a..15692fe998a 100644 --- a/NWNXLib/API/API/CNWSDoor.hpp +++ b/NWNXLib/API/API/CNWSDoor.hpp @@ -13,18 +13,19 @@ NWN_API_PROLOGUE(CNWSDoor) #endif -struct CNWDoorSurfaceMesh; -struct CNWSArea; -struct CResGFF; -struct CResStruct; +class CNWDoorSurfaceMesh; +class CNWSArea; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSDoor : CNWSObject +class CNWSDoor : public CNWSObject { +public: CExoString m_sScripts[15]; uint32_t m_nAppearanceType; uint32_t m_nGenericType; diff --git a/NWNXLib/API/API/CNWSEffectListHandler.hpp b/NWNXLib/API/API/CNWSEffectListHandler.hpp index c3793c4d8c3..f5a87d3bb5d 100644 --- a/NWNXLib/API/API/CNWSEffectListHandler.hpp +++ b/NWNXLib/API/API/CNWSEffectListHandler.hpp @@ -8,8 +8,8 @@ NWN_API_PROLOGUE(CNWSEffectListHandler) #endif -struct CGameEffect; -struct CNWSObject; +class CGameEffect; +class CNWSObject; typedef int32_t (*pfAECommands)(CNWSObject *, CGameEffect *, BOOL); typedef int32_t (*pfRECommands)(CNWSObject *, CGameEffect *); @@ -18,8 +18,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSEffectListHandler : CGameEffectApplierRemover +class CNWSEffectListHandler : public CGameEffectApplierRemover { +public: pfAECommands * m_pApplyEffectCommands; pfRECommands * m_pRemoveEffectCommands; diff --git a/NWNXLib/API/API/CNWSEncounter.hpp b/NWNXLib/API/API/CNWSEncounter.hpp index 4f2a22a6878..d6deee39927 100644 --- a/NWNXLib/API/API/CNWSEncounter.hpp +++ b/NWNXLib/API/API/CNWSEncounter.hpp @@ -14,18 +14,19 @@ NWN_API_PROLOGUE(CNWSEncounter) #endif -struct CEncounterSpawnPoint; -struct CNWSArea; -struct CResGFF; -struct CResStruct; +class CEncounterSpawnPoint; +class CNWSArea; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSEncounter : CNWSObject +class CNWSEncounter : public CNWSObject { +public: uint16_t m_nActivateObjectArrayIndex; int32_t m_nFactionId; CExoLocString m_sLocalizedName; diff --git a/NWNXLib/API/API/CNWSExpression.hpp b/NWNXLib/API/API/CNWSExpression.hpp index bf0b518094d..13fcd660fe0 100644 --- a/NWNXLib/API/API/CNWSExpression.hpp +++ b/NWNXLib/API/API/CNWSExpression.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CNWSExpression) #endif -struct CExoString; -struct CNWSExpressionList; -struct CNWSExpressionNode; +class CExoString; +class CNWSExpressionList; +class CNWSExpressionNode; typedef int BOOL; -struct CNWSExpression +class CNWSExpression { +public: int32_t m_nExpressionId; CExoArrayList m_aStored; BOOL m_bCaseSensitive; diff --git a/NWNXLib/API/API/CNWSExpressionList.hpp b/NWNXLib/API/API/CNWSExpressionList.hpp index e8d7eed0e6c..defc01ec909 100644 --- a/NWNXLib/API/API/CNWSExpressionList.hpp +++ b/NWNXLib/API/API/CNWSExpressionList.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CNWSExpressionList) #endif -struct CNWSExpressionNode; +class CNWSExpressionNode; -struct CNWSExpressionList +class CNWSExpressionList { +public: CNWSExpressionNode *m_pHead, *m_pAfter, *m_pTail; CNWSExpressionList(); diff --git a/NWNXLib/API/API/CNWSExpressionNode.hpp b/NWNXLib/API/API/CNWSExpressionNode.hpp index d7195bbc191..ae0c0d931b0 100644 --- a/NWNXLib/API/API/CNWSExpressionNode.hpp +++ b/NWNXLib/API/API/CNWSExpressionNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSExpressionNode) -struct CNWSExpressionNode +class CNWSExpressionNode { +public: int32_t nTimesVisited; int32_t m_nType; int32_t m_nPosition; diff --git a/NWNXLib/API/API/CNWSFaction.hpp b/NWNXLib/API/API/CNWSFaction.hpp index 6f5e4a2886a..2cddec6fd12 100644 --- a/NWNXLib/API/API/CNWSFaction.hpp +++ b/NWNXLib/API/API/CNWSFaction.hpp @@ -9,15 +9,16 @@ NWN_API_PROLOGUE(CNWSFaction) #endif -struct CFactionManager; +class CFactionManager; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSFaction +class CNWSFaction { +public: CExoArrayList m_listFactionMembers; int32_t m_nFactionId; int32_t m_nParentFactionId; diff --git a/NWNXLib/API/API/CNWSForcedAction.hpp b/NWNXLib/API/API/CNWSForcedAction.hpp index 410eeff0324..e0228b9b8e6 100644 --- a/NWNXLib/API/API/CNWSForcedAction.hpp +++ b/NWNXLib/API/API/CNWSForcedAction.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CNWSForcedAction) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSForcedAction +class CNWSForcedAction { +public: uint32_t m_nActionId; uint16_t m_nGroupId; OBJECT_ID m_oidArea; diff --git a/NWNXLib/API/API/CNWSInventory.hpp b/NWNXLib/API/API/CNWSInventory.hpp index 56527f00389..2bed656a89c 100644 --- a/NWNXLib/API/API/CNWSInventory.hpp +++ b/NWNXLib/API/API/CNWSInventory.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CNWSInventory) #endif -struct CNWSItem; +class CNWSItem; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSInventory +class CNWSInventory { +public: OBJECT_ID m_pEquipSlot[18]; CNWSInventory(); diff --git a/NWNXLib/API/API/CNWSInvitationDetails.hpp b/NWNXLib/API/API/CNWSInvitationDetails.hpp index 2cbeeb6dfaf..4b2739814fe 100644 --- a/NWNXLib/API/API/CNWSInvitationDetails.hpp +++ b/NWNXLib/API/API/CNWSInvitationDetails.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSInvitationDetails) typedef uint32_t OBJECT_ID; -struct CNWSInvitationDetails +class CNWSInvitationDetails { +public: OBJECT_ID m_oidCreature; uint32_t m_nCalenderDay; uint32_t m_nTimeOfDay; diff --git a/NWNXLib/API/API/CNWSItem.hpp b/NWNXLib/API/API/CNWSItem.hpp index 6e53ab32441..25719def951 100644 --- a/NWNXLib/API/API/CNWSItem.hpp +++ b/NWNXLib/API/API/CNWSItem.hpp @@ -14,19 +14,20 @@ NWN_API_PROLOGUE(CNWSItem) #endif -struct CItemRepository; -struct CNWSArea; -struct CNWSCreature; -struct CResGFF; -struct CResStruct; +class CItemRepository; +class CNWSArea; +class CNWSCreature; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSItem : CNWItem, CNWSObject +class CNWSItem : public CNWItem, public CNWSObject { +public: uint8_t m_nLastUsedActiveProperties; uint8_t m_pLastUsedActivePropertyUsesLeft[8]; int32_t m_nArmorValue; diff --git a/NWNXLib/API/API/CNWSJournal.hpp b/NWNXLib/API/API/CNWSJournal.hpp index fd2770d87e7..3e0377a8efc 100644 --- a/NWNXLib/API/API/CNWSJournal.hpp +++ b/NWNXLib/API/API/CNWSJournal.hpp @@ -10,14 +10,15 @@ NWN_API_PROLOGUE(CNWSJournal) #endif -struct CNWSCreature; +class CNWSCreature; typedef int BOOL; -struct CNWSJournal +class CNWSJournal { +public: CExoArrayList m_lstEntries; CNWSCreature * m_pCreature; diff --git a/NWNXLib/API/API/CNWSMessage.hpp b/NWNXLib/API/API/CNWSMessage.hpp index 470d2317282..a2ed2b792ce 100644 --- a/NWNXLib/API/API/CNWSMessage.hpp +++ b/NWNXLib/API/API/CNWSMessage.hpp @@ -16,31 +16,31 @@ NWN_API_PROLOGUE(CNWSMessage) #endif -struct CEffectIconObject; -struct CGameObject; -struct CGameObjectArray; -struct CItemRepository; -struct CLastUpdateObject; -struct CLastUpdatePartyObject; -struct CLoopingVisualEffect; -struct CNWCCMessageData; -struct CNWSArea; -struct CNWSAreaOfEffectObject; -struct CNWSCombatAttackData; -struct CNWSCreature; -struct CNWSDoor; -struct CNWSItem; -struct CNWSObject; -struct CNWSPlaceable; -struct CNWSPlayer; -struct CNWSPlayerInventoryGUI; -struct CNWSPlayerLUOInventory; -struct CNWSPlayerLUOSortedObjectList; -struct CNWSPlayerLastUpdateObject; -struct CNWSStore; -struct CNWSTrigger; +class CEffectIconObject; +class CGameObject; +class CGameObjectArray; +class CItemRepository; +class CLastUpdateObject; +class CLastUpdatePartyObject; +class CLoopingVisualEffect; +class CNWCCMessageData; +class CNWSArea; +class CNWSAreaOfEffectObject; +class CNWSCombatAttackData; +class CNWSCreature; +class CNWSDoor; +class CNWSItem; +class CNWSObject; +class CNWSPlaceable; +class CNWSPlayer; +class CNWSPlayerInventoryGUI; +class CNWSPlayerLUOInventory; +class CNWSPlayerLUOSortedObjectList; +class CNWSPlayerLastUpdateObject; +class CNWSStore; +class CNWSTrigger; namespace Hash { - struct SHA1; + class SHA1; } @@ -51,9 +51,9 @@ typedef uint16_t RESTYPE; typedef uint32_t STRREF; -struct CNWSMessage : CNWMessage +class CNWSMessage : public CNWMessage { - +public: CNWSMessage(); ~CNWSMessage(); OBJECT_ID ReadOBJECTIDServer(); @@ -183,7 +183,7 @@ struct CNWSMessage : CNWMessage void ComputeGameObjectUpdateForYourselfToo(CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, OBJECT_ID oidObjectToUpdate); void ComputeGameObjectUpdateForYourself(CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, OBJECT_ID oidObjectToUpdate); CNWSPlayerLUOSortedObjectList * SortObjectsForGameObjectUpdate(CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, int32_t * nMembersInSortedList); - void ComputeGameObjectUpdateForObject(CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, OBJECT_ID oidObjectToUpdate); + NWNX_IMPORT void ComputeGameObjectUpdateForObject(CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, OBJECT_ID oidObjectToUpdate); BOOL ComputeGameObjectUpdateForCategory(uint32_t nCategory, uint32_t nMessageLimit, CNWSPlayer * pPlayer, CNWSObject * pPlayerGameObject, CGameObjectArray * pGameObjectArray, CNWSPlayerLUOSortedObjectList * pSortedList, int32_t nSortedListSize); void TestPartyObjectUpdateDifferences(CNWSPlayer * pPlayer, CNWSCreature * pPartyCreature, CLastUpdatePartyObject * * pLastUpdatePartyObject, uint32_t * nObjectUpdatesRequired); void StoreValuesInLastUpdatePartyObject(CNWSCreature * pPlayerCreature, CLastUpdatePartyObject * pLastUpdatePartyObject, CNWSCreature * pPartyCreature, uint32_t nObjectUpdatesRequired); diff --git a/NWNXLib/API/API/CNWSModule.hpp b/NWNXLib/API/API/CNWSModule.hpp index 5867fe80b1a..2312a40c06c 100644 --- a/NWNXLib/API/API/CNWSModule.hpp +++ b/NWNXLib/API/API/CNWSModule.hpp @@ -26,19 +26,19 @@ NWN_API_PROLOGUE(CNWSModule) #endif -struct CERFFile; -struct CGameEffect; -struct CNWSArea; -struct CNWSPlayer; -struct CPathfindInformation; -struct CResGFF; -struct CResStruct; -struct NWMODULEENTRYINFO; -struct NWMODULEHEADER; -struct NWPLAYERCHARACTERLISTITEM; +class CERFFile; +class CGameEffect; +class CNWSArea; +class CNWSPlayer; +class CPathfindInformation; +class CResGFF; +class CResStruct; +class NWMODULEENTRYINFO; +class NWMODULEHEADER; +class NWPLAYERCHARACTERLISTITEM; namespace NWSync { -struct Advertisement; // NWSyncAdvertisement +class Advertisement; // NWSyncAdvertisement } typedef int BOOL; @@ -47,8 +47,9 @@ typedef uint16_t RESTYPE; typedef uint32_t STRREF; -struct CNWSModule : CResHelper, CGameObject +class CNWSModule : public CResHelper, public CGameObject { +public: CExoLinkedList m_lstModuleExpansion; CExoLinkedList m_lstModuleCutScene; CExoLinkedList m_lstModuleArea; @@ -170,8 +171,8 @@ struct CNWSModule : CResHelper, CGameObject void ClearAreaVisitedFlags(); BOOL InterAreaDFS(int32_t level, int32_t depth, CPathfindInformation * pcPathfindInformation); uint32_t LoadModuleStart(CExoString sModuleName, BOOL bIsSaveGame = false, int32_t nSourceType = 0, const NWSync::Advertisement & nwsyncModuleSourceAdvert = {}); - uint32_t LoadModuleInProgress(int32_t nAreasLoaded, int32_t nAreasToLoad); - uint32_t LoadModuleFinish(); + NWNX_IMPORT uint32_t LoadModuleInProgress(int32_t nAreasLoaded, int32_t nAreasToLoad); + NWNX_IMPORT uint32_t LoadModuleFinish(); void PackModuleResourcesIntoMessage(); void PackModuleIntoMessage(uint32_t nPlayerId); uint32_t PlotPath(CPathfindInformation * pcPathfindInformation, uint32_t nTimeSlice); diff --git a/NWNXLib/API/API/CNWSObject.hpp b/NWNXLib/API/API/CNWSObject.hpp index af92ef0a06c..35fbab6b0a9 100644 --- a/NWNXLib/API/API/CNWSObject.hpp +++ b/NWNXLib/API/API/CNWSObject.hpp @@ -23,21 +23,21 @@ NWN_API_PROLOGUE(CNWSObject) #endif -struct CExoString; -struct CGameEffect; -struct CGameEffect; -struct CLoopingVisualEffect; -struct CNWCCMessageData; -struct CNWSAnimBase; -struct CNWSArea; -struct CNWSAreaOfEffectObject; -struct CNWSCreature; -struct CNWSDialog; -struct CNWSExpression; -struct CNWSPlayer; -struct CNWSpell; -struct CResGFF; -struct CResStruct; +class CExoString; +class CGameEffect; +class CGameEffect; +class CLoopingVisualEffect; +class CNWCCMessageData; +class CNWSAnimBase; +class CNWSArea; +class CNWSAreaOfEffectObject; +class CNWSCreature; +class CNWSDialog; +class CNWSExpression; +class CNWSPlayer; +class CNWSpell; +class CResGFF; +class CResStruct; typedef TextureReplaceInfo AnimationReplaceInfo; @@ -47,8 +47,9 @@ typedef uint32_t OBJECT_ID; typedef uint32_t STRREF; -struct CNWSObject : CGameObject +class CNWSObject : public CGameObject { +public: CExoLocString m_sForGCC; uint16_t m_nGroupID; uint16_t m_nLastGroupID; diff --git a/NWNXLib/API/API/CNWSObjectActionNode.hpp b/NWNXLib/API/API/CNWSObjectActionNode.hpp index bbc1a552fdb..83d1a4aea78 100644 --- a/NWNXLib/API/API/CNWSObjectActionNode.hpp +++ b/NWNXLib/API/API/CNWSObjectActionNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSObjectActionNode) typedef int BOOL; -struct CNWSObjectActionNode +class CNWSObjectActionNode { +public: uint32_t m_nActionId; uint32_t m_nParamType[12]; intptr_t m_pParameter[12]; diff --git a/NWNXLib/API/API/CNWSObjectEventHandler.hpp b/NWNXLib/API/API/CNWSObjectEventHandler.hpp index 4c5ffa3b48f..d8bfe39727c 100644 --- a/NWNXLib/API/API/CNWSObjectEventHandler.hpp +++ b/NWNXLib/API/API/CNWSObjectEventHandler.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSObjectEventHandler) -struct CNWSObjectEventHandler +class CNWSObjectEventHandler { +public: uint32_t m_nEventId; CExoString m_sScriptName; diff --git a/NWNXLib/API/API/CNWSPVPEntry.hpp b/NWNXLib/API/API/CNWSPVPEntry.hpp index b6ca65e5147..1983c8f6cb4 100644 --- a/NWNXLib/API/API/CNWSPVPEntry.hpp +++ b/NWNXLib/API/API/CNWSPVPEntry.hpp @@ -13,8 +13,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPVPEntry +class CNWSPVPEntry { +public: OBJECT_ID m_oidPC; BOOL m_bILikePlayer; BOOL m_bPlayerLikesMe; diff --git a/NWNXLib/API/API/CNWSPersonalReputation.hpp b/NWNXLib/API/API/CNWSPersonalReputation.hpp index c1d786a29dc..f9d25ea2500 100644 --- a/NWNXLib/API/API/CNWSPersonalReputation.hpp +++ b/NWNXLib/API/API/CNWSPersonalReputation.hpp @@ -13,8 +13,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPersonalReputation +class CNWSPersonalReputation { +public: uint32_t m_nDay; uint32_t m_nTime; BOOL m_bValueDecays; diff --git a/NWNXLib/API/API/CNWSPlaceable.hpp b/NWNXLib/API/API/CNWSPlaceable.hpp index 4da2d7a2bb8..fba2b2c7164 100644 --- a/NWNXLib/API/API/CNWSPlaceable.hpp +++ b/NWNXLib/API/API/CNWSPlaceable.hpp @@ -13,20 +13,21 @@ NWN_API_PROLOGUE(CNWSPlaceable) #endif -struct CItemRepository; -struct CNWSArea; -struct CNWSItem; -struct CNWSObjectActionNode; -struct CResGFF; -struct CResStruct; +class CItemRepository; +class CNWSArea; +class CNWSItem; +class CNWSObjectActionNode; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlaceable : CNWSObject +class CNWSPlaceable : public CNWSObject { +public: CExoLocString m_sLocName; CExoString m_sDisplayName; int32_t m_nUpdateDisplayNameSeq; diff --git a/NWNXLib/API/API/CNWSPlayer.hpp b/NWNXLib/API/API/CNWSPlayer.hpp index f279fe62085..0978dbc1891 100644 --- a/NWNXLib/API/API/CNWSPlayer.hpp +++ b/NWNXLib/API/API/CNWSPlayer.hpp @@ -17,15 +17,15 @@ NWN_API_PROLOGUE(CNWSPlayer) #endif -struct CNWSCreature; -struct CNWSItem; -struct CNWSObject; -struct CNWSPlayerCharSheetGUI; -struct CNWSPlayerInventoryGUI; -struct CNWSPlayerJournalQuest; -struct CNWSPlayerLastUpdateObject; -struct CNWSPlayerStoreGUI; -struct CNWSPlayerTURD; +class CNWSCreature; +class CNWSItem; +class CNWSObject; +class CNWSPlayerCharSheetGUI; +class CNWSPlayerInventoryGUI; +class CNWSPlayerJournalQuest; +class CNWSPlayerLastUpdateObject; +class CNWSPlayerStoreGUI; +class CNWSPlayerTURD; typedef int BOOL; @@ -33,12 +33,15 @@ typedef uint32_t OBJECT_ID; typedef uint32_t STRREF; -struct CNWSPlayer : CNWSClient +class CNWSPlayer : public CNWSClient { - struct NuiState +public: + class NuiState { - struct WindowState + public: + class WindowState { + public: Nui::JSON::WindowToken m_token; Nui::JSON::WindowIdentifier m_id; std::vector m_bind_list; @@ -118,8 +121,8 @@ struct CNWSPlayer : CNWSClient void AllocateAreas(int32_t nAreas); BOOL AddArea(OBJECT_ID oidArea); BOOL GetIsAllowedToSave(); - void DropTURD(); - void EatTURD(CNWSPlayerTURD * pTURD); + NWNX_IMPORT void DropTURD(); + NWNX_IMPORT void EatTURD(CNWSPlayerTURD * pTURD); void CleanMyTURDs(); CNWSPlayerLastUpdateObject * CreateNewPlayerLastUpdateObject(); void ClearPlayerLastUpdateObject(); diff --git a/NWNXLib/API/API/CNWSPlayerCharSheetGUI.hpp b/NWNXLib/API/API/CNWSPlayerCharSheetGUI.hpp index 1a367105ba6..b80089892ca 100644 --- a/NWNXLib/API/API/CNWSPlayerCharSheetGUI.hpp +++ b/NWNXLib/API/API/CNWSPlayerCharSheetGUI.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CNWSPlayerCharSheetGUI) #endif -struct CNWCreatureStatsUpdate; -struct CNWSPlayer; +class CNWCreatureStatsUpdate; +class CNWSPlayer; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerCharSheetGUI +class CNWSPlayerCharSheetGUI { +public: OBJECT_ID m_oidCreatureDisplayed; char m_nActivePanel; CNWCreatureStatsUpdate * m_pLastStatsUpdate; diff --git a/NWNXLib/API/API/CNWSPlayerContainerGUI.hpp b/NWNXLib/API/API/CNWSPlayerContainerGUI.hpp index 9600a1b2caa..90e7b9de115 100644 --- a/NWNXLib/API/API/CNWSPlayerContainerGUI.hpp +++ b/NWNXLib/API/API/CNWSPlayerContainerGUI.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CNWSPlayerContainerGUI) #endif -struct CNWSPlayer; +class CNWSPlayer; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerContainerGUI +class CNWSPlayerContainerGUI { +public: OBJECT_ID m_oidOpen; BOOL m_bOpenedTheInventory; uint8_t m_nSelectedPanel; diff --git a/NWNXLib/API/API/CNWSPlayerInventoryGUI.hpp b/NWNXLib/API/API/CNWSPlayerInventoryGUI.hpp index 598c84f26e2..18826f5f8cd 100644 --- a/NWNXLib/API/API/CNWSPlayerInventoryGUI.hpp +++ b/NWNXLib/API/API/CNWSPlayerInventoryGUI.hpp @@ -7,17 +7,18 @@ NWN_API_PROLOGUE(CNWSPlayerInventoryGUI) #endif -struct CNWSPlayer; -struct CNWSPlayerContainerGUI; -struct CNWSPlayerLUOInventory; +class CNWSPlayer; +class CNWSPlayerContainerGUI; +class CNWSPlayerLUOInventory; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerInventoryGUI +class CNWSPlayerInventoryGUI { +public: CNWSPlayerLUOInventory * m_pcLastUpdateInventory; BOOL m_bGuiInventoryOpen; uint8_t m_nSelectedInventoryPanel; diff --git a/NWNXLib/API/API/CNWSPlayerJournalQuest.hpp b/NWNXLib/API/API/CNWSPlayerJournalQuest.hpp index f53468ae9c4..d176a87ce62 100644 --- a/NWNXLib/API/API/CNWSPlayerJournalQuest.hpp +++ b/NWNXLib/API/API/CNWSPlayerJournalQuest.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWSPlayerJournalQuest) typedef int BOOL; -struct CNWSPlayerJournalQuest +class CNWSPlayerJournalQuest { +public: BOOL m_bOpen; CExoArrayList m_lstModifications; BOOL m_bFullUpdateNeeded; diff --git a/NWNXLib/API/API/CNWSPlayerJournalQuestUpdates.hpp b/NWNXLib/API/API/CNWSPlayerJournalQuestUpdates.hpp index 50dc174be64..106a353efb2 100644 --- a/NWNXLib/API/API/CNWSPlayerJournalQuestUpdates.hpp +++ b/NWNXLib/API/API/CNWSPlayerJournalQuestUpdates.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSPlayerJournalQuestUpdates) -struct CNWSPlayerJournalQuestUpdates +class CNWSPlayerJournalQuestUpdates { +public: uint16_t flags; CExoString szPlot_Id; diff --git a/NWNXLib/API/API/CNWSPlayerLUOAppearanceInfo.hpp b/NWNXLib/API/API/CNWSPlayerLUOAppearanceInfo.hpp index e8066fcb320..4994fb2a24d 100644 --- a/NWNXLib/API/API/CNWSPlayerLUOAppearanceInfo.hpp +++ b/NWNXLib/API/API/CNWSPlayerLUOAppearanceInfo.hpp @@ -14,8 +14,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerLUOAppearanceInfo +class CNWSPlayerLUOAppearanceInfo { +public: OBJECT_ID m_oidLeftHandItem; OBJECT_ID m_oidRightHandItem; uint8_t m_nRightHandItemVFX; diff --git a/NWNXLib/API/API/CNWSPlayerLUOInventory.hpp b/NWNXLib/API/API/CNWSPlayerLUOInventory.hpp index 0ff5b8e7860..eedae32c76f 100644 --- a/NWNXLib/API/API/CNWSPlayerLUOInventory.hpp +++ b/NWNXLib/API/API/CNWSPlayerLUOInventory.hpp @@ -9,15 +9,16 @@ NWN_API_PROLOGUE(CNWSPlayerLUOInventory) #endif -struct CNWSItem; +class CNWSItem; typedef CExoLinkedListNode * CExoLinkedListPosition; typedef uint32_t OBJECT_ID; -struct CNWSPlayerLUOInventory +class CNWSPlayerLUOInventory { +public: OBJECT_ID m_oidInventorySlots[18]; int32_t m_nStackSizes[18]; CExoLinkedList m_pOldRepositoryItems; diff --git a/NWNXLib/API/API/CNWSPlayerLUOInventoryItem.hpp b/NWNXLib/API/API/CNWSPlayerLUOInventoryItem.hpp index acc07dd88ee..8ded94b93e1 100644 --- a/NWNXLib/API/API/CNWSPlayerLUOInventoryItem.hpp +++ b/NWNXLib/API/API/CNWSPlayerLUOInventoryItem.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSPlayerLUOInventoryItem) typedef uint32_t OBJECT_ID; -struct CNWSPlayerLUOInventoryItem +class CNWSPlayerLUOInventoryItem { +public: OBJECT_ID oidObject; uint8_t xPos; uint8_t yPos; diff --git a/NWNXLib/API/API/CNWSPlayerLUOQuickbarItemButton.hpp b/NWNXLib/API/API/CNWSPlayerLUOQuickbarItemButton.hpp index 1a498e138f0..1136ff90c16 100644 --- a/NWNXLib/API/API/CNWSPlayerLUOQuickbarItemButton.hpp +++ b/NWNXLib/API/API/CNWSPlayerLUOQuickbarItemButton.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSPlayerLUOQuickbarItemButton) typedef uint32_t OBJECT_ID; -struct CNWSPlayerLUOQuickbarItemButton +class CNWSPlayerLUOQuickbarItemButton { +public: OBJECT_ID m_oidItem; uint8_t m_nObjectType; int32_t m_nINTParam1; diff --git a/NWNXLib/API/API/CNWSPlayerLUOSortedObjectList.hpp b/NWNXLib/API/API/CNWSPlayerLUOSortedObjectList.hpp index c4c20bb5d87..593784e9e40 100644 --- a/NWNXLib/API/API/CNWSPlayerLUOSortedObjectList.hpp +++ b/NWNXLib/API/API/CNWSPlayerLUOSortedObjectList.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSPlayerLUOSortedObjectList) typedef uint32_t OBJECT_ID; -struct CNWSPlayerLUOSortedObjectList +class CNWSPlayerLUOSortedObjectList { +public: OBJECT_ID oidObject; float fDistanceToPlayer; uint32_t nCategory; diff --git a/NWNXLib/API/API/CNWSPlayerLastUpdateObject.hpp b/NWNXLib/API/API/CNWSPlayerLastUpdateObject.hpp index 1375bba4278..d601da3432d 100644 --- a/NWNXLib/API/API/CNWSPlayerLastUpdateObject.hpp +++ b/NWNXLib/API/API/CNWSPlayerLastUpdateObject.hpp @@ -10,20 +10,21 @@ NWN_API_PROLOGUE(CNWSPlayerLastUpdateObject) #endif -struct CEffectIconObject; -struct CFeatUseListEntry; -struct CNWSStats_Spell; -struct CNWVisibilityNode; -struct CSpell_Add; -struct CSpell_Delete; +class CEffectIconObject; +class CFeatUseListEntry; +class CNWSStats_Spell; +class CNWVisibilityNode; +class CSpell_Add; +class CSpell_Delete; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerLastUpdateObject +class CNWSPlayerLastUpdateObject { +public: uint32_t m_nGold; int16_t m_nArmorClass; int16_t m_nHenchmanArmorClass; diff --git a/NWNXLib/API/API/CNWSPlayerStoreGUI.hpp b/NWNXLib/API/API/CNWSPlayerStoreGUI.hpp index 23ef11fca57..9369d00f19d 100644 --- a/NWNXLib/API/API/CNWSPlayerStoreGUI.hpp +++ b/NWNXLib/API/API/CNWSPlayerStoreGUI.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CNWSPlayerStoreGUI) #endif -struct CNWSPlayer; +class CNWSPlayer; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerStoreGUI +class CNWSPlayerStoreGUI { +public: OBJECT_ID m_oidOpen; uint8_t m_nSelectedPanel; uint8_t m_nSelectedPage; diff --git a/NWNXLib/API/API/CNWSPlayerTURD.hpp b/NWNXLib/API/API/CNWSPlayerTURD.hpp index 56612c3e178..c39cf2fe37a 100644 --- a/NWNXLib/API/API/CNWSPlayerTURD.hpp +++ b/NWNXLib/API/API/CNWSPlayerTURD.hpp @@ -12,18 +12,19 @@ NWN_API_PROLOGUE(CNWSPlayerTURD) #endif -struct CGameEffect; -struct CNWSArea; -struct CResGFF; -struct CResStruct; +class CGameEffect; +class CNWSArea; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSPlayerTURD : CNWSObject +class CNWSPlayerTURD : public CNWSObject { +public: CExoString m_sCommunityName; CExoLocString m_lsFirstName; CExoLocString m_lsLastName; diff --git a/NWNXLib/API/API/CNWSQuickbarButton.hpp b/NWNXLib/API/API/CNWSQuickbarButton.hpp index ab5dfc21413..2e9d4d642ab 100644 --- a/NWNXLib/API/API/CNWSQuickbarButton.hpp +++ b/NWNXLib/API/API/CNWSQuickbarButton.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWSQuickbarButton) typedef uint32_t OBJECT_ID; -struct CNWSQuickbarButton +class CNWSQuickbarButton { +public: OBJECT_ID m_oidItem; OBJECT_ID m_oidSecondaryItem; uint8_t m_nObjectType; diff --git a/NWNXLib/API/API/CNWSRules.hpp b/NWNXLib/API/API/CNWSRules.hpp index 19af3ac9c0a..6b83a9f8e92 100644 --- a/NWNXLib/API/API/CNWSRules.hpp +++ b/NWNXLib/API/API/CNWSRules.hpp @@ -12,9 +12,9 @@ NWN_API_PROLOGUE(CNWSRules) -struct CNWSRules : CNWRules +class CNWSRules : public CNWRules { - +public: CNWSRules(); ~CNWSRules(); diff --git a/NWNXLib/API/API/CNWSScriptVar.hpp b/NWNXLib/API/API/CNWSScriptVar.hpp index d634c7ba1a6..ecaf6fe7e08 100644 --- a/NWNXLib/API/API/CNWSScriptVar.hpp +++ b/NWNXLib/API/API/CNWSScriptVar.hpp @@ -16,8 +16,9 @@ NWN_API_PROLOGUE(CNWSScriptVar) typedef uint32_t OBJECT_ID; -struct CNWSScriptVar +class CNWSScriptVar { +public: int32_t m_int; float m_float; OBJECT_ID m_objectId; diff --git a/NWNXLib/API/API/CNWSScriptVarTable.hpp b/NWNXLib/API/API/CNWSScriptVarTable.hpp index 67130405895..09cc9f54c6d 100644 --- a/NWNXLib/API/API/CNWSScriptVarTable.hpp +++ b/NWNXLib/API/API/CNWSScriptVarTable.hpp @@ -13,18 +13,19 @@ NWN_API_PROLOGUE(CNWSScriptVarTable) #endif -struct CNWSCreature; -struct CNWSScriptVar; -struct CResGFF; -struct CResStruct; +class CNWSCreature; +class CNWSScriptVar; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSScriptVarTable +class CNWSScriptVarTable { +public: std::unordered_map m_vars; CNWSCreature * m_pCreature; diff --git a/NWNXLib/API/API/CNWSSoundObject.hpp b/NWNXLib/API/API/CNWSSoundObject.hpp index 25d94e50421..7ea6e6074f2 100644 --- a/NWNXLib/API/API/CNWSSoundObject.hpp +++ b/NWNXLib/API/API/CNWSSoundObject.hpp @@ -11,18 +11,19 @@ NWN_API_PROLOGUE(CNWSSoundObject) #endif -struct CNWSArea; -struct CNWSMessage; -struct CResGFF; -struct CResStruct; +class CNWSArea; +class CNWSMessage; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSSoundObject : CNWSObject +class CNWSSoundObject : public CNWSObject { +public: BOOL m_bIsActive; BOOL m_bPositional; BOOL m_bLooping; diff --git a/NWNXLib/API/API/CNWSSpellScriptData.hpp b/NWNXLib/API/API/CNWSSpellScriptData.hpp index b9e2ecf81f3..34557b18d57 100644 --- a/NWNXLib/API/API/CNWSSpellScriptData.hpp +++ b/NWNXLib/API/API/CNWSSpellScriptData.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CNWSSpellScriptData) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSSpellScriptData +class CNWSSpellScriptData { +public: int32_t m_nSpellId; uint16_t m_nFeatId; OBJECT_ID m_oidCaster; diff --git a/NWNXLib/API/API/CNWSStats_Spell.hpp b/NWNXLib/API/API/CNWSStats_Spell.hpp index 17957aa8e7c..916439560e4 100644 --- a/NWNXLib/API/API/CNWSStats_Spell.hpp +++ b/NWNXLib/API/API/CNWSStats_Spell.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSStats_Spell) typedef int BOOL; -struct CNWSStats_Spell +class CNWSStats_Spell { +public: uint32_t m_nSpellId; BOOL m_bReadied; uint8_t m_nMetaType; diff --git a/NWNXLib/API/API/CNWSStats_SpellLikeAbility.hpp b/NWNXLib/API/API/CNWSStats_SpellLikeAbility.hpp index 71a7b73ef40..4765ae9a1c0 100644 --- a/NWNXLib/API/API/CNWSStats_SpellLikeAbility.hpp +++ b/NWNXLib/API/API/CNWSStats_SpellLikeAbility.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSStats_SpellLikeAbility) typedef int BOOL; -struct CNWSStats_SpellLikeAbility +class CNWSStats_SpellLikeAbility { +public: uint32_t m_nSpellId; BOOL m_bReadied; uint8_t m_nCasterLevel; diff --git a/NWNXLib/API/API/CNWSStore.hpp b/NWNXLib/API/API/CNWSStore.hpp index 82ecacc7488..cf91feb4f85 100644 --- a/NWNXLib/API/API/CNWSStore.hpp +++ b/NWNXLib/API/API/CNWSStore.hpp @@ -12,23 +12,24 @@ NWN_API_PROLOGUE(CNWSStore) #endif -struct CItemRepository; -struct CNWSArea; -struct CNWSCreature; -struct CNWSItem; -struct CNWSPlayer; -struct CResGFF; -struct CResStruct; -struct CStoreCustomer; -struct CStoreCustomer; +class CItemRepository; +class CNWSArea; +class CNWSCreature; +class CNWSItem; +class CNWSPlayer; +class CResGFF; +class CResStruct; +class CStoreCustomer; +class CStoreCustomer; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSStore : CNWSObject +class CNWSStore : public CNWSObject { +public: CExoString m_sScripts[2]; CItemRepository * m_aInventory[5]; CExoArrayList m_aCurrentCustomers; diff --git a/NWNXLib/API/API/CNWSSysAdmin.hpp b/NWNXLib/API/API/CNWSSysAdmin.hpp index ee981df2845..ecefa796008 100644 --- a/NWNXLib/API/API/CNWSSysAdmin.hpp +++ b/NWNXLib/API/API/CNWSSysAdmin.hpp @@ -12,9 +12,9 @@ NWN_API_PROLOGUE(CNWSSysAdmin) -struct CNWSSysAdmin : CNWSClient +class CNWSSysAdmin : public CNWSClient { - +public: CNWSSysAdmin(uint32_t nPlayerID); ~CNWSSysAdmin(); virtual CNWSSysAdmin * AsNWSSysAdmin(); diff --git a/NWNXLib/API/API/CNWSTagNode.hpp b/NWNXLib/API/API/CNWSTagNode.hpp index c4566aad66c..41fe1b26323 100644 --- a/NWNXLib/API/API/CNWSTagNode.hpp +++ b/NWNXLib/API/API/CNWSTagNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSTagNode) typedef uint32_t OBJECT_ID; -struct CNWSTagNode +class CNWSTagNode { +public: char m_szTag[64+1]; OBJECT_ID m_oidObjectId; diff --git a/NWNXLib/API/API/CNWSTile.hpp b/NWNXLib/API/API/CNWSTile.hpp index f4ba6680bb9..05ce318e80e 100644 --- a/NWNXLib/API/API/CNWSTile.hpp +++ b/NWNXLib/API/API/CNWSTile.hpp @@ -11,17 +11,18 @@ NWN_API_PROLOGUE(CNWSTile) #endif -struct CNWArea; -struct CNWTileData; -struct CPathfindInformation; +class CNWArea; +class CNWTileData; +class CPathfindInformation; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSTile : CNWTile +class CNWSTile : public CNWTile { +public: CNWTileData * m_pTileData; int32_t m_nTriggers; int32_t m_nTriggerSize; diff --git a/NWNXLib/API/API/CNWSTransition.hpp b/NWNXLib/API/API/CNWSTransition.hpp index b3d326f8cfd..3cbb7788d75 100644 --- a/NWNXLib/API/API/CNWSTransition.hpp +++ b/NWNXLib/API/API/CNWSTransition.hpp @@ -8,17 +8,18 @@ NWN_API_PROLOGUE(CNWSTransition) #endif -struct CNWSObject; -struct CResGFF; -struct CResStruct; +class CNWSObject; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSTransition +class CNWSTransition { +public: CExoString m_sTransitionTarget; OBJECT_ID m_oidCachedTransitionTarget; diff --git a/NWNXLib/API/API/CNWSTrigger.hpp b/NWNXLib/API/API/CNWSTrigger.hpp index b11a639c1a7..9ad0bac0525 100644 --- a/NWNXLib/API/API/CNWSTrigger.hpp +++ b/NWNXLib/API/API/CNWSTrigger.hpp @@ -13,18 +13,19 @@ NWN_API_PROLOGUE(CNWSTrigger) #endif -struct CNWSArea; -struct CResGFF; -struct CResStruct; -struct CScriptLocation; +class CNWSArea; +class CResGFF; +class CResStruct; +class CScriptLocation; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSTrigger : CNWSObject +class CNWSTrigger : public CNWSObject { +public: CExoLocString m_sLocalizedName; CExoString m_sDescriptionOverride; CExoString m_sScripts[7]; diff --git a/NWNXLib/API/API/CNWSUUID.hpp b/NWNXLib/API/API/CNWSUUID.hpp index 1e4ae1ebcf4..372e8176ff4 100644 --- a/NWNXLib/API/API/CNWSUUID.hpp +++ b/NWNXLib/API/API/CNWSUUID.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CNWSUUID) #endif -struct CGameObject; -struct CResGFF; -struct CResStruct; +class CGameObject; +class CResGFF; +class CResStruct; -struct CNWSUUID +class CNWSUUID { +public: CGameObject * m_parent; CExoString m_uuid; @@ -31,8 +32,8 @@ struct CNWSUUID bool TryAssign(const CExoString & uuid); void AssignRandom(); CExoString GetOrAssignRandom(); - bool LoadFromGff(CResGFF * pRes, CResStruct * pStruct); - void SaveToGff(CResGFF * pRes, CResStruct * pStruct); + NWNX_IMPORT bool LoadFromGff(CResGFF * pRes, CResStruct * pStruct); + NWNX_IMPORT void SaveToGff(CResGFF * pRes, CResStruct * pStruct); #ifdef NWN_CLASS_EXTENSION_CNWSUUID diff --git a/NWNXLib/API/API/CNWSWaypoint.hpp b/NWNXLib/API/API/CNWSWaypoint.hpp index cceebb48bb2..0f96aeebdc3 100644 --- a/NWNXLib/API/API/CNWSWaypoint.hpp +++ b/NWNXLib/API/API/CNWSWaypoint.hpp @@ -10,18 +10,19 @@ NWN_API_PROLOGUE(CNWSWaypoint) #endif -struct CExoString; -struct CNWSArea; -struct CResGFF; -struct CResStruct; +class CExoString; +class CNWSArea; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWSWaypoint : CNWSObject +class CNWSWaypoint : public CNWSObject { +public: BOOL m_bMapNote; BOOL m_bMapNoteEnabled; CExoLocString m_szMapNote; diff --git a/NWNXLib/API/API/CNWSkill.hpp b/NWNXLib/API/API/CNWSkill.hpp index 4f280b651bc..ae0f7dda4d3 100644 --- a/NWNXLib/API/API/CNWSkill.hpp +++ b/NWNXLib/API/API/CNWSkill.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWSkill) typedef int BOOL; -struct CNWSkill +class CNWSkill { +public: int32_t m_nNameStrref; int32_t m_nDescriptionStrref; int32_t m_nTalentCategory; diff --git a/NWNXLib/API/API/CNWSpell.hpp b/NWNXLib/API/API/CNWSpell.hpp index d7b340ee743..63fe8e83dc4 100644 --- a/NWNXLib/API/API/CNWSpell.hpp +++ b/NWNXLib/API/API/CNWSpell.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(CNWSpell) typedef int BOOL; -struct CNWSpell +class CNWSpell { +public: CExoString m_sLabel; int32_t m_strrefName; uint32_t m_strrefDesc; diff --git a/NWNXLib/API/API/CNWSpellArray.hpp b/NWNXLib/API/API/CNWSpellArray.hpp index 2f82f3f0d8b..5830f8e505c 100644 --- a/NWNXLib/API/API/CNWSpellArray.hpp +++ b/NWNXLib/API/API/CNWSpellArray.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWSpellArray) -struct CNWSpellArray +class CNWSpellArray { +public: int32_t m_nNumSpells; CNWSpell * m_pSpells; diff --git a/NWNXLib/API/API/CNWSync.hpp b/NWNXLib/API/API/CNWSync.hpp index 5416d11614a..6135c2bc73a 100644 --- a/NWNXLib/API/API/CNWSync.hpp +++ b/NWNXLib/API/API/CNWSync.hpp @@ -11,12 +11,13 @@ NWN_API_PROLOGUE(CNWSync) namespace NWSync { -struct CNWSync { +class CNWSync { +public: void *m_internal; char *m_tmp1; uint32_t m_tmp2; - struct ManifestMetaData { + class ManifestMetaData { Hash::SHA1 m_sha1; uint32_t m_hashTreeDepth; CExoString m_moduleName; diff --git a/NWNXLib/API/API/CNWTile.hpp b/NWNXLib/API/API/CNWTile.hpp index 0af2f3cba05..014a2e1ed47 100644 --- a/NWNXLib/API/API/CNWTile.hpp +++ b/NWNXLib/API/API/CNWTile.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNWTile) -struct CNWTile : CCallbackHandlerBase +class CNWTile : public CCallbackHandlerBase { +public: Vector m_vModelPosition; int32_t m_nID; int32_t m_nHeight; diff --git a/NWNXLib/API/API/CNWTileData.hpp b/NWNXLib/API/API/CNWTileData.hpp index 1ebc7d624c4..58ad3ddd285 100644 --- a/NWNXLib/API/API/CNWTileData.hpp +++ b/NWNXLib/API/API/CNWTileData.hpp @@ -10,14 +10,15 @@ NWN_API_PROLOGUE(CNWTileData) #endif -struct CNWTileSurfaceMesh; +class CNWTileSurfaceMesh; typedef int BOOL; -struct CNWTileData +class CNWTileData { +public: CExoLinkedList * m_pMethodStringList; CNWTileSurfaceMesh * m_pSurfaceMesh; CResRef m_refModel; diff --git a/NWNXLib/API/API/CNWTilePathNode.hpp b/NWNXLib/API/API/CNWTilePathNode.hpp index 6a483173ee6..558728d50a7 100644 --- a/NWNXLib/API/API/CNWTilePathNode.hpp +++ b/NWNXLib/API/API/CNWTilePathNode.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWTilePathNode) -struct CNWTilePathNode +class CNWTilePathNode { +public: int32_t m_nRegionNodes; int32_t m_nTileExits; float * m_pfRegionNodes; diff --git a/NWNXLib/API/API/CNWTileSet.hpp b/NWNXLib/API/API/CNWTileSet.hpp index 14edaf3941e..755bb4434dd 100644 --- a/NWNXLib/API/API/CNWTileSet.hpp +++ b/NWNXLib/API/API/CNWTileSet.hpp @@ -12,14 +12,15 @@ NWN_API_PROLOGUE(CNWTileSet) #endif -struct CNWTileData; +class CNWTileData; typedef int BOOL; -struct CNWTileSet : CResHelper +class CNWTileSet : public CResHelper { +public: CResRef m_resrefName; CResRef m_cEnvMap; float m_fHeightTransition; diff --git a/NWNXLib/API/API/CNWTileSetManager.hpp b/NWNXLib/API/API/CNWTileSetManager.hpp index 0b87553c963..a1fedd5bb01 100644 --- a/NWNXLib/API/API/CNWTileSetManager.hpp +++ b/NWNXLib/API/API/CNWTileSetManager.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CNWTileSetManager) #endif -struct CNWTilePathNode; -struct CNWTileSet; +class CNWTilePathNode; +class CNWTileSet; -struct CNWTileSetManager +class CNWTileSetManager { +public: CNWTileSet * m_apTileSets[100]; int32_t m_anTileSetRegistered[100]; CNWTilePathNode * m_apTileNodes[50][4]; diff --git a/NWNXLib/API/API/CNWTileSurfaceMesh.hpp b/NWNXLib/API/API/CNWTileSurfaceMesh.hpp index e800cd1457f..f3d966ef16f 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMesh.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMesh.hpp @@ -12,19 +12,20 @@ NWN_API_PROLOGUE(CNWTileSurfaceMesh) #endif -struct CNWArea; -struct CNWTile; -struct CNWTileSurfaceMeshAABBNode; -struct CNWTileSurfaceMeshHashTableEntry; -struct CPathfindInfoIntraTileSuccessors; -struct CPathfindInformation; +class CNWArea; +class CNWTile; +class CNWTileSurfaceMeshAABBNode; +class CNWTileSurfaceMeshHashTableEntry; +class CPathfindInfoIntraTileSuccessors; +class CPathfindInformation; typedef int BOOL; -struct CNWTileSurfaceMesh : CResHelper +class CNWTileSurfaceMesh : public CResHelper { +public: CResRef m_cWalkMesh; uint8_t m_nPathNode; int32_t m_nPathNodeOrientation; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshAABBNode.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshAABBNode.hpp index b1f08e0e20c..71fd19fb3de 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshAABBNode.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshAABBNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshAABBNode) -struct CNWTileSurfaceMeshAABBNode +class CNWTileSurfaceMeshAABBNode { +public: Vector vBoundBoxMin; Vector vBoundBoxMax; int32_t nTriangleId; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshHashTableEntry.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshHashTableEntry.hpp index cff50133b7a..a5c39d04e30 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshHashTableEntry.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshHashTableEntry.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshHashTableEntry) -struct CNWTileSurfaceMeshHashTableEntry +class CNWTileSurfaceMeshHashTableEntry { +public: int32_t m_nBestTriangle; int32_t m_nRecentTriangle; float m_fBestAttemptedDepth; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshLocalInfo.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshLocalInfo.hpp index 4002d0563e5..bcc14b41550 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshLocalInfo.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshLocalInfo.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshLocalInfo) -struct CNWTileSurfaceMeshLocalInfo +class CNWTileSurfaceMeshLocalInfo { +public: int32_t pnEdgeUsed[12]; Vector pfVertex[3]; int32_t pnVertexIndex[3]; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshNodeFace.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshNodeFace.hpp index b18faa33181..cb7ccd9b1cc 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshNodeFace.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshNodeFace.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshNodeFace) -struct CNWTileSurfaceMeshNodeFace +class CNWTileSurfaceMeshNodeFace { +public: int32_t * pnUselessPointer1; int32_t * pnUselessPointer2; int32_t * pnUselessPointer3; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshNodeVertex.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshNodeVertex.hpp index 8159d4c0088..d85308d18c4 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshNodeVertex.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshNodeVertex.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshNodeVertex) -struct CNWTileSurfaceMeshNodeVertex +class CNWTileSurfaceMeshNodeVertex { +public: float fVirtualWasteOfSpace; Vector vCoord; Vector vTexCoord; diff --git a/NWNXLib/API/API/CNWTileSurfaceMeshSortSuccessors.hpp b/NWNXLib/API/API/CNWTileSurfaceMeshSortSuccessors.hpp index a3edfdcfe48..285cfe9b571 100644 --- a/NWNXLib/API/API/CNWTileSurfaceMeshSortSuccessors.hpp +++ b/NWNXLib/API/API/CNWTileSurfaceMeshSortSuccessors.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CNWTileSurfaceMeshSortSuccessors) -struct CNWTileSurfaceMeshSortSuccessors +class CNWTileSurfaceMeshSortSuccessors { +public: int32_t nPathLevel; float fEstimateDistance; diff --git a/NWNXLib/API/API/CNWVirtualMachineCommands.hpp b/NWNXLib/API/API/CNWVirtualMachineCommands.hpp index 6cd4bf1765e..d3c37f56d14 100644 --- a/NWNXLib/API/API/CNWVirtualMachineCommands.hpp +++ b/NWNXLib/API/API/CNWVirtualMachineCommands.hpp @@ -9,9 +9,9 @@ NWN_API_PROLOGUE(CNWVirtualMachineCommands) #endif -struct C2DA; -struct CResGFF; -struct CResStruct; +class C2DA; +class CResGFF; +class CResStruct; typedef int32_t (*pfCVMCommands)(int32_t, int32_t); @@ -19,8 +19,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CNWVirtualMachineCommands : CVirtualMachineCmdImplementer +class CNWVirtualMachineCommands : public CVirtualMachineCmdImplementer { +public: pfCVMCommands * m_pVirtualMachineCommands; ~CNWVirtualMachineCommands(); @@ -469,7 +470,7 @@ struct CNWVirtualMachineCommands : CVirtualMachineCmdImplementer int32_t ExecuteCommandGetTurnResistanceHD(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandGetUseableFlag(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandGetUserDefinedEventNumber(int32_t nCommandId, int32_t nParameters); - int32_t ExecuteCommandGetVar(int32_t nCommandId, int32_t nParameters); + NWNX_IMPORT int32_t ExecuteCommandGetVar(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandGetWaypointByTag(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandGetTransitionTarget(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandGetSurfaceMaterial(int32_t nCommandId, int32_t nParameters); @@ -525,7 +526,7 @@ struct CNWVirtualMachineCommands : CVirtualMachineCmdImplementer int32_t ExecuteCommandPersonalReputationAccess(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandPickUpItem(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandPlayAnimation(int32_t nCommandId, int32_t nParameters); - int32_t ExecuteCommandPlaySound(int32_t nCommandId, int32_t nParameters); + NWNX_IMPORT int32_t ExecuteCommandPlaySound(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandPlaySoundByStrRef(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandPopUpGUIPanel(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandPostString(int32_t nCommandId, int32_t nParameters); @@ -652,7 +653,7 @@ struct CNWVirtualMachineCommands : CVirtualMachineCmdImplementer int32_t ExecuteCommandSetTransitionTarget(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSetTrapInfo(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSetUseableFlag(int32_t nCommandId, int32_t nParameters); - int32_t ExecuteCommandSetVar(int32_t nCommandId, int32_t nParameters); + NWNX_IMPORT int32_t ExecuteCommandSetVar(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSetWeather(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSetXP(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSetXPScale(int32_t nCommandId, int32_t nParameters); @@ -683,8 +684,8 @@ struct CNWVirtualMachineCommands : CVirtualMachineCmdImplementer int32_t ExecuteCommandStringToObject(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSummonAssociate(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandSurrenderToEnemies(int32_t nCommandId, int32_t nParameters); - int32_t ExecuteCommandTagEffect(int32_t nCommandId, int32_t nParameters); - int32_t ExecuteCommandTagItemProperty(int32_t nCommandId, int32_t nParameters); + NWNX_IMPORT int32_t ExecuteCommandTagEffect(int32_t nCommandId, int32_t nParameters); + NWNX_IMPORT int32_t ExecuteCommandTagItemProperty(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandTakeGoldFromCreature(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandTalent(int32_t nCommandId, int32_t nParameters); int32_t ExecuteCommandTalentAccess(int32_t nCommandId, int32_t nParameters); diff --git a/NWNXLib/API/API/CNWVisibilityNode.hpp b/NWNXLib/API/API/CNWVisibilityNode.hpp index ea8369e5ef8..ee13d86f63b 100644 --- a/NWNXLib/API/API/CNWVisibilityNode.hpp +++ b/NWNXLib/API/API/CNWVisibilityNode.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CNWVisibilityNode) typedef uint32_t OBJECT_ID; -struct CNWVisibilityNode +class CNWVisibilityNode { +public: OBJECT_ID m_oidCreature; uint8_t m_bSeen : 1; uint8_t m_bHeard : 1; diff --git a/NWNXLib/API/API/CNetLayer.hpp b/NWNXLib/API/API/CNetLayer.hpp index 77219e8af14..67686dff136 100644 --- a/NWNXLib/API/API/CNetLayer.hpp +++ b/NWNXLib/API/API/CNetLayer.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CNetLayer) #endif -struct CBaseExoApp; -struct CNetLayerInternal; -struct CNetLayerPlayerInfo; -struct CNetLayerSessionInfo; +class CBaseExoApp; +class CNetLayerInternal; +class CNetLayerPlayerInfo; +class CNetLayerSessionInfo; typedef int BOOL; -struct CNetLayer +class CNetLayer { +public: CNetLayerInternal * m_pcNetLayerInternal; CNetLayer(); diff --git a/NWNXLib/API/API/CNetLayerPlayerCDKeyInfo.hpp b/NWNXLib/API/API/CNetLayerPlayerCDKeyInfo.hpp index b8938b3be8f..65d9f713004 100644 --- a/NWNXLib/API/API/CNetLayerPlayerCDKeyInfo.hpp +++ b/NWNXLib/API/API/CNetLayerPlayerCDKeyInfo.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CNetLayerPlayerCDKeyInfo) typedef int BOOL; -struct CNetLayerPlayerCDKeyInfo +class CNetLayerPlayerCDKeyInfo { +public: CExoString sPublic; CExoString sResponse; BOOL bValidated; diff --git a/NWNXLib/API/API/CNetLayerPlayerInfo.hpp b/NWNXLib/API/API/CNetLayerPlayerInfo.hpp index 3fc8794b939..7b71c1da5f3 100644 --- a/NWNXLib/API/API/CNetLayerPlayerInfo.hpp +++ b/NWNXLib/API/API/CNetLayerPlayerInfo.hpp @@ -15,8 +15,9 @@ NWN_API_PROLOGUE(CNetLayerPlayerInfo) typedef int BOOL; -struct CNetLayerPlayerInfo +class CNetLayerPlayerInfo { +public: BOOL m_bPlayerInUse; CExoString m_sPlayerName; int32_t m_nPlayerLanguage; diff --git a/NWNXLib/API/API/CNetLayerSessionInfo.hpp b/NWNXLib/API/API/CNetLayerSessionInfo.hpp index 6294a580f50..6f4bd68887f 100644 --- a/NWNXLib/API/API/CNetLayerSessionInfo.hpp +++ b/NWNXLib/API/API/CNetLayerSessionInfo.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CNetLayerSessionInfo) #endif -struct CExtendedServerInfo; +class CExtendedServerInfo; typedef int BOOL; -struct CNetLayerSessionInfo +class CNetLayerSessionInfo { +public: uint32_t m_nConnectionId; CExoString m_sSessionName; uint32_t m_nProtocol; diff --git a/NWNXLib/API/API/CNetLayerWindow.hpp b/NWNXLib/API/API/CNetLayerWindow.hpp index 76604ff45d7..29f216d45b8 100644 --- a/NWNXLib/API/API/CNetLayerWindow.hpp +++ b/NWNXLib/API/API/CNetLayerWindow.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CNetLayerWindow) #endif -struct CNetLayerInternal; -struct z_stream; +class CNetLayerInternal; +class z_stream; typedef int BOOL; -struct CNetLayerWindow +class CNetLayerWindow { +public: BOOL m_bInitialized; CNetLayerInternal * m_pNetLayer; BOOL m_bWindowInUse; diff --git a/NWNXLib/API/API/CObjectLookupTable.hpp b/NWNXLib/API/API/CObjectLookupTable.hpp index 27677592fe0..7c9af9d0c48 100644 --- a/NWNXLib/API/API/CObjectLookupTable.hpp +++ b/NWNXLib/API/API/CObjectLookupTable.hpp @@ -13,8 +13,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CObjectLookupTable +class CObjectLookupTable { +public: OBJECT_ID * m_pdwObjectTable; uint32_t m_dwStart; uint32_t m_dwEnd; diff --git a/NWNXLib/API/API/CObjectTableManager.hpp b/NWNXLib/API/API/CObjectTableManager.hpp index 28c81f3e79b..03ddb7d88cb 100644 --- a/NWNXLib/API/API/CObjectTableManager.hpp +++ b/NWNXLib/API/API/CObjectTableManager.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CObjectTableManager) #endif -struct CObjectLookupTable; +class CObjectLookupTable; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CObjectTableManager +class CObjectTableManager { +public: CObjectLookupTable * m_pObjectTableArray[0xff]; uint32_t m_dwMaxPlayerID; diff --git a/NWNXLib/API/API/CPathfindInfoIntraTileSuccessors.hpp b/NWNXLib/API/API/CPathfindInfoIntraTileSuccessors.hpp index 437c3989389..6a6d7964c89 100644 --- a/NWNXLib/API/API/CPathfindInfoIntraTileSuccessors.hpp +++ b/NWNXLib/API/API/CPathfindInfoIntraTileSuccessors.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CPathfindInfoIntraTileSuccessors) -struct CPathfindInfoIntraTileSuccessors +class CPathfindInfoIntraTileSuccessors { +public: float fXTransit; float fYTransit; float fNewX; diff --git a/NWNXLib/API/API/CPathfindInformation.hpp b/NWNXLib/API/API/CPathfindInformation.hpp index 3dd49d91dd1..5150cb95d81 100644 --- a/NWNXLib/API/API/CPathfindInformation.hpp +++ b/NWNXLib/API/API/CPathfindInformation.hpp @@ -10,16 +10,17 @@ NWN_API_PROLOGUE(CPathfindInformation) #endif -struct CNWTileSurfaceMeshHashTableEntry; -struct CPathfindInfoIntraTileSuccessors; +class CNWTileSurfaceMeshHashTableEntry; +class CPathfindInfoIntraTileSuccessors; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CPathfindInformation +class CPathfindInformation { +public: BOOL m_bClientMoving; float m_fPersonalSpace; float m_fCreaturePersonalSpace; diff --git a/NWNXLib/API/API/CPersistantWorldOptions.hpp b/NWNXLib/API/API/CPersistantWorldOptions.hpp index 56c5dfecbf3..048809825a3 100644 --- a/NWNXLib/API/API/CPersistantWorldOptions.hpp +++ b/NWNXLib/API/API/CPersistantWorldOptions.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CPersistantWorldOptions) typedef int BOOL; -struct CPersistantWorldOptions +class CPersistantWorldOptions { +public: BOOL bVaultCharsOnly; BOOL bSaveCharsInSaveGame; BOOL bSuppressBaseServerVault; diff --git a/NWNXLib/API/API/CPlayOptions.hpp b/NWNXLib/API/API/CPlayOptions.hpp index 1277fd4ec75..becf72e83b4 100644 --- a/NWNXLib/API/API/CPlayOptions.hpp +++ b/NWNXLib/API/API/CPlayOptions.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CPlayOptions) typedef int BOOL; -struct CPlayOptions +class CPlayOptions { +public: BOOL bAllKillable; BOOL bNonPartyKillable; BOOL bRequireResurrection; diff --git a/NWNXLib/API/API/CRes.hpp b/NWNXLib/API/API/CRes.hpp index 415a420ce5b..fe25c80e99b 100644 --- a/NWNXLib/API/API/CRes.hpp +++ b/NWNXLib/API/API/CRes.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CRes) #endif -struct CKeyTableEntry; +class CKeyTableEntry; typedef int BOOL; typedef CExoLinkedListNode * CExoLinkedListPosition; -struct CRes +class CRes { +public: uint16_t m_nDemands; RESID m_nID; uint32_t m_status; diff --git a/NWNXLib/API/API/CRes2DA.hpp b/NWNXLib/API/API/CRes2DA.hpp index 622244e1c10..a340a211a1b 100644 --- a/NWNXLib/API/API/CRes2DA.hpp +++ b/NWNXLib/API/API/CRes2DA.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CRes2DA) #endif -struct EXO2DAHEADER; +class EXO2DAHEADER; typedef int BOOL; -struct CRes2DA : CRes +class CRes2DA : public CRes { +public: BOOL m_bLoaded; uint32_t m_n2DANormalSize; uint8_t * m_p2DAData; diff --git a/NWNXLib/API/API/CResARE.hpp b/NWNXLib/API/API/CResARE.hpp index 0472399ed15..4876a1ffb59 100644 --- a/NWNXLib/API/API/CResARE.hpp +++ b/NWNXLib/API/API/CResARE.hpp @@ -12,9 +12,9 @@ NWN_API_PROLOGUE(CResARE) -struct CResARE : CResGFF +class CResARE : public CResGFF { - +public: #ifdef NWN_CLASS_EXTENSION_CResARE diff --git a/NWNXLib/API/API/CResDWK.hpp b/NWNXLib/API/API/CResDWK.hpp index 66b942a5b02..b0c95112f6e 100644 --- a/NWNXLib/API/API/CResDWK.hpp +++ b/NWNXLib/API/API/CResDWK.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResDWK) typedef int BOOL; -struct CResDWK : CRes +class CResDWK : public CRes { +public: BOOL m_bLoaded; uint32_t m_nDWKNormalSize; uint8_t * m_pDWKData; diff --git a/NWNXLib/API/API/CResGFF.hpp b/NWNXLib/API/API/CResGFF.hpp index 3d09dfbe6bb..c3c9a0cfb7f 100644 --- a/NWNXLib/API/API/CResGFF.hpp +++ b/NWNXLib/API/API/CResGFF.hpp @@ -11,21 +11,22 @@ NWN_API_PROLOGUE(CResGFF) #endif -struct CExoFile; -struct CResGFFField; -struct CResGFFFileHeader; -struct CResGFFLabel; -struct CResGFFStruct; -struct CResList; -struct CResStruct; +class CExoFile; +class CResGFFField; +class CResGFFFileHeader; +class CResGFFLabel; +class CResGFFStruct; +class CResList; +class CResStruct; typedef int BOOL; typedef uint16_t RESTYPE; -struct CResGFF : CRes +class CResGFF : public CRes { +public: uint32_t STRUCT_GROWSIZE; uint32_t FIELD_GROWSIZE; uint32_t LABEL_GROWSIZE; diff --git a/NWNXLib/API/API/CResGFFField.hpp b/NWNXLib/API/API/CResGFFField.hpp index 5ed4e75c347..8f82ead8a27 100644 --- a/NWNXLib/API/API/CResGFFField.hpp +++ b/NWNXLib/API/API/CResGFFField.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResGFFField) -struct CResGFFField +class CResGFFField { +public: uint32_t m_nType; uint32_t m_nLabelIndex; uint32_t m_nDataOrDataOffset; diff --git a/NWNXLib/API/API/CResGFFFileHeader.hpp b/NWNXLib/API/API/CResGFFFileHeader.hpp index efbb89d8d70..091be7b2581 100644 --- a/NWNXLib/API/API/CResGFFFileHeader.hpp +++ b/NWNXLib/API/API/CResGFFFileHeader.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResGFFFileHeader) -struct CResGFFFileHeader +class CResGFFFileHeader { +public: uint32_t m_nFileType; uint32_t m_nFileVersion; uint32_t m_nStructOffset; diff --git a/NWNXLib/API/API/CResGFFLabel.hpp b/NWNXLib/API/API/CResGFFLabel.hpp index 4da308bc324..a677c56797e 100644 --- a/NWNXLib/API/API/CResGFFLabel.hpp +++ b/NWNXLib/API/API/CResGFFLabel.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResGFFLabel) -struct CResGFFLabel +class CResGFFLabel { +public: char m_pLabel[16]; diff --git a/NWNXLib/API/API/CResGFFStruct.hpp b/NWNXLib/API/API/CResGFFStruct.hpp index d589d58f974..b03ad26adff 100644 --- a/NWNXLib/API/API/CResGFFStruct.hpp +++ b/NWNXLib/API/API/CResGFFStruct.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResGFFStruct) -struct CResGFFStruct +class CResGFFStruct { +public: uint32_t m_nType; uint32_t m_nDataOrDataOffset; uint32_t m_nFieldCount; diff --git a/NWNXLib/API/API/CResGenericFileHeader.hpp b/NWNXLib/API/API/CResGenericFileHeader.hpp index c7f9703af5e..bb7e9fe0c6c 100644 --- a/NWNXLib/API/API/CResGenericFileHeader.hpp +++ b/NWNXLib/API/API/CResGenericFileHeader.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResGenericFileHeader) -struct CResGenericFileHeader +class CResGenericFileHeader { +public: uint32_t m_nFileType; uint32_t m_nVersion; diff --git a/NWNXLib/API/API/CResHelper.hpp b/NWNXLib/API/API/CResHelper.hpp index 4782aa5bf3b..83f42033234 100644 --- a/NWNXLib/API/API/CResHelper.hpp +++ b/NWNXLib/API/API/CResHelper.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResHelper) typedef int BOOL; -template struct CResHelper +template class CResHelper { +public: T * m_pRes; CResRef m_cResRef; diff --git a/NWNXLib/API/API/CResIFO.hpp b/NWNXLib/API/API/CResIFO.hpp index 22e6603274b..124d097aa8c 100644 --- a/NWNXLib/API/API/CResIFO.hpp +++ b/NWNXLib/API/API/CResIFO.hpp @@ -12,9 +12,9 @@ NWN_API_PROLOGUE(CResIFO) -struct CResIFO : CResGFF +class CResIFO : public CResGFF { - +public: #ifdef NWN_CLASS_EXTENSION_CResIFO diff --git a/NWNXLib/API/API/CResLTR.hpp b/NWNXLib/API/API/CResLTR.hpp index 0420c4c1dd6..23b0b061fc4 100644 --- a/NWNXLib/API/API/CResLTR.hpp +++ b/NWNXLib/API/API/CResLTR.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CResLTR) #endif -struct EXOLTRHEADER; +class EXOLTRHEADER; typedef int BOOL; -struct CResLTR : CRes +class CResLTR : public CRes { +public: float * * * m_pStartTripleLetterProb; float * * * m_pMiddleTripleLetterProb; float * * * m_pEndTripleLetterProb; diff --git a/NWNXLib/API/API/CResList.hpp b/NWNXLib/API/API/CResList.hpp index 4fba0f1087f..857038bf658 100644 --- a/NWNXLib/API/API/CResList.hpp +++ b/NWNXLib/API/API/CResList.hpp @@ -9,8 +9,9 @@ NWN_API_PROLOGUE(CResList) #endif -struct CResList : CResStruct +class CResList : public CResStruct { +public: char m_pLabel[16]; diff --git a/NWNXLib/API/API/CResNCS.hpp b/NWNXLib/API/API/CResNCS.hpp index f4f1c2441ea..3084fc176fd 100644 --- a/NWNXLib/API/API/CResNCS.hpp +++ b/NWNXLib/API/API/CResNCS.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResNCS) typedef int BOOL; -struct CResNCS : CRes +class CResNCS : public CRes { +public: BOOL m_bLoaded; uint32_t m_nNCSNormalSize; uint8_t * m_pNCSData; diff --git a/NWNXLib/API/API/CResNDB.hpp b/NWNXLib/API/API/CResNDB.hpp index 829b9a231b4..9f8363754b0 100644 --- a/NWNXLib/API/API/CResNDB.hpp +++ b/NWNXLib/API/API/CResNDB.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResNDB) typedef int BOOL; -struct CResNDB : CRes +class CResNDB : public CRes { +public: BOOL m_bLoaded; uint32_t m_nNDBNormalSize; uint8_t * m_pNDBData; diff --git a/NWNXLib/API/API/CResNSS.hpp b/NWNXLib/API/API/CResNSS.hpp index 70a5d28d42b..a81abf3885b 100644 --- a/NWNXLib/API/API/CResNSS.hpp +++ b/NWNXLib/API/API/CResNSS.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResNSS) typedef int BOOL; -struct CResNSS : CRes +class CResNSS : public CRes { +public: BOOL m_bLoaded; uint32_t m_nNSSNormalSize; uint8_t * m_pNSSData; diff --git a/NWNXLib/API/API/CResPWK.hpp b/NWNXLib/API/API/CResPWK.hpp index 367a0c2c7d1..e897d3d09cb 100644 --- a/NWNXLib/API/API/CResPWK.hpp +++ b/NWNXLib/API/API/CResPWK.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResPWK) typedef int BOOL; -struct CResPWK : CRes +class CResPWK : public CRes { +public: BOOL m_bLoaded; uint32_t m_nPWKNormalSize; uint8_t * m_pPWKData; diff --git a/NWNXLib/API/API/CResRef.hpp b/NWNXLib/API/API/CResRef.hpp index 2a2c2d2b11a..19cb5bd0fc9 100644 --- a/NWNXLib/API/API/CResRef.hpp +++ b/NWNXLib/API/API/CResRef.hpp @@ -7,15 +7,16 @@ NWN_API_PROLOGUE(CResRef) #endif -struct CExoString; +class CExoString; typedef int BOOL; typedef uint8_t RESREF[16]; -struct CResRef +class CResRef { +public: RESREF m_resRefLowerCase; RESREF m_resRef; diff --git a/NWNXLib/API/API/CResSET.hpp b/NWNXLib/API/API/CResSET.hpp index 35411ee8266..6981eb9f9a6 100644 --- a/NWNXLib/API/API/CResSET.hpp +++ b/NWNXLib/API/API/CResSET.hpp @@ -8,14 +8,15 @@ NWN_API_PROLOGUE(CResSET) #endif -struct SETSection; +class SETSection; typedef int BOOL; -struct CResSET : CRes +class CResSET : public CRes { +public: BOOL m_bLoaded; uint32_t m_nSETNormalSize; SETSection * m_pSection; diff --git a/NWNXLib/API/API/CResStruct.hpp b/NWNXLib/API/API/CResStruct.hpp index d8aac2e9620..3f0f6a10b4f 100644 --- a/NWNXLib/API/API/CResStruct.hpp +++ b/NWNXLib/API/API/CResStruct.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CResStruct) #endif -struct CResStructInternal; -struct CResStructLookUp; -struct CStringFieldIDType; +class CResStructInternal; +class CResStructLookUp; +class CStringFieldIDType; typedef int BOOL; -struct CResStruct +class CResStruct { +public: CResStructHeader m_cHeader; CResStructLookUp * m_pLookUp; void * m_pData; diff --git a/NWNXLib/API/API/CResStructHeader.hpp b/NWNXLib/API/API/CResStructHeader.hpp index ae0931d32da..04c7c0e9635 100644 --- a/NWNXLib/API/API/CResStructHeader.hpp +++ b/NWNXLib/API/API/CResStructHeader.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResStructHeader) -struct CResStructHeader +class CResStructHeader { +public: uint32_t m_nType; uint32_t m_nFields; diff --git a/NWNXLib/API/API/CResStructLookUp.hpp b/NWNXLib/API/API/CResStructLookUp.hpp index 14019d4f24c..bb8239de1fe 100644 --- a/NWNXLib/API/API/CResStructLookUp.hpp +++ b/NWNXLib/API/API/CResStructLookUp.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CResStructLookUp) -struct CResStructLookUp +class CResStructLookUp { +public: uint32_t m_nType; uint32_t m_nSize; uint32_t m_nOffset; diff --git a/NWNXLib/API/API/CResTLK.hpp b/NWNXLib/API/API/CResTLK.hpp index 815b2c83d44..866fcd08388 100644 --- a/NWNXLib/API/API/CResTLK.hpp +++ b/NWNXLib/API/API/CResTLK.hpp @@ -12,9 +12,9 @@ NWN_API_PROLOGUE(CResTLK) -struct CResTLK : CRes +class CResTLK : public CRes { - +public: CResTLK(); virtual ~CResTLK(); diff --git a/NWNXLib/API/API/CResWOK.hpp b/NWNXLib/API/API/CResWOK.hpp index d5d013657fe..b15ff90689a 100644 --- a/NWNXLib/API/API/CResWOK.hpp +++ b/NWNXLib/API/API/CResWOK.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CResWOK) typedef int BOOL; -struct CResWOK : CRes +class CResWOK : public CRes { +public: BOOL m_bLoaded; uint32_t m_nWOKNormalSize; uint8_t * m_pWOKData; diff --git a/NWNXLib/API/API/CResetOption.hpp b/NWNXLib/API/API/CResetOption.hpp index 0198bda0a9e..3f3262a7062 100644 --- a/NWNXLib/API/API/CResetOption.hpp +++ b/NWNXLib/API/API/CResetOption.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CResetOption) typedef int BOOL; -struct CResetOption +class CResetOption { +public: BOOL bOnVacant; BOOL bOnVictory; BOOL bOnFailure; diff --git a/NWNXLib/API/API/CScriptCompiler.hpp b/NWNXLib/API/API/CScriptCompiler.hpp index eb4f4094b89..75783b60f65 100644 --- a/NWNXLib/API/API/CScriptCompiler.hpp +++ b/NWNXLib/API/API/CScriptCompiler.hpp @@ -10,24 +10,25 @@ NWN_API_PROLOGUE(CScriptCompiler) #endif -struct CExoStringList; -struct CScriptCompilerIdListEntry; -struct CScriptCompilerIdentifierHashTableEntry; -struct CScriptCompilerKeyWordEntry; -struct CScriptCompilerStackEntry; -struct CScriptCompilerStructureEntry; -struct CScriptCompilerStructureFieldEntry; -struct CScriptCompilerSymbolTableEntry; -struct CScriptCompilerVarStackEntry; -struct CScriptParseTreeNode; -struct CScriptParseTreeNodeBlock; +class CExoStringList; +class CScriptCompilerIdListEntry; +class CScriptCompilerIdentifierHashTableEntry; +class CScriptCompilerKeyWordEntry; +class CScriptCompilerStackEntry; +class CScriptCompilerStructureEntry; +class CScriptCompilerStructureFieldEntry; +class CScriptCompilerSymbolTableEntry; +class CScriptCompilerVarStackEntry; +class CScriptParseTreeNode; +class CScriptParseTreeNodeBlock; typedef int BOOL; -struct CScriptCompiler +class CScriptCompiler { +public: int32_t m_nKeyWords; CScriptCompilerKeyWordEntry * m_pcKeyWords; int32_t m_nParseTreeNodeBlockEmptyNodes; diff --git a/NWNXLib/API/API/CScriptCompilerIdListEntry.hpp b/NWNXLib/API/API/CScriptCompilerIdListEntry.hpp index f77804fcf71..c50e1e18263 100644 --- a/NWNXLib/API/API/CScriptCompilerIdListEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerIdListEntry.hpp @@ -14,8 +14,9 @@ typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CScriptCompilerIdListEntry +class CScriptCompilerIdListEntry { +public: CExoString m_psIdentifier; uint32_t m_nIdentifierLength; uint32_t m_nIdentifierHash; diff --git a/NWNXLib/API/API/CScriptCompilerIdentifierHashTableEntry.hpp b/NWNXLib/API/API/CScriptCompilerIdentifierHashTableEntry.hpp index e6e86bc91be..a71eae93c42 100644 --- a/NWNXLib/API/API/CScriptCompilerIdentifierHashTableEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerIdentifierHashTableEntry.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CScriptCompilerIdentifierHashTableEntry) -struct CScriptCompilerIdentifierHashTableEntry +class CScriptCompilerIdentifierHashTableEntry { +public: uint32_t m_nHashValue; uint32_t m_nIdentifierType; uint32_t m_nIdentifierIndex; diff --git a/NWNXLib/API/API/CScriptCompilerIncludeFileStackEntry.hpp b/NWNXLib/API/API/CScriptCompilerIncludeFileStackEntry.hpp index 78e6bf66c5c..e1ec6422662 100644 --- a/NWNXLib/API/API/CScriptCompilerIncludeFileStackEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerIncludeFileStackEntry.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CScriptCompilerIncludeFileStackEntry) -struct CScriptCompilerIncludeFileStackEntry +class CScriptCompilerIncludeFileStackEntry { +public: CExoString m_sCompiledScriptName; CScriptSourceFile m_cSourceScript; int32_t m_nLine; diff --git a/NWNXLib/API/API/CScriptCompilerKeyWordEntry.hpp b/NWNXLib/API/API/CScriptCompilerKeyWordEntry.hpp index 8ad1756730a..098c0bf3c0d 100644 --- a/NWNXLib/API/API/CScriptCompilerKeyWordEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerKeyWordEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptCompilerKeyWordEntry) -struct CScriptCompilerKeyWordEntry +class CScriptCompilerKeyWordEntry { +public: CExoString m_sAlphanumericName; uint32_t m_nHashValue; uint32_t m_nNameLength; diff --git a/NWNXLib/API/API/CScriptCompilerStackEntry.hpp b/NWNXLib/API/API/CScriptCompilerStackEntry.hpp index e7701ff21c6..49896ca9e8b 100644 --- a/NWNXLib/API/API/CScriptCompilerStackEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerStackEntry.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CScriptCompilerStackEntry) #endif -struct CScriptParseTreeNode; +class CScriptParseTreeNode; -struct CScriptCompilerStackEntry +class CScriptCompilerStackEntry { +public: int32_t nState; int32_t nRule; int32_t nTerm; diff --git a/NWNXLib/API/API/CScriptCompilerStructureEntry.hpp b/NWNXLib/API/API/CScriptCompilerStructureEntry.hpp index 333581fd5a7..33108b9e2ea 100644 --- a/NWNXLib/API/API/CScriptCompilerStructureEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerStructureEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptCompilerStructureEntry) -struct CScriptCompilerStructureEntry +class CScriptCompilerStructureEntry { +public: CExoString m_psName; int32_t m_nFieldStart; int32_t m_nFieldEnd; diff --git a/NWNXLib/API/API/CScriptCompilerStructureFieldEntry.hpp b/NWNXLib/API/API/CScriptCompilerStructureFieldEntry.hpp index af95fab5b68..ccbb38123ed 100644 --- a/NWNXLib/API/API/CScriptCompilerStructureFieldEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerStructureFieldEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptCompilerStructureFieldEntry) -struct CScriptCompilerStructureFieldEntry +class CScriptCompilerStructureFieldEntry { +public: uint8_t m_pchType; CExoString m_psStructureName; CExoString m_psVarName; diff --git a/NWNXLib/API/API/CScriptCompilerSymbolTableEntry.hpp b/NWNXLib/API/API/CScriptCompilerSymbolTableEntry.hpp index 17aff1e1891..ae051b422d5 100644 --- a/NWNXLib/API/API/CScriptCompilerSymbolTableEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerSymbolTableEntry.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CScriptCompilerSymbolTableEntry) -struct CScriptCompilerSymbolTableEntry +class CScriptCompilerSymbolTableEntry { +public: uint32_t m_nSymbolType; uint32_t m_nSymbolSubType1; uint32_t m_nSymbolSubType2; diff --git a/NWNXLib/API/API/CScriptCompilerVarStackEntry.hpp b/NWNXLib/API/API/CScriptCompilerVarStackEntry.hpp index 8e4c93f3279..17842723742 100644 --- a/NWNXLib/API/API/CScriptCompilerVarStackEntry.hpp +++ b/NWNXLib/API/API/CScriptCompilerVarStackEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptCompilerVarStackEntry) -struct CScriptCompilerVarStackEntry +class CScriptCompilerVarStackEntry { +public: CExoString m_psVarName; int32_t m_nVarType; int32_t m_nVarLevel; diff --git a/NWNXLib/API/API/CScriptEvent.hpp b/NWNXLib/API/API/CScriptEvent.hpp index 1d853e463cb..244b2d69b1f 100644 --- a/NWNXLib/API/API/CScriptEvent.hpp +++ b/NWNXLib/API/API/CScriptEvent.hpp @@ -9,16 +9,17 @@ NWN_API_PROLOGUE(CScriptEvent) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CScriptEvent +class CScriptEvent { +public: uint16_t m_nType; CExoArrayList m_nParamInteger; CExoArrayList m_fParamFloat; diff --git a/NWNXLib/API/API/CScriptLocation.hpp b/NWNXLib/API/API/CScriptLocation.hpp index 038de198516..ff7121f7665 100644 --- a/NWNXLib/API/API/CScriptLocation.hpp +++ b/NWNXLib/API/API/CScriptLocation.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CScriptLocation) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CScriptLocation +class CScriptLocation { +public: Vector m_vPosition; Vector m_vOrientation; OBJECT_ID m_oArea; diff --git a/NWNXLib/API/API/CScriptLog.hpp b/NWNXLib/API/API/CScriptLog.hpp index e7e677c276e..1128fe77b19 100644 --- a/NWNXLib/API/API/CScriptLog.hpp +++ b/NWNXLib/API/API/CScriptLog.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptLog) -struct CScriptLog +class CScriptLog { +public: CExoString m_sScriptName; int32_t m_nTimesRun; uint32_t m_nTotalTime; diff --git a/NWNXLib/API/API/CScriptParseTreeNode.hpp b/NWNXLib/API/API/CScriptParseTreeNode.hpp index 8cd0604d66f..3b7c023b2d8 100644 --- a/NWNXLib/API/API/CScriptParseTreeNode.hpp +++ b/NWNXLib/API/API/CScriptParseTreeNode.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(CScriptParseTreeNode) #endif -struct CExoString; +class CExoString; -struct CScriptParseTreeNode +class CScriptParseTreeNode { +public: int32_t nOperation; CExoString * m_psStringData; int32_t nIntegerData; diff --git a/NWNXLib/API/API/CScriptParseTreeNodeBlock.hpp b/NWNXLib/API/API/CScriptParseTreeNodeBlock.hpp index 46c3cfb6492..67f7b936c98 100644 --- a/NWNXLib/API/API/CScriptParseTreeNodeBlock.hpp +++ b/NWNXLib/API/API/CScriptParseTreeNodeBlock.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CScriptParseTreeNodeBlock) -struct CScriptParseTreeNodeBlock +class CScriptParseTreeNodeBlock { +public: CScriptParseTreeNode m_pNodes[4096]; CScriptParseTreeNodeBlock * m_pNextBlock; diff --git a/NWNXLib/API/API/CScriptSourceFile.hpp b/NWNXLib/API/API/CScriptSourceFile.hpp index 38ee35b7c61..f19ea9366e7 100644 --- a/NWNXLib/API/API/CScriptSourceFile.hpp +++ b/NWNXLib/API/API/CScriptSourceFile.hpp @@ -9,14 +9,14 @@ NWN_API_PROLOGUE(CScriptSourceFile) #endif -struct CExoString; +class CExoString; -struct CScriptSourceFile : CResHelper +class CScriptSourceFile : public CResHelper { - +public: CScriptSourceFile(); int32_t LoadScript(const CExoString & sFileName, char * * pScript, uint32_t * nScriptLength); void UnloadScript(); diff --git a/NWNXLib/API/API/CScriptTalent.hpp b/NWNXLib/API/API/CScriptTalent.hpp index 031da6e51fc..759a5af5a20 100644 --- a/NWNXLib/API/API/CScriptTalent.hpp +++ b/NWNXLib/API/API/CScriptTalent.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CScriptTalent) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CScriptTalent +class CScriptTalent { +public: int32_t m_nType; int32_t m_nID; uint8_t m_nMultiClass; diff --git a/NWNXLib/API/API/CServerAIBodyBagInfo.hpp b/NWNXLib/API/API/CServerAIBodyBagInfo.hpp index 287b8060221..54759f40a27 100644 --- a/NWNXLib/API/API/CServerAIBodyBagInfo.hpp +++ b/NWNXLib/API/API/CServerAIBodyBagInfo.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CServerAIBodyBagInfo) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CServerAIBodyBagInfo +class CServerAIBodyBagInfo { +public: OBJECT_ID m_oidBodyBag; Vector m_vPosition; diff --git a/NWNXLib/API/API/CServerAIEventNode.hpp b/NWNXLib/API/API/CServerAIEventNode.hpp index 8bbea24942f..12aed3fcdd8 100644 --- a/NWNXLib/API/API/CServerAIEventNode.hpp +++ b/NWNXLib/API/API/CServerAIEventNode.hpp @@ -7,16 +7,17 @@ NWN_API_PROLOGUE(CServerAIEventNode) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CServerAIEventNode +class CServerAIEventNode { +public: uint32_t m_nCalendarDay; uint32_t m_nTimeOfDay; OBJECT_ID m_nCallerObjectId; diff --git a/NWNXLib/API/API/CServerAIList.hpp b/NWNXLib/API/API/CServerAIList.hpp index f4e96fa064e..8f7caad1bb6 100644 --- a/NWNXLib/API/API/CServerAIList.hpp +++ b/NWNXLib/API/API/CServerAIList.hpp @@ -8,15 +8,16 @@ NWN_API_PROLOGUE(CServerAIList) #endif -struct CNWSObject; +class CNWSObject; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CServerAIList +class CServerAIList { +public: CExoArrayList m_aoGameObjects; int32_t m_nPosition; diff --git a/NWNXLib/API/API/CServerAIMaster.hpp b/NWNXLib/API/API/CServerAIMaster.hpp index fc4e61d02f2..158e382d584 100644 --- a/NWNXLib/API/API/CServerAIMaster.hpp +++ b/NWNXLib/API/API/CServerAIMaster.hpp @@ -12,24 +12,25 @@ NWN_API_PROLOGUE(CServerAIMaster) #endif -struct CGameEffect; -struct CGameEffectApplierRemover; -struct CItemPropertyApplierRemover; -struct CNWItemProperty; -struct CNWSCreature; -struct CNWSItem; -struct CNWSObject; -struct CResGFF; -struct CResStruct; -struct CServerExoAppInternal; +class CGameEffect; +class CGameEffectApplierRemover; +class CItemPropertyApplierRemover; +class CNWItemProperty; +class CNWSCreature; +class CNWSItem; +class CNWSObject; +class CResGFF; +class CResStruct; +class CServerExoAppInternal; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CServerAIMaster +class CServerAIMaster { +public: CServerExoAppInternal * m_pExoAppInternal; CServerAIList m_apGameAIList[5]; CExoLinkedList m_lEventQueue; diff --git a/NWNXLib/API/API/CServerExoApp.hpp b/NWNXLib/API/API/CServerExoApp.hpp index f82cbd839dd..1b3691f6733 100644 --- a/NWNXLib/API/API/CServerExoApp.hpp +++ b/NWNXLib/API/API/CServerExoApp.hpp @@ -13,40 +13,41 @@ NWN_API_PROLOGUE(CServerExoApp) #endif -struct AdvertLUT; -struct CCampaignDB; -struct CConnectionLib; -struct CGameObject; -struct CGameObjectArray; -struct CNWSArea; -struct CNWSAreaOfEffectObject; -struct CNWSClient; -struct CNWSCreature; -struct CNWSDoor; -struct CNWSEncounter; -struct CNWSItem; -struct CNWSModule; -struct CNWSPlaceable; -struct CNWSPlayer; -struct CNWSSoundObject; -struct CNWSStore; -struct CNWSTrigger; -struct CNWSWaypoint; -struct CNetLayer; -struct CServerAIMaster; -struct CServerExoAppInternal; -struct CWorldTimer; +class AdvertLUT; +class CCampaignDB; +class CConnectionLib; +class CGameObject; +class CGameObjectArray; +class CNWSArea; +class CNWSAreaOfEffectObject; +class CNWSClient; +class CNWSCreature; +class CNWSDoor; +class CNWSEncounter; +class CNWSItem; +class CNWSModule; +class CNWSPlaceable; +class CNWSPlayer; +class CNWSSoundObject; +class CNWSStore; +class CNWSTrigger; +class CNWSWaypoint; +class CNetLayer; +class CServerAIMaster; +class CServerExoAppInternal; +class CWorldTimer; namespace NWSync { -struct Advertisement; // NWSyncAdvertisement +class Advertisement; // NWSyncAdvertisement } typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CServerExoApp : CBaseExoApp +class CServerExoApp : public CBaseExoApp { +public: CServerExoAppInternal * m_pcExoAppInternal; CServerExoApp(void ); diff --git a/NWNXLib/API/API/CServerExoAppInternal.hpp b/NWNXLib/API/API/CServerExoAppInternal.hpp index 7ce557f0482..a5eab161b07 100644 --- a/NWNXLib/API/API/CServerExoAppInternal.hpp +++ b/NWNXLib/API/API/CServerExoAppInternal.hpp @@ -13,39 +13,40 @@ NWN_API_PROLOGUE(CServerExoAppInternal) #endif -struct C2DA; -struct CCampaignDB; -struct CConnectionLib; -struct CFactionManager; -struct CGameObject; -struct CGameObjectArray; -struct CNWPlaceMeshManager; -struct CNWSArea; -struct CNWSAreaOfEffectObject; -struct CNWSCreature; -struct CNWSDoor; -struct CNWSEncounter; -struct CNWSItem; -struct CNWSMessage; -struct CNWSModule; -struct CNWSObject; -struct CNWSPlaceable; -struct CNWSPlayer; -struct CNWSSoundObject; -struct CNWSStore; -struct CNWSTrigger; -struct CNWSWaypoint; -struct CNWVirtualMachineCommands; -struct CNetLayer; -struct CServerAIMaster; -struct CServerInfo; -struct CWorldTimer; -struct SSubNetProfile; +class C2DA; +class CCampaignDB; +class CConnectionLib; +class CFactionManager; +class CGameObject; +class CGameObjectArray; +class CNWPlaceMeshManager; +class CNWSArea; +class CNWSAreaOfEffectObject; +class CNWSCreature; +class CNWSDoor; +class CNWSEncounter; +class CNWSItem; +class CNWSMessage; +class CNWSModule; +class CNWSObject; +class CNWSPlaceable; +class CNWSPlayer; +class CNWSSoundObject; +class CNWSStore; +class CNWSTrigger; +class CNWSWaypoint; +class CNWVirtualMachineCommands; +class CNetLayer; +class CServerAIMaster; +class CServerInfo; +class CWorldTimer; +class SSubNetProfile; namespace NWSync { -struct Advertisement; // NWSyncAdvertisement +class Advertisement; // NWSyncAdvertisement } -struct AdvertLUT { +class AdvertLUT { +public: std::unordered_map> m_map; }; @@ -56,8 +57,9 @@ typedef uint16_t RESTYPE; typedef uint32_t STRREF; -struct CServerExoAppInternal +class CServerExoAppInternal { +public: uint8_t ScratchMessageBuffer[65536]; BOOL m_bMultiplayerEnabled; BOOL m_bGameSpyEnabled; @@ -148,7 +150,7 @@ struct CServerExoAppInternal CServerExoAppInternal(); ~CServerExoAppInternal(); BOOL Initialize(); - BOOL MainLoop(); + NWNX_IMPORT BOOL MainLoop(); void StartServices(); void StopServices(); void ShutdownNetLayer(); diff --git a/NWNXLib/API/API/CServerInfo.hpp b/NWNXLib/API/API/CServerInfo.hpp index fee8d71a0d2..6a21df45402 100644 --- a/NWNXLib/API/API/CServerInfo.hpp +++ b/NWNXLib/API/API/CServerInfo.hpp @@ -21,8 +21,9 @@ NWN_API_PROLOGUE(CServerInfo) typedef int BOOL; -struct CServerInfo +class CServerInfo { +public: int32_t m_nDataChangedFlags; int16_t m_nServerMode; CExoString m_sModuleName; diff --git a/NWNXLib/API/API/CServerNetOptions.hpp b/NWNXLib/API/API/CServerNetOptions.hpp index ee464f7eecc..bffa61e592e 100644 --- a/NWNXLib/API/API/CServerNetOptions.hpp +++ b/NWNXLib/API/API/CServerNetOptions.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CServerNetOptions) typedef int BOOL; -struct CServerNetOptions +class CServerNetOptions { +public: int32_t m_nGameRegion; CExoString m_szGameDetails; int16_t m_GameType; diff --git a/NWNXLib/API/API/CServerOptionLookup.hpp b/NWNXLib/API/API/CServerOptionLookup.hpp index 261b5040d02..96b692258b5 100644 --- a/NWNXLib/API/API/CServerOptionLookup.hpp +++ b/NWNXLib/API/API/CServerOptionLookup.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CServerOptionLookup) -struct CServerOptionLookup +class CServerOptionLookup { +public: int * pData; int nType; diff --git a/NWNXLib/API/API/CSpell_Add.hpp b/NWNXLib/API/API/CSpell_Add.hpp index 1935be3c8ae..b78b1624315 100644 --- a/NWNXLib/API/API/CSpell_Add.hpp +++ b/NWNXLib/API/API/CSpell_Add.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CSpell_Add) typedef int BOOL; -struct CSpell_Add +class CSpell_Add { +public: uint32_t m_nSpellID; BOOL m_bReadied; BOOL m_bDomainSpell; diff --git a/NWNXLib/API/API/CSpell_Delete.hpp b/NWNXLib/API/API/CSpell_Delete.hpp index 562b5cca709..59572e1509a 100644 --- a/NWNXLib/API/API/CSpell_Delete.hpp +++ b/NWNXLib/API/API/CSpell_Delete.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CSpell_Delete) -struct CSpell_Delete +class CSpell_Delete { +public: uint8_t m_nSpellLevel; uint8_t m_nSpellSlot; diff --git a/NWNXLib/API/API/CStoreCustomer.hpp b/NWNXLib/API/API/CStoreCustomer.hpp index e0df0315304..00f74923182 100644 --- a/NWNXLib/API/API/CStoreCustomer.hpp +++ b/NWNXLib/API/API/CStoreCustomer.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CStoreCustomer) typedef uint32_t OBJECT_ID; -struct CStoreCustomer +class CStoreCustomer { +public: OBJECT_ID m_oidObject; uint8_t m_nPage; uint8_t m_nPanel; diff --git a/NWNXLib/API/API/CStringFieldIDType.hpp b/NWNXLib/API/API/CStringFieldIDType.hpp index 3811dc730b7..c120849eecb 100644 --- a/NWNXLib/API/API/CStringFieldIDType.hpp +++ b/NWNXLib/API/API/CStringFieldIDType.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(CStringFieldIDType) -struct CStringFieldIDType +class CStringFieldIDType { +public: char sz[16]; diff --git a/NWNXLib/API/API/CTlkFile.hpp b/NWNXLib/API/API/CTlkFile.hpp index 9c8e006c512..11951d7244a 100644 --- a/NWNXLib/API/API/CTlkFile.hpp +++ b/NWNXLib/API/API/CTlkFile.hpp @@ -17,8 +17,9 @@ NWN_API_PROLOGUE(CTlkFile) typedef int BOOL; -struct CTlkFile : CExoFile +class CTlkFile : public CExoFile { +public: TLK_FILE_HEADER m_header; std::unordered_map m_cache; diff --git a/NWNXLib/API/API/CTlkResFile.hpp b/NWNXLib/API/API/CTlkResFile.hpp index 079974fa11a..70854df78ed 100644 --- a/NWNXLib/API/API/CTlkResFile.hpp +++ b/NWNXLib/API/API/CTlkResFile.hpp @@ -10,14 +10,14 @@ NWN_API_PROLOGUE(CTlkResFile) #endif -struct CResRef; +class CResRef; -struct CTlkResFile : CResHelper, CTlkFile +class CTlkResFile : public CResHelper, public CTlkFile { - +public: CTlkResFile(const CResRef & pResRef); virtual ~CTlkResFile(); diff --git a/NWNXLib/API/API/CTlkTable.hpp b/NWNXLib/API/API/CTlkTable.hpp index 4d5de2ec12c..e173aac2af8 100644 --- a/NWNXLib/API/API/CTlkTable.hpp +++ b/NWNXLib/API/API/CTlkTable.hpp @@ -9,18 +9,19 @@ NWN_API_PROLOGUE(CTlkTable) #endif -struct CTlkFile; -struct CTlkTableToken; -struct CTlkTableTokenCustom; -struct STR_RES; +class CTlkFile; +class CTlkTableToken; +class CTlkTableTokenCustom; +class STR_RES; typedef int BOOL; typedef uint32_t STRREF; -struct CTlkTable +class CTlkTable { +public: CTlkFile * m_pTlkFile[2]; CTlkFile * m_pTlkFileAlternate[2]; uint8_t m_currentGender; diff --git a/NWNXLib/API/API/CTlkTableToken.hpp b/NWNXLib/API/API/CTlkTableToken.hpp index 5a475e65eda..3d62b2bfa23 100644 --- a/NWNXLib/API/API/CTlkTableToken.hpp +++ b/NWNXLib/API/API/CTlkTableToken.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CTlkTableToken) -struct CTlkTableToken +class CTlkTableToken { +public: uint32_t m_nHash; CExoString m_sToken; uint32_t m_nActionCode; diff --git a/NWNXLib/API/API/CTlkTableTokenCustom.hpp b/NWNXLib/API/API/CTlkTableTokenCustom.hpp index 400071d64d0..979747b5690 100644 --- a/NWNXLib/API/API/CTlkTableTokenCustom.hpp +++ b/NWNXLib/API/API/CTlkTableTokenCustom.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CTlkTableTokenCustom) -struct CTlkTableTokenCustom +class CTlkTableTokenCustom { +public: uint32_t m_nNumber; CExoString m_sValue; diff --git a/NWNXLib/API/API/CTwoDimArrays.hpp b/NWNXLib/API/API/CTwoDimArrays.hpp index 51e7689e34c..764aa053dba 100644 --- a/NWNXLib/API/API/CTwoDimArrays.hpp +++ b/NWNXLib/API/API/CTwoDimArrays.hpp @@ -15,8 +15,9 @@ NWN_API_PROLOGUE(CTwoDimArrays) typedef int BOOL; -struct CTwoDimArrays +class CTwoDimArrays { +public: C2DA * * m_paIPRPCostTables; uint8_t m_nNumIPRPCostTables; uint8_t m_lstEpicBaseAttackBonus[60]; diff --git a/NWNXLib/API/API/CVirtualMachine.hpp b/NWNXLib/API/API/CVirtualMachine.hpp index ae5a6206729..bea3d44ee4e 100644 --- a/NWNXLib/API/API/CVirtualMachine.hpp +++ b/NWNXLib/API/API/CVirtualMachine.hpp @@ -14,22 +14,23 @@ NWN_API_PROLOGUE(CVirtualMachine) #endif -struct CResGFF; -struct CResStruct; -struct CScriptCompiler; -struct CScriptLog; -struct CScriptLog; -struct CVirtualMachineCmdImplementer; -struct CVirtualMachineDebuggingContext; -struct CVirtualMachineDebuggerInstance; +class CResGFF; +class CResStruct; +class CScriptCompiler; +class CScriptLog; +class CScriptLog; +class CVirtualMachineCmdImplementer; +class CVirtualMachineDebuggingContext; +class CVirtualMachineDebuggerInstance; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CVirtualMachine +class CVirtualMachine { +public: CScriptCompiler * m_pJitCompiler; int32_t m_nReturnValueParameterType; void * m_pReturnValue; @@ -62,8 +63,8 @@ struct CVirtualMachine CVirtualMachine(); ~CVirtualMachine(); BOOL RunScript(CExoString * psFileName, OBJECT_ID oid, BOOL bOidValid = true, int32_t nScriptEventID = 0); - int32_t RunScriptChunk(const CExoString & sScriptChunk, OBJECT_ID oid, BOOL bOidValid = true, BOOL bWrapIntoMain = true); - BOOL RunScriptSituation(void * pScriptSituation, OBJECT_ID oid, BOOL bOidValid = true); + NWNX_IMPORT int32_t RunScriptChunk(const CExoString & sScriptChunk, OBJECT_ID oid, BOOL bOidValid = true, BOOL bWrapIntoMain = true); + NWNX_IMPORT BOOL RunScriptSituation(void * pScriptSituation, OBJECT_ID oid, BOOL bOidValid = true); BOOL GetRunScriptReturnValue(int32_t * nParameterType, void * * pParameter); void SetDebugGUIFlag(BOOL bValue); void SetScriptParameters(const CExoArrayList & lParameters); diff --git a/NWNXLib/API/API/CVirtualMachineCmdImplementer.hpp b/NWNXLib/API/API/CVirtualMachineCmdImplementer.hpp index a1adf2121a8..516f2002fd8 100644 --- a/NWNXLib/API/API/CVirtualMachineCmdImplementer.hpp +++ b/NWNXLib/API/API/CVirtualMachineCmdImplementer.hpp @@ -8,16 +8,17 @@ NWN_API_PROLOGUE(CVirtualMachineCmdImplementer) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; typedef int BOOL; typedef uint32_t OBJECT_ID; -struct CVirtualMachineCmdImplementer +class CVirtualMachineCmdImplementer { +public: BOOL m_bValidObjectRunScript; OBJECT_ID m_oidObjectRunScript; diff --git a/NWNXLib/API/API/CVirtualMachineDebugLoader.hpp b/NWNXLib/API/API/CVirtualMachineDebugLoader.hpp index 5525d97d3d5..e3ebcd6fa4d 100644 --- a/NWNXLib/API/API/CVirtualMachineDebugLoader.hpp +++ b/NWNXLib/API/API/CVirtualMachineDebugLoader.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CVirtualMachineDebugLoader) #endif -struct CExoString; +class CExoString; typedef int BOOL; -struct CVirtualMachineDebugLoader : CResHelper +class CVirtualMachineDebugLoader : public CResHelper { +public: BOOL m_bLoaded; DataBlockRef m_pNDB; diff --git a/NWNXLib/API/API/CVirtualMachineDebuggerInstance.hpp b/NWNXLib/API/API/CVirtualMachineDebuggerInstance.hpp index 0917012d293..ba0acb5cff3 100644 --- a/NWNXLib/API/API/CVirtualMachineDebuggerInstance.hpp +++ b/NWNXLib/API/API/CVirtualMachineDebuggerInstance.hpp @@ -10,14 +10,15 @@ NWN_API_PROLOGUE(CVirtualMachineDebuggerInstance) #endif -struct CVirtualMachine; +class CVirtualMachine; typedef int BOOL; -struct CVirtualMachineDebuggerInstance +class CVirtualMachineDebuggerInstance { +public: CVirtualMachine * m_pVMachine; int32_t * m_pnInstructionPointer; char * m_pDebugInputMessageBuffer; diff --git a/NWNXLib/API/API/CVirtualMachineDebuggingContext.hpp b/NWNXLib/API/API/CVirtualMachineDebuggingContext.hpp index 16cb77900a8..4bbf15bab21 100644 --- a/NWNXLib/API/API/CVirtualMachineDebuggingContext.hpp +++ b/NWNXLib/API/API/CVirtualMachineDebuggingContext.hpp @@ -7,14 +7,15 @@ NWN_API_PROLOGUE(CVirtualMachineDebuggingContext) #endif -struct CVirtualMachineDebuggerInstance; +class CVirtualMachineDebuggerInstance; typedef int BOOL; -struct CVirtualMachineDebuggingContext +class CVirtualMachineDebuggingContext { +public: BOOL m_bStepInto; BOOL m_bStepOver; BOOL m_bRunToLineNumber; diff --git a/NWNXLib/API/API/CVirtualMachineFile.hpp b/NWNXLib/API/API/CVirtualMachineFile.hpp index 5bc5bad5f63..ca9025ed22f 100644 --- a/NWNXLib/API/API/CVirtualMachineFile.hpp +++ b/NWNXLib/API/API/CVirtualMachineFile.hpp @@ -9,14 +9,15 @@ NWN_API_PROLOGUE(CVirtualMachineFile) #endif -struct CExoString; +class CExoString; typedef int BOOL; -struct CVirtualMachineFile : CResHelper +class CVirtualMachineFile : public CResHelper { +public: CVirtualMachineFile(); ~CVirtualMachineFile(); diff --git a/NWNXLib/API/API/CVirtualMachineScript.hpp b/NWNXLib/API/API/CVirtualMachineScript.hpp index d7d18428191..36572bdc8d5 100644 --- a/NWNXLib/API/API/CVirtualMachineScript.hpp +++ b/NWNXLib/API/API/CVirtualMachineScript.hpp @@ -8,13 +8,14 @@ NWN_API_PROLOGUE(CVirtualMachineScript) #endif -struct CVirtualMachineStack; +class CVirtualMachineStack; -struct CVirtualMachineScript +class CVirtualMachineScript { +public: CVirtualMachineStack * m_pStack; int32_t m_nStackSize; int32_t m_nInstructPtr; @@ -24,9 +25,9 @@ struct CVirtualMachineScript DataBlockRef m_pNDB; int32_t m_nScriptEventID; - struct JmpData + class JmpData { - struct Target + class Target { int32_t nVMInstPtr; int32_t nInstPtr; diff --git a/NWNXLib/API/API/CVirtualMachineStack.hpp b/NWNXLib/API/API/CVirtualMachineStack.hpp index 21f91f3dceb..cc42997c71e 100644 --- a/NWNXLib/API/API/CVirtualMachineStack.hpp +++ b/NWNXLib/API/API/CVirtualMachineStack.hpp @@ -7,17 +7,18 @@ NWN_API_PROLOGUE(CVirtualMachineStack) #endif -struct CResGFF; -struct CResStruct; -struct CVirtualMachine; -struct StackElement; +class CResGFF; +class CResStruct; +class CVirtualMachine; +class StackElement; typedef int BOOL; -struct CVirtualMachineStack +class CVirtualMachineStack { +public: int32_t m_nStackPointer; int32_t m_nBasePointer; int32_t m_nTotalSize; diff --git a/NWNXLib/API/API/CWalkHitInfo.hpp b/NWNXLib/API/API/CWalkHitInfo.hpp index aeb93a4667e..fdc44a62ac2 100644 --- a/NWNXLib/API/API/CWalkHitInfo.hpp +++ b/NWNXLib/API/API/CWalkHitInfo.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CWalkHitInfo) -struct CWalkHitInfo +class CWalkHitInfo { +public: int32_t m_nFailureReason; Vector m_vIntersectedAt; Vector m_vNormalOfIntersectedLine; diff --git a/NWNXLib/API/API/CWorldJournalEntry.hpp b/NWNXLib/API/API/CWorldJournalEntry.hpp index 3dd1dcb64f5..64156382755 100644 --- a/NWNXLib/API/API/CWorldJournalEntry.hpp +++ b/NWNXLib/API/API/CWorldJournalEntry.hpp @@ -14,8 +14,9 @@ typedef int BOOL; typedef uint32_t STRREF; -struct CWorldJournalEntry +class CWorldJournalEntry { +public: CExoString szText; CExoString szName; uint32_t nCalendarDay; diff --git a/NWNXLib/API/API/CWorldTimer.hpp b/NWNXLib/API/API/CWorldTimer.hpp index cf1552d3088..4fe1ca4732b 100644 --- a/NWNXLib/API/API/CWorldTimer.hpp +++ b/NWNXLib/API/API/CWorldTimer.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(CWorldTimer) typedef int BOOL; -struct CWorldTimer +class CWorldTimer { +public: BOOL m_bFixedSnapshotRate; int32_t m_nFixedSnapshotsPerSecond; uint64_t m_nTimeSnapshot; diff --git a/NWNXLib/API/API/CachedRulesetEntry.hpp b/NWNXLib/API/API/CachedRulesetEntry.hpp index 7c45be0ce86..18d7ae61223 100644 --- a/NWNXLib/API/API/CachedRulesetEntry.hpp +++ b/NWNXLib/API/API/CachedRulesetEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(CachedRulesetEntry) -struct CachedRulesetEntry +class CachedRulesetEntry { +public: CExoString s; int32_t i; float f; diff --git a/NWNXLib/API/API/CassowarySolverEngineStructure.hpp b/NWNXLib/API/API/CassowarySolverEngineStructure.hpp index b5b46f8e5e0..cc5d0b3414a 100644 --- a/NWNXLib/API/API/CassowarySolverEngineStructure.hpp +++ b/NWNXLib/API/API/CassowarySolverEngineStructure.hpp @@ -9,7 +9,7 @@ NWN_API_PROLOGUE(CassowarySolverEngineStructure) #endif struct CassowarySolverEngineStructureShared; -struct CassowarySolverEngineStructure : public SharedPtrEngineStructure +struct CassowarySolverEngineStructure : SharedPtrEngineStructure { virtual ~CassowarySolverEngineStructure() {} diff --git a/NWNXLib/API/API/ENCAPSULATED_HEADER.hpp b/NWNXLib/API/API/ENCAPSULATED_HEADER.hpp index 41bd9c367a8..bff869605d1 100644 --- a/NWNXLib/API/API/ENCAPSULATED_HEADER.hpp +++ b/NWNXLib/API/API/ENCAPSULATED_HEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(ENCAPSULATED_HEADER) -struct ENCAPSULATED_HEADER +class ENCAPSULATED_HEADER { +public: uint32_t nFileType; uint32_t nFileVersion; uint32_t nNumLanguages; diff --git a/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY.hpp b/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY.hpp index 471935d648e..b38e190d456 100644 --- a/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY.hpp +++ b/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY.hpp @@ -13,8 +13,9 @@ typedef uint8_t RESREF[16]; typedef uint16_t RESTYPE; -struct ENCAPSULATED_KEYLISTENTRY +class ENCAPSULATED_KEYLISTENTRY { +public: RESREF resRef; uint32_t nID; RESTYPE nType; diff --git a/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY_E1.hpp b/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY_E1.hpp index 70a3f5a9593..d4b046809d4 100644 --- a/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY_E1.hpp +++ b/NWNXLib/API/API/ENCAPSULATED_KEYLISTENTRY_E1.hpp @@ -13,8 +13,9 @@ typedef uint8_t RESREF[16]; typedef uint16_t RESTYPE; -struct ENCAPSULATED_KEYLISTENTRY_E1 +class ENCAPSULATED_KEYLISTENTRY_E1 { +public: RESREF resRef; uint32_t nID; RESTYPE nType; diff --git a/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY.hpp b/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY.hpp index d2d9b5cd801..9a5501dcb94 100644 --- a/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY.hpp +++ b/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(ENCAPSULATED_RESLISTENTRY) -struct ENCAPSULATED_RESLISTENTRY +class ENCAPSULATED_RESLISTENTRY { +public: uint32_t nOffsetToResource; uint32_t nResourceSize; diff --git a/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY_E1.hpp b/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY_E1.hpp index 00964f1b9e5..b08ef364b09 100644 --- a/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY_E1.hpp +++ b/NWNXLib/API/API/ENCAPSULATED_RESLISTENTRY_E1.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(ENCAPSULATED_RESLISTENTRY_E1) -struct ENCAPSULATED_RESLISTENTRY_E1 +class ENCAPSULATED_RESLISTENTRY_E1 { +public: uint32_t nOffsetToResource; uint32_t nResourceSize; uint32_t nCompressionType; diff --git a/NWNXLib/API/API/EXO2DAHEADER.hpp b/NWNXLib/API/API/EXO2DAHEADER.hpp index 665755a241b..bf1440e1a69 100644 --- a/NWNXLib/API/API/EXO2DAHEADER.hpp +++ b/NWNXLib/API/API/EXO2DAHEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(EXO2DAHEADER) -struct EXO2DAHEADER +class EXO2DAHEADER { +public: uint32_t nType; uint32_t nVersion; diff --git a/NWNXLib/API/API/EXOLOCSTRING.hpp b/NWNXLib/API/API/EXOLOCSTRING.hpp index d1bf42497a3..f2263e3df05 100644 --- a/NWNXLib/API/API/EXOLOCSTRING.hpp +++ b/NWNXLib/API/API/EXOLOCSTRING.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(EXOLOCSTRING) -struct EXOLOCSTRING +class EXOLOCSTRING { +public: int32_t nID; CExoString sString; diff --git a/NWNXLib/API/API/EXOLTRHEADER.hpp b/NWNXLib/API/API/EXOLTRHEADER.hpp index 78b206204a1..9fc7e994107 100644 --- a/NWNXLib/API/API/EXOLTRHEADER.hpp +++ b/NWNXLib/API/API/EXOLTRHEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(EXOLTRHEADER) -struct EXOLTRHEADER +class EXOLTRHEADER { +public: uint32_t m_nType; uint32_t m_nVersion; uint8_t m_nNumLetters; diff --git a/NWNXLib/API/API/HttpConnection.hpp b/NWNXLib/API/API/HttpConnection.hpp index cbf184f6ac4..6dbfddf94da 100644 --- a/NWNXLib/API/API/HttpConnection.hpp +++ b/NWNXLib/API/API/HttpConnection.hpp @@ -4,7 +4,8 @@ NWN_API_PROLOGUE(HttpConnection) #endif -struct HttpConnection { +class HttpConnection { +public: static void UpdateAll(); }; diff --git a/NWNXLib/API/API/InstanceLookupList.hpp b/NWNXLib/API/API/InstanceLookupList.hpp index 2cfa3e58071..54209b3d377 100644 --- a/NWNXLib/API/API/InstanceLookupList.hpp +++ b/NWNXLib/API/API/InstanceLookupList.hpp @@ -3,7 +3,8 @@ namespace InstanceLookup { template -struct List { +class List { +public: V *m_pthis; }; diff --git a/NWNXLib/API/API/JsonEngineStructure.hpp b/NWNXLib/API/API/JsonEngineStructure.hpp index 1d015852969..9d22794359c 100644 --- a/NWNXLib/API/API/JsonEngineStructure.hpp +++ b/NWNXLib/API/API/JsonEngineStructure.hpp @@ -6,14 +6,15 @@ NWN_API_PROLOGUE(JsonEngineStructure) #endif -struct JsonEngineStructureShared +class JsonEngineStructureShared { +public: const uint64_t m_id; json m_json; CExoString m_error; }; -struct JsonEngineStructure : public SharedPtrEngineStructure +struct JsonEngineStructure : SharedPtrEngineStructure { JsonEngineStructure(); JsonEngineStructure(const json& j, const CExoString& err); diff --git a/NWNXLib/API/API/KEYFILE_HEADER.hpp b/NWNXLib/API/API/KEYFILE_HEADER.hpp index 0d05454208d..6ea86815bc0 100644 --- a/NWNXLib/API/API/KEYFILE_HEADER.hpp +++ b/NWNXLib/API/API/KEYFILE_HEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(KEYFILE_HEADER) -struct KEYFILE_HEADER +class KEYFILE_HEADER { +public: uint32_t nFileType; uint32_t nFileVersion; uint32_t nResFiles; diff --git a/NWNXLib/API/API/KEYFILE_KEYENTRY.hpp b/NWNXLib/API/API/KEYFILE_KEYENTRY.hpp index acd980dbfb1..8aaae7de2d4 100644 --- a/NWNXLib/API/API/KEYFILE_KEYENTRY.hpp +++ b/NWNXLib/API/API/KEYFILE_KEYENTRY.hpp @@ -13,8 +13,9 @@ typedef uint8_t RESREF[16]; typedef uint16_t RESTYPE; -struct KEYFILE_KEYENTRY +class KEYFILE_KEYENTRY { +public: RESREF resRef; RESTYPE nType; uint32_t nID; diff --git a/NWNXLib/API/API/KEYFILE_KEYENTRY_E1.hpp b/NWNXLib/API/API/KEYFILE_KEYENTRY_E1.hpp index ae66b55b265..14578247dd5 100644 --- a/NWNXLib/API/API/KEYFILE_KEYENTRY_E1.hpp +++ b/NWNXLib/API/API/KEYFILE_KEYENTRY_E1.hpp @@ -13,8 +13,9 @@ typedef uint8_t RESREF[16]; typedef uint16_t RESTYPE; -struct KEYFILE_KEYENTRY_E1 +class KEYFILE_KEYENTRY_E1 { +public: RESREF resRef; RESTYPE nType; uint32_t nID; diff --git a/NWNXLib/API/API/KEYFILE_RESFILENAME.hpp b/NWNXLib/API/API/KEYFILE_RESFILENAME.hpp index 07b848cf384..5db0728f4e8 100644 --- a/NWNXLib/API/API/KEYFILE_RESFILENAME.hpp +++ b/NWNXLib/API/API/KEYFILE_RESFILENAME.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(KEYFILE_RESFILENAME) -struct KEYFILE_RESFILENAME +class KEYFILE_RESFILENAME { +public: uint32_t nFileSize; uint32_t nFileNameOffset; uint16_t nFileNameSize; diff --git a/NWNXLib/API/API/KXPacket.hpp b/NWNXLib/API/API/KXPacket.hpp index 070a8494f48..272ae0d37c0 100644 --- a/NWNXLib/API/API/KXPacket.hpp +++ b/NWNXLib/API/API/KXPacket.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(KXPacket) -struct KXPacket +class KXPacket { +public: diff --git a/NWNXLib/API/API/KeyFileData.hpp b/NWNXLib/API/API/KeyFileData.hpp index b1da601599a..426c39e20d1 100644 --- a/NWNXLib/API/API/KeyFileData.hpp +++ b/NWNXLib/API/API/KeyFileData.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(KeyFileData) -struct KeyFileData +class KeyFileData { +public: int month; int day; int year; diff --git a/NWNXLib/API/API/LerpFloat.hpp b/NWNXLib/API/API/LerpFloat.hpp index 5aaaf6722ad..8f8afa9311d 100644 --- a/NWNXLib/API/API/LerpFloat.hpp +++ b/NWNXLib/API/API/LerpFloat.hpp @@ -7,13 +7,14 @@ NWN_API_PROLOGUE(LerpFloat) #endif -struct CResGFF; -struct CResStruct; +class CResGFF; +class CResStruct; -template struct totally_ordered +template class totally_ordered { +public: friend bool operator<=(const T& a, const T& b) { return a < b || a == b; } friend bool operator>(const T& a, const T& b) { return !(a <= b); } friend bool operator!=(const T& a, const T& b) { return !(a == b); } @@ -26,8 +27,9 @@ enum class LerpTimerType { }; -struct LerpFloat +class LerpFloat { +public: LerpTimerType m_timer_type; mutable float m_value_to; mutable float m_value_from; @@ -37,10 +39,11 @@ struct LerpFloat int m_behavior_flags; mutable int m_repeats_remaining; - struct TimeType + class TimeType { - struct World : public totally_ordered + class World : public totally_ordered { + public: uint32_t m_day; uint32_t m_time; diff --git a/NWNXLib/API/API/LerpVector.hpp b/NWNXLib/API/API/LerpVector.hpp index 834e1c28787..59602416bf1 100644 --- a/NWNXLib/API/API/LerpVector.hpp +++ b/NWNXLib/API/API/LerpVector.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(LerpVector) -struct LerpVector +class LerpVector { +public: LerpFloat x; LerpFloat y; LerpFloat z; diff --git a/NWNXLib/API/API/MaterialShaderParam.hpp b/NWNXLib/API/API/MaterialShaderParam.hpp index 93ea3d45b56..b91123ef006 100644 --- a/NWNXLib/API/API/MaterialShaderParam.hpp +++ b/NWNXLib/API/API/MaterialShaderParam.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(MaterialShaderParam) -struct MaterialShaderParam +class MaterialShaderParam { +public: int m_nType; char m_sMaterialName[16+1]; char m_sParamName[64+1]; diff --git a/NWNXLib/API/API/NWAREAEXPANSION.hpp b/NWNXLib/API/API/NWAREAEXPANSION.hpp index 1f63267470b..e17164b19be 100644 --- a/NWNXLib/API/API/NWAREAEXPANSION.hpp +++ b/NWNXLib/API/API/NWAREAEXPANSION.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(NWAREAEXPANSION) -struct NWAREAEXPANSION +class NWAREAEXPANSION { +public: CExoLocString lsName; int32_t nID; diff --git a/NWNXLib/API/API/NWAREAHEADER.hpp b/NWNXLib/API/API/NWAREAHEADER.hpp index 87143a9fa6c..55579181492 100644 --- a/NWNXLib/API/API/NWAREAHEADER.hpp +++ b/NWNXLib/API/API/NWAREAHEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(NWAREAHEADER) -struct NWAREAHEADER +class NWAREAHEADER { +public: int32_t nAreaID; int32_t nCreatorID; uint32_t nVersion; diff --git a/NWNXLib/API/API/NWERFHEADER.hpp b/NWNXLib/API/API/NWERFHEADER.hpp index 27608c949ad..d49c16e365e 100644 --- a/NWNXLib/API/API/NWERFHEADER.hpp +++ b/NWNXLib/API/API/NWERFHEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(NWERFHEADER) -struct NWERFHEADER +class NWERFHEADER { +public: char sVersion[8]; uint32_t nStringCount; uint32_t nTotalStringSize; diff --git a/NWNXLib/API/API/NWMODULECUTSCENE.hpp b/NWNXLib/API/API/NWMODULECUTSCENE.hpp index 5c020b952e7..044e9501c4d 100644 --- a/NWNXLib/API/API/NWMODULECUTSCENE.hpp +++ b/NWNXLib/API/API/NWMODULECUTSCENE.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(NWMODULECUTSCENE) -struct NWMODULECUTSCENE +class NWMODULECUTSCENE { +public: CResRef refName; uint32_t nID; diff --git a/NWNXLib/API/API/NWMODULEENTRYINFO.hpp b/NWNXLib/API/API/NWMODULEENTRYINFO.hpp index cdb5c030627..c030bde9ccb 100644 --- a/NWNXLib/API/API/NWMODULEENTRYINFO.hpp +++ b/NWNXLib/API/API/NWMODULEENTRYINFO.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(NWMODULEENTRYINFO) -struct NWMODULEENTRYINFO +class NWMODULEENTRYINFO { +public: CResRef refArea; float nX; float nY; diff --git a/NWNXLib/API/API/NWMODULEEXPANSION.hpp b/NWNXLib/API/API/NWMODULEEXPANSION.hpp index 8f519d6d7d5..92a14676242 100644 --- a/NWNXLib/API/API/NWMODULEEXPANSION.hpp +++ b/NWNXLib/API/API/NWMODULEEXPANSION.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(NWMODULEEXPANSION) -struct NWMODULEEXPANSION +class NWMODULEEXPANSION { +public: CExoLocString lsName; int32_t nID; diff --git a/NWNXLib/API/API/NWMODULEHEADER.hpp b/NWNXLib/API/API/NWMODULEHEADER.hpp index e1b90aec7ba..4954b4c434a 100644 --- a/NWNXLib/API/API/NWMODULEHEADER.hpp +++ b/NWNXLib/API/API/NWMODULEHEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(NWMODULEHEADER) -struct NWMODULEHEADER +class NWMODULEHEADER { +public: char pModuleID[32]; int32_t nModuleCreatorID; uint32_t nModuleVersion; diff --git a/NWNXLib/API/API/NWPLAYERLISTITEM.hpp b/NWNXLib/API/API/NWPLAYERLISTITEM.hpp index 67dbe6ae730..23bfed29227 100644 --- a/NWNXLib/API/API/NWPLAYERLISTITEM.hpp +++ b/NWNXLib/API/API/NWPLAYERLISTITEM.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(NWPLAYERLISTITEM) typedef int BOOL; -struct NWPLAYERLISTITEM +class NWPLAYERLISTITEM { +public: CExoString sCommunityName; CExoLocString sLocFirstName; CExoLocString sLocLastName; diff --git a/NWNXLib/API/API/NWPlayerCharacterListClass_st.hpp b/NWNXLib/API/API/NWPlayerCharacterListClass_st.hpp index be40bb02664..97f87c81c26 100644 --- a/NWNXLib/API/API/NWPlayerCharacterListClass_st.hpp +++ b/NWNXLib/API/API/NWPlayerCharacterListClass_st.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(NWPlayerCharacterListClass_st) -struct NWPlayerCharacterListClass_st +class NWPlayerCharacterListClass_st { +public: int32_t nClass; uint8_t nClassLevel; diff --git a/NWNXLib/API/API/NWPlayerCharacterList_st.hpp b/NWNXLib/API/API/NWPlayerCharacterList_st.hpp index 906ad8b84d6..64feb74e61f 100644 --- a/NWNXLib/API/API/NWPlayerCharacterList_st.hpp +++ b/NWNXLib/API/API/NWPlayerCharacterList_st.hpp @@ -15,8 +15,9 @@ NWN_API_PROLOGUE(NWPlayerCharacterList_st) -struct NWPlayerCharacterList_st +class NWPlayerCharacterList_st { +public: CExoLocString sLocFirstName; CExoLocString sLocLastName; uint8_t nType; diff --git a/NWNXLib/API/API/NWSyncAdvertisement.hpp b/NWNXLib/API/API/NWSyncAdvertisement.hpp index db30219a0a7..481a3f03e3d 100644 --- a/NWNXLib/API/API/NWSyncAdvertisement.hpp +++ b/NWNXLib/API/API/NWSyncAdvertisement.hpp @@ -13,7 +13,8 @@ NWN_API_PROLOGUE(NWSyncAdvertisement) #endif -struct Advertisement { +class Advertisement { +public: Hash::SHA1 m_primary_manifest; std::vector m_additional_manifests; CExoString m_url; diff --git a/NWNXLib/API/API/NWSyncAdvertisementManifest.hpp b/NWNXLib/API/API/NWSyncAdvertisementManifest.hpp index ab4871a868e..997916a0708 100644 --- a/NWNXLib/API/API/NWSyncAdvertisementManifest.hpp +++ b/NWNXLib/API/API/NWSyncAdvertisementManifest.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(NWSyncAdvertisementManifest) -struct AdvertisementManifest +class AdvertisementManifest { +public: Hash::SHA1 m_hash; uint8_t m_flags; uint8_t m_languageId; diff --git a/NWNXLib/API/API/NWVMachineUtils.hpp b/NWNXLib/API/API/NWVMachineUtils.hpp index 521afeaccf1..bd7e4533ddc 100644 --- a/NWNXLib/API/API/NWVMachineUtils.hpp +++ b/NWNXLib/API/API/NWVMachineUtils.hpp @@ -16,8 +16,9 @@ NWN_API_PROLOGUE(NWVMachineUtils) typedef int BOOL; -struct NWVMachineUtils +class NWVMachineUtils { +public: static DataBlockRef SerializeToGff(CGameObject* o, BOOL bSaveObjectState); static CGameObject* DeserializeFromGff(DataViewRef d, BOOL bLoadObjectState, const CScriptLocation& loc, OBJECT_ID owner, const CExoString& sNewTag, BOOL bObjectCopy = false); static JsonEngineStructure SerializeToJson(CGameObject* o, BOOL bSaveObjectState); diff --git a/NWNXLib/API/API/ObjectVisualTransformData.hpp b/NWNXLib/API/API/ObjectVisualTransformData.hpp index d6103fdeaf2..5915ab64e30 100644 --- a/NWNXLib/API/API/ObjectVisualTransformData.hpp +++ b/NWNXLib/API/API/ObjectVisualTransformData.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(ObjectVisualTransformData) -struct ObjectVisualTransformData +class ObjectVisualTransformData { +public: std::map m_scopes; ObjectVisualTransformData() {} diff --git a/NWNXLib/API/API/RESID.hpp b/NWNXLib/API/API/RESID.hpp index e3878a2fe66..01983706493 100644 --- a/NWNXLib/API/API/RESID.hpp +++ b/NWNXLib/API/API/RESID.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(RESID) -struct RESID +class RESID { +public: uint32_t m_resFileSource; uint32_t m_resFileId; uint32_t m_resTableId; diff --git a/NWNXLib/API/API/RES_FIXED_HEADER.hpp b/NWNXLib/API/API/RES_FIXED_HEADER.hpp index 23c768908f1..5660a84ebc8 100644 --- a/NWNXLib/API/API/RES_FIXED_HEADER.hpp +++ b/NWNXLib/API/API/RES_FIXED_HEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(RES_FIXED_HEADER) -struct RES_FIXED_HEADER +class RES_FIXED_HEADER { +public: uint32_t nFileType; uint32_t nFileVersion; uint32_t nNumber; diff --git a/NWNXLib/API/API/SETEntry.hpp b/NWNXLib/API/API/SETEntry.hpp index 1e16c6a4d72..b2c9ce09ca9 100644 --- a/NWNXLib/API/API/SETEntry.hpp +++ b/NWNXLib/API/API/SETEntry.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(SETEntry) -struct SETEntry +class SETEntry { +public: CExoString m_sEntry; CExoString m_sValue; diff --git a/NWNXLib/API/API/SETSection.hpp b/NWNXLib/API/API/SETSection.hpp index 9da9f570814..890b2d29bb9 100644 --- a/NWNXLib/API/API/SETSection.hpp +++ b/NWNXLib/API/API/SETSection.hpp @@ -8,13 +8,14 @@ NWN_API_PROLOGUE(SETSection) #endif -struct SETEntry; +class SETEntry; -struct SETSection +class SETSection { +public: CExoString m_sSection; SETEntry * m_pEntry; uint32_t m_nNumEntries; diff --git a/NWNXLib/API/API/SHA1.hpp b/NWNXLib/API/API/SHA1.hpp index 5b203c6cfb1..3a939bb44a1 100644 --- a/NWNXLib/API/API/SHA1.hpp +++ b/NWNXLib/API/API/SHA1.hpp @@ -8,7 +8,8 @@ NWN_API_PROLOGUE(SHA1) #endif -struct SHA1 { +class SHA1 { +public: bool m_empty; uint8_t m_data[20]; char m_hex[41]; diff --git a/NWNXLib/API/API/SJournalEntry.hpp b/NWNXLib/API/API/SJournalEntry.hpp index b1557c88b9f..951d88eeda1 100644 --- a/NWNXLib/API/API/SJournalEntry.hpp +++ b/NWNXLib/API/API/SJournalEntry.hpp @@ -14,8 +14,9 @@ NWN_API_PROLOGUE(SJournalEntry) typedef int BOOL; -struct SJournalEntry +class SJournalEntry { +public: CExoLocString szName; CExoLocString szText; uint32_t nCalendarDay; diff --git a/NWNXLib/API/API/SNWItemFlags.hpp b/NWNXLib/API/API/SNWItemFlags.hpp index 1d8a617c4e8..4cfea867da3 100644 --- a/NWNXLib/API/API/SNWItemFlags.hpp +++ b/NWNXLib/API/API/SNWItemFlags.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(SNWItemFlags) -struct SNWItemFlags +class SNWItemFlags { +public: uint8_t m_nDropable; uint8_t m_nPickpocketable; diff --git a/NWNXLib/API/API/SSubNetProfile.hpp b/NWNXLib/API/API/SSubNetProfile.hpp index 6a0497b5b83..65755b8b79c 100644 --- a/NWNXLib/API/API/SSubNetProfile.hpp +++ b/NWNXLib/API/API/SSubNetProfile.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(SSubNetProfile) -struct SSubNetProfile +class SSubNetProfile { +public: uint32_t nPlayerID; CExoString sPlayerName; CExoString sCDPublicKey; diff --git a/NWNXLib/API/API/STR_RES.hpp b/NWNXLib/API/API/STR_RES.hpp index c1a62ef456d..7ed1a766a7a 100644 --- a/NWNXLib/API/API/STR_RES.hpp +++ b/NWNXLib/API/API/STR_RES.hpp @@ -13,8 +13,9 @@ NWN_API_PROLOGUE(STR_RES) -struct STR_RES +class STR_RES { +public: CExoString szText; CResRef cSoundResRef; float fSoundLength; diff --git a/NWNXLib/API/API/STR_RES_HEADER.hpp b/NWNXLib/API/API/STR_RES_HEADER.hpp index 77bf5fb1002..3dab8b75a24 100644 --- a/NWNXLib/API/API/STR_RES_HEADER.hpp +++ b/NWNXLib/API/API/STR_RES_HEADER.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(STR_RES_HEADER) -struct STR_RES_HEADER : STR_RES_HEADER_OLD +class STR_RES_HEADER : public STR_RES_HEADER_OLD { +public: float fSoundLength; diff --git a/NWNXLib/API/API/STR_RES_HEADER_OLD.hpp b/NWNXLib/API/API/STR_RES_HEADER_OLD.hpp index 2aa440a3ba9..aa699c7f633 100644 --- a/NWNXLib/API/API/STR_RES_HEADER_OLD.hpp +++ b/NWNXLib/API/API/STR_RES_HEADER_OLD.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(STR_RES_HEADER_OLD) typedef uint8_t RESREF[16]; -struct STR_RES_HEADER_OLD +class STR_RES_HEADER_OLD { +public: uint32_t wFlags; RESREF sndResRef; uint32_t volumeVariance; diff --git a/NWNXLib/API/API/ScriptParam.hpp b/NWNXLib/API/API/ScriptParam.hpp index 7ae32768415..ae9ae0fe82d 100644 --- a/NWNXLib/API/API/ScriptParam.hpp +++ b/NWNXLib/API/API/ScriptParam.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(ScriptParam) -struct ScriptParam +class ScriptParam { +public: CExoString key; CExoString value; diff --git a/NWNXLib/API/API/StackElement.hpp b/NWNXLib/API/API/StackElement.hpp index adac414ac31..9f9afc44fe4 100644 --- a/NWNXLib/API/API/StackElement.hpp +++ b/NWNXLib/API/API/StackElement.hpp @@ -12,8 +12,9 @@ NWN_API_PROLOGUE(StackElement) typedef uint32_t OBJECT_ID; -struct StackElement +class StackElement { +public: OBJECT_ID m_nStackObjectID; int32_t m_nStackInt; float m_fStackFloat; diff --git a/NWNXLib/API/API/TLK_FILE_HEADER.hpp b/NWNXLib/API/API/TLK_FILE_HEADER.hpp index 98a716ae89b..a9d891ac28a 100644 --- a/NWNXLib/API/API/TLK_FILE_HEADER.hpp +++ b/NWNXLib/API/API/TLK_FILE_HEADER.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(TLK_FILE_HEADER) -struct TLK_FILE_HEADER +class TLK_FILE_HEADER { +public: uint32_t fileType; uint32_t versionNum; uint32_t LanguageType; diff --git a/NWNXLib/API/API/TextureReplaceInfo.hpp b/NWNXLib/API/API/TextureReplaceInfo.hpp index ad28ea77674..a4a1009e752 100644 --- a/NWNXLib/API/API/TextureReplaceInfo.hpp +++ b/NWNXLib/API/API/TextureReplaceInfo.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(TextureReplaceInfo) -struct TextureReplaceInfo +class TextureReplaceInfo { +public: char m_sOldName[16+1]; char m_sNewName[16+1]; diff --git a/NWNXLib/API/API/Vector.hpp b/NWNXLib/API/API/Vector.hpp index 4a559a08e37..f53b0880acc 100644 --- a/NWNXLib/API/API/Vector.hpp +++ b/NWNXLib/API/API/Vector.hpp @@ -17,8 +17,9 @@ inline Vector operator*(const Vector& v, float s); inline Vector operator*(float s, const Vector& v); inline Vector operator/(const Vector& v, float s); -struct Vector +class Vector { +public: float x; float y; float z; diff --git a/NWNXLib/API/API/Vector2.hpp b/NWNXLib/API/API/Vector2.hpp index 8392a4a7b0b..52041dfc6ee 100644 --- a/NWNXLib/API/API/Vector2.hpp +++ b/NWNXLib/API/API/Vector2.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(Vector2) -struct Vector2 +class Vector2 { +public: float x; float y; diff --git a/NWNXLib/API/API/Vector4.hpp b/NWNXLib/API/API/Vector4.hpp index 56780f52d6f..f72d51301dd 100644 --- a/NWNXLib/API/API/Vector4.hpp +++ b/NWNXLib/API/API/Vector4.hpp @@ -11,8 +11,9 @@ NWN_API_PROLOGUE(Vector4) -struct Vector4 +class Vector4 { +public: float x; float y; float z; diff --git a/NWNXLib/API/CMakeLists.txt b/NWNXLib/API/CMakeLists.txt index 10e0742c6ad..a3dc486033f 100644 --- a/NWNXLib/API/CMakeLists.txt +++ b/NWNXLib/API/CMakeLists.txt @@ -1,4 +1,8 @@ +if(MSVC) +nwnxlib_add("FunctionsWindows.cpp") +else() nwnxlib_add("FunctionsLinux.cpp") +endif() set(NWN_API_INCLUDE "ApiExtensions.hpp") diff --git a/NWNXLib/API/Functions.hpp b/NWNXLib/API/Functions.hpp index 91a1a6c420e..4554035fb81 100644 --- a/NWNXLib/API/Functions.hpp +++ b/NWNXLib/API/Functions.hpp @@ -5,14 +5,10 @@ namespace NWNXLib::API::Functions { void Initialize(); -#define NWNXLIB_FUNCTION(name) \ - extern void* name; +#define NWNXLIB_FUNCTION(symgcc, symmsvc) \ +NWNX_IMPORT extern void* symgcc; -#ifdef _WIN32 - static_assert(false, "Windows is not supported."); -#else - #include "API/FunctionsLinux.hpp" -#endif +#include "FunctionsList.hpp" #undef NWNXLIB_FUNCTION } diff --git a/NWNXLib/API/FunctionsLinux.cpp b/NWNXLib/API/FunctionsLinux.cpp index d2ad7af06e2..f4d641dfb65 100644 --- a/NWNXLib/API/FunctionsLinux.cpp +++ b/NWNXLib/API/FunctionsLinux.cpp @@ -5,20 +5,20 @@ #define NWNXLIB_FUNCTION_NO_VERSION_CHECK -#define NWNXLIB_FUNCTION(name) \ - void* NWNXLib::API::Functions::name; -#include "FunctionsLinux.hpp" +#define NWNXLIB_FUNCTION(symgcc, symmsvc) \ + void* NWNXLib::API::Functions::symgcc; +#include "FunctionsList.hpp" #undef NWNXLIB_FUNCTION void NWNXLib::API::Functions::Initialize() { -#define NWNXLIB_FUNCTION(name) \ - name = const_cast(dlsym(RTLD_DEFAULT, #name )); \ - if (!name) \ +#define NWNXLIB_FUNCTION(symgcc, symmsvc) \ + symgcc = const_cast(dlsym(RTLD_DEFAULT, #symgcc )); \ + if (!symgcc) \ { \ - printf("dlsym(%s) = null\n", #name); \ + printf("dlsym(%s) = null\n", #symgcc); \ } -#include "FunctionsLinux.hpp" +#include "FunctionsList.hpp" #undef NWNXLIB_FUNCTION } diff --git a/NWNXLib/API/FunctionsLinux.hpp b/NWNXLib/API/FunctionsLinux.hpp deleted file mode 100644 index 6a2d2473cbf..00000000000 --- a/NWNXLib/API/FunctionsLinux.hpp +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef NWNXLIB_FUNCTION_NO_VERSION_CHECK -NWNX_EXPECT_VERSION(8193, 35); -#endif - -NWNXLIB_FUNCTION(_ZN21CServerExoAppInternal8SaveGameEjR10CExoStringS1_P10CNWSPlayeriS1_) -NWNXLIB_FUNCTION(_ZN16CGameObjectArrayC1Ei) -NWNXLIB_FUNCTION(_ZN10CNWSPlayerD0Ev) -NWNXLIB_FUNCTION(_ZN10CNWSPlayerD1Ev) -NWNXLIB_FUNCTION(_ZN10CNWSModule15LoadModuleStartE10CExoStringiiRKN6NWSync13AdvertisementE) - -// Hooking functions that override a virtual function doesn't work with the new &Class::Function way... -// .. so we need these! -NWNXLIB_FUNCTION(_ZN11CNWSTrigger12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN12CNWSCreature12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN12CNWSWaypoint12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN13CNWSEncounter12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN13CNWSPlaceable12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN14CNWSPlayerTURD12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN15CNWSSoundObject12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN22CNWSAreaOfEffectObject12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN8CNWSDoor12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN8CNWSItem12EventHandlerEjjPvjj) -NWNXLIB_FUNCTION(_ZN9CNWSStore12EventHandlerEjjPvjj) - -NWNXLIB_FUNCTION(_ZN11CNWSTrigger8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN12CNWSCreature8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN12CNWSWaypoint8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN13CNWSEncounter8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN13CNWSPlaceable8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN14CNWSPlayerTURD8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN15CNWSSoundObject8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN22CNWSAreaOfEffectObject8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN8CNWSDoor8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN8CNWSItem8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN9CNWSStore8AIUpdateEv) -NWNXLIB_FUNCTION(_ZN12CNWSCreature11ClearActionEP20CNWSObjectActionNodei) - -NWNXLIB_FUNCTION(_ZN21CNWSEffectListHandler15OnEffectAppliedEP10CNWSObjectP11CGameEffecti) -NWNXLIB_FUNCTION(_ZN21CNWSEffectListHandler15OnEffectRemovedEP10CNWSObjectP11CGameEffect) - -NWNXLIB_FUNCTION(_ZN16CNWSAmbientSound15PlayBattleMusicEi) - -NWNXLIB_FUNCTION(_ZN10CNWSObject19GetCurrentHitPointsEi) -NWNXLIB_FUNCTION(_ZN12CNWSCreature15GetMaxHitPointsEi) - -// *** diff --git a/NWNXLib/API/FunctionsList.hpp b/NWNXLib/API/FunctionsList.hpp new file mode 100644 index 00000000000..8e18cbe0fee --- /dev/null +++ b/NWNXLib/API/FunctionsList.hpp @@ -0,0 +1,47 @@ +#ifndef NWNXLIB_FUNCTION_NO_VERSION_CHECK +NWNX_EXPECT_VERSION(8193, 35); +#endif + +NWNXLIB_FUNCTION(_ZN21CServerExoAppInternal8SaveGameEjR10CExoStringS1_P10CNWSPlayeriS1_, ?SaveGame@CServerExoAppInternal@@QEAAHIAEAVCExoString@@0PEAVCNWSPlayer@@H0@Z) +NWNXLIB_FUNCTION(_ZN16CGameObjectArrayC1Ei, ??0CGameObjectArray@@QEAA@H@Z) +NWNXLIB_FUNCTION(_ZN10CNWSPlayerD0Ev, ??1CNWSPlayer@@UEAA@XZ) +NWNXLIB_FUNCTION(_ZN10CNWSPlayerD1Ev, ??1CNWSPlayer@@UEAA@XZ) +NWNXLIB_FUNCTION(_ZN10CNWSObjectD1Ev, ??1CNWSObject@@UEAA@XZ) +NWNXLIB_FUNCTION(_ZN8CNWSAreaD1Ev, ??1CNWSArea@@UEAA@XZ) +NWNXLIB_FUNCTION(_ZN10CNWSModule15LoadModuleStartE10CExoStringiiRKN6NWSync13AdvertisementE, ?LoadModuleStart@CNWSModule@@QEAAIVCExoString@@HHAEBUAdvertisement@NWSync@@@Z) + +// Hooking functions that override a virtual functions doesn't work with the new &Class::Function way... +// .. so we need these! + +NWNXLIB_FUNCTION(_ZN11CNWSTrigger12EventHandlerEjjPvjj, ?EventHandler@CNWSTrigger@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN12CNWSCreature12EventHandlerEjjPvjj, ?EventHandler@CNWSCreature@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN12CNWSWaypoint12EventHandlerEjjPvjj, ?EventHandler@CNWSWaypoint@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN13CNWSEncounter12EventHandlerEjjPvjj, ?EventHandler@CNWSEncounter@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN13CNWSPlaceable12EventHandlerEjjPvjj, ?EventHandler@CNWSPlaceable@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN14CNWSPlayerTURD12EventHandlerEjjPvjj, ?EventHandler@CNWSPlayerTURD@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN15CNWSSoundObject12EventHandlerEjjPvjj, ?EventHandler@CNWSSoundObject@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN22CNWSAreaOfEffectObject12EventHandlerEjjPvjj, ?EventHandler@CNWSAreaOfEffectObject@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN8CNWSDoor12EventHandlerEjjPvjj, ?EventHandler@CNWSDoor@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN8CNWSItem12EventHandlerEjjPvjj, ?EventHandler@CNWSItem@@UEAAXIIPEAXII@Z) +NWNXLIB_FUNCTION(_ZN9CNWSStore12EventHandlerEjjPvjj, ?EventHandler@CNWSStore@@UEAAXIIPEAXII@Z) + +NWNXLIB_FUNCTION(_ZN11CNWSTrigger8AIUpdateEv, ?AIUpdate@CNWSTrigger@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN12CNWSCreature8AIUpdateEv, ?AIUpdate@CNWSCreature@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN12CNWSWaypoint8AIUpdateEv, ?AIUpdate@CNWSWaypoint@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN13CNWSEncounter8AIUpdateEv, ?AIUpdate@CNWSEncounter@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN13CNWSPlaceable8AIUpdateEv, ?AIUpdate@CNWSPlaceable@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN14CNWSPlayerTURD8AIUpdateEv, ?AIUpdate@CNWSPlayerTURD@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN15CNWSSoundObject8AIUpdateEv, ?AIUpdate@CNWSSoundObject@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN22CNWSAreaOfEffectObject8AIUpdateEv, ?AIUpdate@CNWSAreaOfEffectObject@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN8CNWSDoor8AIUpdateEv, ?AIUpdate@CNWSDoor@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN8CNWSItem8AIUpdateEv, ?AIUpdate@CNWSItem@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN9CNWSStore8AIUpdateEv, ?AIUpdate@CNWSStore@@UEAAXXZ) +NWNXLIB_FUNCTION(_ZN12CNWSCreature11ClearActionEP20CNWSObjectActionNodei, ?ClearAction@CNWSCreature@@MEAAHPEAVCNWSObjectActionNode@@H@Z); + +NWNXLIB_FUNCTION(_ZN21CNWSEffectListHandler15OnEffectAppliedEP10CNWSObjectP11CGameEffecti, ?OnEffectApplied@CNWSEffectListHandler@@UEAAHPEAVCNWSObject@@PEAVCGameEffect@@H@Z) +NWNXLIB_FUNCTION(_ZN21CNWSEffectListHandler15OnEffectRemovedEP10CNWSObjectP11CGameEffect, ?OnEffectRemoved@CNWSEffectListHandler@@UEAAHPEAVCNWSObject@@PEAVCGameEffect@@@Z) + +NWNXLIB_FUNCTION(_ZN16CNWSAmbientSound15PlayBattleMusicEi, ?PlayBattleMusic@CNWSAmbientSound@@UEAAXH@Z); + +NWNXLIB_FUNCTION(_ZN10CNWSObject19GetCurrentHitPointsEi, ?GetCurrentHitPoints@CNWSObject@@UEAAFH@Z); +NWNXLIB_FUNCTION(_ZN12CNWSCreature15GetMaxHitPointsEi, ?GetMaxHitPoints@CNWSCreature@@UEAAFH@Z); diff --git a/NWNXLib/API/FunctionsWindows.cpp b/NWNXLib/API/FunctionsWindows.cpp new file mode 100644 index 00000000000..44d8ca7f8e0 --- /dev/null +++ b/NWNXLib/API/FunctionsWindows.cpp @@ -0,0 +1,25 @@ +#include + +#include "Functions.hpp" + +#define NWNXLIB_FUNCTION_NO_VERSION_CHECK + +#define NWNXLIB_FUNCTION(symgcc, symmsvc) \ + void* NWNXLib::API::Functions::symgcc; +#include "FunctionsList.hpp" +#undef NWNXLIB_FUNCTION + +void NWNXLib::API::Functions::Initialize() +{ + HMODULE module = GetModuleHandle(nullptr); + +#define NWNXLIB_FUNCTION(symgcc, symmsvc) \ + symgcc = reinterpret_cast(GetProcAddress(module, #symmsvc )); \ + if (!symgcc) \ + { \ + printf("GetProcAddress(%s) = null\n", #symmsvc); \ + } + +#include "FunctionsList.hpp" +#undef NWNXLIB_FUNCTION +} diff --git a/NWNXLib/API/Globals.hpp b/NWNXLib/API/Globals.hpp index 20e6d5f572d..0c51f2494fe 100644 --- a/NWNXLib/API/Globals.hpp +++ b/NWNXLib/API/Globals.hpp @@ -1,25 +1,26 @@ #pragma once +#include "nwn_api.hpp" #include -extern CExoString g_sBuildNumber; -extern CExoString g_sBuildRevision; -extern CExoString g_sBuildPostfix; -extern class CExoBase *g_pExoBase; -extern class CExoResMan *g_pExoResMan; -extern class CVirtualMachine *g_pVirtualMachine; -extern class CScriptCompiler *g_pScriptCompiler; -extern class CAppManager *g_pAppManager; -extern class CTlkTable *g_pTlkTable; -extern class CNWRules *g_pRules; +NWNX_IMPORT extern CExoString g_sBuildNumber; +NWNX_IMPORT extern CExoString g_sBuildRevision; +NWNX_IMPORT extern CExoString g_sBuildPostfix; +NWNX_IMPORT extern class CExoBase *g_pExoBase; +NWNX_IMPORT extern class CExoResMan *g_pExoResMan; +NWNX_IMPORT extern class CVirtualMachine *g_pVirtualMachine; +NWNX_IMPORT extern class CScriptCompiler *g_pScriptCompiler; +NWNX_IMPORT extern class CAppManager *g_pAppManager; +NWNX_IMPORT extern class CTlkTable *g_pTlkTable; +NWNX_IMPORT extern class CNWRules *g_pRules; namespace Task { -extern class CExoTaskManager *g_pExoTaskManager; +NWNX_IMPORT extern class CExoTaskManager *g_pExoTaskManager; } -extern int32_t g_bEnableCombatDebugging; -extern int32_t g_bEnableSavingThrowDebugging; -extern int32_t g_bEnableMovementSpeedDebugging; -extern int32_t g_bEnableHitDieDebugging; -extern int32_t g_bExitProgram; +NWNX_IMPORT extern int32_t g_bEnableCombatDebugging; +NWNX_IMPORT extern int32_t g_bEnableSavingThrowDebugging; +NWNX_IMPORT extern int32_t g_bEnableMovementSpeedDebugging; +NWNX_IMPORT extern int32_t g_bEnableHitDieDebugging; +NWNX_IMPORT extern int32_t g_bExitProgram; namespace NWNXLib::API::Globals { diff --git a/NWNXLib/API/nwn_api.hpp b/NWNXLib/API/nwn_api.hpp index 80a1e6a5faa..672ff5bdce2 100644 --- a/NWNXLib/API/nwn_api.hpp +++ b/NWNXLib/API/nwn_api.hpp @@ -22,7 +22,13 @@ NWNX_INTERNAL_STRINGIFY(NWNX_TARGET_NWN_BUILD) \ #define NWN_API_PROLOGUE(...) #define NWN_API_EPILOGUE(...) -struct CExoLinkedListNode; +#if WIN32 +#define NWNX_IMPORT __declspec(dllimport) +#else +#define NWNX_IMPORT +#endif + +class CExoLinkedListNode; typedef uint16_t RESTYPE; typedef uint32_t ObjectID; typedef uint32_t PlayerID; diff --git a/NWNXLib/Assert.cpp b/NWNXLib/Assert.cpp index 42f3df52fb9..4df87260973 100644 --- a/NWNXLib/Assert.cpp +++ b/NWNXLib/Assert.cpp @@ -1,11 +1,10 @@ #include "nwnx.hpp" -#include #include - -#include +#if !WIN32 #include +#endif namespace NWNXLib::Assert { @@ -36,10 +35,12 @@ void FailInternal(const char* condition, const char* file, int line, const char* std::fflush(stdout); NWNXLib::Log::WriteToLogFile(buffer); +#if !WIN32 if (Platform::IsDebuggerPresent()) { raise(SIGTRAP); } +#endif } } diff --git a/NWNXLib/CMakeLists.txt b/NWNXLib/CMakeLists.txt index d16b90b016b..ea5912df902 100644 --- a/NWNXLib/CMakeLists.txt +++ b/NWNXLib/CMakeLists.txt @@ -23,7 +23,6 @@ nwnxlib_add( "Utils.cpp" "Encoding.cpp" "Plugin.cpp" - "Commands.cpp" "ScriptAPI.cpp" "MessageBus.cpp" "Hooks.cpp" @@ -31,13 +30,19 @@ nwnxlib_add( "POS.cpp" ) +if(MSVC) +nwnxlib_add("CommandsWindows.cpp") +else() +nwnxlib_add("CommandsLinux.cpp") +endif() + add_subdirectory(API) add_subdirectory(External) add_subdirectory(Platform) add_subdirectory(Services) add_subdirectory(Utils) -add_library(NWNXLib STATIC "${NWNXLIB_SOURCE}") +add_library(NWNXLib OBJECT "${NWNXLIB_SOURCE}") add_sanitizers(NWNXLib) target_compile_definitions(NWNXLib PRIVATE "-DPLUGIN_NAME=\"NWNXLib\"") diff --git a/NWNXLib/Commands.cpp b/NWNXLib/CommandsLinux.cpp similarity index 97% rename from NWNXLib/Commands.cpp rename to NWNXLib/CommandsLinux.cpp index 6ed9ba8262e..d841fb17a8b 100644 --- a/NWNXLib/Commands.cpp +++ b/NWNXLib/CommandsLinux.cpp @@ -91,7 +91,7 @@ extern "C" char *fgets(char * str, int num, FILE *stream) using Type = char*(*)(char*,int,FILE*); static Type real; if (!real) - real = (Type)dlsym(RTLD_NEXT, "fgets"); + real = (Type)NWNXLib::Platform::GetSymbol(RTLD_NEXT, "fgets"); char *ret = real(str, num, stream); if (ret && stream == stdin && num == 1024) diff --git a/NWNXLib/CommandsWindows.cpp b/NWNXLib/CommandsWindows.cpp new file mode 100644 index 00000000000..8e7bda308cc --- /dev/null +++ b/NWNXLib/CommandsWindows.cpp @@ -0,0 +1,83 @@ +#include "nwnx.hpp" +#include +#include +#include + +namespace NWNXLib::Commands +{ + +using CommandFunc = std::function; + +static std::unordered_map s_commandMap; +static std::deque> s_commandQueue; +static std::mutex s_queueLock; + +bool Register(const std::string& cmd, CommandFunc func) +{ + auto it = s_commandMap.find(cmd); + if (it == s_commandMap.end()) + { + s_commandMap[cmd] = func; + LOG_INFO("Registering command '%s'", cmd); + return true; + } + else + { + LOG_WARNING("Command '%s' already registered", cmd); + return false; + } +} + +void Unregister(const std::string& cmd) +{ + LOG_INFO("Unregistering command '%s'", cmd); + s_commandMap.erase(cmd); +} + +// This runs on a side thread that processes input. +bool Schedule(std::string&& cmdline) +{ + auto trim = [](std::string &s) + { + s.erase(0, s.find_first_not_of(" \n\r\t")); + s.erase(s.find_last_not_of(" \n\r\t") + 1); + }; + + trim(cmdline); + std::string cmd, args; + size_t space = cmdline.find(' '); + + cmd = cmdline.substr(0, space); + args = (space == std::string::npos) ? "" : cmdline.substr(space, std::string::npos); + + trim(cmd); trim(args); + + std::lock_guard guard(s_queueLock); + auto it = s_commandMap.find(cmd); + if (it != s_commandMap.end()) + { + s_commandQueue.emplace_back(cmd, args); + LOG_DEBUG("Scheduled command '%s' with args '%s'", cmd, args); + return true; + } + + return false; +} + +void RunScheduled() +{ + std::lock_guard guard(s_queueLock); + for (auto item: s_commandQueue) + { + LOG_DEBUG("Running command '%s', args: '%s'", item.first, item.second); + auto it = s_commandMap.find(item.first); + if (it != s_commandMap.end()) + { + auto func = it->second; + func(item.first, item.second); + } + } + s_commandQueue.clear(); +} + +} diff --git a/NWNXLib/External/CMakeLists.txt b/NWNXLib/External/CMakeLists.txt index 2ce57c9b6de..b3594cf3137 100644 --- a/NWNXLib/External/CMakeLists.txt +++ b/NWNXLib/External/CMakeLists.txt @@ -1,2 +1,6 @@ add_subdirectory(funchook) add_subdirectory(sqlite3) + +if(MSVC) +add_subdirectory(detours) +endif() diff --git a/NWNXLib/External/detours/CMakeLists.txt b/NWNXLib/External/detours/CMakeLists.txt new file mode 100644 index 00000000000..d243e9a5816 --- /dev/null +++ b/NWNXLib/External/detours/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(detours STATIC + src/creatwth.cpp + src/detours.cpp + src/detours.h + src/detver.h + src/disasm.cpp + src/disolarm.cpp + src/disolarm64.cpp + src/disolia64.cpp + src/disolx64.cpp + src/disolx86.cpp + src/image.cpp + src/modules.cpp + src/uimports.cpp) + +set_property (SOURCE src/uimports.cpp APPEND PROPERTY HEADER_FILE_ONLY true) +target_include_directories(detours PUBLIC src) diff --git a/NWNXLib/External/detours/src/Makefile b/NWNXLib/External/detours/src/Makefile new file mode 100644 index 00000000000..320f3b786c3 --- /dev/null +++ b/NWNXLib/External/detours/src/Makefile @@ -0,0 +1,117 @@ +############################################################################## +## +## Makefile for Detours. +## +## Microsoft Research Detours Package, Version 4.0.1 +## +## Copyright (c) Microsoft Corporation. All rights reserved. +## + +ROOT = .. +!include "$(ROOT)\system.mak" + +!IF "$(DETOURS_SOURCE_BROWSING)" == "" +DETOURS_SOURCE_BROWSING = 0 +!ENDIF + +#######################/####################################################### +## +CFLAGS=/W4 /WX /Zi /MT /Gy /Gm- /Zl /Od + +!IF $(DETOURS_SOURCE_BROWSING)==1 +CFLAGS=$(CFLAGS) /FR +!ELSE +CFLAGS=$(CFLAGS) /DWIN32_LEAN_AND_MEAN /D_WIN32_WINNT=0x501 +!ENDIF + +!IF "$(DETOURS_TARGET_PROCESSOR)" == "IA64" +CFLAGS=$(CFLAGS) /wd4163 # intrinsic rdtebex not available; using newer Windows headers with older compiler +!ENDIF + +!if defined(DETOURS_WIN_7) && defined(DETOURS_CL_17_OR_NEWER) +CFLAGS=$(CFLAGS) /D_USING_V110_SDK71_ +!elseif defined(DETOURS_ANALYZE) +CFLAGS=$(CFLAGS) /analyze +!endif + +OBJS = \ + $(OBJD)\detours.obj \ + $(OBJD)\modules.obj \ + $(OBJD)\disasm.obj \ + $(OBJD)\image.obj \ + $(OBJD)\creatwth.obj \ + $(OBJD)\disolx86.obj \ + $(OBJD)\disolx64.obj \ + $(OBJD)\disolia64.obj \ + $(OBJD)\disolarm.obj \ + $(OBJD)\disolarm64.obj \ + +############################################################################## +## +.SUFFIXES: .cpp .h .obj + +!ifdef DETOURS_ANALYZE +.cpp{$(OBJD)}.obj: + $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< +!else +.cpp{$(OBJD)}.obj:: + $(CC) $(CFLAGS) /Fd$(LIBD)\detours.pdb /Fo$(OBJD)\ /c $< +!endif + +############################################################################## + +all: dirs \ + $(LIBD)\detours.lib \ + $(INCD)\detours.h \ + $(INCD)\detver.h \ +!IF $(DETOURS_SOURCE_BROWSING)==1 + $(OBJD)\detours.bsc \ +!endif + +############################################################################## + +clean: + -del *~ 2>nul + -del $(LIBD)\detours.pdb $(LIBD)\detours.lib 2>nul + -rmdir /q /s $(OBJD) 2>nul + +realclean: clean + -rmdir /q /s $(OBJDS) 2>nul + +############################################################################## + +dirs: + @if not exist "$(INCD)" mkdir "$(INCD)" && echo. Created $(INCD) + @if not exist "$(LIBD)" mkdir "$(LIBD)" && echo. Created $(LIBD) + @if not exist "$(BIND)" mkdir "$(BIND)" && echo. Created $(BIND) + @if not exist "$(OBJD)" mkdir "$(OBJD)" && echo. Created $(OBJD) + +$(OBJD)\detours.bsc : $(OBJS) + bscmake /v /n /o $@ $(OBJS:.obj=.sbr) + +$(LIBD)\detours.lib : $(OBJS) + link /lib /out:$@ $(OBJS) + +$(INCD)\detours.h : detours.h + copy detours.h $@ + +$(INCD)\detver.h : detver.h + copy detver.h $@ + +$(OBJD)\detours.obj : detours.cpp detours.h +$(OBJD)\modules.obj : modules.cpp detours.h +$(OBJD)\disasm.obj : disasm.cpp detours.h +$(OBJD)\image.obj : image.cpp detours.h +$(OBJD)\creatwth.obj : creatwth.cpp uimports.cpp detours.h +$(OBJD)\disolx86.obj: disasm.cpp detours.h +$(OBJD)\disolx64.obj: disasm.cpp detours.h +$(OBJD)\disolia64.obj: disasm.cpp detours.h +$(OBJD)\disolarm.obj: disasm.cpp detours.h +$(OBJD)\disolarm64.obj: disasm.cpp detours.h + +test: all + cd $(MAKEDIR)\..\samples\slept + nmake /nologo test + cd $(MAKEDIR) + +################################################################# End of File. diff --git a/NWNXLib/External/detours/src/creatwth.cpp b/NWNXLib/External/detours/src/creatwth.cpp new file mode 100644 index 00000000000..300bb2c875f --- /dev/null +++ b/NWNXLib/External/detours/src/creatwth.cpp @@ -0,0 +1,1567 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Create a process with a DLL (creatwth.cpp of detours.lib) +// +// Microsoft Research Detours Package, Version 4.0.1 +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + +// #define DETOUR_DEBUG 1 +#define DETOURS_INTERNAL +#include "detours.h" +#include + +#if DETOURS_VERSION != 0x4c0c1 // 0xMAJORcMINORcPATCH +#error detours.h version mismatch +#endif + +#define IMPORT_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT] +#define BOUND_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT] +#define CLR_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR] +#define IAT_DIRECTORY OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT] + +////////////////////////////////////////////////////////////////////////////// +// +const GUID DETOUR_EXE_HELPER_GUID = { /* ea0251b9-5cde-41b5-98d0-2af4a26b0fee */ + 0xea0251b9, 0x5cde, 0x41b5, + { 0x98, 0xd0, 0x2a, 0xf4, 0xa2, 0x6b, 0x0f, 0xee }}; + +////////////////////////////////////////////////////////////////////////////// +// +// Enumate through modules in the target process. +// +static BOOL WINAPI LoadNtHeaderFromProcess(HANDLE hProcess, + HMODULE hModule, + PIMAGE_NT_HEADERS32 pNtHeader) +{ + PBYTE pbModule = (PBYTE)hModule; + + if (pbModule == NULL) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + MEMORY_BASIC_INFORMATION mbi; + ZeroMemory(&mbi, sizeof(mbi)); + + if (VirtualQueryEx(hProcess, hModule, &mbi, sizeof(mbi)) == 0) { + return FALSE; + } + + IMAGE_DOS_HEADER idh; + + if (!ReadProcessMemory(hProcess, pbModule, &idh, sizeof(idh), NULL)) { + DETOUR_TRACE(("ReadProcessMemory(idh@%p..%p) failed: %d\n", + pbModule, pbModule + sizeof(idh), GetLastError())); + return FALSE; + } + + if (idh.e_magic != IMAGE_DOS_SIGNATURE || + (DWORD)idh.e_lfanew > mbi.RegionSize || + (DWORD)idh.e_lfanew < sizeof(idh)) { + + SetLastError(ERROR_BAD_EXE_FORMAT); + return FALSE; + } + + if (!ReadProcessMemory(hProcess, pbModule + idh.e_lfanew, + pNtHeader, sizeof(*pNtHeader), NULL)) { + DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p:%p) failed: %d\n", + pbModule + idh.e_lfanew, + pbModule + idh.e_lfanew + sizeof(*pNtHeader), + pbModule, + GetLastError())); + return FALSE; + } + + if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { + SetLastError(ERROR_BAD_EXE_FORMAT); + return FALSE; + } + + return TRUE; +} + +static HMODULE WINAPI EnumerateModulesInProcess(HANDLE hProcess, + HMODULE hModuleLast, + PIMAGE_NT_HEADERS32 pNtHeader) +{ + PBYTE pbLast = (PBYTE)hModuleLast + MM_ALLOCATION_GRANULARITY; + + MEMORY_BASIC_INFORMATION mbi; + ZeroMemory(&mbi, sizeof(mbi)); + + // Find the next memory region that contains a mapped PE image. + // + + for (;; pbLast = (PBYTE)mbi.BaseAddress + mbi.RegionSize) { + if (VirtualQueryEx(hProcess, (PVOID)pbLast, &mbi, sizeof(mbi)) == 0) { + break; + } + + // Usermode address space has such an unaligned region size always at the + // end and only at the end. + // + if ((mbi.RegionSize & 0xfff) == 0xfff) { + break; + } + if (((PBYTE)mbi.BaseAddress + mbi.RegionSize) < pbLast) { + break; + } + + // Skip uncommitted regions and guard pages. + // + if ((mbi.State != MEM_COMMIT) || + ((mbi.Protect & 0xff) == PAGE_NOACCESS) || + (mbi.Protect & PAGE_GUARD)) { + continue; + } + + if (LoadNtHeaderFromProcess(hProcess, (HMODULE)pbLast, pNtHeader)) { + return (HMODULE)pbLast; + } + } + return NULL; +} + +////////////////////////////////////////////////////////////////////////////// +// +// Find a region of memory in which we can create a replacement import table. +// +static PBYTE FindAndAllocateNearBase(HANDLE hProcess, PBYTE pbModule, PBYTE pbBase, DWORD cbAlloc) +{ + MEMORY_BASIC_INFORMATION mbi; + ZeroMemory(&mbi, sizeof(mbi)); + + PBYTE pbLast = pbBase; + for (;; pbLast = (PBYTE)mbi.BaseAddress + mbi.RegionSize) { + + ZeroMemory(&mbi, sizeof(mbi)); + if (VirtualQueryEx(hProcess, (PVOID)pbLast, &mbi, sizeof(mbi)) == 0) { + if (GetLastError() == ERROR_INVALID_PARAMETER) { + break; + } + DETOUR_TRACE(("VirtualQueryEx(%p) failed: %d\n", + pbLast, GetLastError())); + break; + } + // Usermode address space has such an unaligned region size always at the + // end and only at the end. + // + if ((mbi.RegionSize & 0xfff) == 0xfff) { + break; + } + + // Skip anything other than a pure free region. + // + if (mbi.State != MEM_FREE) { + continue; + } + + // Use the max of mbi.BaseAddress and pbBase, in case mbi.BaseAddress < pbBase. + PBYTE pbAddress = (PBYTE)mbi.BaseAddress > pbBase ? (PBYTE)mbi.BaseAddress : pbBase; + + // Round pbAddress up to the nearest MM allocation boundary. + const DWORD_PTR mmGranularityMinusOne = (DWORD_PTR)(MM_ALLOCATION_GRANULARITY -1); + pbAddress = (PBYTE)(((DWORD_PTR)pbAddress + mmGranularityMinusOne) & ~mmGranularityMinusOne); + +#ifdef _WIN64 + // The offset from pbModule to any replacement import must fit into 32 bits. + // For simplicity, we check that the offset to the last byte fits into 32 bits, + // instead of the largest offset we'll actually use. The values are very similar. + const size_t GB4 = ((((size_t)1) << 32) - 1); + if ((size_t)(pbAddress + cbAlloc - 1 - pbModule) > GB4) { + DETOUR_TRACE(("FindAndAllocateNearBase(1) failing due to distance >4GB %p\n", pbAddress)); + return NULL; + } +#else + UNREFERENCED_PARAMETER(pbModule); +#endif + + DETOUR_TRACE(("Free region %p..%p\n", + mbi.BaseAddress, + (PBYTE)mbi.BaseAddress + mbi.RegionSize)); + + for (; pbAddress < (PBYTE)mbi.BaseAddress + mbi.RegionSize; pbAddress += MM_ALLOCATION_GRANULARITY) { + PBYTE pbAlloc = (PBYTE)VirtualAllocEx(hProcess, pbAddress, cbAlloc, + MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + if (pbAlloc == NULL) { + DETOUR_TRACE(("VirtualAllocEx(%p) failed: %d\n", pbAddress, GetLastError())); + continue; + } +#ifdef _WIN64 + // The offset from pbModule to any replacement import must fit into 32 bits. + if ((size_t)(pbAddress + cbAlloc - 1 - pbModule) > GB4) { + DETOUR_TRACE(("FindAndAllocateNearBase(2) failing due to distance >4GB %p\n", pbAddress)); + return NULL; + } +#endif + DETOUR_TRACE(("[%p..%p] Allocated for import table.\n", + pbAlloc, pbAlloc + cbAlloc)); + return pbAlloc; + } + } + return NULL; +} + +static inline DWORD PadToDword(DWORD dw) +{ + return (dw + 3) & ~3u; +} + +static inline DWORD PadToDwordPtr(DWORD dw) +{ + return (dw + 7) & ~7u; +} + +static inline HRESULT ReplaceOptionalSizeA(_Inout_z_count_(cchDest) LPSTR pszDest, + _In_ size_t cchDest, + _In_z_ LPCSTR pszSize) +{ + if (cchDest == 0 || pszDest == NULL || pszSize == NULL || + pszSize[0] == '\0' || pszSize[1] == '\0' || pszSize[2] != '\0') { + + // can not write into empty buffer or with string other than two chars. + return ERROR_INVALID_PARAMETER; + } + + for (; cchDest >= 2; cchDest--, pszDest++) { + if (pszDest[0] == '?' && pszDest[1] == '?') { + pszDest[0] = pszSize[0]; + pszDest[1] = pszSize[1]; + break; + } + } + + return S_OK; +} + +static BOOL RecordExeRestore(HANDLE hProcess, HMODULE hModule, DETOUR_EXE_RESTORE& der) +{ + // Save the various headers for DetourRestoreAfterWith. + ZeroMemory(&der, sizeof(der)); + der.cb = sizeof(der); + + der.pidh = (PBYTE)hModule; + der.cbidh = sizeof(der.idh); + if (!ReadProcessMemory(hProcess, der.pidh, &der.idh, sizeof(der.idh), NULL)) { + DETOUR_TRACE(("ReadProcessMemory(idh@%p..%p) failed: %d\n", + der.pidh, der.pidh + der.cbidh, GetLastError())); + return FALSE; + } + DETOUR_TRACE(("IDH: %p..%p\n", der.pidh, der.pidh + der.cbidh)); + + // We read the NT header in two passes to get the full size. + // First we read just the Signature and FileHeader. + der.pinh = der.pidh + der.idh.e_lfanew; + der.cbinh = FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader); + if (!ReadProcessMemory(hProcess, der.pinh, &der.inh, der.cbinh, NULL)) { + DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p) failed: %d\n", + der.pinh, der.pinh + der.cbinh, GetLastError())); + return FALSE; + } + + // Second we read the OptionalHeader and Section headers. + der.cbinh = (FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + + der.inh.FileHeader.SizeOfOptionalHeader + + der.inh.FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER)); + + if (der.cbinh > sizeof(der.raw)) { + return FALSE; + } + + if (!ReadProcessMemory(hProcess, der.pinh, &der.inh, der.cbinh, NULL)) { + DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p) failed: %d\n", + der.pinh, der.pinh + der.cbinh, GetLastError())); + return FALSE; + } + DETOUR_TRACE(("INH: %p..%p\n", der.pinh, der.pinh + der.cbinh)); + + // Third, we read the CLR header + + if (der.inh.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC) { + if (der.inh32.CLR_DIRECTORY.VirtualAddress != 0 && + der.inh32.CLR_DIRECTORY.Size != 0) { + + DETOUR_TRACE(("CLR32.VirtAddr=%x, CLR.Size=%x\n", + der.inh32.CLR_DIRECTORY.VirtualAddress, + der.inh32.CLR_DIRECTORY.Size)); + + der.pclr = ((PBYTE)hModule) + der.inh32.CLR_DIRECTORY.VirtualAddress; + } + } + else if (der.inh.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC) { + if (der.inh64.CLR_DIRECTORY.VirtualAddress != 0 && + der.inh64.CLR_DIRECTORY.Size != 0) { + + DETOUR_TRACE(("CLR64.VirtAddr=%x, CLR.Size=%x\n", + der.inh64.CLR_DIRECTORY.VirtualAddress, + der.inh64.CLR_DIRECTORY.Size)); + + der.pclr = ((PBYTE)hModule) + der.inh64.CLR_DIRECTORY.VirtualAddress; + } + } + + if (der.pclr != 0) { + der.cbclr = sizeof(der.clr); + if (!ReadProcessMemory(hProcess, der.pclr, &der.clr, der.cbclr, NULL)) { + DETOUR_TRACE(("ReadProcessMemory(clr@%p..%p) failed: %d\n", + der.pclr, der.pclr + der.cbclr, GetLastError())); + return FALSE; + } + DETOUR_TRACE(("CLR: %p..%p\n", der.pclr, der.pclr + der.cbclr)); + } + + return TRUE; +} + +////////////////////////////////////////////////////////////////////////////// +// +#if DETOURS_32BIT +#define DWORD_XX DWORD32 +#define IMAGE_NT_HEADERS_XX IMAGE_NT_HEADERS32 +#define IMAGE_NT_OPTIONAL_HDR_MAGIC_XX IMAGE_NT_OPTIONAL_HDR32_MAGIC +#define IMAGE_ORDINAL_FLAG_XX IMAGE_ORDINAL_FLAG32 +#define UPDATE_IMPORTS_XX UpdateImports32 +#define DETOURS_BITS_XX 32 +#include "uimports.cpp" +#undef DETOUR_EXE_RESTORE_FIELD_XX +#undef DWORD_XX +#undef IMAGE_NT_HEADERS_XX +#undef IMAGE_NT_OPTIONAL_HDR_MAGIC_XX +#undef IMAGE_ORDINAL_FLAG_XX +#undef UPDATE_IMPORTS_XX +#endif // DETOURS_32BIT + +#if DETOURS_64BIT +#define DWORD_XX DWORD64 +#define IMAGE_NT_HEADERS_XX IMAGE_NT_HEADERS64 +#define IMAGE_NT_OPTIONAL_HDR_MAGIC_XX IMAGE_NT_OPTIONAL_HDR64_MAGIC +#define IMAGE_ORDINAL_FLAG_XX IMAGE_ORDINAL_FLAG64 +#define UPDATE_IMPORTS_XX UpdateImports64 +#define DETOURS_BITS_XX 64 +#include "uimports.cpp" +#undef DETOUR_EXE_RESTORE_FIELD_XX +#undef DWORD_XX +#undef IMAGE_NT_HEADERS_XX +#undef IMAGE_NT_OPTIONAL_HDR_MAGIC_XX +#undef IMAGE_ORDINAL_FLAG_XX +#undef UPDATE_IMPORTS_XX +#endif // DETOURS_64BIT + +////////////////////////////////////////////////////////////////////////////// +// +#if DETOURS_64BIT + +C_ASSERT(sizeof(IMAGE_NT_HEADERS64) == sizeof(IMAGE_NT_HEADERS32) + 16); + +static BOOL UpdateFrom32To64(HANDLE hProcess, HMODULE hModule, WORD machine, + DETOUR_EXE_RESTORE& der) +{ + IMAGE_DOS_HEADER idh; + IMAGE_NT_HEADERS32 inh32; + IMAGE_NT_HEADERS64 inh64; + IMAGE_SECTION_HEADER sects[32]; + PBYTE pbModule = (PBYTE)hModule; + DWORD n; + + ZeroMemory(&inh32, sizeof(inh32)); + ZeroMemory(&inh64, sizeof(inh64)); + ZeroMemory(sects, sizeof(sects)); + + DETOUR_TRACE(("UpdateFrom32To64(%04x)\n", machine)); + //////////////////////////////////////////////////////// Read old headers. + // + if (!ReadProcessMemory(hProcess, pbModule, &idh, sizeof(idh), NULL)) { + DETOUR_TRACE(("ReadProcessMemory(idh@%p..%p) failed: %d\n", + pbModule, pbModule + sizeof(idh), GetLastError())); + return FALSE; + } + DETOUR_TRACE(("ReadProcessMemory(idh@%p..%p)\n", + pbModule, pbModule + sizeof(idh))); + + PBYTE pnh = pbModule + idh.e_lfanew; + if (!ReadProcessMemory(hProcess, pnh, &inh32, sizeof(inh32), NULL)) { + DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p) failed: %d\n", + pnh, pnh + sizeof(inh32), GetLastError())); + return FALSE; + } + DETOUR_TRACE(("ReadProcessMemory(inh@%p..%p)\n", pnh, pnh + sizeof(inh32))); + + if (inh32.FileHeader.NumberOfSections > (sizeof(sects)/sizeof(sects[0]))) { + return FALSE; + } + + PBYTE psects = pnh + + FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + + inh32.FileHeader.SizeOfOptionalHeader; + ULONG cb = inh32.FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER); + if (!ReadProcessMemory(hProcess, psects, §s, cb, NULL)) { + DETOUR_TRACE(("ReadProcessMemory(ish@%p..%p) failed: %d\n", + psects, psects + cb, GetLastError())); + return FALSE; + } + DETOUR_TRACE(("ReadProcessMemory(ish@%p..%p)\n", psects, psects + cb)); + + ////////////////////////////////////////////////////////// Convert header. + // + inh64.Signature = inh32.Signature; + inh64.FileHeader = inh32.FileHeader; + inh64.FileHeader.Machine = machine; + inh64.FileHeader.SizeOfOptionalHeader = sizeof(IMAGE_OPTIONAL_HEADER64); + + inh64.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR64_MAGIC; + inh64.OptionalHeader.MajorLinkerVersion = inh32.OptionalHeader.MajorLinkerVersion; + inh64.OptionalHeader.MinorLinkerVersion = inh32.OptionalHeader.MinorLinkerVersion; + inh64.OptionalHeader.SizeOfCode = inh32.OptionalHeader.SizeOfCode; + inh64.OptionalHeader.SizeOfInitializedData = inh32.OptionalHeader.SizeOfInitializedData; + inh64.OptionalHeader.SizeOfUninitializedData = inh32.OptionalHeader.SizeOfUninitializedData; + inh64.OptionalHeader.AddressOfEntryPoint = inh32.OptionalHeader.AddressOfEntryPoint; + inh64.OptionalHeader.BaseOfCode = inh32.OptionalHeader.BaseOfCode; + inh64.OptionalHeader.ImageBase = inh32.OptionalHeader.ImageBase; + inh64.OptionalHeader.SectionAlignment = inh32.OptionalHeader.SectionAlignment; + inh64.OptionalHeader.FileAlignment = inh32.OptionalHeader.FileAlignment; + inh64.OptionalHeader.MajorOperatingSystemVersion + = inh32.OptionalHeader.MajorOperatingSystemVersion; + inh64.OptionalHeader.MinorOperatingSystemVersion + = inh32.OptionalHeader.MinorOperatingSystemVersion; + inh64.OptionalHeader.MajorImageVersion = inh32.OptionalHeader.MajorImageVersion; + inh64.OptionalHeader.MinorImageVersion = inh32.OptionalHeader.MinorImageVersion; + inh64.OptionalHeader.MajorSubsystemVersion = inh32.OptionalHeader.MajorSubsystemVersion; + inh64.OptionalHeader.MinorSubsystemVersion = inh32.OptionalHeader.MinorSubsystemVersion; + inh64.OptionalHeader.Win32VersionValue = inh32.OptionalHeader.Win32VersionValue; + inh64.OptionalHeader.SizeOfImage = inh32.OptionalHeader.SizeOfImage; + inh64.OptionalHeader.SizeOfHeaders = inh32.OptionalHeader.SizeOfHeaders; + inh64.OptionalHeader.CheckSum = inh32.OptionalHeader.CheckSum; + inh64.OptionalHeader.Subsystem = inh32.OptionalHeader.Subsystem; + inh64.OptionalHeader.DllCharacteristics = inh32.OptionalHeader.DllCharacteristics; + inh64.OptionalHeader.SizeOfStackReserve = inh32.OptionalHeader.SizeOfStackReserve; + inh64.OptionalHeader.SizeOfStackCommit = inh32.OptionalHeader.SizeOfStackCommit; + inh64.OptionalHeader.SizeOfHeapReserve = inh32.OptionalHeader.SizeOfHeapReserve; + inh64.OptionalHeader.SizeOfHeapCommit = inh32.OptionalHeader.SizeOfHeapCommit; + inh64.OptionalHeader.LoaderFlags = inh32.OptionalHeader.LoaderFlags; + inh64.OptionalHeader.NumberOfRvaAndSizes = inh32.OptionalHeader.NumberOfRvaAndSizes; + for (n = 0; n < IMAGE_NUMBEROF_DIRECTORY_ENTRIES; n++) { + inh64.OptionalHeader.DataDirectory[n] = inh32.OptionalHeader.DataDirectory[n]; + } + + /////////////////////////////////////////////////////// Write new headers. + // + DWORD dwProtect = 0; + if (!DetourVirtualProtectSameExecuteEx(hProcess, pbModule, inh64.OptionalHeader.SizeOfHeaders, + PAGE_EXECUTE_READWRITE, &dwProtect)) { + return FALSE; + } + + if (!WriteProcessMemory(hProcess, pnh, &inh64, sizeof(inh64), NULL)) { + DETOUR_TRACE(("WriteProcessMemory(inh@%p..%p) failed: %d\n", + pnh, pnh + sizeof(inh64), GetLastError())); + return FALSE; + } + DETOUR_TRACE(("WriteProcessMemory(inh@%p..%p)\n", pnh, pnh + sizeof(inh64))); + + psects = pnh + + FIELD_OFFSET(IMAGE_NT_HEADERS, OptionalHeader) + + inh64.FileHeader.SizeOfOptionalHeader; + cb = inh64.FileHeader.NumberOfSections * sizeof(IMAGE_SECTION_HEADER); + if (!WriteProcessMemory(hProcess, psects, §s, cb, NULL)) { + DETOUR_TRACE(("WriteProcessMemory(ish@%p..%p) failed: %d\n", + psects, psects + cb, GetLastError())); + return FALSE; + } + DETOUR_TRACE(("WriteProcessMemory(ish@%p..%p)\n", psects, psects + cb)); + + // Record the updated headers. + if (!RecordExeRestore(hProcess, hModule, der)) { + return FALSE; + } + + // Remove the import table. + if (der.pclr != NULL && (der.clr.Flags & 1)) { + inh64.IMPORT_DIRECTORY.VirtualAddress = 0; + inh64.IMPORT_DIRECTORY.Size = 0; + + if (!WriteProcessMemory(hProcess, pnh, &inh64, sizeof(inh64), NULL)) { + DETOUR_TRACE(("WriteProcessMemory(inh@%p..%p) failed: %d\n", + pnh, pnh + sizeof(inh64), GetLastError())); + return FALSE; + } + } + + DWORD dwOld = 0; + if (!VirtualProtectEx(hProcess, pbModule, inh64.OptionalHeader.SizeOfHeaders, + dwProtect, &dwOld)) { + return FALSE; + } + + return TRUE; +} +#endif // DETOURS_64BIT + +////////////////////////////////////////////////////////////////////////////// +// +BOOL WINAPI DetourUpdateProcessWithDll(_In_ HANDLE hProcess, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_ DWORD nDlls) +{ + // Find the next memory region that contains a mapped PE image. + // + BOOL bHas64BitDll = FALSE; + BOOL bHas32BitExe = FALSE; + BOOL bIs32BitProcess; + HMODULE hModule = NULL; + HMODULE hLast = NULL; + + DETOUR_TRACE(("DetourUpdateProcessWithDll(%p,dlls=%d)\n", hProcess, nDlls)); + + for (;;) { + IMAGE_NT_HEADERS32 inh; + + if ((hLast = EnumerateModulesInProcess(hProcess, hLast, &inh)) == NULL) { + break; + } + + DETOUR_TRACE(("%p machine=%04x magic=%04x\n", + hLast, inh.FileHeader.Machine, inh.OptionalHeader.Magic)); + + if ((inh.FileHeader.Characteristics & IMAGE_FILE_DLL) == 0) { + hModule = hLast; + if (inh.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC + && inh.FileHeader.Machine != 0) { + + bHas32BitExe = TRUE; + } + DETOUR_TRACE(("%p Found EXE\n", hLast)); + } + else { + if (inh.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC + && inh.FileHeader.Machine != 0) { + + bHas64BitDll = TRUE; + } + } + } + + if (hModule == NULL) { + SetLastError(ERROR_INVALID_OPERATION); + return FALSE; + } + + if (!bHas32BitExe) { + bIs32BitProcess = FALSE; + } + else if (!bHas64BitDll) { + bIs32BitProcess = TRUE; + } + else { + if (!IsWow64Process(hProcess, &bIs32BitProcess)) { + return FALSE; + } + } + + DETOUR_TRACE((" 32BitExe=%d 32BitProcess\n", bHas32BitExe, bIs32BitProcess)); + + return DetourUpdateProcessWithDllEx(hProcess, + hModule, + bIs32BitProcess, + rlpDlls, + nDlls); +} + +BOOL WINAPI DetourUpdateProcessWithDllEx(_In_ HANDLE hProcess, + _In_ HMODULE hModule, + _In_ BOOL bIs32BitProcess, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_ DWORD nDlls) +{ + // Find the next memory region that contains a mapped PE image. + // + BOOL bIs32BitExe = FALSE; + + DETOUR_TRACE(("DetourUpdateProcessWithDllEx(%p,%p,dlls=%d)\n", hProcess, hModule, nDlls)); + + IMAGE_NT_HEADERS32 inh; + + if (hModule == NULL || LoadNtHeaderFromProcess(hProcess, hModule, &inh) == NULL) { + SetLastError(ERROR_INVALID_OPERATION); + return FALSE; + } + + if (inh.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC + && inh.FileHeader.Machine != 0) { + + bIs32BitExe = TRUE; + } + + DETOUR_TRACE((" 32BitExe=%d 32BitProcess\n", bIs32BitExe, bIs32BitProcess)); + + if (hModule == NULL) { + SetLastError(ERROR_INVALID_OPERATION); + return FALSE; + } + + // Save the various headers for DetourRestoreAfterWith. + // + DETOUR_EXE_RESTORE der; + + if (!RecordExeRestore(hProcess, hModule, der)) { + return FALSE; + } + +#if defined(DETOURS_64BIT) + // Try to convert a neutral 32-bit managed binary to a 64-bit managed binary. + if (bIs32BitExe && !bIs32BitProcess) { + if (!der.pclr // Native binary + || (der.clr.Flags & 1) == 0 // Or mixed-mode MSIL + || (der.clr.Flags & 2) != 0) { // Or 32BIT Required MSIL + + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (!UpdateFrom32To64(hProcess, hModule, +#if defined(DETOURS_X64) + IMAGE_FILE_MACHINE_AMD64, +#elif defined(DETOURS_IA64) + IMAGE_FILE_MACHINE_IA64, +#elif defined(DETOURS_ARM64) + IMAGE_FILE_MACHINE_ARM64, +#else +#error Must define one of DETOURS_X64 or DETOURS_IA64 or DETOURS_ARM64 on 64-bit. +#endif + der)) { + return FALSE; + } + bIs32BitExe = FALSE; + } +#endif // DETOURS_64BIT + + // Now decide if we can insert the detour. + +#if defined(DETOURS_32BIT) + if (bIs32BitProcess) { + // 32-bit native or 32-bit managed process on any platform. + if (!UpdateImports32(hProcess, hModule, rlpDlls, nDlls)) { + return FALSE; + } + } + else { + // 64-bit native or 64-bit managed process. + // + // Can't detour a 64-bit process with 32-bit code. + // Note: This happens for 32-bit PE binaries containing only + // manage code that have been marked as 64-bit ready. + // + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } +#elif defined(DETOURS_64BIT) + if (bIs32BitProcess || bIs32BitExe) { + // Can't detour a 32-bit process with 64-bit code. + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + else { + // 64-bit native or 64-bit managed process on any platform. + if (!UpdateImports64(hProcess, hModule, rlpDlls, nDlls)) { + return FALSE; + } + } +#else +#pragma Must define one of DETOURS_32BIT or DETOURS_64BIT. +#endif // DETOURS_64BIT + + /////////////////////////////////////////////////// Update the CLR header. + // + if (der.pclr != NULL) { + DETOUR_CLR_HEADER clr; + CopyMemory(&clr, &der.clr, sizeof(clr)); + clr.Flags &= 0xfffffffe; // Clear the IL_ONLY flag. + + DWORD dwProtect; + if (!DetourVirtualProtectSameExecuteEx(hProcess, der.pclr, sizeof(clr), PAGE_READWRITE, &dwProtect)) { + DETOUR_TRACE(("VirtualProtectEx(clr) write failed: %d\n", GetLastError())); + return FALSE; + } + + if (!WriteProcessMemory(hProcess, der.pclr, &clr, sizeof(clr), NULL)) { + DETOUR_TRACE(("WriteProcessMemory(clr) failed: %d\n", GetLastError())); + return FALSE; + } + + if (!VirtualProtectEx(hProcess, der.pclr, sizeof(clr), dwProtect, &dwProtect)) { + DETOUR_TRACE(("VirtualProtectEx(clr) restore failed: %d\n", GetLastError())); + return FALSE; + } + DETOUR_TRACE(("CLR: %p..%p\n", der.pclr, der.pclr + der.cbclr)); + +#if DETOURS_64BIT + if (der.clr.Flags & 0x2) { // Is the 32BIT Required Flag set? + // X64 never gets here because the process appears as a WOW64 process. + // However, on IA64, it doesn't appear to be a WOW process. + DETOUR_TRACE(("CLR Requires 32-bit\n", der.pclr, der.pclr + der.cbclr)); + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } +#endif // DETOURS_64BIT + } + + //////////////////////////////// Save the undo data to the target process. + // + if (!DetourCopyPayloadToProcess(hProcess, DETOUR_EXE_RESTORE_GUID, &der, sizeof(der))) { + DETOUR_TRACE(("DetourCopyPayloadToProcess failed: %d\n", GetLastError())); + return FALSE; + } + return TRUE; +} + +////////////////////////////////////////////////////////////////////////////// +// +BOOL WINAPI DetourCreateProcessWithDllA(_In_opt_ LPCSTR lpApplicationName, + _Inout_opt_ LPSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOA lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ LPCSTR lpDllName, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA) +{ + DWORD dwMyCreationFlags = (dwCreationFlags | CREATE_SUSPENDED); + PROCESS_INFORMATION pi; + BOOL fResult = FALSE; + + if (pfCreateProcessA == NULL) { + pfCreateProcessA = CreateProcessA; + } + + fResult = pfCreateProcessA(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwMyCreationFlags, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + &pi); + + if (lpProcessInformation != NULL) { + CopyMemory(lpProcessInformation, &pi, sizeof(pi)); + } + + if (!fResult) { + return FALSE; + } + + LPCSTR rlpDlls[2]; + DWORD nDlls = 0; + if (lpDllName != NULL) { + rlpDlls[nDlls++] = lpDllName; + } + + if (!DetourUpdateProcessWithDll(pi.hProcess, rlpDlls, nDlls)) { + TerminateProcess(pi.hProcess, ~0u); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(pi.hThread); + } + return TRUE; +} + + +BOOL WINAPI DetourCreateProcessWithDllW(_In_opt_ LPCWSTR lpApplicationName, + _Inout_opt_ LPWSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCWSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOW lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ LPCSTR lpDllName, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW) +{ + DWORD dwMyCreationFlags = (dwCreationFlags | CREATE_SUSPENDED); + PROCESS_INFORMATION pi; + + if (pfCreateProcessW == NULL) { + pfCreateProcessW = CreateProcessW; + } + + BOOL fResult = pfCreateProcessW(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwMyCreationFlags, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + &pi); + + if (lpProcessInformation) { + CopyMemory(lpProcessInformation, &pi, sizeof(pi)); + } + + if (!fResult) { + return FALSE; + } + + LPCSTR rlpDlls[2]; + DWORD nDlls = 0; + if (lpDllName != NULL) { + rlpDlls[nDlls++] = lpDllName; + } + + if (!DetourUpdateProcessWithDll(pi.hProcess, rlpDlls, nDlls)) { + TerminateProcess(pi.hProcess, ~0u); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(pi.hThread); + } + return TRUE; +} + +BOOL WINAPI DetourCopyPayloadToProcess(_In_ HANDLE hProcess, + _In_ REFGUID rguid, + _In_reads_bytes_(cbData) PVOID pvData, + _In_ DWORD cbData) +{ + DWORD cbTotal = (sizeof(IMAGE_DOS_HEADER) + + sizeof(IMAGE_NT_HEADERS) + + sizeof(IMAGE_SECTION_HEADER) + + sizeof(DETOUR_SECTION_HEADER) + + sizeof(DETOUR_SECTION_RECORD) + + cbData); + + PBYTE pbBase = (PBYTE)VirtualAllocEx(hProcess, NULL, cbTotal, + MEM_COMMIT, PAGE_READWRITE); + if (pbBase == NULL) { + DETOUR_TRACE(("VirtualAllocEx(%d) failed: %d\n", cbTotal, GetLastError())); + return FALSE; + } + + PBYTE pbTarget = pbBase; + IMAGE_DOS_HEADER idh; + IMAGE_NT_HEADERS inh; + IMAGE_SECTION_HEADER ish; + DETOUR_SECTION_HEADER dsh; + DETOUR_SECTION_RECORD dsr; + SIZE_T cbWrote = 0; + + ZeroMemory(&idh, sizeof(idh)); + idh.e_magic = IMAGE_DOS_SIGNATURE; + idh.e_lfanew = sizeof(idh); + if (!WriteProcessMemory(hProcess, pbTarget, &idh, sizeof(idh), &cbWrote) || + cbWrote != sizeof(idh)) { + DETOUR_TRACE(("WriteProcessMemory(idh) failed: %d\n", GetLastError())); + return FALSE; + } + pbTarget += sizeof(idh); + + ZeroMemory(&inh, sizeof(inh)); + inh.Signature = IMAGE_NT_SIGNATURE; + inh.FileHeader.SizeOfOptionalHeader = sizeof(inh.OptionalHeader); + inh.FileHeader.Characteristics = IMAGE_FILE_DLL; + inh.FileHeader.NumberOfSections = 1; + inh.OptionalHeader.Magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; + if (!WriteProcessMemory(hProcess, pbTarget, &inh, sizeof(inh), &cbWrote) || + cbWrote != sizeof(inh)) { + return FALSE; + } + pbTarget += sizeof(inh); + + ZeroMemory(&ish, sizeof(ish)); + memcpy(ish.Name, ".detour", sizeof(ish.Name)); + ish.VirtualAddress = (DWORD)((pbTarget + sizeof(ish)) - pbBase); + ish.SizeOfRawData = (sizeof(DETOUR_SECTION_HEADER) + + sizeof(DETOUR_SECTION_RECORD) + + cbData); + if (!WriteProcessMemory(hProcess, pbTarget, &ish, sizeof(ish), &cbWrote) || + cbWrote != sizeof(ish)) { + return FALSE; + } + pbTarget += sizeof(ish); + + ZeroMemory(&dsh, sizeof(dsh)); + dsh.cbHeaderSize = sizeof(dsh); + dsh.nSignature = DETOUR_SECTION_HEADER_SIGNATURE; + dsh.nDataOffset = sizeof(DETOUR_SECTION_HEADER); + dsh.cbDataSize = (sizeof(DETOUR_SECTION_HEADER) + + sizeof(DETOUR_SECTION_RECORD) + + cbData); + if (!WriteProcessMemory(hProcess, pbTarget, &dsh, sizeof(dsh), &cbWrote) || + cbWrote != sizeof(dsh)) { + return FALSE; + } + pbTarget += sizeof(dsh); + + ZeroMemory(&dsr, sizeof(dsr)); + dsr.cbBytes = cbData + sizeof(DETOUR_SECTION_RECORD); + dsr.nReserved = 0; + dsr.guid = rguid; + if (!WriteProcessMemory(hProcess, pbTarget, &dsr, sizeof(dsr), &cbWrote) || + cbWrote != sizeof(dsr)) { + return FALSE; + } + pbTarget += sizeof(dsr); + + if (!WriteProcessMemory(hProcess, pbTarget, pvData, cbData, &cbWrote) || + cbWrote != cbData) { + return FALSE; + } + pbTarget += cbData; + + DETOUR_TRACE(("Copied %d byte payload into target process at %p\n", + cbTotal, pbTarget - cbTotal)); + return TRUE; +} + +static BOOL s_fSearchedForHelper = FALSE; +static PDETOUR_EXE_HELPER s_pHelper = NULL; + +VOID CALLBACK DetourFinishHelperProcess(_In_ HWND, + _In_ HINSTANCE, + _In_ LPSTR, + _In_ INT) +{ + LPCSTR * rlpDlls = NULL; + DWORD Result = 9900; + DWORD cOffset = 0; + DWORD cSize = 0; + HANDLE hProcess = NULL; + + if (s_pHelper == NULL) { + DETOUR_TRACE(("DetourFinishHelperProcess called with s_pHelper = NULL.\n")); + Result = 9905; + goto Cleanup; + } + + hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, s_pHelper->pid); + if (hProcess == NULL) { + DETOUR_TRACE(("OpenProcess(pid=%d) failed: %d\n", + s_pHelper->pid, GetLastError())); + Result = 9901; + goto Cleanup; + } + + rlpDlls = new NOTHROW LPCSTR [s_pHelper->nDlls]; + cSize = s_pHelper->cb - sizeof(DETOUR_EXE_HELPER); + for (DWORD n = 0; n < s_pHelper->nDlls; n++) { + size_t cchDest = 0; + HRESULT hr = StringCchLengthA(&s_pHelper->rDlls[cOffset], cSize - cOffset, &cchDest); + if (!SUCCEEDED(hr)) { + Result = 9902; + goto Cleanup; + } + + rlpDlls[n] = &s_pHelper->rDlls[cOffset]; + cOffset += (DWORD)cchDest + 1; + } + + if (!DetourUpdateProcessWithDll(hProcess, rlpDlls, s_pHelper->nDlls)) { + DETOUR_TRACE(("DetourUpdateProcessWithDll(pid=%d) failed: %d\n", + s_pHelper->pid, GetLastError())); + Result = 9903; + goto Cleanup; + } + Result = 0; + + Cleanup: + if (rlpDlls != NULL) { + delete[] rlpDlls; + rlpDlls = NULL; + } + + ExitProcess(Result); +} + +BOOL WINAPI DetourIsHelperProcess(VOID) +{ + PVOID pvData; + DWORD cbData; + + if (s_fSearchedForHelper) { + return (s_pHelper != NULL); + } + + s_fSearchedForHelper = TRUE; + pvData = DetourFindPayloadEx(DETOUR_EXE_HELPER_GUID, &cbData); + + if (pvData == NULL || cbData < sizeof(DETOUR_EXE_HELPER)) { + return FALSE; + } + + s_pHelper = (PDETOUR_EXE_HELPER)pvData; + if (s_pHelper->cb < sizeof(*s_pHelper)) { + s_pHelper = NULL; + return FALSE; + } + + return TRUE; +} + +static +BOOL WINAPI AllocExeHelper(_Out_ PDETOUR_EXE_HELPER *pHelper, + _In_ DWORD dwTargetPid, + _In_ DWORD nDlls, + _In_reads_(nDlls) LPCSTR *rlpDlls) +{ + PDETOUR_EXE_HELPER Helper = NULL; + BOOL Result = FALSE; + _Field_range_(0, cSize - 4) DWORD cOffset = 0; + DWORD cSize = 4; + + if (pHelper == NULL) { + goto Cleanup; + } + *pHelper = NULL; + + if (nDlls < 1 || nDlls > 4096) { + SetLastError(ERROR_INVALID_PARAMETER); + goto Cleanup; + } + + for (DWORD n = 0; n < nDlls; n++) { + HRESULT hr; + size_t cchDest = 0; + + hr = StringCchLengthA(rlpDlls[n], 4096, &cchDest); + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + cSize += (DWORD)cchDest + 1; + } + + Helper = (PDETOUR_EXE_HELPER) new NOTHROW BYTE[sizeof(DETOUR_EXE_HELPER) + cSize]; + if (Helper == NULL) { + goto Cleanup; + } + + Helper->cb = sizeof(DETOUR_EXE_HELPER) + cSize; + Helper->pid = dwTargetPid; + Helper->nDlls = nDlls; + + for (DWORD n = 0; n < nDlls; n++) { + HRESULT hr; + size_t cchDest = 0; + + if (cOffset > 0x10000 || cSize > 0x10000 || cOffset + 2 >= cSize) { + goto Cleanup; + } + + if (cOffset + 2 >= cSize || cOffset + 65536 < cSize) { + goto Cleanup; + } + + _Analysis_assume_(cOffset + 1 < cSize); + _Analysis_assume_(cOffset < 0x10000); + _Analysis_assume_(cSize < 0x10000); + + PCHAR psz = &Helper->rDlls[cOffset]; + + hr = StringCchCopyA(psz, cSize - cOffset, rlpDlls[n]); + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + +// REVIEW 28020 The expression '1<=_Param_(2)& &_Param_(2)<=2147483647' is not true at this call. +// REVIEW 28313 Analysis will not proceed past this point because of annotation evaluation. The annotation expression *_Param_(3)<_Param_(2)&&*_Param_(3)<=stringLength$(_Param_(1)) cannot be true under any assumptions at this point in the program. +#pragma warning(suppress:28020 28313) + hr = StringCchLengthA(psz, cSize - cOffset, &cchDest); + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + // Replace "32." with "64." or "64." with "32." + + for (DWORD c = (DWORD)cchDest + 1; c > 3; c--) { +#if DETOURS_32BIT + if (psz[c - 3] == '3' && psz[c - 2] == '2' && psz[c - 1] == '.') { + psz[c - 3] = '6'; psz[c - 2] = '4'; + break; + } +#else + if (psz[c - 3] == '6' && psz[c - 2] == '4' && psz[c - 1] == '.') { + psz[c - 3] = '3'; psz[c - 2] = '2'; + break; + } +#endif + } + + cOffset += (DWORD)cchDest + 1; + } + + *pHelper = Helper; + Helper = NULL; + Result = TRUE; + + Cleanup: + if (Helper != NULL) { + delete[] (PBYTE)Helper; + Helper = NULL; + } + return Result; +} + +static +VOID WINAPI FreeExeHelper(PDETOUR_EXE_HELPER *pHelper) +{ + if (*pHelper != NULL) { + delete[] (PBYTE)*pHelper; + *pHelper = NULL; + } +} + +BOOL WINAPI DetourProcessViaHelperA(_In_ DWORD dwTargetPid, + _In_ LPCSTR lpDllName, + _In_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA) +{ + return DetourProcessViaHelperDllsA(dwTargetPid, 1, &lpDllName, pfCreateProcessA); +} + + +BOOL WINAPI DetourProcessViaHelperDllsA(_In_ DWORD dwTargetPid, + _In_ DWORD nDlls, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA) +{ + BOOL Result = FALSE; + PROCESS_INFORMATION pi; + STARTUPINFOA si; + CHAR szExe[MAX_PATH]; + CHAR szCommand[MAX_PATH]; + PDETOUR_EXE_HELPER helper = NULL; + HRESULT hr; + DWORD nLen = GetEnvironmentVariableA("WINDIR", szExe, ARRAYSIZE(szExe)); + + DETOUR_TRACE(("DetourProcessViaHelperDlls(pid=%d,dlls=%d)\n", dwTargetPid, nDlls)); + if (nDlls < 1 || nDlls > 4096) { + SetLastError(ERROR_INVALID_PARAMETER); + goto Cleanup; + } + if (!AllocExeHelper(&helper, dwTargetPid, nDlls, rlpDlls)) { + goto Cleanup; + } + + if (nLen == 0 || nLen >= ARRAYSIZE(szExe)) { + goto Cleanup; + } + +#if DETOURS_OPTION_BITS +#if DETOURS_32BIT + hr = StringCchCatA(szExe, ARRAYSIZE(szExe), "\\sysnative\\rundll32.exe"); +#else // !DETOURS_32BIT + hr = StringCchCatA(szExe, ARRAYSIZE(szExe), "\\syswow64\\rundll32.exe"); +#endif // !DETOURS_32BIT +#else // DETOURS_OPTIONS_BITS + hr = StringCchCatA(szExe, ARRAYSIZE(szExe), "\\system32\\rundll32.exe"); +#endif // DETOURS_OPTIONS_BITS + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + hr = StringCchPrintfA(szCommand, ARRAYSIZE(szCommand), + "rundll32.exe \"%hs\",#1", &helper->rDlls[0]); + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + ZeroMemory(&pi, sizeof(pi)); + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + + DETOUR_TRACE(("DetourProcessViaHelperDlls(\"%hs\", \"%hs\")\n", szExe, szCommand)); + if (pfCreateProcessA(szExe, szCommand, NULL, NULL, FALSE, CREATE_SUSPENDED, + NULL, NULL, &si, &pi)) { + + if (!DetourCopyPayloadToProcess(pi.hProcess, + DETOUR_EXE_HELPER_GUID, + helper, helper->cb)) { + DETOUR_TRACE(("DetourCopyPayloadToProcess failed: %d\n", GetLastError())); + TerminateProcess(pi.hProcess, ~0u); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + goto Cleanup; + } + + ResumeThread(pi.hThread); + WaitForSingleObject(pi.hProcess, INFINITE); + + DWORD dwResult = 500; + GetExitCodeProcess(pi.hProcess, &dwResult); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + if (dwResult != 0) { + DETOUR_TRACE(("Rundll32.exe failed: result=%d\n", dwResult)); + goto Cleanup; + } + Result = TRUE; + } + else { + DETOUR_TRACE(("CreateProcess failed: %d\n", GetLastError())); + goto Cleanup; + } + + Cleanup: + FreeExeHelper(&helper); + return Result; +} + +BOOL WINAPI DetourProcessViaHelperW(_In_ DWORD dwTargetPid, + _In_ LPCSTR lpDllName, + _In_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW) +{ + return DetourProcessViaHelperDllsW(dwTargetPid, 1, &lpDllName, pfCreateProcessW); +} + +BOOL WINAPI DetourProcessViaHelperDllsW(_In_ DWORD dwTargetPid, + _In_ DWORD nDlls, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW) +{ + BOOL Result = FALSE; + PROCESS_INFORMATION pi; + STARTUPINFOW si; + WCHAR szExe[MAX_PATH]; + WCHAR szCommand[MAX_PATH]; + PDETOUR_EXE_HELPER helper = NULL; + HRESULT hr; + DWORD nLen = GetEnvironmentVariableW(L"WINDIR", szExe, ARRAYSIZE(szExe)); + + DETOUR_TRACE(("DetourProcessViaHelperDlls(pid=%d,dlls=%d)\n", dwTargetPid, nDlls)); + if (nDlls < 1 || nDlls > 4096) { + SetLastError(ERROR_INVALID_PARAMETER); + goto Cleanup; + } + if (!AllocExeHelper(&helper, dwTargetPid, nDlls, rlpDlls)) { + goto Cleanup; + } + + if (nLen == 0 || nLen >= ARRAYSIZE(szExe)) { + goto Cleanup; + } + +#if DETOURS_OPTION_BITS +#if DETOURS_32BIT + hr = StringCchCatW(szExe, ARRAYSIZE(szExe), L"\\sysnative\\rundll32.exe"); +#else // !DETOURS_32BIT + hr = StringCchCatW(szExe, ARRAYSIZE(szExe), L"\\syswow64\\rundll32.exe"); +#endif // !DETOURS_32BIT +#else // DETOURS_OPTIONS_BITS + hr = StringCchCatW(szExe, ARRAYSIZE(szExe), L"\\system32\\rundll32.exe"); +#endif // DETOURS_OPTIONS_BITS + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + hr = StringCchPrintfW(szCommand, ARRAYSIZE(szCommand), + L"rundll32.exe \"%hs\",#1", &helper->rDlls[0]); + if (!SUCCEEDED(hr)) { + goto Cleanup; + } + + ZeroMemory(&pi, sizeof(pi)); + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + + DETOUR_TRACE(("DetourProcessViaHelperDlls(\"%ls\", \"%ls\")\n", szExe, szCommand)); + if (pfCreateProcessW(szExe, szCommand, NULL, NULL, FALSE, CREATE_SUSPENDED, + NULL, NULL, &si, &pi)) { + + if (!DetourCopyPayloadToProcess(pi.hProcess, + DETOUR_EXE_HELPER_GUID, + helper, helper->cb)) { + DETOUR_TRACE(("DetourCopyPayloadToProcess failed: %d\n", GetLastError())); + TerminateProcess(pi.hProcess, ~0u); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + goto Cleanup; + } + + ResumeThread(pi.hThread); + + ResumeThread(pi.hThread); + WaitForSingleObject(pi.hProcess, INFINITE); + + DWORD dwResult = 500; + GetExitCodeProcess(pi.hProcess, &dwResult); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + if (dwResult != 0) { + DETOUR_TRACE(("Rundll32.exe failed: result=%d\n", dwResult)); + goto Cleanup; + } + Result = TRUE; + } + else { + DETOUR_TRACE(("CreateProcess failed: %d\n", GetLastError())); + goto Cleanup; + } + + Cleanup: + FreeExeHelper(&helper); + return Result; +} + +BOOL WINAPI DetourCreateProcessWithDllExA(_In_opt_ LPCSTR lpApplicationName, + _Inout_opt_ LPSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOA lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ LPCSTR lpDllName, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA) +{ + if (pfCreateProcessA == NULL) { + pfCreateProcessA = CreateProcessA; + } + + PROCESS_INFORMATION backup; + if (lpProcessInformation == NULL) { + lpProcessInformation = &backup; + ZeroMemory(&backup, sizeof(backup)); + } + + if (!pfCreateProcessA(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwCreationFlags | CREATE_SUSPENDED, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + lpProcessInformation)) { + return FALSE; + } + + LPCSTR szDll = lpDllName; + + if (!DetourUpdateProcessWithDll(lpProcessInformation->hProcess, &szDll, 1) && + !DetourProcessViaHelperA(lpProcessInformation->dwProcessId, + lpDllName, + pfCreateProcessA)) { + + TerminateProcess(lpProcessInformation->hProcess, ~0u); + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(lpProcessInformation->hThread); + } + + if (lpProcessInformation == &backup) { + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + } + + return TRUE; +} + +BOOL WINAPI DetourCreateProcessWithDllExW(_In_opt_ LPCWSTR lpApplicationName, + _Inout_opt_ LPWSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCWSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOW lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ LPCSTR lpDllName, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW) +{ + if (pfCreateProcessW == NULL) { + pfCreateProcessW = CreateProcessW; + } + + PROCESS_INFORMATION backup; + if (lpProcessInformation == NULL) { + lpProcessInformation = &backup; + ZeroMemory(&backup, sizeof(backup)); + } + + if (!pfCreateProcessW(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwCreationFlags | CREATE_SUSPENDED, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + lpProcessInformation)) { + return FALSE; + } + + + LPCSTR sz = lpDllName; + + if (!DetourUpdateProcessWithDll(lpProcessInformation->hProcess, &sz, 1) && + !DetourProcessViaHelperW(lpProcessInformation->dwProcessId, + lpDllName, + pfCreateProcessW)) { + + TerminateProcess(lpProcessInformation->hProcess, ~0u); + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(lpProcessInformation->hThread); + } + + if (lpProcessInformation == &backup) { + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + } + return TRUE; +} + +BOOL WINAPI DetourCreateProcessWithDllsA(_In_opt_ LPCSTR lpApplicationName, + _Inout_opt_ LPSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOA lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ DWORD nDlls, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEA pfCreateProcessA) +{ + if (pfCreateProcessA == NULL) { + pfCreateProcessA = CreateProcessA; + } + + PROCESS_INFORMATION backup; + if (lpProcessInformation == NULL) { + lpProcessInformation = &backup; + ZeroMemory(&backup, sizeof(backup)); + } + + if (!pfCreateProcessA(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwCreationFlags | CREATE_SUSPENDED, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + lpProcessInformation)) { + return FALSE; + } + + if (!DetourUpdateProcessWithDll(lpProcessInformation->hProcess, rlpDlls, nDlls) && + !DetourProcessViaHelperDllsA(lpProcessInformation->dwProcessId, + nDlls, + rlpDlls, + pfCreateProcessA)) { + + TerminateProcess(lpProcessInformation->hProcess, ~0u); + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(lpProcessInformation->hThread); + } + + if (lpProcessInformation == &backup) { + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + } + + return TRUE; +} + +BOOL WINAPI DetourCreateProcessWithDllsW(_In_opt_ LPCWSTR lpApplicationName, + _Inout_opt_ LPWSTR lpCommandLine, + _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, + _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, + _In_ BOOL bInheritHandles, + _In_ DWORD dwCreationFlags, + _In_opt_ LPVOID lpEnvironment, + _In_opt_ LPCWSTR lpCurrentDirectory, + _In_ LPSTARTUPINFOW lpStartupInfo, + _Out_ LPPROCESS_INFORMATION lpProcessInformation, + _In_ DWORD nDlls, + _In_reads_(nDlls) LPCSTR *rlpDlls, + _In_opt_ PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW) +{ + if (pfCreateProcessW == NULL) { + pfCreateProcessW = CreateProcessW; + } + + PROCESS_INFORMATION backup; + if (lpProcessInformation == NULL) { + lpProcessInformation = &backup; + ZeroMemory(&backup, sizeof(backup)); + } + + if (!pfCreateProcessW(lpApplicationName, + lpCommandLine, + lpProcessAttributes, + lpThreadAttributes, + bInheritHandles, + dwCreationFlags | CREATE_SUSPENDED, + lpEnvironment, + lpCurrentDirectory, + lpStartupInfo, + lpProcessInformation)) { + return FALSE; + } + + + if (!DetourUpdateProcessWithDll(lpProcessInformation->hProcess, rlpDlls, nDlls) && + !DetourProcessViaHelperDllsW(lpProcessInformation->dwProcessId, + nDlls, + rlpDlls, + pfCreateProcessW)) { + + TerminateProcess(lpProcessInformation->hProcess, ~0u); + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + return FALSE; + } + + if (!(dwCreationFlags & CREATE_SUSPENDED)) { + ResumeThread(lpProcessInformation->hThread); + } + + if (lpProcessInformation == &backup) { + CloseHandle(lpProcessInformation->hProcess); + CloseHandle(lpProcessInformation->hThread); + } + return TRUE; +} + +// +///////////////////////////////////////////////////////////////// End of File. diff --git a/NWNXLib/External/detours/src/detours.cpp b/NWNXLib/External/detours/src/detours.cpp new file mode 100644 index 00000000000..e126cf0ec7a --- /dev/null +++ b/NWNXLib/External/detours/src/detours.cpp @@ -0,0 +1,2471 @@ +////////////////////////////////////////////////////////////////////////////// +// +// Core Detours Functionality (detours.cpp of detours.lib) +// +// Microsoft Research Detours Package, Version 4.0.1 +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// + + +//#define DETOUR_DEBUG 1 +#define DETOURS_INTERNAL +#include "detours.h" + +#if DETOURS_VERSION != 0x4c0c1 // 0xMAJORcMINORcPATCH +#error detours.h version mismatch +#endif + +#define NOTHROW + +////////////////////////////////////////////////////////////////////////////// +// +struct _DETOUR_ALIGN +{ + BYTE obTarget : 3; + BYTE obTrampoline : 5; +}; + +C_ASSERT(sizeof(_DETOUR_ALIGN) == 1); + +////////////////////////////////////////////////////////////////////////////// +// +// Region reserved for system DLLs, which cannot be used for trampolines. +// +static PVOID s_pSystemRegionLowerBound = (PVOID)(ULONG_PTR)0x70000000; +static PVOID s_pSystemRegionUpperBound = (PVOID)(ULONG_PTR)0x80000000; + +////////////////////////////////////////////////////////////////////////////// +// +static bool detour_is_imported(PBYTE pbCode, PBYTE pbAddress) +{ + MEMORY_BASIC_INFORMATION mbi; + VirtualQuery((PVOID)pbCode, &mbi, sizeof(mbi)); + __try { + PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER)mbi.AllocationBase; + if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE) { + return false; + } + + PIMAGE_NT_HEADERS pNtHeader = (PIMAGE_NT_HEADERS)((PBYTE)pDosHeader + + pDosHeader->e_lfanew); + if (pNtHeader->Signature != IMAGE_NT_SIGNATURE) { + return false; + } + + if (pbAddress >= ((PBYTE)pDosHeader + + pNtHeader->OptionalHeader + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress) && + pbAddress < ((PBYTE)pDosHeader + + pNtHeader->OptionalHeader + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].VirtualAddress + + pNtHeader->OptionalHeader + .DataDirectory[IMAGE_DIRECTORY_ENTRY_IAT].Size)) { + return true; + } + } +#pragma prefast(suppress:28940, "A bad pointer means this probably isn't a PE header.") + __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ? + EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { + return false; + } + return false; +} + +inline ULONG_PTR detour_2gb_below(ULONG_PTR address) +{ + return (address > (ULONG_PTR)0x7ff80000) ? address - 0x7ff80000 : 0x80000; +} + +inline ULONG_PTR detour_2gb_above(ULONG_PTR address) +{ +#if defined(DETOURS_64BIT) + return (address < (ULONG_PTR)0xffffffff80000000) ? address + 0x7ff80000 : (ULONG_PTR)0xfffffffffff80000; +#else + return (address < (ULONG_PTR)0x80000000) ? address + 0x7ff80000 : (ULONG_PTR)0xfff80000; +#endif +} + +///////////////////////////////////////////////////////////////////////// X86. +// +#ifdef DETOURS_X86 + +struct _DETOUR_TRAMPOLINE +{ + BYTE rbCode[30]; // target code + jmp to pbRemain + BYTE cbCode; // size of moved target code. + BYTE cbCodeBreak; // padding to make debugging easier. + BYTE rbRestore[22]; // original target code. + BYTE cbRestore; // size of original target code. + BYTE cbRestoreBreak; // padding to make debugging easier. + _DETOUR_ALIGN rAlign[8]; // instruction alignment array. + PBYTE pbRemain; // first instruction after moved code. [free list] + PBYTE pbDetour; // first instruction of detour function. +}; + +C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 72); + +enum { + SIZE_OF_JMP = 5 +}; + +inline PBYTE detour_gen_jmp_immediate(PBYTE pbCode, PBYTE pbJmpVal) +{ + PBYTE pbJmpSrc = pbCode + 5; + *pbCode++ = 0xE9; // jmp +imm32 + *((INT32*&)pbCode)++ = (INT32)(pbJmpVal - pbJmpSrc); + return pbCode; +} + +inline PBYTE detour_gen_jmp_indirect(PBYTE pbCode, PBYTE *ppbJmpVal) +{ + *pbCode++ = 0xff; // jmp [+imm32] + *pbCode++ = 0x25; + *((INT32*&)pbCode)++ = (INT32)((PBYTE)ppbJmpVal); + return pbCode; +} + +inline PBYTE detour_gen_brk(PBYTE pbCode, PBYTE pbLimit) +{ + while (pbCode < pbLimit) { + *pbCode++ = 0xcc; // brk; + } + return pbCode; +} + +inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals) +{ + if (pbCode == NULL) { + return NULL; + } + if (ppGlobals != NULL) { + *ppGlobals = NULL; + } + + // First, skip over the import vector if there is one. + if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [imm32] + // Looks like an import alias jump, then get the code it points to. + PBYTE pbTarget = *(UNALIGNED PBYTE *)&pbCode[2]; + if (detour_is_imported(pbCode, pbTarget)) { + PBYTE pbNew = *(UNALIGNED PBYTE *)pbTarget; + DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + + // Then, skip over a patch jump + if (pbCode[0] == 0xeb) { // jmp +imm8 + PBYTE pbNew = pbCode + 2 + *(CHAR *)&pbCode[1]; + DETOUR_TRACE(("%p->%p: skipped over short jump.\n", pbCode, pbNew)); + pbCode = pbNew; + + // First, skip over the import vector if there is one. + if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [imm32] + // Looks like an import alias jump, then get the code it points to. + PBYTE pbTarget = *(UNALIGNED PBYTE *)&pbCode[2]; + if (detour_is_imported(pbCode, pbTarget)) { + pbNew = *(UNALIGNED PBYTE *)pbTarget; + DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + // Finally, skip over a long jump if it is the target of the patch jump. + else if (pbCode[0] == 0xe9) { // jmp +imm32 + pbNew = pbCode + 5 + *(UNALIGNED INT32 *)&pbCode[1]; + DETOUR_TRACE(("%p->%p: skipped over long jump.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + return pbCode; +} + +inline void detour_find_jmp_bounds(PBYTE pbCode, + PDETOUR_TRAMPOLINE *ppLower, + PDETOUR_TRAMPOLINE *ppUpper) +{ + // We have to place trampolines within +/- 2GB of code. + ULONG_PTR lo = detour_2gb_below((ULONG_PTR)pbCode); + ULONG_PTR hi = detour_2gb_above((ULONG_PTR)pbCode); + DETOUR_TRACE(("[%p..%p..%p]\n", lo, pbCode, hi)); + + // And, within +/- 2GB of relative jmp targets. + if (pbCode[0] == 0xe9) { // jmp +imm32 + PBYTE pbNew = pbCode + 5 + *(UNALIGNED INT32 *)&pbCode[1]; + + if (pbNew < pbCode) { + hi = detour_2gb_above((ULONG_PTR)pbNew); + } + else { + lo = detour_2gb_below((ULONG_PTR)pbNew); + } + DETOUR_TRACE(("[%p..%p..%p] +imm32\n", lo, pbCode, hi)); + } + + *ppLower = (PDETOUR_TRAMPOLINE)lo; + *ppUpper = (PDETOUR_TRAMPOLINE)hi; +} + +inline BOOL detour_does_code_end_function(PBYTE pbCode) +{ + if (pbCode[0] == 0xeb || // jmp +imm8 + pbCode[0] == 0xe9 || // jmp +imm32 + pbCode[0] == 0xe0 || // jmp eax + pbCode[0] == 0xc2 || // ret +imm8 + pbCode[0] == 0xc3 || // ret + pbCode[0] == 0xcc) { // brk + return TRUE; + } + else if (pbCode[0] == 0xf3 && pbCode[1] == 0xc3) { // rep ret + return TRUE; + } + else if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] + return TRUE; + } + else if ((pbCode[0] == 0x26 || // jmp es: + pbCode[0] == 0x2e || // jmp cs: + pbCode[0] == 0x36 || // jmp ss: + pbCode[0] == 0x3e || // jmp ds: + pbCode[0] == 0x64 || // jmp fs: + pbCode[0] == 0x65) && // jmp gs: + pbCode[1] == 0xff && // jmp [+imm32] + pbCode[2] == 0x25) { + return TRUE; + } + return FALSE; +} + +inline ULONG detour_is_code_filler(PBYTE pbCode) +{ + // 1-byte through 11-byte NOPs. + if (pbCode[0] == 0x90) { + return 1; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x90) { + return 2; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x00) { + return 3; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x40 && + pbCode[3] == 0x00) { + return 4; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x44 && + pbCode[3] == 0x00 && pbCode[4] == 0x00) { + return 5; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x0F && pbCode[2] == 0x1F && + pbCode[3] == 0x44 && pbCode[4] == 0x00 && pbCode[5] == 0x00) { + return 6; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x80 && + pbCode[3] == 0x00 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00) { + return 7; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x84 && + pbCode[3] == 0x00 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00) { + return 8; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x0F && pbCode[2] == 0x1F && + pbCode[3] == 0x84 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00) { + return 9; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x66 && pbCode[2] == 0x0F && + pbCode[3] == 0x1F && pbCode[4] == 0x84 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00 && + pbCode[9] == 0x00) { + return 10; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x66 && pbCode[2] == 0x66 && + pbCode[3] == 0x0F && pbCode[4] == 0x1F && pbCode[5] == 0x84 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00 && + pbCode[9] == 0x00 && pbCode[10] == 0x00) { + return 11; + } + + // int 3. + if (pbCode[0] == 0xcc) { + return 1; + } + return 0; +} + +#endif // DETOURS_X86 + +///////////////////////////////////////////////////////////////////////// X64. +// +#ifdef DETOURS_X64 + +struct _DETOUR_TRAMPOLINE +{ + // An X64 instuction can be 15 bytes long. + // In practice 11 seems to be the limit. + BYTE rbCode[30]; // target code + jmp to pbRemain. + BYTE cbCode; // size of moved target code. + BYTE cbCodeBreak; // padding to make debugging easier. + BYTE rbRestore[30]; // original target code. + BYTE cbRestore; // size of original target code. + BYTE cbRestoreBreak; // padding to make debugging easier. + _DETOUR_ALIGN rAlign[8]; // instruction alignment array. + PBYTE pbRemain; // first instruction after moved code. [free list] + PBYTE pbDetour; // first instruction of detour function. + BYTE rbCodeIn[8]; // jmp [pbDetour] +}; + +C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 96); + +enum { + SIZE_OF_JMP = 5 +}; + +inline PBYTE detour_gen_jmp_immediate(PBYTE pbCode, PBYTE pbJmpVal) +{ + PBYTE pbJmpSrc = pbCode + 5; + *pbCode++ = 0xE9; // jmp +imm32 + *((INT32*&)pbCode)++ = (INT32)(pbJmpVal - pbJmpSrc); + return pbCode; +} + +inline PBYTE detour_gen_jmp_indirect(PBYTE pbCode, PBYTE *ppbJmpVal) +{ + PBYTE pbJmpSrc = pbCode + 6; + *pbCode++ = 0xff; // jmp [+imm32] + *pbCode++ = 0x25; + *((INT32*&)pbCode)++ = (INT32)((PBYTE)ppbJmpVal - pbJmpSrc); + return pbCode; +} + +inline PBYTE detour_gen_brk(PBYTE pbCode, PBYTE pbLimit) +{ + while (pbCode < pbLimit) { + *pbCode++ = 0xcc; // brk; + } + return pbCode; +} + +inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals) +{ + if (pbCode == NULL) { + return NULL; + } + if (ppGlobals != NULL) { + *ppGlobals = NULL; + } + + // First, skip over the import vector if there is one. + if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] + // Looks like an import alias jump, then get the code it points to. + PBYTE pbTarget = pbCode + 6 + *(UNALIGNED INT32 *)&pbCode[2]; + if (detour_is_imported(pbCode, pbTarget)) { + PBYTE pbNew = *(UNALIGNED PBYTE *)pbTarget; + DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + + // Then, skip over a patch jump + if (pbCode[0] == 0xeb) { // jmp +imm8 + PBYTE pbNew = pbCode + 2 + *(CHAR *)&pbCode[1]; + DETOUR_TRACE(("%p->%p: skipped over short jump.\n", pbCode, pbNew)); + pbCode = pbNew; + + // First, skip over the import vector if there is one. + if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] + // Looks like an import alias jump, then get the code it points to. + PBYTE pbTarget = pbCode + 6 + *(UNALIGNED INT32 *)&pbCode[2]; + if (detour_is_imported(pbCode, pbTarget)) { + pbNew = *(UNALIGNED PBYTE *)pbTarget; + DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + // Finally, skip over a long jump if it is the target of the patch jump. + else if (pbCode[0] == 0xe9) { // jmp +imm32 + pbNew = pbCode + 5 + *(UNALIGNED INT32 *)&pbCode[1]; + DETOUR_TRACE(("%p->%p: skipped over long jump.\n", pbCode, pbNew)); + pbCode = pbNew; + } + } + return pbCode; +} + +inline void detour_find_jmp_bounds(PBYTE pbCode, + PDETOUR_TRAMPOLINE *ppLower, + PDETOUR_TRAMPOLINE *ppUpper) +{ + // We have to place trampolines within +/- 2GB of code. + ULONG_PTR lo = detour_2gb_below((ULONG_PTR)pbCode); + ULONG_PTR hi = detour_2gb_above((ULONG_PTR)pbCode); + DETOUR_TRACE(("[%p..%p..%p]\n", lo, pbCode, hi)); + + // And, within +/- 2GB of relative jmp vectors. + if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] + PBYTE pbNew = pbCode + 6 + *(UNALIGNED INT32 *)&pbCode[2]; + + if (pbNew < pbCode) { + hi = detour_2gb_above((ULONG_PTR)pbNew); + } + else { + lo = detour_2gb_below((ULONG_PTR)pbNew); + } + DETOUR_TRACE(("[%p..%p..%p] [+imm32]\n", lo, pbCode, hi)); + } + // And, within +/- 2GB of relative jmp targets. + else if (pbCode[0] == 0xe9) { // jmp +imm32 + PBYTE pbNew = pbCode + 5 + *(UNALIGNED INT32 *)&pbCode[1]; + + if (pbNew < pbCode) { + hi = detour_2gb_above((ULONG_PTR)pbNew); + } + else { + lo = detour_2gb_below((ULONG_PTR)pbNew); + } + DETOUR_TRACE(("[%p..%p..%p] +imm32\n", lo, pbCode, hi)); + } + + *ppLower = (PDETOUR_TRAMPOLINE)lo; + *ppUpper = (PDETOUR_TRAMPOLINE)hi; +} + +inline BOOL detour_does_code_end_function(PBYTE pbCode) +{ + if (pbCode[0] == 0xeb || // jmp +imm8 + pbCode[0] == 0xe9 || // jmp +imm32 + pbCode[0] == 0xe0 || // jmp eax + pbCode[0] == 0xc2 || // ret +imm8 + pbCode[0] == 0xc3 || // ret + pbCode[0] == 0xcc) { // brk + return TRUE; + } + else if (pbCode[0] == 0xf3 && pbCode[1] == 0xc3) { // rep ret + return TRUE; + } + else if (pbCode[0] == 0xff && pbCode[1] == 0x25) { // jmp [+imm32] + return TRUE; + } + else if ((pbCode[0] == 0x26 || // jmp es: + pbCode[0] == 0x2e || // jmp cs: + pbCode[0] == 0x36 || // jmp ss: + pbCode[0] == 0x3e || // jmp ds: + pbCode[0] == 0x64 || // jmp fs: + pbCode[0] == 0x65) && // jmp gs: + pbCode[1] == 0xff && // jmp [+imm32] + pbCode[2] == 0x25) { + return TRUE; + } + return FALSE; +} + +inline ULONG detour_is_code_filler(PBYTE pbCode) +{ + // 1-byte through 11-byte NOPs. + if (pbCode[0] == 0x90) { + return 1; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x90) { + return 2; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x00) { + return 3; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x40 && + pbCode[3] == 0x00) { + return 4; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x44 && + pbCode[3] == 0x00 && pbCode[4] == 0x00) { + return 5; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x0F && pbCode[2] == 0x1F && + pbCode[3] == 0x44 && pbCode[4] == 0x00 && pbCode[5] == 0x00) { + return 6; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x80 && + pbCode[3] == 0x00 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00) { + return 7; + } + if (pbCode[0] == 0x0F && pbCode[1] == 0x1F && pbCode[2] == 0x84 && + pbCode[3] == 0x00 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00) { + return 8; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x0F && pbCode[2] == 0x1F && + pbCode[3] == 0x84 && pbCode[4] == 0x00 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00) { + return 9; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x66 && pbCode[2] == 0x0F && + pbCode[3] == 0x1F && pbCode[4] == 0x84 && pbCode[5] == 0x00 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00 && + pbCode[9] == 0x00) { + return 10; + } + if (pbCode[0] == 0x66 && pbCode[1] == 0x66 && pbCode[2] == 0x66 && + pbCode[3] == 0x0F && pbCode[4] == 0x1F && pbCode[5] == 0x84 && + pbCode[6] == 0x00 && pbCode[7] == 0x00 && pbCode[8] == 0x00 && + pbCode[9] == 0x00 && pbCode[10] == 0x00) { + return 11; + } + + // int 3. + if (pbCode[0] == 0xcc) { + return 1; + } + return 0; +} + +#endif // DETOURS_X64 + +//////////////////////////////////////////////////////////////////////// IA64. +// +#ifdef DETOURS_IA64 + +struct _DETOUR_TRAMPOLINE +{ + // On the IA64, a trampoline is used for both incoming and outgoing calls. + // + // The trampoline contains the following bundles for the outgoing call: + // movl gp=target_gp; + // + // brl target_code; + // + // The trampoline contains the following bundles for the incoming call: + // alloc r41=ar.pfs, b, 0, 8, 0 + // mov r40=rp + // + // adds r50=0, r39 + // adds r49=0, r38 + // adds r48=0, r37 ;; + // + // adds r47=0, r36 + // adds r46=0, r35 + // adds r45=0, r34 + // + // adds r44=0, r33 + // adds r43=0, r32 + // adds r42=0, gp ;; + // + // movl gp=ffffffff`ffffffff ;; + // + // brl.call.sptk.few rp=disas!TestCodes+20e0 (00000000`00404ea0) ;; + // + // adds gp=0, r42 + // mov rp=r40, +0 ;; + // mov.i ar.pfs=r41 + // + // br.ret.sptk.many rp ;; + // + // This way, we only have to relocate a single bundle. + // + // The complicated incoming trampoline is required because we have to + // create an additional stack frame so that we save and restore the gp. + // We must do this because gp is a caller-saved register, but not saved + // if the caller thinks the target is in the same DLL, which changes + // when we insert a detour. + // + DETOUR_IA64_BUNDLE bMovlTargetGp; // Bundle which sets target GP + BYTE rbCode[sizeof(DETOUR_IA64_BUNDLE)]; // moved bundle. + DETOUR_IA64_BUNDLE bBrlRemainEip; // Brl to pbRemain + // This must be adjacent to bBranchIslands. + + // Each instruction in the moved bundle could be a IP-relative chk or branch or call. + // Any such instructions are changed to point to a brl in bBranchIslands. + // This must be adjacent to bBrlRemainEip -- see "pbPool". + DETOUR_IA64_BUNDLE bBranchIslands[DETOUR_IA64_INSTRUCTIONS_PER_BUNDLE]; + + // Target of brl inserted in target function + DETOUR_IA64_BUNDLE bAllocFrame; // alloc frame + DETOUR_IA64_BUNDLE bSave37to39; // save r37, r38, r39. + DETOUR_IA64_BUNDLE bSave34to36; // save r34, r35, r36. + DETOUR_IA64_BUNDLE bSaveGPto33; // save gp, r32, r33. + DETOUR_IA64_BUNDLE bMovlDetourGp; // set detour GP. + DETOUR_IA64_BUNDLE bCallDetour; // call detour. + DETOUR_IA64_BUNDLE bPopFrameGp; // pop frame and restore gp. + DETOUR_IA64_BUNDLE bReturn; // return to caller. + + PLABEL_DESCRIPTOR pldTrampoline; + + BYTE rbRestore[sizeof(DETOUR_IA64_BUNDLE)]; // original target bundle. + BYTE cbRestore; // size of original target code. + BYTE cbCode; // size of moved target code. + _DETOUR_ALIGN rAlign[14]; // instruction alignment array. + PBYTE pbRemain; // first instruction after moved code. [free list] + PBYTE pbDetour; // first instruction of detour function. + PPLABEL_DESCRIPTOR ppldDetour; // [pbDetour,gpDetour] + PPLABEL_DESCRIPTOR ppldTarget; // [pbTarget,gpDetour] +}; + +C_ASSERT(sizeof(DETOUR_IA64_BUNDLE) == 16); +C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 256 + DETOUR_IA64_INSTRUCTIONS_PER_BUNDLE * 16); + +enum { + SIZE_OF_JMP = sizeof(DETOUR_IA64_BUNDLE) +}; + +inline PBYTE detour_skip_jmp(PBYTE pPointer, PVOID *ppGlobals) +{ + PBYTE pGlobals = NULL; + PBYTE pbCode = NULL; + + if (pPointer != NULL) { + PPLABEL_DESCRIPTOR ppld = (PPLABEL_DESCRIPTOR)pPointer; + pbCode = (PBYTE)ppld->EntryPoint; + pGlobals = (PBYTE)ppld->GlobalPointer; + } + if (ppGlobals != NULL) { + *ppGlobals = pGlobals; + } + if (pbCode == NULL) { + return NULL; + } + + DETOUR_IA64_BUNDLE *pb = (DETOUR_IA64_BUNDLE *)pbCode; + + // IA64 Local Import Jumps look like: + // addl r2=ffffffff`ffe021c0, gp ;; + // ld8 r2=[r2] + // nop.i 0 ;; + // + // ld8 r3=[r2], 8 ;; + // ld8 gp=[r2] + // mov b6=r3, +0 + // + // nop.m 0 + // nop.i 0 + // br.cond.sptk.few b6 + // + + // 002024000200100b + if ((pb[0].wide[0] & 0xfffffc000603ffff) == 0x002024000200100b && + pb[0].wide[1] == 0x0004000000203008 && + pb[1].wide[0] == 0x001014180420180a && + pb[1].wide[1] == 0x07000830c0203008 && + pb[2].wide[0] == 0x0000000100000010 && + pb[2].wide[1] == 0x0080006000000200) { + + ULONG64 offset = + ((pb[0].wide[0] & 0x0000000001fc0000) >> 18) | // imm7b + ((pb[0].wide[0] & 0x000001ff00000000) >> 25) | // imm9d + ((pb[0].wide[0] & 0x00000000f8000000) >> 11); // imm5c + if (pb[0].wide[0] & 0x0000020000000000) { // sign + offset |= 0xffffffffffe00000; + } + PBYTE pbTarget = pGlobals + offset; + DETOUR_TRACE(("%p: potential import jump, target=%p\n", pb, pbTarget)); + + if (detour_is_imported(pbCode, pbTarget) && *(PBYTE*)pbTarget != NULL) { + DETOUR_TRACE(("%p: is import jump, label=%p\n", pb, *(PBYTE *)pbTarget)); + + PPLABEL_DESCRIPTOR ppld = (PPLABEL_DESCRIPTOR)*(PBYTE *)pbTarget; + pbCode = (PBYTE)ppld->EntryPoint; + pGlobals = (PBYTE)ppld->GlobalPointer; + if (ppGlobals != NULL) { + *ppGlobals = pGlobals; + } + } + } + return pbCode; +} + + +inline void detour_find_jmp_bounds(PBYTE pbCode, + PDETOUR_TRAMPOLINE *ppLower, + PDETOUR_TRAMPOLINE *ppUpper) +{ + (void)pbCode; + *ppLower = (PDETOUR_TRAMPOLINE)(ULONG_PTR)0x0000000000080000; + *ppUpper = (PDETOUR_TRAMPOLINE)(ULONG_PTR)0xfffffffffff80000; +} + +inline BOOL detour_does_code_end_function(PBYTE pbCode) +{ + // Routine not needed on IA64. + (void)pbCode; + return FALSE; +} + +inline ULONG detour_is_code_filler(PBYTE pbCode) +{ + // Routine not needed on IA64. + (void)pbCode; + return 0; +} + +#endif // DETOURS_IA64 + +#ifdef DETOURS_ARM + +struct _DETOUR_TRAMPOLINE +{ + // A Thumb-2 instruction can be 2 or 4 bytes long. + BYTE rbCode[62]; // target code + jmp to pbRemain + BYTE cbCode; // size of moved target code. + BYTE cbCodeBreak; // padding to make debugging easier. + BYTE rbRestore[22]; // original target code. + BYTE cbRestore; // size of original target code. + BYTE cbRestoreBreak; // padding to make debugging easier. + _DETOUR_ALIGN rAlign[8]; // instruction alignment array. + PBYTE pbRemain; // first instruction after moved code. [free list] + PBYTE pbDetour; // first instruction of detour function. +}; + +C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 104); + +enum { + SIZE_OF_JMP = 8 +}; + +inline PBYTE align4(PBYTE pValue) +{ + return (PBYTE)(((ULONG)pValue) & ~(ULONG)3u); +} + +inline ULONG fetch_thumb_opcode(PBYTE pbCode) +{ + ULONG Opcode = *(UINT16 *)&pbCode[0]; + if (Opcode >= 0xe800) { + Opcode = (Opcode << 16) | *(UINT16 *)&pbCode[2]; + } + return Opcode; +} + +inline void write_thumb_opcode(PBYTE &pbCode, ULONG Opcode) +{ + if (Opcode >= 0x10000) { + *((UINT16*&)pbCode)++ = Opcode >> 16; + } + *((UINT16*&)pbCode)++ = (UINT16)Opcode; +} + +PBYTE detour_gen_jmp_immediate(PBYTE pbCode, PBYTE *ppPool, PBYTE pbJmpVal) +{ + PBYTE pbLiteral; + if (ppPool != NULL) { + *ppPool = *ppPool - 4; + pbLiteral = *ppPool; + } + else { + pbLiteral = align4(pbCode + 6); + } + + *((PBYTE*&)pbLiteral) = DETOURS_PBYTE_TO_PFUNC(pbJmpVal); + LONG delta = pbLiteral - align4(pbCode + 4); + + write_thumb_opcode(pbCode, 0xf8dff000 | delta); // LDR PC,[PC+n] + + if (ppPool == NULL) { + if (((ULONG)pbCode & 2) != 0) { + write_thumb_opcode(pbCode, 0xdefe); // BREAK + } + pbCode += 4; + } + return pbCode; +} + +inline PBYTE detour_gen_brk(PBYTE pbCode, PBYTE pbLimit) +{ + while (pbCode < pbLimit) { + write_thumb_opcode(pbCode, 0xdefe); + } + return pbCode; +} + +inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals) +{ + if (pbCode == NULL) { + return NULL; + } + if (ppGlobals != NULL) { + *ppGlobals = NULL; + } + + // Skip over the import jump if there is one. + pbCode = (PBYTE)DETOURS_PFUNC_TO_PBYTE(pbCode); + ULONG Opcode = fetch_thumb_opcode(pbCode); + + if ((Opcode & 0xfbf08f00) == 0xf2400c00) { // movw r12,#xxxx + ULONG Opcode2 = fetch_thumb_opcode(pbCode+4); + + if ((Opcode2 & 0xfbf08f00) == 0xf2c00c00) { // movt r12,#xxxx + ULONG Opcode3 = fetch_thumb_opcode(pbCode+8); + if (Opcode3 == 0xf8dcf000) { // ldr pc,[r12] + PBYTE pbTarget = (PBYTE)(((Opcode2 << 12) & 0xf7000000) | + ((Opcode2 << 1) & 0x08000000) | + ((Opcode2 << 16) & 0x00ff0000) | + ((Opcode >> 4) & 0x0000f700) | + ((Opcode >> 15) & 0x00000800) | + ((Opcode >> 0) & 0x000000ff)); + if (detour_is_imported(pbCode, pbTarget)) { + PBYTE pbNew = *(PBYTE *)pbTarget; + pbNew = DETOURS_PFUNC_TO_PBYTE(pbNew); + DETOUR_TRACE(("%p->%p: skipped over import table.\n", pbCode, pbNew)); + return pbNew; + } + } + } + } + return pbCode; +} + +inline void detour_find_jmp_bounds(PBYTE pbCode, + PDETOUR_TRAMPOLINE *ppLower, + PDETOUR_TRAMPOLINE *ppUpper) +{ + // We have to place trampolines within +/- 2GB of code. + ULONG_PTR lo = detour_2gb_below((ULONG_PTR)pbCode); + ULONG_PTR hi = detour_2gb_above((ULONG_PTR)pbCode); + DETOUR_TRACE(("[%p..%p..%p]\n", lo, pbCode, hi)); + + *ppLower = (PDETOUR_TRAMPOLINE)lo; + *ppUpper = (PDETOUR_TRAMPOLINE)hi; +} + + +inline BOOL detour_does_code_end_function(PBYTE pbCode) +{ + ULONG Opcode = fetch_thumb_opcode(pbCode); + if ((Opcode & 0xffffff87) == 0x4700 || // bx + (Opcode & 0xf800d000) == 0xf0009000) { // b + return TRUE; + } + if ((Opcode & 0xffff8000) == 0xe8bd8000) { // pop {...,pc} + __debugbreak(); + return TRUE; + } + if ((Opcode & 0xffffff00) == 0x0000bd00) { // pop {...,pc} + __debugbreak(); + return TRUE; + } + return FALSE; +} + +inline ULONG detour_is_code_filler(PBYTE pbCode) +{ + if (pbCode[0] == 0x00 && pbCode[1] == 0xbf) { // nop. + return 2; + } + if (pbCode[0] == 0x00 && pbCode[1] == 0x00) { // zero-filled padding. + return 2; + } + return 0; +} + +#endif // DETOURS_ARM + +#ifdef DETOURS_ARM64 + +struct _DETOUR_TRAMPOLINE +{ + // An ARM64 instruction is 4 bytes long. + // + // The overwrite is always 2 instructions plus a literal, so 16 bytes, 4 instructions. + // + // Copied instructions can expand. + // + // The scheme using MovImmediate can cause an instruction + // to grow as much as 6 times. + // That would be Bcc or Tbz with a large address space: + // 4 instructions to form immediate + // inverted tbz/bcc + // br + // + // An expansion of 4 is not uncommon -- bl/blr and small address space: + // 3 instructions to form immediate + // br or brl + // + // A theoretical maximum for rbCode is thefore 4*4*6 + 16 = 112 (another 16 for jmp to pbRemain). + // + // With literals, the maximum expansion is 5, including the literals: 4*4*5 + 16 = 96. + // + // The number is rounded up to 128. m_rbScratchDst should match this. + // + BYTE rbCode[128]; // target code + jmp to pbRemain + BYTE cbCode; // size of moved target code. + BYTE cbCodeBreak[3]; // padding to make debugging easier. + BYTE rbRestore[24]; // original target code. + BYTE cbRestore; // size of original target code. + BYTE cbRestoreBreak[3]; // padding to make debugging easier. + _DETOUR_ALIGN rAlign[8]; // instruction alignment array. + PBYTE pbRemain; // first instruction after moved code. [free list] + PBYTE pbDetour; // first instruction of detour function. +}; + +C_ASSERT(sizeof(_DETOUR_TRAMPOLINE) == 184); + +enum { + SIZE_OF_JMP = 16 +}; + +inline ULONG fetch_opcode(PBYTE pbCode) +{ + return *(ULONG *)pbCode; +} + +inline void write_opcode(PBYTE &pbCode, ULONG Opcode) +{ + *(ULONG *)pbCode = Opcode; + pbCode += 4; +} + +PBYTE detour_gen_jmp_immediate(PBYTE pbCode, PBYTE *ppPool, PBYTE pbJmpVal) +{ + PBYTE pbLiteral; + if (ppPool != NULL) { + *ppPool = *ppPool - 8; + pbLiteral = *ppPool; + } + else { + pbLiteral = pbCode + 8; + } + + *((PBYTE*&)pbLiteral) = pbJmpVal; + LONG delta = (LONG)(pbLiteral - pbCode); + + write_opcode(pbCode, 0x58000011 | ((delta / 4) << 5)); // LDR X17,[PC+n] + write_opcode(pbCode, 0xd61f0000 | (17 << 5)); // BR X17 + + if (ppPool == NULL) { + pbCode += 8; + } + return pbCode; +} + +inline PBYTE detour_gen_brk(PBYTE pbCode, PBYTE pbLimit) +{ + while (pbCode < pbLimit) { + write_opcode(pbCode, 0xd4100000 | (0xf000 << 5)); + } + return pbCode; +} + +inline INT64 detour_sign_extend(UINT64 value, UINT bits) +{ + const UINT left = 64 - bits; + const INT64 m1 = -1; + const INT64 wide = (INT64)(value << left); + const INT64 sign = (wide < 0) ? (m1 << left) : 0; + return value | sign; +} + +inline PBYTE detour_skip_jmp(PBYTE pbCode, PVOID *ppGlobals) +{ + if (pbCode == NULL) { + return NULL; + } + if (ppGlobals != NULL) { + *ppGlobals = NULL; + } + + // Skip over the import jump if there is one. + pbCode = (PBYTE)pbCode; + ULONG Opcode = fetch_opcode(pbCode); + + if ((Opcode & 0x9f00001f) == 0x90000010) { // adrp x16, IAT + ULONG Opcode2 = fetch_opcode(pbCode + 4); + + if ((Opcode2 & 0xffe003ff) == 0xf9400210) { // ldr x16, [x16, IAT] + ULONG Opcode3 = fetch_opcode(pbCode + 8); + + if (Opcode3 == 0xd61f0200) { // br x16 + +/* https://static.docs.arm.com/ddi0487/bb/DDI0487B_b_armv8_arm.pdf + The ADRP instruction shifts a signed, 21-bit immediate left by 12 bits, adds it to the value of the program counter with + the bottom 12 bits cleared to zero, and then writes the result to a general-purpose register. This permits the + calculation of the address at a 4KB aligned memory region. In conjunction with an ADD (immediate) instruction, or + a Load/Store instruction with a 12-bit immediate offset, this allows for the calculation of, or access to, any address + within +/- 4GB of the current PC. + +PC-rel. addressing + This section describes the encoding of the PC-rel. addressing instruction class. The encodings in this section are + decoded from Data Processing -- Immediate on page C4-226. + Add/subtract (immediate) + This section describes the encoding of the Add/subtract (immediate) instruction class. The encodings in this section + are decoded from Data Processing -- Immediate on page C4-226. + Decode fields + Instruction page + op + 0 ADR + 1 ADRP + +C6.2.10 ADRP + Form PC-relative address to 4KB page adds an immediate value that is shifted left by 12 bits, to the PC value to + form a PC-relative address, with the bottom 12 bits masked out, and writes the result to the destination register. + ADRP ,