Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reliance on plugin? #11

Closed
HookedBehemoth opened this issue Aug 11, 2022 · 7 comments
Closed

reliance on plugin? #11

HookedBehemoth opened this issue Aug 11, 2022 · 7 comments

Comments

@HookedBehemoth
Copy link
Contributor

I'm trying to figure out why this requires a native plugin before installing it. I'd like to avoid running precompiled dll's if it's not strictly necessary.
Could "PtrToGuidTest" not be expressed in lua? It seems you're able to set the value from lua. Is it too slow to do it like that?

@Bolt-Scripts
Copy link
Owner

As it is it simply isn't possible from my understanding to take the ptr and get the data from it within lua since GUID is a value type and not a managed object.
At least that's what praydog said and I couldn't figure any weird workaround.
Support for this could be added into the REF sdk itself, but I figured it'd be at the least more interesting to make a plugin for it, but also it meant people wouldn't have to update REF for it to work. But if at some point support for this is added then could transition away from the plugin.
Still, I wonder why you want to avoid it so much

@HookedBehemoth
Copy link
Contributor Author

Thanks for the explanation.
I'd like to avoid running random binaries where I can't verify the code easily. As an individual modder, you don't have anything to loose from potentially shipping malware.
Don't see this as an allegation, but in my background, mainly switch modding, this wasn't that uncommon.

@Bolt-Scripts
Copy link
Owner

Yeah I get you. The source is in the repo but it'd be kinda hard to verify I didn't modify any of the like sol or lua files and then youd have to build it to make sure the dll matches or something idk.
But I assure you my c++ skills are not good enough to write malware lmao
Just an unfortunate roadblock that I needed to be able to read the GUIDs passed from the pointer in the arguments of a method, which is the crux of being able to display custom text in the UI.

@Strackeror
Copy link

So, I was surprised this was actually impossible to do, and indeed you can't actually get a value type from a pointer right now in REFramework.

BUT

After some research into the lua layer source code, I found the REField:get_data() function can take a pointer as an argument, and so I managed to make the mod work with this piece of lua:

local GuidType = sdk.find_type_definition("System.Guid")
local suidArg;
local function PreMsg(args)
  suidArg = GuidType:get_field("mData1"):get_data(args[2]);
end

@Bolt-Scripts
Copy link
Owner

Woah, that is sneaky!
I never would've thought to do that, but I wouldn't have had any reason to look for undocumented functionality I suppose.
But thanks for hunting this down, next update I shall remove the custom plugin in favor of this.
Might be good to also update the doc with the capability?

@Strackeror
Copy link

I'll see if I can make a pull request to the reframework book for that, if I can find a way to formulate that well.
Though to be frank I don't think this way of doing it is ideal, and there should just be a sdk.to_value_type() in REFramework itself

Strackeror added a commit to Strackeror/reframework-book that referenced this issue Aug 12, 2022
See Bolt-Scripts/MHR-InGame-ModMenu-API#11 , this is currently the only way to get fields from value type params in hooked functions
@Bolt-Scripts
Copy link
Owner

True, and I agree.
Still, this would've saved me a lot of headache earlier trying to get anything working 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants