Click here to Skip to main content
15,914,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: A strange appearance about the NaN 1.#IND Pin
«_Superman_»28-May-13 20:45
professional«_Superman_»28-May-13 20:45 
GeneralRe: A strange appearance about the NaN 1.#IND Pin
Henry Hong28-May-13 23:37
Henry Hong28-May-13 23:37 
GeneralRe: A strange appearance about the NaN 1.#IND Pin
Henry Hong29-May-13 16:23
Henry Hong29-May-13 16:23 
QuestionCAsyncSocket questions Pin
ForNow28-May-13 4:43
ForNow28-May-13 4:43 
AnswerRe: CAsyncSocket questions Pin
Sivaraman Dhamodharan28-May-13 20:49
Sivaraman Dhamodharan28-May-13 20:49 
GeneralRe: CAsyncSocket questions Pin
ForNow28-May-13 22:33
ForNow28-May-13 22:33 
Questionproblem with using program Creating a Serial communication on Win32 Pin
sindbad1128-May-13 2:00
sindbad1128-May-13 2:00 
AnswerRe: problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt28-May-13 2:19
professionalJochen Arndt28-May-13 2:19 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
sindbad1128-May-13 22:07
sindbad1128-May-13 22:07 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt28-May-13 22:52
professionalJochen Arndt28-May-13 22:52 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
sindbad1128-May-13 23:49
sindbad1128-May-13 23:49 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt29-May-13 0:31
professionalJochen Arndt29-May-13 0:31 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
sindbad1112-Aug-13 1:19
sindbad1112-Aug-13 1:19 
GeneralRe: problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt16-Aug-13 2:52
professionalJochen Arndt16-Aug-13 2:52 
General: problem with using program Creating a Serial communication on Win32 Pin
sindbad116-Sep-13 23:29
sindbad116-Sep-13 23:29 
GeneralRe: : problem with using program Creating a Serial communication on Win32 Pin
Jochen Arndt6-Sep-13 23:45
professionalJochen Arndt6-Sep-13 23:45 
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 

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.