| View previous topic :: View next topic |
| Author |
Message |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Wed Aug 29, 2012 1:15 am Post subject: C++ Timer and Forms? |
|
|
Iv been messing with C++ for the past week but iv yet to get something working.
Im creating a blank dll project but i need to programmatically create a timer and populate a form.
SetTimer works but this isnt what im after.
Anyone know?
I made a version in C# that im trying to do the exact same thing in C++;
Looks like this and works fine. I know you'l be thinking why am i doing it like this. Why wouldnt i just create a thread and keep it open with a loop.
I have my reasons and this method works pefect for what i need, so bare with me.
DllMain
| Code: | public static int DllMain(String arg)
{
MakeTimer(HackTimer, 50);
KeepAlive();
return 0;
} |
The timer
| Code: | static void MakeTimer(EventHandler timed, int Intervals)
{
System.Windows.Forms.Timer TM = new System.Windows.Forms.Timer();
TM.Interval = Intervals;
TM.Start();
TM.Tick += new EventHandler(timed);
} |
Form
| Code: | static void KeepAlive()
{
Form Fm = new Form();
Fm.FormBorderStyle = FormBorderStyle.None;
Fm.Size = new Size(0, 0);
Fm.ShowInTaskbar = false;
Fm.BackColor = Color.LimeGreen;
Fm.TransparencyKey = Color.LimeGreen;
Application.Run(Fm);
} |
_________________
|
|
| Back to top |
|
 |
n0 m3rcY Cheater
Reputation: 0
Joined: 18 Jun 2012 Posts: 42
|
Posted: Thu Aug 30, 2012 2:08 am Post subject: |
|
|
| You could always just create a different thread in a loop and have a pointer to a boolean as a parameter, then just while(bool) loop with a sleep() at the end of the loop and kill the thread when you're done.
|
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Thu Aug 30, 2012 6:06 am Post subject: |
|
|
Iv already tried this method. That works for a normal process but this process is killing the thread.
Creating a loop to force the thread to stay open is killed too. Well not killed but forces the process to close.
The timer method in my C# dll works perfect and doesnt get killed but i have no idea how to do the same in C++.
Iv tried SetTimer but that gets killed. Iv tried loading a form in the background with a timer but that gets killed.
In my C# dll, if i only create the timer, it gets killed but for some reason, creating a form after the timer keeps it open.
Im trying everything but the only method i know that works is in C# fudge.
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25814 Location: The netherlands
|
Posted: Thu Aug 30, 2012 6:23 am Post subject: |
|
|
Have you tried spawning another thread from your thread, and in that newly spawned thread do everything and let the original one just die
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Thu Aug 30, 2012 11:00 am Post subject: |
|
|
| Dark Byte wrote: | | Have you tried spawning another thread from your thread, and in that newly spawned thread do everything and let the original one just die |
Yea i tried that too, both threads die even with an inf loop. I thought that would work but same result.
The only thing that works so far is the method iv done in C#.
Im gonna do some reading and see if i can trick the process into thinking the thread was terminated.
Cause if i use an inf loop, the process knows this and terminates itself.
If i can fake the return value, maybe it'l stay open. Not sure if thats even possible but im gonna give it a go.
_________________
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25814 Location: The netherlands
|
Posted: Thu Aug 30, 2012 1:22 pm Post subject: |
|
|
Have you tried it in a process that isn't protected by nprotect?
If it also happens in another process, it might be because of a compiler optimization (you can turn that off, -O0)
And yes, nprotect has the habbit of destroying threads that haven't been registered properly
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Thu Aug 30, 2012 1:36 pm Post subject: |
|
|
Yea everything is tested on a normal process first, to make sure the code works.
I'v been at it for over a week now, i'll post a solution here if i ever come up with a working method.
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Pingo Grandmaster Cheater
Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Mon Sep 03, 2012 1:59 am Post subject: |
|
|
Just got back from a long weekend so sorry for the late reply.
No reason Wiccaan, im just trying anything.
I think i tried a threading class, cant remember. I'll go read over the docs you linked.
Yea i know the timer needs to be created in a window, i tried that too.
_________________
|
|
| Back to top |
|
 |
|