|
i don't know if that makes sense or not but somehow i managed to solve that problem.
What I did is.
mytabcontrol was inside of calculator
so whenever i changed something i inform that to mytabcontrol ( i have valid m_hWnd since it's inside calculator )
now all tabs are initialized inside tab control so they wont have problem getting m_hWnd for tabone so if they get called they will inform tab_one to redraw it(invalidate) now problems was if i calls tab_one from tabcontrol , then tab_one will be reinitialzed which will read defaults values of calculaotr so graph will be same.
now i have calcparam which holds all values of calculator inside(calculator)
and tab_one was reading those value. but now i created another calcparam inside tab_one and made sure tab_one read that calcparam not the one from calculator and if i change something in calculator.
it does this
memcpy( &m_tabMyTabCtrl.m_tabPages[i]->CalcParam,&CalcParam,sizeof(CALC_PARAMS));
m_tabMyTabCtrl.m_tabPages[i]->Invalidate( );
// m_tabmytabcontrol is instance of mytabcontrol inside gphview and tabpages is instance of tabone defined in mytabcontrol
that's how i got it work.
anyways thx a lot,
cheers from canada.
|
|
|
|
|
mohit`12 wrote: anyways thx a lot,
You're welcome
|
|
|
|
|
if m_hWnd is 0X000000 means that the windows isnt created or yet destroyed.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
okay Hey,
I found out my problem but no solution yet. The reason m_hWnd is getting null because i am trying to update tab_one out side of that class which is mytabcontrol:
This is what happening :
My Tab Control (Holds Tab) Tab_one ( Holds data and on draw graph)
switch tab(tab_current changes) Draws first graph initial graph
if(tab_current changes) OnDraw() is called
tab_one is already initialized
---------> calls method -----------> ongraph1(){changes graph &try to update which should call ondraw again
it wont update because ongraph1() got called by mytabcontrol who doesn't know what m_hWnd is for tab_one if you call updategraph() inside of tab_one it will work and will show value of m_hWnd..but from mytabcontrol NOPE..
so is there anyway i can inform mytabcontrol that tab_one is initialzed and has soem value of m_hWnd and use that value to updategraph.
|
|
|
|
|
you are mixing something that is buggy. Use some pointers to the approbiate objects.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I Know it's buggy and that's y i am here to find solution and solve buggy code.
thx tho.
|
|
|
|
|
we have a saying: "Help yourself and so god will help you".
you got to do your homeworks yourself
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
haha. I think that saying "" does WORK.. I was trying this since last week and finally today i solved it. GOD HELPED ME....It wasn't that easy though. But this is not the end yet..got some more problems to solve. Let the GOD help me for all of them ![Big Grin | :-D](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
In a form, I am having a message map at the Tab-level like below:
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange)
From TabCtrl::OnDateTimeChange(), I have a call to next level DataFormDlg::OnDateTimeChange
TabCtrl::OnDateTimeChange
{
DataFormDlg->OnDateTimeChange;
}
Inside DataFormDlg, I have another message map as below
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange) and the function is
DataFormDlg::OnDateTimeChange ()
{
//body
}
Now when I click at the datepicker control, the DTN_DATETIMECHANGE event is triggering twice. So, the TabCtrl -> DataFormDlg -> OnDateTimeChange() is executing twice.
Could you please help me finding what is going wrong here?
Thanks,
|
|
|
|
|
|
MODIFIED QUESTION
hello guys...I want to play wave audio data but it is not playing properly, plays differently
WAVEFORMATEX _oFormat;
LPWAVEFORMATEX _pFormat = NULL;
HGLOBAL _hWaveData;
PCHAR _pWaveData;
HGLOBAL _hWaveHeader;
LPWAVEHDR _pWaveHeader;
HWAVEOUT _hOutputDevice = NULL;
DWORD _nAlignedBufferSize = 0;
MMRESULT rc = 0;
HANDLE fileHandle = NULL;
DWORD size = 0;
DWORD readBytes = 0;
void* block = NULL;
_pFormat = &_oFormat;
_pFormat->wFormatTag = WAVE_FORMAT_PCM;
_pFormat->nChannels = 1;
_pFormat->nSamplesPerSec = 8000;
_pFormat->wBitsPerSample = 8;
_pFormat->nBlockAlign = 1;
_pFormat->nAvgBytesPerSec = 8000;
_pFormat->cbSize = 0;
_hWaveHeader = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, (DWORD)sizeof(WAVEHDR));
if(!_hWaveHeader) return false;
_pWaveHeader = (LPWAVEHDR) GlobalLock(_hWaveHeader);
if(!_pWaveHeader) return false;
_hWaveData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, AUDIO_BUFFER_SIZE);
if(!_hWaveData) return false;
_pWaveHeader->lpData = _pWaveData = (LPSTR)GlobalLock(_hWaveData);
rc = waveOutOpen(&_hOutputDevice, WAVE_MAPPER,_pFormat, (DWORD) &waveOutProc, 0, CALLBACK_FUNCTION);
if (rc!=MMSYSERR_NOERROR)
MessageBox(NULL,"Error:","",NULL);
if ((fileHandle = CreateFile("\sounds\\ringout.wav", GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL)) == INVALID_HANDLE_VALUE)
return NULL;
do {
if( (size = GetFileSize(fileHandle,NULL)) == 0)
break;
if ( (block = HeapAlloc(GetProcessHeap(), 0, size)) == NULL)
break;
ReadFile(fileHandle, block, size, &readBytes, NULL);
} while(0);
CloseHandle(fileHandle);
CopyMemory(_pWaveHeader, &block, sizeof(block));
_nAlignedBufferSize = (AUDIO_BUFFER_SIZE - AUDIO_BUFFER_SIZE % _pFormat->nBlockAlign );
_pWaveHeader->dwFlags = 0;
_pWaveHeader->dwBufferLength = _nAlignedBufferSize;
rc = waveOutPrepareHeader(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));
rc = waveOutWrite(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));
modified on Thursday, August 12, 2010 12:32 PM
|
|
|
|
|
|
overloaded Name wrote: What can be the problem
How should we know? You have not said what the problem is. "Plays differently" and "is not running" don't mean a whole lot.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Could it be the improperly escaped backslash in the path to the file?
"\sounds\\ringout.wav"
|
|
|
|
|
And the other one?
It's time for a new signature.
|
|
|
|
|
|
Niklas Lindquist wrote:
"\sounds\\ringout.wav"
I think perhaps you meant:
"\\sounds\\ringout.wav"
[edit]Sorry, I see what you were trying to point out to the OP.[/edit]
It's time for a new signature.
|
|
|
|
|
Niklas Lindquist wrote: Could it be the improperly escaped backslash in the path to the file?
well i dont think so..because in all other cases file is not accessed and played, no sound plays.
|
|
|
|
|
I think your create statement should read
if ((fileHandle = CreateFile("\\sounds\\ringout.wav",
Also, your existing code merely returns NULL if CreateFile() fails, rather than posting a useful message.
It's time for a new signature.
|
|
|
|
|
Hello all,
I'm injecting my DLL (Hooking) to explorer.exe using CreatRemoteThread, Now this works fine in windows XP but when i tried in Windows Server 2003, CreateRemoteThread fails with error code 5 (Access Denied), What permission do i need to set?
#include "windows.h"
#include "stdio.h"
#include <tlhelp32.h>
#include <shlwapi.h>
BOOL Inject_DLL(DWORD dwID)
{
HANDLE hToken = NULL;
HANDLE hProc = NULL;
HANDLE hThread = NULL;
BOOL bReturn = FALSE;
BOOL bLibLoaded = FALSE;
BOOL bWriteCheck = FALSE;
char szErrBuff[MAX_PATH] = "";
char szDllFolder[2 * MAX_PATH] = "";
char szDllPath[2 * MAX_PATH] = "C:\\DelDll\\DetourExample.dll";
void* pLibRemote = NULL;
HMODULE hKernel32 = NULL;
DWORD err = 0;
TCHAR szTemp[MAX_PATH] = "";
DWORD dwDesiredAccess;
TCHAR szError[MAX_PATH] = "";
dwDesiredAccess = PROCESS_CREATE_THREAD |
PROCESS_QUERY_INFORMATION |
PROCESS_VM_OPERATION|
PROCESS_VM_WRITE |
PROCESS_VM_READ;
hProc = OpenProcess(dwDesiredAccess, FALSE, dwID);
if(hProc == NULL || hProc == INVALID_HANDLE_VALUE)
{
MessageBox(NULL, "Cannot Open Process", "Error", MB_OK);
printf("Cannot Open Process\n");
goto Cleanup;
}
hKernel32 = GetModuleHandle("Kernel32");
if(hKernel32 == INVALID_HANDLE_VALUE || hKernel32 == NULL)
{
hKernel32 = LoadLibrary("Kernel32");
if(hKernel32 == INVALID_HANDLE_VALUE || hKernel32 == NULL)
{
MessageBox(NULL, "Cannot Load Kernel", "Error", MB_OK);
printf("Cannot Load Kernel32");
goto Cleanup;
}
else
{
bLibLoaded = TRUE;
}
}
pLibRemote = VirtualAllocEx(hProc, NULL, sizeof(szDllPath), MEM_COMMIT, PAGE_READWRITE );
if(pLibRemote == NULL)
{
MessageBox(NULL, "Virtual Alloc Failed", "Error", MB_OK);
printf("Virtual Alloc Failed\n");
goto Cleanup;
}
bWriteCheck = WriteProcessMemory(hProc, pLibRemote, (void*)szDllPath, sizeof(szDllPath), NULL );
if(bWriteCheck == 0)
{
MessageBox(NULL, "WriteProcess Memory Failed", "Error", MB_OK);
printf("WriteProcessMemory Failes\n");
goto Cleanup;
}
hThread = CreateRemoteThread( hProc,
NULL,
NULL,
(LPTHREAD_START_ROUTINE)GetProcAddress(hKernel32,"LoadLibraryA"),
pLibRemote,
NULL, NULL);
if(hThread != INVALID_HANDLE_VALUE && hThread != NULL)
{
WaitForSingleObject( hThread, INFINITE );
bReturn = TRUE;
}
else
{
DWORD err = GetLastError();
TCHAR szTemp[MAX_PATH] = "";
sprintf(szTemp, "CreateRemoteThread Failed, Error = %d", err);
MessageBox(NULL, szTemp, "Error", MB_OK);
}
Cleanup:
if(hThread != INVALID_HANDLE_VALUE && hThread != NULL)
{
CloseHandle(hThread);
hThread = NULL;
}
if(pLibRemote)
{
VirtualFreeEx(hProc, pLibRemote, sizeof(szDllPath), MEM_DECOMMIT);
pLibRemote = NULL;
}
if(hProc != INVALID_HANDLE_VALUE && hProc != NULL)
{
CloseHandle(hProc);
hProc = NULL;
}
if((hKernel32 != INVALID_HANDLE_VALUE && hKernel32 != NULL) && bLibLoaded)
{
FreeLibrary(hKernel32);
hKernel32 = NULL;
}
return bReturn;
}
int main()
{
BOOL bReturn = FALSE;
bReturn = Inject_DLL(3188);
return bReturn;
}
Thanks.
|
|
|
|
|
Use GetLastError[^] to determine the error code
I am a HUMAN. I have that keyword (??? too much) in my name........
_AnsHUMAN_b>
|
|
|
|
|
thats what gothic_coder already told:- CreateRemoteThread fails with error code 5 (Access Denied) ![Hmmm | :|](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_line.gif)
|
|
|
|
|
I would expect that you need to request administrator privileges to run this under Vista and beyond. As a simple test right click your exe file and select "run as administrator" to see if it works. If so then add administrator privilege to your manifest.
It's time for a new signature.
|
|
|
|
|
Some times you need to just have Debug Privileges to inject a DLL into another process when you get the "access denied". So, just grant yourself Debug Privileges.
I have done this on vista 32bit with no problems.
Problems come in with the same code in 64bit versions.
|
|
|
|
|
Thanks all,
Yes some other techie guys told me to raise the privileges, But doing that also won't make difference, Here's what i'm doing..
BOOL EnablePriv(LPCSTR lpszPriv)
{
BOOL bRet;
HANDLE hToken;
LUID luid;
TOKEN_PRIVILEGES tkprivs;
ZeroMemory(&tkprivs, sizeof(tkprivs));
if(!OpenProcessToken(GetCurrentProcess(), (TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY), &hToken))
return FALSE;
if(!LookupPrivilegeValue(NULL, lpszPriv, &luid)){
CloseHandle(hToken); return FALSE;
}
tkprivs.PrivilegeCount = 1;
tkprivs.Privileges[0].Luid = luid;
tkprivs.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
bRet = AdjustTokenPrivileges(hToken, FALSE, &tkprivs, sizeof(tkprivs), NULL, NULL);
CloseHandle(hToken);
return bRet;
}
|
|
|
|
|