|
carrie wrote:
I've been asked to write a program that will start another program up and then log all calls it makes to WriteProcessMemory() and any changes it makes to its variables.
What value can you get out of this output, seriously curious here. Is the idea to detect memory flaws in a programs process? How do you analize this?
Nick Parker
|
|
|
|
|
Maybe something like BoundsChecker would work for you.
When someone asks you for the impossible maybe it's time to ask them what they really want.
Todd Smith
|
|
|
|
|
hehe, thanks for all the help guys, more pointers are always welcome
My program would be starting the other process up so I'll take a good look at hooks(thanks). The main reason for doing it is because there is a group of us working on a set of programs. We're all students and bored doing the usual 2nd year programming stuff so we're writing some other games and apps and taking requests from local businesses for fun.
Just now the way we work it is that we have everyone send in the executables once they're finished their programs but we're trying to get this program and the ftp site-to-site program up and running to make life easier. Because we don't send the sources around we like to be able to check that our programs are working on others machines as well so we can then pass them on.
Anyway, thanks for the tips and keep them coming if anyone knows the solution to my CFtpConnection::Command problems feel free to help
|
|
|
|
|
What does that mean? The messagebox appears and it goes into assembly debugging, i'm trying to enumerate all the available compression driver on the system, here's the code:
void onConvert()
{
acmDriverEnum((ACMDRIVERENUMCB)listCallback, NULL, ACM_DRIVERENUMF_DISABLED);
}
BOOL WINAPI listCallback(HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport)
{
if (fdwSupport == ACMDRIVERDETAILS_SUPPORTF_CODEC)
{
ACMDRIVERDETAILS details;
int box;
int test;
details.cbStruct = sizeof(details);
box = acmDriverDetails(hadid, &details, NULL);
SendMessage(GetDlgItem(ghWnd, IDC_CODECS), LB_ADDSTRING, 0, (LPARAM)details.szLongName);
}
return true;
}
First i call the onConvert and then it uses the listCallback function to enumerate the different drivers.
Thanks in advance
-Redeemer
|
|
|
|
|
Hm...
- Did you placed a breakpoint on the very first statement of your listCallback?
- The cast to ACMDRIVERENUMCB for the first parameter to acmDriverEnum() should not be necessary. If the compiler complains about it, there is something wrong.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
I have a dll that I would like to embed in an exe so I only have to distribute one file with out extracting. Is there a way to put the dll in the exe and still be able to access its functions?
Thanks,
Clint
|
|
|
|
|
you could attach it to the end of the EXE and extract it at runtime, then use LoadLibrary/GetProcAddress to access the functions.
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
I was hoping to avoid making a temp file. Are there any other ways or is this pretty much the only way?
If this is the only way how does one extract a dll? I am still learning how resources work, over and above icons.
|
|
|
|
|
i don't think it's the only way, but it might be the only way without getting into some serious low level stuff.
you could put it in a resource, sure. that would be the most VisualStudio-friendly way. it would take about ten lines of C (plus error checking) to get the DLL out of memory and into a file - no big deal.
or, you could concatenate the DLL onto the end of the EXE, using an external app, with a length DWORD at the very end, so you know how many bytes to extract from the EXE. this method is trickier and might not be worth the effort. the resource method is probably safer.
HRSRC hRsrc = FindResource(hInstance, pName, "DLL");
if (hRsrc)
{
HGLOBAL hGlobal = LoadResource(hInstance, hRsrc);
if (hGlobal)
{
BYTE *pDLL = (BYTE *)LockResource(hGlobal);
DWORD dwSize = SizeofResource(hInstance, hRsrc);
... now open a file, and write the dwSize BYTEs starting at pDLL to a file.
UnlockResource(hGlobal);
FreeResource(hGlobal);
...
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
Thanks, it doesn't look too hard.
Cheers,
Clint
|
|
|
|
|
One more tip:
If you link to your dll with delay loading, you do not have to trickle with GetProcAddress() and can also easily export/import classes.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
What do mean about delay loading? Did you mean runtime linking? Any examples?
|
|
|
|
|
when you build the DLL, it will build a .LIB file that contains stub function calls. if you link to this .LIB, it will handle the LoadLibrary/GetProcAddress stuff for you - you just call the DLL functions as if they were from a static library.
there may be some compiler switch necessary to enable the creation of this .LIB, but it's an easy one to find, IIRC.
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
Link to the DLL (means link to the .lib file of the DLL) as if you want to load it implicitly. Pass a /DELAYLOAD:MyDLL.dll command line switch to the linker.
In this case the linker does not really link the dll as implicit loaded, but provides stubs for all DLL functions. Loading of the dll is delayed until the first call to the dll.
This gives you the possibility to unpack your DLL from the resource to disk before you call it first time. Otherwise (if linked implicitly) the loader will complain about "MyDLL.dll could not be found".
Delay loading is explained in detail in the VC docs and in tons of MSDN articles.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Place your dll in with the resource data of your application. Inclusion is straightforward: place your dll in the source directory of your application, and add the following line to your .RC file:
<br />
DATNT BINRES MOVEABLE PURE "NAMEOFYOURDLL.DLL" <br />
Now, within the initialization of your application, load the resource and write it out to a temporary file.
<br />
HRSRC hRsrc;<br />
HGLOBAL hResource;<br />
DWORD dwSize; <br />
LPVOID lpvDll;<br />
HFILE hfTempFile;<br />
•<br />
•<br />
•<br />
<br />
hRsrc = FindResource(hInst,MAKEINTRESOURCE(DATNT),"BINRES");<br />
<br />
hResource = LoadResource(hInst, hRsrc);<br />
dwSize = SizeofResource(hInst, hRsrc);<br />
lpvDll = LockResource(hResource);<br />
<br />
hfTempFile = _lcreat("tempname.tmp",0);<br />
_hwrite(hfTempFile, lpvDll, dwSize); <br />
_lclose(hfTempFile);<br />
At this point, you'd dynamically load your dll. Once it is loaded, you can safely delete the temporary file.
|
|
|
|
|
A couple of commercial options:
Dll to Lib http://www.binary-soft.com
Fusion http://www.bit-arts.com (although I'm having problems with their site)
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
|
FILE *fp;
fp = fopen(filename, mode);
fclose(fp);
There are open file but
I would like to know the instruction showing directory list.
somebody help me... thank a lots
|
|
|
|
|
see FindFirstFile and FindNextFile
also, there are a number of classes on this site that encapsulate this operation
-c
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
I can't find FindFirstFile() and FindNextFile. Please tell me URL that is the example for FindFirstFile() and FindNextFile,.... Thank
|
|
|
|
|
here is a C++ wrapper for FindFirstFile/FindNextFile :
http://www.codeproject.com/file/sadirread.asp
but, you can find information about these functions in the MSDN
Conservative:
One who admires radicals centuries after they're dead.
-- Leo C. Rosten
|
|
|
|
|
I'm making a list of all the available audio decoders in the system by calling acmDriverEnum , but i get some compile errors that i can't figure out how to get rid of, here's the callback prototype:
BOOL ACMDRIVERENUMCB listCallback(HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport);
and here's the callback function (not finished yet, i just want it to compile):
BOOL ACMDRIVERENUMCB listCallback(HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport)
{
if (fwdSupport == ACMDRIVERDETAILS_SUPPORTF_CODEC)
{
ACMDRIVERDETAILS details;
acmDriverDetails(hadid, &details, 0);
}
}
these are the compile errors i get:
<br />
e:\mp3organizer\convertaudio\main.h(5) : error C2146: syntax error : missing ';' before identifier 'listCallback'<br />
e:\mp3organizer\convertaudio\main.h(5) : error C2377: 'ACMDRIVERENUMCB' : redefinition; typedef cannot be overloaded with any other symbol<br />
e:\program files\microsoft visual studio\vc98\include\msacm.h(250) : see declaration of 'ACMDRIVERENUMCB'<br />
e:\mp3organizer\convertaudio\main.h(5) : fatal error C1004: unexpected end of file found<br />
All help appreciated, thankyou.
|
|
|
|
|
Without taking a look at the code in MSDN or windows headers, I assume that ACMDRIVEREENUMCB is the typedef for the callback function type. (The type for a pointer to the callback function.)
Try BOOL WINAPI myCallback (HACMDRIVERID hadid, DWORD dwInstance, DWORD fdwSupport) instead of.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
|
I need to send key strokes to another process, which is a directx exculsion mode program.
I have tried use keybd_event but only the first time is successful. So I guess maybe it will need another way to send keyboard data to the application, maybe fill the keyboard's buffer directly? or something else.
I'm keen to find out the solution. If you have any comment or suggestion, please let me know.
My mail is davihigh@yahoo.com.cn
Thank you!
|
|
|
|