0

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?

MrRetro
  • 19
  • 2
  • Have you tried outside of `DllMain`? There are many things which will fail there to prevent issues. [PlayFunction doesn't work in DLL, but does work in standalone exe](https://stackoverflow.com/questions/57629715/playfunction-doesnt-work-in-dll-but-does-work-in-standalone-exe) – Retired Ninja Apr 22 '23 at 22:08

0 Answers0