It is possible, but you need to use a process *handle*, not a process ID. Use OpenProcess to get a process handle from a process ID. Don't forget to close the handle later, when you don't need it anymore. Btw, you need admin rights to open a system process.
The trouble is that you shouldn't use the VCL in a hook DLL. Look at the size of your hook dll. It should not get much bigger than 100kb. I bet yours is *much* bigger. It must be, because ShowMessage uses the VCL. The VCL is not thread safe, it's a resource hog and was never intended to be used inside of a hook dll.
Also when talking about WinLogon.exe - that is a system process! You shouldn't show any windows in system processes! Most system processes are non interactive, they are not connected to any visible desktop. So even if you succeed in showing a window, nobody would see it. But some system processes will directly blue screen your OS if you show a window inside of them. You must not even use FindWindow and such GUI APIs in some system processes. Have a look here:
ok but , same thing with only a sleep(20000);
winamp freeze while 20s and the dll is only 14k.
sleep cmd is not allowed too? maybe i do something wrong
Everytime a DLL gets loaded, this is a special moment for the process. During that moment some things may not work. So if you do a Sleep(20000) in the DLL's initialization, this might freeze the target process.
Why do you want to put a Sleep in your DLL's initialization? That doesn't make much sense to me...
the sleep function is just a test with the most basic dll , to be sure the trouble is not the dll like you said. i just try with this dll to understand why it freeze.
the dll i want to inject is just an irc bot with little functions . (~100ko)
Well, your freeze test should teach you one thing (so it was a good test), namely: In the initialization of your dll only do what is necessary. Try to do the main work outside of the initialization phase. If you just want to hook some APIs, that is no problem, because installing the hooks is quite fast. If you want to create windows and such stuff, you need to create your own private thread for that.
ok , so that is my error
i m noob in prog , and im not familiar with the difference between the initialization part and outside this part .
So i will looking for how to make a dll proprely