|
It's the operating system who load the program to memory, not program itself. You can appoint a base address when you compile a program. System try to load program on that address, if failed, it load program by it's own rule.Access other process's memory also has it's own rule. I suggest you read about the book <<programming applications="" for="" microsoft="" windows="" fourth="" edition="">> by Jeffrey Richter.I thought there you can find the answer you want.
Thinking in difference!
|
|
|
|
|
Thanks. I do know that the OS tries to place the program first then to the program. I am just wondering if the WINAPI or something in C++ allowed for finding where a program was loaded. For example, I want to find out where Minesweeper is loaded into memory so I can try to read its memory block and figure out what tiles are bombs. That is what I am aiming to do. I will try to find that book and see if it can yeild what I am looking for... given I am not exactly sure what the code will be that I want.
Thanks again.
|
|
|
|
|
There's an MSDN article titled "Minimizing the Memory Footprint of Your Windows CE-based Program" by Douglas Boling that might give you some clues. See the "An Application's Address Space " section. I did not look to see what API was used.
|
|
|
|
|
I still cant get this frickn' CTreeCtrl to insert a line...
m_cSlidOpen->m_ctrlXMLTree.InsertItem(m_strSectionName);
Where as m_cSlidOpen is the class varible to the class that contains the tree control, m_ctrlXMLTree, (this is because the current class is doing all the parsing), my program crashes when ever it gets to this... m_strSectionName is a valid CString.
How do I fix this.. i've tried adding in TVI_ROOT and it still does this
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Did you try something like this?
TV_INSERTSTRUCT tv_is;<br />
<br />
tv_is.hParent = TVI_ROOT;<br />
tv_is.hInsertAfter = TVI_LAST ;<br />
tv_is.item.mask = TVIF_TEXT;<br />
tv_is.item.pszText = m_strSectionName.GetBuffer(1);<br />
tv_is.item.cchTextMax = m_strSectionName.GetLength();<br />
<br />
HTREEITEM hItem = m_ctrlXMLTree.InsertItem(&tv_is);
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
Thank you it stop it from crashing.
I tired that but now its not updating the tree control even after a UpdateData(FALSE);
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
Hi friends,
How can i handle hardware interrupts in win2k?
|
|
|
|
|
Greetings
I have a command line tool and I want to provide a GUI interface to schedule the tool to perform its job. Now the problem is how do you I invoke the Query Interface wizard thru API? I can create a test sample job using the following code but I am unable to start the wizard so that the user can set it times directly thru my app.
Thanks in advance.
ITaskScheduler * sITS;
HRESULT InitTSAPI()
{
HRESULT hr = S_OK;
_ASSERTE ( SUCCEEDED(CoInitialize(NULL)) ); // init COM
if (SUCCEEDED(hr)) {
hr = CoCreateInstance(CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER, IID_ITaskScheduler, (void **) &sITS);
if (FAILED(hr)) {
return hr;
CoUninitialize();
}
}
return hr;
}
HRESULT CreateTask ( WCHAR * pTaskName )
{
HRESULT hr = S_OK;
ITask * task = 0;
IPersistFile * pFile = 0;
hr = sITS->NewWorkItem( pTaskName, CLSID_CTask, IID_ITask, (IUnknown**)&task );
if ( FAILED ( hr ))
return hr;
hr = task->QueryInterface(IID_IPersistFile, (void **)&pFile);
task->Release();
hr = pFile->Save ( NULL, TRUE);
_ASSERTE ( SUCCEEDED ( hr ));
pFile->Release();
return S_OK;
}
void main()
{
InitTSAPI();
CreateTask(L"Test Task");
sITS->Release();
}
|
|
|
|
|
Hi all
I know that in win32 access to GUI objects from another thread is a bad thing. I can't understand why...
If, for instance if have an edit box created in the main thread A
and I try to this from thread B:
EditBox.GetWindowText(...);
what can be wrong here?
the GetWindowText will send WM_GETTEXT message to the window in thread A
and thread and A will dispatch it and call control's WinProc, isn't it?
|
|
|
|
|
It's only bad in MFC, because of how MFC keeps track of the associations between C++ objects and GDI handles. If you do anything more complicated than sending a message, MFC will assert all over the place.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated Aug 30!
|
|
|
|
|
Can you add some more info about this?
thanks?
|
|
|
|
|
Hi!
I think WM_GETTEXT should solve your problem
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowMessages/WM_GETTEXT.asp
Use SendMessage
mfg
|
|
|
|
|
Sending messages can result in a deadlock situation. Read more about this from http://www.flounder.com/uithreads.htm and http://www.flounder.com/workerthreads.htm.
|
|
|
|
|
Because of the potential for deadlock situations.
Thread 1 creates Window 1
Thread 2 creates Window 2
Thread 1 calls Function 1 that eventually calls GetWindowText(Window2) which causes a blocking SendMessage() call.
at the same time ...
Thread 2 calls Function 2 that eventually calls GetWindowText(Window1) ...
(of course it could be anything that generates a SendMessage() or causes the thread to block)
So :
- Thread 1 enters Function 1
- Thread 2 enters Function 2 everything is cool
- Function 1 calls SendMessage(Window1) which blocks becuase Thread 2 isn't pumping messages as it is in Function 2
- Function 2 calls SendMessage(Window2) which blocks becuase Thread 1 isn't pumping messages as it is waiting on SendMessage(Window1)
It's very easy for the above to occur without carefull thought to window/thread interaction - that's why it's a bad thing.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hello,
It's probably a stupid question but how do you create a binary file with CreateFile? But the file must be scrambled so when you open it (in notepad for instance) you can't read (or manipulate) the data.
Thanks in advance,
Tom
|
|
|
|
|
Encrypt and sign the file.
The topic of encryption and cryptographic signatures is a bit big for me to explain in a couple of lines of text so look around for some tutorials on the net... Good luck!
|
|
|
|
|
I am looking for imformation that someone without a PHD in math can use to implement a spectrum analyzer in C++. I am trying to use the Fast Fourier Transform to create a spectrum analyzer. I cannot seem to find any info that I can understand.
What I know is that there are many FFT implementations out there but do you apply it to my problem?
I want to use a samplng rate of 44100 Hz and or 48000 Hz.
I believe I should use a 1024 samples
I believe I want a spacing of 100 Hz
I just need some direction.
Thanks,
Steve
|
|
|
|
|
OK, here's the basic facts. There's a well known signal theory theorem stating that the most signifcant frequency computed by an FFT is half the sampling rate (google for Nyquist frequency for further info). Assuming that you're sampling at 48 kHz, that means that the maximum frequency obtained after FFT is 24 kHz. We denote this maximum frequency as fs. Now, suppose you compute the transform in 1024-sample chunks. Then the output of the FFT routine is a 1024-point chunk of frequency components in the range [-fs, fs). The spacing between frequency points is thus 2fs/1024 = 46.875 Hz. Considering that you want 100 Hz precision, you'd only actually need 512-sample chunks (giving 93.75 Hz resolution).
Additional issues to keep in mind:
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Beware
in many cases the fft return complex numbers.
|
|
|
|
|
you basically need to take the magnitude of the fft,,
try matlab, its very easy
you just need a series of number, and then type
y=fft(funcation, );
and then,, take the absolute value of it
x= abs(y);
take an introductory signal analysis book,, its very easy
done
Ehsan Behboudi
|
|
|
|
|
Joaquin,
Thanks for your timely response. I believe that I am following your explanation.
I do have several questions though.
1) With the sample rates you used in your example are you implying that the sample rate
should be base 2.
I believe that the typical range of human hearing is 20k to 20,000kHz.
2) So, if I want to display lets say 64 bars(samples??) to represent the sound starting from
20hz to 20,000kHz how does this work? Do I just select the frequencies that I want from the
fft calculation?
Thanks,
Steve Messer
|
|
|
|
|
1) With the sample rates you used in your example are you implying that the sample rate should be base 2.
No. In the example the sampling rate f2 is 48,000, which certainly is not a power of 2. What should be a a power of two is the size of the chunks passed to the FFT routine --some FFT libraries do not impose this restriction, but even so there're efficiency advantages in doing it that way.
2) So, if I want to display lets say 64 bars(samples??) to represent the sound starting from 20hz to 20,000kHz how does this work? Do I just select the frequencies that I want from the fft calculation?
Not exactly, you've got to do some postprocessing in order to get something with physical meaning. Let's do the planning:
1. As your maximum frequency is 20 kHz then fs must be at least 40 kHz. It is a good idea to have it a little higher to reduce the aliasing, so 48 kHz seems a good choice --plus, many sound formats come sampled at this very frequency. So, your maximum frequency is 24 kHz and you want 20 Hz resolution. This gives 48,000/20 = 2400 for the size of the chunks. If your FFT routine accepts this size, you're done. If not, then choose the next power of 2 (4096).
2. as you already know, FFT outputs values in the [-fs,fs), range, so it is giving you results for negative frequencies. Also, FFT values are complex numbers, with imaginary as well as real part. This has little physical meaning, so most spectrum analyzers display the energy of the signal as a function of frequency, which is more easily understandable by a human user. So, if we write X(f) for the FFT at frequency f, the energy of the function is
E<sub>X</sub>(f) = |X(f)|<sup>2</sup> + |X(-f)|<sup>2</sup> where |·| is the complex absolute value function (also called modulus). This operation "folds" the negative frequencies into the positive axis, so you only have now positive frequencies and real values (energies), which is fine.
3. Finally, the frequency bands you want to display are not evenly spaced, but they follow an exponential distribution from 20 Hz to 20 kHz. This is fine, as it models the perception system of the human ear. But the FFT gives evenly spaced frequency values (or energies, if you applied the transformation above). To transform from what you've got to the exponential bands, just group the energy points in frequency bands around the frequencies of interest (higher frequencies will get more points) and sum their energies for each band.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín,
RE: 1) Sorry, I mean't base 2 on the size of the chucks but thanks for pointing it out.
RE: 2) Explicado muy bien. Gracias.
RE: 3) You mention picking frequencies of interest. None are particularly interesting to me ,
seriouly is there a techique or formula for picking these points of interest?
New 1) If you want to display the right and left channel at the same time having calculated them
separately do you just average them together?
Muchas gracias Joaguin. De donde está usted?
hasta la vez próxima
Steve
|
|
|
|
|
RE: 3) You mention picking frequencies of interest. None are particularly interesting to me,seriouly is there a techique or formula for picking these points of interest?
Well, frequency spectrums come in two flavors:
- linear: points in the x-axis are evenly spaced (with respect to frequency).
- logarithmic: points in the x-axis are not evenly spaced (like 10 Hz, 20, Hz, 30, HZ, etc.) but on an exponential fashion: for instance, 101 Hz, 102=100 Hz, 103=1000 Hz, etc.
Why the second style (called logarithmic scale)? Many systems, including the human ear, perceive exponentially distributed frequencies as being "perceptually" distributed in an uniform scale. For instance, the musical note C0 has a frequency 16.35 Hz, C1 is at 2·16.35=32.70 Hz, and C2 is at 4·16.35=65.40 Hz, although they "sound" as evenly distributed. Got the idea?
If you want to write a logarithmic spectrum displayer, the problem is that FFT outputs results in a linear scale. To transform to logartichmic you have to do some math in order to compute the different exponential bands and group all points inside a band into a single sample (suming their energies as described in my previous post).
Apart from this, no frequency is regarded as specially important. Go find an electronic spectrum analyzer (like the one in your music equipment) and use those values, for instance.
New 1) If you want to display the right and left channel at the same time having calculated themseparately do you just average them together?
I guess you mean the right and left channel of a stereo signal. The proper way to add them is by suming their energies is
Total = sqrt(Right<sup>2</sup>+Left<sup>2</sup>).
Muchas gracias Joaguin. De donde está usted?
De España. Suerte con tu proyecto,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín,
Las gracias, usted ha sido el más provechoso. Era misionario en Madrid hace aproximadamente 13 años. Estuve en Talavera de la Reina, Getafe, Torrejon, y algunos otros lugares. Bien, sido un placer que hablar con usted.
Haz bien y no mires a quien,
Steve
PS: Sorry for my poor spanish spelling it has been a while.
|
|
|
|
|