ā Importing functions by RVA instead of Name
right now, I have a function imported from a cpp library
which I pass in a function name and params, and it gives me
back a pointer to that function. And currently, I just cast it
to a unmanaged function pointer and it works fine.
Does anyone here know if there is a way to simplify this process
by using a custom attribute?
example:
instead of
just
or similar.
How can I go about making ResolvableAttribute?
16 Replies
Get the attribute and call
ResolveFunc
with the value of ResolvableAttributeright, but where? is there a way to override invoke in the attribute class?
I'm not sure what do you mean override invoke, you can do it with reflection.
what will reflection even do for me in this case?
I'm working with function pointers, and I need to
make an attribute which shortens the process
thats all
if I have
and I call it, it should
make sure it has the pointer by calling ResolveFunc with the
value ive passed in, and then call it with the args pA and pB
instead of
I want to put the
functionality inside the attribute somehow, and get rid of the
annoyingly long cast if possible
What's the return type of
ResolveFunc
?IntPtr
which is the address of the function in memory
when I cast it as a func pointer it works, im just looking to simplify the process
A very simple example
Init would initialize all fields that has the attribute
Resolvable
would
public static extern void DoThing(int pA, int pB);
be considered a field?
Yup, it's a field
oh I didnt know that
interesting
and it can be set to a delegate?
oops sorry, I messed u, you need to define the delegate
is the delegate not already defined here somehow?
like void DoThing(int pA, int pB);
or field with an action
I messed up, that won't work with GetField
Lemme send the correct code
This
Or
okay then thanks!!
š
np š
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.