1

This is probably something obvious but it doesn't make much sense to me. I'm trying to create a dll which is to be injected into a game process using C++. I have read that I shouldn't be calling anything like CreateThread from this method because it's 'dangerous'. Is it still dangerous if I have another method like this? (pseudo):

foo()
{
    CreateThread();
}

DllMain(reason)
{
    if(reason == attach)
    {
        foo();
    }
}

If this is not safe, how exactly should this be done?

Jordan
  • 117
  • 1
  • 12

1 Answers1

1

Yes, you're still violating the "you shouldn't be making API calls and/or create threads" rule. Just because you make the API call from a function that's called by DllMain doesn't change that as it's still being called from inside DllMain, just further down the call stack.

There are more relevant answers and links in this stackoverflow question.

Community
  • 1
  • 1
Timo Geusch
  • 24,095
  • 5
  • 52
  • 70