Exemple #1
0
 public ObjectStorageService(HookService hookService)
 {
     objectDestructorHook = hookService.RequestHook <ObjectDestructorHook>(OnObjectDestructor, FunctionsLinux._ZN10CNWSObjectD1Ev, HookOrder.VeryEarly);
     areaDestructorHook   = hookService.RequestHook <AreaDestructorHook>(OnAreaDestructor, FunctionsLinux._ZN8CNWSAreaD1Ev, HookOrder.VeryEarly);
     eatTURDHook          = hookService.RequestHook <EatTURDHook>(OnEatTURD, FunctionsLinux._ZN10CNWSPlayer7EatTURDEP14CNWSPlayerTURD, HookOrder.VeryEarly);
     dropTURDHook         = hookService.RequestHook <DropTURDHook>(OnDropTURD, FunctionsLinux._ZN10CNWSPlayer8DropTURDEv, HookOrder.VeryEarly);
     saveToGffHook        = hookService.RequestHook <SaveToGffHook>(OnSaveToGff, FunctionsLinux._ZN8CNWSUUID9SaveToGffEP7CResGFFP10CResStruct, HookOrder.VeryEarly);
     loadFromGffHook      = hookService.RequestHook <LoadFromGffHook>(OnLoadFromGff, FunctionsLinux._ZN8CNWSUUID11LoadFromGffEP7CResGFFP10CResStruct, HookOrder.VeryEarly);
 }
Exemple #2
0
 public DialogService(HookService hookService)
 {
     getStartEntryHook         = hookService.RequestHook <GetStartEntryHook>(OnGetStartEntry, FunctionsLinux._ZN10CNWSDialog13GetStartEntryEP10CNWSObject, HookOrder.Early);
     getStartEntryOneLinerHook = hookService.RequestHook <GetStartEntryOneLinerHook>(OnGetStartEntryOneLiner, FunctionsLinux._ZN10CNWSDialog21GetStartEntryOneLinerEP10CNWSObjectR13CExoLocStringR7CResRefS5_R13CExoArrayListI11ScriptParamE, HookOrder.Early);
     sendDialogEntryHook       = hookService.RequestHook <SendDialogEntryHook>(OnSendDialogEntry, FunctionsLinux._ZN10CNWSDialog15SendDialogEntryEP10CNWSObjectjji, HookOrder.Early);
     sendDialogRepliesHook     = hookService.RequestHook <SendDialogRepliesHook>(OnSendDialogReplies, FunctionsLinux._ZN10CNWSDialog17SendDialogRepliesEP10CNWSObjectj, HookOrder.Early);
     handleReplyHook           = hookService.RequestHook <HandleReplyHook>(OnHandleReply, FunctionsLinux._ZN10CNWSDialog11HandleReplyEjP10CNWSObjectjij, HookOrder.Early);
     checkScriptHook           = hookService.RequestHook <CheckScriptHook>(OnCheckScript, FunctionsLinux._ZN10CNWSDialog11CheckScriptEP10CNWSObjectRK7CResRefRK13CExoArrayListI11ScriptParamE, HookOrder.Early);
     runScriptHook             = hookService.RequestHook <RunScriptHook>(OnRunScript, FunctionsLinux._ZN10CNWSDialog9RunScriptEP10CNWSObjectRK7CResRefRK13CExoArrayListI11ScriptParamE, HookOrder.Early);
 }
Exemple #3
0
        /// <summary>
        /// Requests a hook for a native function.
        /// </summary>
        /// <param name="handler">A delegate pointer (delegate*) to be invoked when the original game function is called. Once hooked, the original function will not be called, and must be invoked manually via the returned object.</param>
        /// <param name="address">The address of the native function. Use the constants available in <see cref="NWN.Native.API.FunctionsLinux"/>.</param>
        /// <param name="order">The execution order for this hook. See the constants in <see cref="HookOrder"/>.</param>
        /// <typeparam name="T">The delegate type that identically matches the native function signature.</typeparam>
        /// <returns>A wrapper object containing a delegate to the original function. The wrapped object can be disposed to release the hook.</returns>
        public FunctionHook <T> RequestHook <T>(void *handler, uint address, int order = HookOrder.Default) where T : Delegate
        {
            Log.Debug("Requesting function hook for {HookType}, address {Address}", typeof(T).Name, $"0x{address:X}");
            IntPtr nativeFuncPtr = VM.RequestHook(new IntPtr(address), (IntPtr)handler, order);

            FunctionHook <T> retVal = new FunctionHook <T>(this, nativeFuncPtr);

            hooks.Add(retVal);

            return(retVal);
        }
Exemple #4
0
        /// <summary>
        /// Requests a hook for a native function.
        /// </summary>
        /// <param name="handler">The handler to be invoked when this function is called. Once hooked, the original function will not be called, and must be invoked manually via the returned object.</param>
        /// <param name="address">The address of the native function. Use the constants available in <see cref="NWN.Native.API.FunctionsLinux"/>.</param>
        /// <param name="order">The execution order for this hook. See the constants in <see cref="HookOrder"/>.</param>
        /// <typeparam name="T">The delegate type that identically matches the native function signature.</typeparam>
        /// <returns>A wrapper object containing a delegate to the original function. The wrapped object can be disposed to release the hook.</returns>
        public FunctionHook <T> RequestHook <T>(T handler, uint address, int order = HookOrder.Default) where T : Delegate
        {
            Log.Debug("Requesting function hook for {HookType}, address {Address}", typeof(T).Name, $"0x{address:X}");
            IntPtr managedFuncPtr = Marshal.GetFunctionPointerForDelegate(handler);
            IntPtr nativeFuncPtr  = VM.RequestHook(new IntPtr(address), managedFuncPtr, order);

            FunctionHook <T> hook = new FunctionHook <T>(this, nativeFuncPtr, handler);

            hooks.Add(hook);

            return(hook);
        }
        public PlayerNameOverrideService(HookService hookService)
        {
            NwModule.Instance.OnClientLeave += OnClientLeave;

            writeGameObjUpdateUpdateObjectHook           = hookService.RequestHook <WriteGameObjUpdateUpdateObjectHook>(OnWriteGameObjUpdateUpdateObject, FunctionsLinux._ZN11CNWSMessage31WriteGameObjUpdate_UpdateObjectEP10CNWSPlayerP10CNWSObjectP17CLastUpdateObjectjj, HookOrder.Early);
            sendServerToPlayerExamineGuiCreatureDataHook = hookService.RequestHook <SendServerToPlayerExamineGuiCreatureDataHook>(OnSendServerToPlayerExamineGuiCreatureData, FunctionsLinux._ZN11CNWSMessage41SendServerToPlayerExamineGui_CreatureDataEP10CNWSPlayerj, HookOrder.Early);

            sendServerToPlayerPlayerListAllHook    = hookService.RequestHook <SendServerToPlayerPlayerListAllHook>(OnSendServerToPlayerPlayerListAll, FunctionsLinux._ZN11CNWSMessage32SendServerToPlayerPlayerList_AllEP10CNWSPlayer, HookOrder.Early);
            sendServerToPlayerPlayerListAddHook    = hookService.RequestHook <SendServerToPlayerPlayerListAddHook>(OnSendServerToPlayerPlayerListAdd, FunctionsLinux._ZN11CNWSMessage32SendServerToPlayerPlayerList_AddEjP10CNWSPlayer, HookOrder.Early);
            sendServerToPlayerPlayerListDeleteHook = hookService.RequestHook <SendServerToPlayerPlayerListDeleteHook>(OnSendServerToPlayerPlayerListDelete, FunctionsLinux._ZN11CNWSMessage35SendServerToPlayerPlayerList_DeleteEjP10CNWSPlayer, HookOrder.Early);

            sendServerToPlayerDungeonMasterUpdatePartyListHook = hookService.RequestHook <SendServerToPlayerDungeonMasterUpdatePartyListHook>(OnSendServerToPlayerDungeonMasterUpdatePartyList, FunctionsLinux._ZN11CNWSMessage46SendServerToPlayerDungeonMasterUpdatePartyListEj, HookOrder.Early);
            sendServerToPlayerPopUpGUIPanelHook = hookService.RequestHook <SendServerToPlayerPopUpGUIPanelHook>(OnSendServerToPlayerPopUpGUIPanel, FunctionsLinux._ZN11CNWSMessage31SendServerToPlayerPopUpGUIPanelEjiiii10CExoString, HookOrder.Early);

            sendServerToPlayerChatPartyHook = hookService.RequestHook <SendServerToPlayerChatPartyHook>(OnSendServerToPlayerChatParty, FunctionsLinux._ZN11CNWSMessage28SendServerToPlayerChat_PartyEjj10CExoString, HookOrder.Early);
            sendServerToPlayerChatShoutHook = hookService.RequestHook <SendServerToPlayerChatShoutHook>(OnSendServerToPlayerChatShout, FunctionsLinux._ZN11CNWSMessage28SendServerToPlayerChat_ShoutEjj10CExoString, HookOrder.Early);
            sendServerToPlayerChatTellHook  = hookService.RequestHook <SendServerToPlayerChatTellHook>(OnSendServerToPlayerChatTell, FunctionsLinux._ZN11CNWSMessage27SendServerToPlayerChat_TellEjj10CExoString, HookOrder.Early);
        }
Exemple #6
0
        public ServerLogRedirectorService(HookService hookService)
        {
            switch (EnvironmentConfig.LogMode)
            {
            case LogMode.Default:
                return;

            case LogMode.Duplicate:
                callOriginal = true;
                break;

            case LogMode.Redirect:
                callOriginal = false;
                break;
            }

            writeToLogFileHook            = hookService.RequestHook <WriteToLogFileHook>(OnWriteToLogFile, FunctionsLinux._ZN17CExoDebugInternal14WriteToLogFileERK10CExoString, HookOrder.VeryEarly);
            writeToErrorFileHook          = hookService.RequestHook <WriteToErrorFileHook>(OnWriteToErrorFile, FunctionsLinux._ZN17CExoDebugInternal16WriteToErrorFileERK10CExoString, HookOrder.VeryEarly);
            executeCommandPrintStringHook = hookService.RequestHook <ExecuteCommandPrintStringHook>(OnExecuteCommandPrintString, FunctionsLinux._ZN25CNWVirtualMachineCommands25ExecuteCommandPrintStringEii, HookOrder.VeryEarly);
        }
Exemple #7
0
        public WeaponService(HookService hookService, EventService eventService)
        {
            this.hookService  = hookService;
            this.eventService = eventService;

            getWeaponFocusHook                    = hookService.RequestHook <GetWeaponFocusHook>(OnGetWeaponFocus, FunctionsLinux._ZN17CNWSCreatureStats14GetWeaponFocusEP8CNWSItem, HookOrder.Late);
            getEpicWeaponFocusHook                = hookService.RequestHook <GetEpicWeaponFocusHook>(OnGetEpicWeaponFocus, FunctionsLinux._ZN17CNWSCreatureStats18GetEpicWeaponFocusEP8CNWSItem, HookOrder.Late);
            getWeaponFinesseHook                  = hookService.RequestHook <GetWeaponFinesseHook>(OnGetWeaponFinesse, FunctionsLinux._ZN17CNWSCreatureStats16GetWeaponFinesseEP8CNWSItem, HookOrder.Final);
            getWeaponImprovedCriticalHook         = hookService.RequestHook <GetWeaponImprovedCriticalHook>(OnGetWeaponImprovedCritical, FunctionsLinux._ZN17CNWSCreatureStats25GetWeaponImprovedCriticalEP8CNWSItem, HookOrder.Late);
            getEpicWeaponOverwhelmingCriticalHook = hookService.RequestHook <GetEpicWeaponOverwhelmingCriticalHook>(OnGetEpicWeaponOverwhelmingCritical, FunctionsLinux._ZN17CNWSCreatureStats33GetEpicWeaponOverwhelmingCriticalEP8CNWSItem, HookOrder.Late);
            getEpicWeaponDevastatingCriticalHook  = hookService.RequestHook <GetEpicWeaponDevastatingCriticalHook>(OnGetEpicWeaponDevastatingCritical, FunctionsLinux._ZN17CNWSCreatureStats32GetEpicWeaponDevastatingCriticalEP8CNWSItem, HookOrder.Late);
            getWeaponSpecializationHook           = hookService.RequestHook <GetWeaponSpecializationHook>(OnGetWeaponSpecialization, FunctionsLinux._ZN17CNWSCreatureStats23GetWeaponSpecializationEP8CNWSItem, HookOrder.Late);
            getEpicWeaponSpecializationHook       = hookService.RequestHook <GetEpicWeaponSpecializationHook>(OnGetEpicWeaponSpecialization, FunctionsLinux._ZN17CNWSCreatureStats27GetEpicWeaponSpecializationEP8CNWSItem, HookOrder.Late);
            getIsWeaponOfChoiceHook               = hookService.RequestHook <GetIsWeaponOfChoiceHook>(OnGetIsWeaponOfChoice, FunctionsLinux._ZN17CNWSCreatureStats19GetIsWeaponOfChoiceEj, HookOrder.Late);
            getDamageBonusHook                    = hookService.RequestHook <GetDamageBonusHook>(OnGetDamageBonus, FunctionsLinux._ZN17CNWSCreatureStats14GetDamageBonusEP12CNWSCreaturei, HookOrder.Late);
            getMeleeDamageBonusHook               = hookService.RequestHook <GetMeleeDamageBonusHook>(OnGetMeleeDamageBonus, FunctionsLinux._ZN17CNWSCreatureStats19GetMeleeDamageBonusEih, HookOrder.Late);
            getRangedDamageBonusHook              = hookService.RequestHook <GetRangedDamageBonusHook>(OnGetRangedDamageBonus, FunctionsLinux._ZN17CNWSCreatureStats20GetRangedDamageBonusEv, HookOrder.Late);
            getMeleeAttackBonusHook               = hookService.RequestHook <GetMeleeAttackBonusHook>(OnGetMeleeAttackBonus, FunctionsLinux._ZN17CNWSCreatureStats19GetMeleeAttackBonusEiii, HookOrder.Late);
            getRangedAttackBonusHook              = hookService.RequestHook <GetRangedAttackBonusHook>(OnGetRangedAttackBonus, FunctionsLinux._ZN17CNWSCreatureStats20GetRangedAttackBonusEii, HookOrder.Late);
            getAttackModifierVersusHook           = hookService.RequestHook <GetAttackModifierVersusHook>(OnGetAttackModifierVersus, FunctionsLinux._ZN17CNWSCreatureStats23GetAttackModifierVersusEP12CNWSCreature, HookOrder.Late);
            getUseMonkAttackTablesHook            = hookService.RequestHook <GetUseMonkAttackTablesHook>(OnGetUseMonkAttackTables, FunctionsLinux._ZN17CNWSCreatureStats22GetUseMonkAttackTablesEi, HookOrder.Final);

            weaponFinesseSizeMap[(uint)BaseItem.Rapier] = (byte)CreatureSize.Medium;
        }
Exemple #8
0
 public ObjectVisibilityService(HookService hookService)
 {
     testObjectVisibleHook = hookService.RequestHook <TestObjectVisibleHook>(OnTestObjectVisible, FunctionsLinux._ZN11CNWSMessage17TestObjectVisibleEP10CNWSObjectS1_, HookOrder.Late);
 }
Exemple #9
0
 public PlayerRestDurationOverrideService(HookService hookService)
 {
     aiActionRestHook = hookService.RequestHook <AIActionRestHook>(OnAIActionRest, FunctionsLinux._ZN12CNWSCreature12AIActionRestEP20CNWSObjectActionNode, HookOrder.Late);
 }
 public DamageLevelOverrideService(HookService hookService)
 {
     damageLevelHook = hookService.RequestHook <GetDamageLevel>(OnGetDamageLevel, FunctionsLinux._ZN10CNWSObject14GetDamageLevelEv, HookOrder.Late);
 }
Exemple #11
0
 void ICoreService.Init()
 {
     loadModuleInProgressHook = hookService.RequestHook <LoadModuleInProgressHook>(OnModuleLoadProgressChange, FunctionsLinux._ZN10CNWSModule20LoadModuleInProgressEii, HookOrder.Earliest);
 }
 public CreatureWalkRateCapService(HookService hookService)
 {
     walkRateHook = hookService.RequestHook <GetWalkRateHook>(OnGetWalkRate, FunctionsLinux._ZN12CNWSCreature11GetWalkRateEv, HookOrder.Late);
 }
 public CreatureForceWalkService(HookService hookService)
 {
     removeLimitMovementSpeedHook = hookService.RequestHook <RemoveLimitMovementSpeedHook>(OnRemoveLimitMovementSpeed, FunctionsLinux._ZN21CNWSEffectListHandler26OnRemoveLimitMovementSpeedEP10CNWSObjectP11CGameEffect, HookOrder.Late);
 }
Exemple #14
0
 internal void RemoveHook <T>(FunctionHook <T> hook) where T : Delegate
 {
     hooks.Remove(hook);
 }
Exemple #15
0
 public ChatService(HookService hookService, NwServer nwServer)
 {
     this.nwServer = nwServer;
     sendServerToPlayerChatMessageHook = hookService.RequestHook <SendServerToPlayerChatMessageHook>(OnSendServerToPlayerChatMessage, FunctionsLinux._ZN11CNWSMessage29SendServerToPlayerChatMessageEhj10CExoStringjRKS0_, HookOrder.Late);
 }