This is Win32 related problem and all the code is native.
I have 3 layers compiled as dll libraries depending on each other:
[Module 1] -> [Module 2] -> [Module 3] -> [My Module 4]
Module 1 is an app loading Module 2. Module 2 loads Module 3. Module 3 loads My Module 4.
Whenever a call is made from Module 1 it goes through all layers up to module 4.
In Module 4 I would like to somehow trace that it’s called by Module 3 from Module 2 from Module 1 by getting for example HMOUDLE handle for each of them or anything else uniquely identifying them. I can’t think of any Win32 API allowing me to perform such a trace, can you advise?
You should be able to use StackWalk64 along with SymFromAddr on the relevant address from the STACKFRAME64 structures of interest. Not quite what you want but cannot think of any other way to get close.