I injected dll in one of my process successfully and as part of a test, I want to call PlaySound to actually play some sound from injected dll. In dll main I have this
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved )
{
std::cout << "Injected\n";
while (1)
PlaySound(L"file.wav", NULL, SND_FILENAME);
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
In other sources it works, but in dll, it doesn't. I also tried to create thread, but it gave no effect at all, am I missing something, or it shouldn't work by definition?