Click here to Skip to main content
15,901,035 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: : problem with using program Creating a Serial communication on Win32 Pin
sindbad117-Sep-13 0:08
sindbad117-Sep-13 0:08 
GeneralRe: : problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt7-Sep-13 0:28
professionalJochen Arndt7-Sep-13 0:28 
GeneralRe: : problem with using program Creating a Serial communication on Win32 Pin
sindbad117-Sep-13 0:56
sindbad117-Sep-13 0:56 
GeneralRe: : problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt7-Sep-13 2:31
professionalJochen Arndt7-Sep-13 2:31 
QuestionCoding guidelines C Pin
topcatalpha27-May-13 2:56
topcatalpha27-May-13 2:56 
QuestionRe: Coding guidelines C Pin
Maximilien27-May-13 7:08
Maximilien27-May-13 7:08 
AnswerRe: Coding guidelines C Pin
topcatalpha28-May-13 20:41
topcatalpha28-May-13 20:41 
QuestionPlaySoundA does not return within injected DLL Pin
Furblog Sidloth26-May-13 0:42
Furblog Sidloth26-May-13 0:42 
Hi, i have the following problem:

I have a process which uses PlaySoundA[^] WINAPI function to play a specific sound (let's be it "c:\test.wav"). So the process has already loaded the needed "winmm.dll"

I want to play the same sound when the DLL is injected into the process, so the code looks like:

C++
#define WINVER 0x600
#define _WIN32_WINDOWS 0x600
#define _WIN32_WINNT 0x600

#include <windows.h>

typedef bool __stdcall (*psfunc)(LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound);

void play() {
    psfunc ps;
    HMODULE winmm = GetModuleHandle("winmm");;
    ps = (psfunc)GetProcAddress(winmm, "PlaySoundA");
    ps("c:\\test.wav", 0, SND_FILENAME | SND_ASYNC);
}

BOOL __stdcall DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
{
    switch (dwReason)
    {
        case DLL_PROCESS_ATTACH:
            OutputDebugString("play before");
            play();
            OutputDebugString("play after");
            break;

        case DLL_PROCESS_DETACH:
            break;

        case DLL_THREAD_ATTACH:
            break;

        case DLL_THREAD_DETACH:
            break;
    }
    return TRUE;
}


The dll is injected correctly via CreateRemoteThread & LoadLibrary.
But the sound is never played and the dll is blocking at the call of
C++
ps("c:\\test.wav", 0, SND_FILENAME | SND_ASYNC);


Trying to exit the process freezes too because of the blocking thread.
Why does it never return? Procss Monitor doesn't show any error.
How can I solve this?
SuggestionRe: PlaySoundA does not return within injected DLL Pin
Richard MacCutchan26-May-13 0:54
mveRichard MacCutchan26-May-13 0:54 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Furblog Sidloth26-May-13 20:39
Furblog Sidloth26-May-13 20:39 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Richard MacCutchan26-May-13 21:38
mveRichard MacCutchan26-May-13 21:38 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Erudite_Eric27-May-13 5:48
Erudite_Eric27-May-13 5:48 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Richard MacCutchan27-May-13 5:53
mveRichard MacCutchan27-May-13 5:53 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Erudite_Eric27-May-13 10:54
Erudite_Eric27-May-13 10:54 
GeneralRe: PlaySoundA does not return within injected DLL Pin
Richard MacCutchan27-May-13 20:59
mveRichard MacCutchan27-May-13 20:59 
QuestionModeless Dialog CricheditCtrl Issues Pin
ForNow25-May-13 19:34
ForNow25-May-13 19:34 
AnswerRe: Modeless Dialog CricheditCtrl Issues Pin
Richard MacCutchan26-May-13 0:45
mveRichard MacCutchan26-May-13 0:45 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
ForNow26-May-13 2:29
ForNow26-May-13 2:29 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
Richard MacCutchan26-May-13 2:32
mveRichard MacCutchan26-May-13 2:32 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
ForNow26-May-13 2:45
ForNow26-May-13 2:45 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
Richard MacCutchan26-May-13 3:02
mveRichard MacCutchan26-May-13 3:02 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
ForNow26-May-13 3:09
ForNow26-May-13 3:09 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
Richard MacCutchan26-May-13 3:31
mveRichard MacCutchan26-May-13 3:31 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
ForNow26-May-13 3:48
ForNow26-May-13 3:48 
GeneralRe: Modeless Dialog CricheditCtrl Issues Pin
Richard MacCutchan26-May-13 3:53
mveRichard MacCutchan26-May-13 3:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.