ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Private function issues in standart UI (https://www.esoui.com/forums/showthread.php?t=9451)

GRascm 11/04/20 01:20 PM

Private function issues in standart UI
 
1 Attachment(s)
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 :rolleyes:).

Baertram 11/04/20 04:02 PM

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.

votan 11/05/20 04:56 AM

Quote:

Originally Posted by GRascm (Post 42540)
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.

GRascm 11/05/20 12:36 PM

Thank you for you replies!

Quote:

Originally Posted by votan (Post 42561)
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.


Quote:

Originally Posted by Baertram (Post 42552)
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.

Baertram 11/06/20 08:32 AM

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.

GRascm 11/09/20 10:47 AM

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.


All times are GMT -6. The time now is 12:36 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI