dll not working...

I have dll file with hook on windows openings and title change.
the main program start this hook and after check data file for saved data from this dll file. the saving is in SaveData function.

THE PROBLEM. the program work correctly some time, but after some time it stops. the SaveData function don't save data. the effect like hook stoped. maybe in dll file is some error that stops it ???? please help me to find out this problem.

hello andrezzz, , I will first say that I do not think your version of the hook callback function has the correct parameter Types, This is a system function and all of the parameters should be 32 bit. . . you have -

and I beleive it would be better coding methods to NOT do file access in your Hook DLL, all of the DLLs are runing in separate processes, if there is simulanious access to a file from two different processes, then there is conflick

I would post a message to the Calling program of the hook (your program), with the Lparam and wParam of the hook function and then do all the file access from a single thread (your program)

0

andrezzzAuthor Commented: 2005-05-04

can you explane this :
I would post a message to the Calling program of the hook (your program), with the Lparam and wParam of the hook function and then do all the file access from a single thread (your program)

can you give one simple example ?

0

andrezzzAuthor Commented: 2005-05-04

in main program i have
Procedure RunStopHook(State : boolean) stdcall;
external 'sdf.dll' index 1;
in form create i have RunStopHook(true); which start the hook

----------------------------------------
when programs runs about 10 minits sudednly it stops hooking. when i press button start hook wich have StartStopHook(true); then nothing happens, but if I press STOP hook button and after START hook button (stop hook calls StartStopHook(false) and Start hook button calls StartStopHook(true)) then hook resume his work. why it stops suddenly ??? and after stoping and starting it, it starts again

Here is my code for my version of a Shell Hook, I use a Memory Mapped file to to hold the Form's handle and a Text buffer for the program's file path, which can be way longer than 255 charaters. I do NOT do any file access in the DLL, I do all file writting in the Form that calles the DLL.

I believe that is all of the code needed, although you may need some other units in your uses clause, but I do not think so. . . . .

I ran this shell hook for more than 30 minutes on a windows XP machine, and it worked for all shell activity the entire time, and did not stop untill I pressed the Stop Hook button. . . .

I noticed that you posted another question here at

dll not working II ....

and got only one comment, I do not beleive that robert_marquardt is correct about the SysHook variable, I have read about and used (in my code above) the

CallNextHookEx(0, Code, hWnd, NotUsed);

I think it should just have a Zero as the System Hook handle, the system Hook handle is old left over requirements from the windows 16-Bit (windows 3.1) days, It seems that the current 32-bit systems are not stupid enough to religh on a dummy coder to return the correct hook handle in order to function right, I would think the current systems are smart enough keep tract of their hooks internally. . .

anyway the Borland Code Central entry 15387 has a working program to "Hack" a Delphi executable and insert a "Shared" memory segment, but you can do it with a Memory mapped file, so you do not really need that