I have a function with a certain number of parameters. But I need to avoid calling any parameter in the function body:

void MyClass::MyMethod(int32 parm1, FString parm2, UObject* parm3) { void* firstParmPtr = ?; // как мне получить указатель? Где находится адрес первого параметра? } 

The value of the firstParmPtr pointer must be equal to &parm1 .

Found an interesting moment. Arguments are on the stack, as are new variables. Thus, I can define one variable in the function body and subtract the size of all function arguments (there is a way to do it).

 void MyClass::MyMethod(int32 parm1, FString parm2, UObject* parm3) { uint64 _framePtr; UFunction* func = FindFunction("MyMethod"); void* firstParmPtr = &_framePtr - func->ParamsSize; // Вроде оно... } 

However, this option does not work. _framePtr too far in the stack from the parameter list. Much more than the sizeof each parameter. Then how should I act? Maybe you need to subtract some more constant?

Need any information about this. And the address of the return value is also interesting. And it is also desirable without the use of assembly inserts. Although it is possible and their, but this is not the main object of interest, since I can not compile this.

  • Some information is in this answer . In general, everything depends on the architecture of the company. Specify the architecture and more precisely formulate the final goal, maybe we'll figure it out. - avp
  • I hope you understand that the optimizer is not something that can simply inline your function, it can even throw out its calculation, if it can prove that its result is not interesting to anyone? - VladD
  • Answer: no way to get it. Where could such an idea come from? What makes you think that the arguments are on the stack? - AnT
  • On AMD64 and ARM, some of the parameters are passed through registers. - maestro
  • 2
    By the way, you completely forgot about the this parameter. And now, if you can - the main question - why? This is a serious question, because maybe you are just asking how to hold the microscope correctly in order to hammer in nails, and it would be right to ask - how to hammer nails in? Maybe your main task is solved in a completely different way? - Harry

0