Thread Tools Display Modes
11/04/20, 01:20 PM   #1
GRascm
AddOn Author - Click to view addons
Join Date: Oct 2020
Posts: 3
Private function issues in standart UI

Hi, everyone!

I was trying to implement new main menu for gamepad, based on ZO_RadialMenu.
Because it would be much comfortable to use such menu, that the current one.
Here you can see what i mean:
Warning: Spoiler


And everything was perfectly fine, until i tried to use item from the inventory.
I got the following error message:
Warning: Spoiler


To show the inventory menu, i use simple code:
Lua Code:
  1. SCENE_MANAGER:Show(menuEntryData.scene)

And the main problem is, that if i hit an "I" button to open inventory first, and than try to open it from my menu (pressing "start" on gamepad), everything works perfectly fine.

So my hypothesis is that inventory menu makes some initialization on first opening, and, when i trigger that from insecure code, that initialization makes full inventory insecure.

The fact confirming that is that when i try to open inventory with "I" button later (after it was insecurly initialized) it still doesn't work. And if i initialize it securely (pressing "I") than it perfectly working in my menu.

So, is there anything i missing, that could fix my problem?
It looks like currently impossible to implement main menu replacement with such limitations. And it not because it was forbidden, but rather, due to the imperfection of security system.

I saw ZOS developers posting on this forum, and maybe thay can give some advices (or just implement such menu themselves ).
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20201104_215656.png
Views:	791
Size:	1.11 MB
ID:	1327  
  Reply With Quote
11/04/20, 04:02 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Try CallSecureProtected as wrapper around UseItem.
Lua Code:
  1. if IsProtectedFunction("UseItem") then
  2.             CallSecureProtected("UseItem", bagId, slotIndex)
  3.         else
  4.             UseItem(bagId, slotIndex)
  5.         end


If this does not work I'm not sure if there is a way to make your code NOT taint the inventory code. I'm pretty unsure why the code get's insecure though. Are you hooking/chaning any inventory code for your menu? If so try SecurePostHook instead of ZO_PostHook etc.
  Reply With Quote
11/05/20, 04:56 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by GRascm View Post
To show the inventory menu, i use simple code:
Lua Code:
  1. SCENE_MANAGER:Show(menuEntryData.scene)

And the main problem is, that if i hit an "I" button to open inventory first, and than try to open it from my menu (pressing "start" on gamepad), everything works perfectly fine.
If the inventory scene gets initialized from custom code(=addon) everything is tainted. (insecure)
The build-in code is not written to take care of CallSecureProtected, because it normally doesn't need to.

Add the inventory fragment to the base scene at startup (built-in code will initialize it immediately)
And remove the fragment on EVENT_PLAYER_ACTIVATED. And beware, it could cause side-effects with other addons not expecting this to happen that early.

Last edited by votan : 11/05/20 at 05:26 AM.
  Reply With Quote
11/05/20, 12:36 PM   #4
GRascm
AddOn Author - Click to view addons
Join Date: Oct 2020
Posts: 3
Thank you for you replies!

Originally Posted by votan View Post
Add the inventory fragment to the base scene at startup (built-in code will initialize it immediately)
And remove the fragment on EVENT_PLAYER_ACTIVATED. And beware, it could cause side-effects with other addons not expecting this to happen that early.
I've tried to do it, but nothing works

Digging basic esoui code deeper, gave me this:
https://github.com/esoui/esoui/blob/...entory.lua#L64

OnDeferredInitialize called when scene changes state to SCENE_SHOWING first time.
And, it's a hardcoded scene here:
https://github.com/esoui/esoui/blob/...entory.lua#L27
And callback registration happens here:
https://github.com/esoui/esoui/blob/...creen.lua#L227

As i can see, i can't override anything on this path, to force deferred initialization complete in secure way.


Originally Posted by Baertram View Post
Try CallSecureProtected as wrapper around UseItem.
Simple wrapper works fine for this case:

Lua Code:
  1. function UseItem(bag, index)
  2.     CallSecureProtected("UseItem", bag, index)
  3. end

But the solution seems dirty, and, still all interface accessed from main menu becomes tainted because of deferred initialization (ZO_Gamepad_ParametricList_Screen is basic class for almost all gamepad interface accessible from main menu).
And there potentially can be private functions, that couldn't be overrided that easily.
Also, it's too hard to find all functions i should override.

But looks like it's my only option.
  Reply With Quote
11/06/20, 08:32 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Overriding the functions will most likely end in an addon that will break about all other addons around, using these functions
Maybe ask ZOs_DanBrown here in the forum if he got any other idea or if your addon idea would not be possible this way.
  Reply With Quote
11/09/20, 10:47 AM   #6
GRascm
AddOn Author - Click to view addons
Join Date: Oct 2020
Posts: 3
I've managed to abuse "playerSubmenu" scene, and default main menu implementation, to avoid code tainting. User expirience get worse a bit, due to proxy dialog showing to open inventory and settings, but it is working correctly now.

Here you can see how to achieve this, if you interested:
https://github.com/GRascm/eso_agui/c...313adR162-R165
https://github.com/GRascm/eso_agui/c...ad6ff9313adR48


I'm going to report issue to "Bug Reports" section of this forum later, and maybe ZOS will fix it eventually.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Private function issues in standart UI

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off