Making two infinate loops inside the other?
Hello, I am creating a program that opens and closes your CD drive repeatedly, and fixes your mouse position. I have created an initial while condition that loops the opening and closing of the drive. I was wondering how I can introduce a second infinate loop, fixing the position of the mouse. Using SetCursorPos( X, Y ); I want to make sure that the user has his mouse fixed, so he can't move it. Placing this line of code after the device eject or load function still gives the user enough time to close the application.
Thank you.
*SP* infinite
while(1)
{
DWORD d = 0;
DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
}
CloseHandle(hcd);
return 0;
}
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
Pray tell, why should we offer assistance toward something that sounds malicious?
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
I'm not planning on releasing this commercially, I only plan to see its cause and effect, the programming interests me.
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
Well, I've yet to purchase a virus, so color me unimpressed.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Two nested infinite loops? Is that what you'd call an alpha loop?
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Not sure, do you have any ideas?
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
It's a joke. Google around "infinity" and "cardinality".
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
Ok, I understand this is potentially malicious, but I AM really not planning on releasing this to people or to any external sites. I just would like to know how to run a second loop inside the other, whilst continuing the other one.
Like most people who do this sort of thing, I'm not stupid enough to do so.
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
Why would you need to nest infinite loops? Are you saying you want to execute 2 statements as part of a loop, and execute more statements as part of the same loop? Well, add another statement following the first two in the same loop.
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
I can't, because if I do the below, it opens the drive, then stops on the looped cursor position.
while(1)
{
DWORD d = 0;
DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
while(2)
{
SetCursorPos( X, Y );
}
DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0,
&d, NULL);
}
What should I do?
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
Does this sort of thing make sense:
while ( 1 )
{
// PART A
DWORD d = 0;
DeviceIoControl(hcd, IOCTL_STORAGE_EJECT_MEDIA, NULL,
0, NULL, 0, &d, NULL);
DeviceIoControl(hcd, IOCTL_STORAGE_LOAD_MEDIA, NULL,
0, NULL, 0, &d, NULL);
// PART B
SetCursorPos( X, Y );
}
Dave Sinkula
long time no c
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
Nearly, I tried that myself. I'll explain:
When the drive loads, this sets the mouse position, then it gives the user time to react by closing the window, before the drive loads again. You see? And yes, even giving this condition after the ejection still doesn't suffice.
I want them both to be running at the same time constantly.
On that note, is it possible to hide the command window? This would suffice...
cosmos22
Junior Poster in Training
80 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0