The Gold Road Chapter – which includes the Scribing system – and Update 42 is now available to test on the PTS! You can read the latest patch notes here: https://forums.elderscrollsonline.com/en/discussion/656454/
Maintenance for the week of April 29:
• PC/Mac: No maintenance – April 29

CallSecureProtected fails

Ausare
Ausare
Hi.
I've been trying to debug my favorite Bank Manager Revived ad-don with some bug that it was not working on my computer.

I found that these calls fail silently:
if CallSecureProtected("PickupInventoryItem", fromBag, fromSlot, quantity) then
            CallSecureProtected("PlaceInInventory", destBag, destSlot)

After experimenting, it appears that for me such an unprotected call works fine:
if PickupInventoryItem(fromBag, fromSlot, quantity)
        PlaceInInventory(destBag, destSlot)

Now when I try to test it with the author, I find that original code works for him. And my code gives him this error:
user:/AddOns/BankManagerRevived/src/BankManager.lua:14: attempt to access a private function 'PickupInventoryItem' from insecure code
stack traceback:
	user:/AddOns/BankManagerRevived/src/BankManager.lua:14: in function 'func'
	EsoUI/Libraries/Globals/globalapi.lua:181: in function '(anonymous)'

What is going on?
  • Garkin
    Garkin
    ✭✭✭
    A few more questions:
    - CallSecureProtected function is not mentioned in provided documentation
    - Documentation does not contain return values from the protected functions
    - Function PickupInventoryItem is protected, not private. So why error message says that function is private?
    - Can you please specify when protected functions can be used? As far as I know they can't be used in combat, but is there any other restriction?

    As for the code:
    - Update 4 adds a new protected function RequestMoveItem which provides more direct way to move item, you don't need to clear cursor, pick the item and then place it somewhere.
    Garkin / EU / CSF guild
    My addons: SkyShards, LoreBooks, Dustman, Map Coordinates, No, thank you, ... (full list)
    I'm taking care of: Azurah - Interface Enhanced, Srendarr - Aura, Buff & Debuff Tracker and more
    My folder with updated/modified addons: DROPBOX
  • Ausare
    Ausare
    Ok, I'm new in lua scripting. I'm a c++ developer.
    First, RequestMoveItem is nowhere in the documentation. Only in patch notes.
    I've tried it on release builds and it does not work.

    I tried to ignore return values from the calls. It did not change anything.

    The message about private function is being shown by the ESO itself. So ask developers.
    Addon uses functionality in banks. So it is non combat by default.

    CallSecureProtected is undocumented function found by original developer and it has been working let's say for 99% of the systems.
    Edited by Ausare on October 6, 2014 6:12PM
  • Garkin
    Garkin
    ✭✭✭
    Ausare wrote: »
    Ok, I'm new in lua scripting. I'm a c++ developer.
    First, RequestMoveItem is nowhere in the documentation. Only in patch notes.
    I've tried it on release builds and it does not work.
    - RequestMoveItem is in the UI documentation attached to this post:
    http://forums.elderscrollsonline.com/discussion/127820/

    This function works for me - at least in modified CDGBankStack addon.
    Ausare wrote: »
    I tried to ignore return values from the calls. It did not change anything.
    Return values exists, but they are not listed in the document.
    Ausare wrote: »
    The message about private function is being shown by the ESO itself. So ask developers.
    As your questions are directed to the ZOS developers, I've tried to add some more related questions for them.
    Ausare wrote: »
    Addon uses functionality in banks. So it is non combat by default.
    That's why I've tried to ask developers if there is any other restriction.
    Ausare wrote: »
    CallSecureProtected is undocumented function found by original developer and it has been working let's say for 99% of the systems.
    I think that the first addon which have used this function was beeradg's BankStuffer about 6 months ago. However I still have no idea what exactly this function does...
    Garkin / EU / CSF guild
    My addons: SkyShards, LoreBooks, Dustman, Map Coordinates, No, thank you, ... (full list)
    I'm taking care of: Azurah - Interface Enhanced, Srendarr - Aura, Buff & Debuff Tracker and more
    My folder with updated/modified addons: DROPBOX
  • ZOS_ChipHilseberg
    ZOS_ChipHilseberg
    ✭✭✭
    There are two rules with protected functions. First, they cannot be called while the UI is in lockdown mode. The sole determiner of lockdown is if the player is in combat. Second, they can only be called using CallSecureProtected, which accepts the name of the function to call and the arguments to pass to that function. If the call succeeds, CallSecureProtected returns true followed by the function returns. If the call fails, it returns false and a string describing the reason why the call failed. Invoking protected functions directly should fail with the "attempt to access a private function" error. The error does not differentiate between private and protected because of the additional bookkeeping and performance cost it would take to separate the two cases at that point.

    CallSecureProtected is one of a group of functions that are directly added to the lua state, whereas most functions are added through code generation (which also makes the documentation). We can look into adding these to the documentation manually. The full list is:
    • ScriptBuildInfo
    • LoadString
    • CallSecureProtected
    • InsecureNext
    • AreId64sEqual
    • CompareId64s

    As far as the documentation on protected functions. I couldn't find a protected function that was supposed to be returning values. Do you have a specific example?
    Staff Post
  • Garkin
    Garkin
    ✭✭✭
    As far as the documentation on protected functions. I couldn't find a protected function that was supposed to be returning values. Do you have a specific example?
    I saw code using return value from CallSecureProtected function and I thought that it is return value from the protected function. My mistake.

    Garkin / EU / CSF guild
    My addons: SkyShards, LoreBooks, Dustman, Map Coordinates, No, thank you, ... (full list)
    I'm taking care of: Azurah - Interface Enhanced, Srendarr - Aura, Buff & Debuff Tracker and more
    My folder with updated/modified addons: DROPBOX
  • Ausare
    Ausare
    Thank you, ZOS_ChipHilseberg
  • Ausare
    Ausare
    Ok. By the documentation it is listed that it is protected function
    RequestMoveItem *protected* (...

    and the call to it using CallSecureProtected returns "requested function was not found or is not protected"

    And the same for some other functions.
Sign In or Register to comment.