|
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
|
|
|
|
|
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)
|
|
|
|
|
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;
}
|
|
|
|
|
Hi!
I've a vector of strings. I've to pass the strings in the vector to a function and there I've to replace some of the characters in the string. I've to return the rearranged string and store it in an array. I used the following code to do this:
stringc swapChars(stringc& str1)
{
std::string str(str1.c_str());
std::string strChar;
std::string strChar1;
int length = str.size();
stringstream ss;
stringstream ss1;
char chr =65 + rand() % 26;
char chr1 = chr;
ss << chr;
ss >> strChar;
str.replace((int)length/3,1,strChar);
while(chr == chr1)
{
chr = 65 + rand() % 26;
}
chr = chr + 32;
ss1 << chr;
ss1 >> strChar1;
str.replace((int)length*2/3,1,strChar1);
return str.c_str();
}
Above is the function where I'm rearranging the string. This is how I'm calling the above function:
vector<stringc> players;
array<stringc> nameFirstPart,nameSecondPart;
unsigned int t = time(NULL);
for(register int i = 0; i<players.size()-1; i++)
{
srand(t);
nameSecondPart.push_back(swapChars(players[++i]));
t++;
}
This is where i'm printing the string:
for(register int k = 0; k < nameSecondPart.size(); k++)
{
printf("%s \n",nameSecondPart[k].c_str());
}
While printing the strings I get unexpected and irrelevant strings or characters in between. Why it comes like this? How to avoid this?
|
|
|
|
|
T.RATHA KRISHNAN wrote: unexpected and irrelevant strings or characters in between
What do you intend, exactly?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|