Loading File on DLL_PROCESS_ATTACH - is it safe with respect to the loaderlock?

286 Views Asked by At

I want to create a dll that loads an ini file DLL_PROCESS_ATTACH. The is in the same directory as the executable loading the dll. Can this be done safely with respect to the loader lock?

regards Tobias

1

There are 1 best solutions below

2
On BEST ANSWER

According to Microsoft's best practices for DLLs, it is safe to open, read and write files.

Do's and don'ts reproduced in summary below

enter image description here

EDIT following on from your clarification in comments, yes it is safe to call GetModuleFileName because, as MSDN says (at the bottom of the page) that function is implemented in kernel32.dll (see above "safe" section).