I currently have a C ++ exe project in which the dynamic loading of N DLLs.
Those DLLs will make calls for functions that are reused inside the exe project.
Now, as part of my exe project, I want to know that callers come from a DLL.
Can this be done using any available Windows API?
It depends on your actual purpose. You cannot do this if you expect the DLLs to be malicious (that is, if you expect them to try to trick you). But if it's just for debugging or logging or something like that harmless, you can look at the stack and get the address that the team retwill use to return to the caller, list through the loaded DLLs and check which of them the address is inside.
ret
To get the "return address", you can use _ ReturnAddress built into Visual C ++, and then you can use GetModuleHandleEx , passing in GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESSto get the handle to the DLL where the address is located.
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
: . "" , "" "" DLL. , - , .
, , , , DLL . , 5 - ....
DLL, , . API , . , DLL.
, , , exe.
: , ?
? "GetModuleBaseRoutine"
exe, , DLL (. ), , DLL , . DLL, .
, , DLL, , , , DLL exe. , , , DLL , , , .
Source: https://habr.com/ru/post/1767304/More articles:openid with django - pythonProperty Location Data - Where can I find datasets? - gisCreate HTML file with JavaScript - javascriptScala for understanding returning an ordered map - scalaDjango Advantage forms.Form vs forms.ModelForm - django-modelsMicrosoft Exchange Web Service URL - c #Problem with the algorithm: packs of rods in a row - javascriptundefined method 'password_confirmation' for user: Authlogic testing with cucumber and Factory girl - ruby-on-railsДесятичное число с плавающей точкой - decimalJava dynamic page header - javaAll Articles