9 Replies - 21504 Views - Last Post: 28 March 2012 - 12:05 AM Rate Topic: -----

#1 ILIKECPP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 14-October 08

Hiding the console window

Post icon  Posted 05 December 2008 - 04:18 PM

Hey
I have this code for an annoying little beeper program:
#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;

int main(void)
{

    beeper:
    cout << "\a";
    Sleep(200);
    cout << "\a";
    Sleep(200);
    cout << "\a";
    Sleep(200);
    cout << "\a";
    Sleep(200);
    cout << "\a";
    Sleep(10000);
    goto beeper;
}


My question is, how can I hide the actual console window? So it only shows up in the Task Manager processes window? I tried FreeConsole() and that hid it, but it also stopped the beeps. Help please?

Thank you,
Mike

Is This A Good Question/Topic? 0
  • +

Replies To: Hiding the console window

#2 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Hiding the console window

Posted 06 December 2008 - 07:00 AM

Use the ShowWindow() API Function.
Was This Post Helpful? 0
  • +
  • -

#3 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: Hiding the console window

Posted 06 December 2008 - 07:25 AM

View Postborn2c0de, on 6 Dec, 2008 - 06:00 AM, said:

Use the ShowWindow() API Function.


This will work with a console application? I'm reading the specs now and it looks like it requires a full windows application.
Was This Post Helpful? 0
  • +
  • -

#4 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: Hiding the console window

Posted 06 December 2008 - 07:32 AM

BTW for implementing your program as a good little tormenter I would suggest just having one or two beeps go off then have it sleep for a random amount of time between two variables that would equal anywhere from 5 to 15 minutes. :evil:

There are little gadgets you can buy from the online tech geek sites that have a little circuit board with a wicked little speaker on it that you can set for random beeping and I think they have a magnet on the board so u can attach it almost anywhere. The sound has the right freq so you can't tell where it is coming from and ppl can never find em, drives em insane apparently.

If this is what you are trying to do and you have this beep too often in a row it may push someone over the line where they just reboot (u might have this covered) or even just reload the computer. Less is more, and subtle is much less!

BTW I like your idea, I wonder if someone could make a viri that is no more harmful than to install maddening little noise makers like this Hmmm? muhahaha...
Was This Post Helpful? 0
  • +
  • -

#5 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: Hiding the console window

Posted 06 December 2008 - 07:38 AM

View Postborn2c0de, on 6 Dec, 2008 - 06:00 AM, said:

Use the ShowWindow() API Function.


I found this code here that was compiled as a win32 app to hide a console window. So as long as ilovecpp compiles as a win32 he should be fine right right? You were right it looks like showwindow is the way to do it!

[edit] I just did it as a normal console application without compiling as win32 and it works fine, as expected so no need to go through the extra step if you don't want to.[/edit]

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
int main()
{
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );

return 0;
}


Now just title your executable svch0st.exe and you are all set! :)

Hey, does anyone know how to get a .exe file to call it's process something else when you run it? Is that even possible? Have the beeper program call its process something like svch0st and it would blend in to a lot of ppl.

This post has been edited by badjava: 06 December 2008 - 07:45 AM

Was This Post Helpful? 1

#6 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: Hiding the console window

Posted 06 December 2008 - 08:32 AM

View PostILIKECPP, on 5 Dec, 2008 - 03:18 PM, said:

Hey
I have this code for an annoying little beeper program:


OK I fixed this up a bit for you see what you think. It will wait for 5-60 minutes after the program starts and hides the console window. Then it will fire off the sets of beeps and wait again anywhere from 5 to 60 minutes before it beeps and keeps repeating that cycle.

I am working on version two which will only launch the beep function if it is an even (or odd) numbered day of the month and will only sound off if it is between the hours of 8 am and 5 pm. :evil:

Feel free to tweak the initial lag time, say if u wanted to get further away from the target system before any odd beeping started and the number of beeps u hear at a given time. This was just my artistic impression of what you are working towards.

I'm actually going to install this on my wife's computer right now...

Now we just need a way to get it installed on its own and rename its process! muahahaha

#define _WIN32_WINNT 0x0500
#include <iostream>
#include <time.h>
#include <windows.h>

using namespace std;

int main(void)
{
        
    HWND hWnd = GetConsoleWindow();//hide console, minimizes with no taskbar button
    ShowWindow( hWnd, SW_HIDE );
    
    srand((unsigned)time(0)); //seed rand() for true random number generation

    int random_beep;
    int lowest=5, highest=60; //range of minutes to delay next operation
    int range=(highest-lowest)+1;
    
    int start_lag = 0;
    
    // the example code i grabbed was a roller type, haven't tested it as a
    // single number generator yet but at the worst this will shuffle your
    // random number from 5 to 15 minutes, 3 times  :)/>   
    for(int index=0; index<3; index++){
    start_lag = lowest+int(range*rand()/(RAND_MAX + 1.0));
    }

    start_lag = (start_lag*1000)*60; //convert lag seconds to minutes
    Sleep(start_lag); //pause system for system_lag minutes

    beeper:
    cout << "\a"; // Tell pc to send beep sound
    Sleep(200);   // pause for 200 milliseconds
    cout << "\a"; // Tell pc to send beep sound
    Sleep(200);   // pause for 200 milliseconds
    cout << "\a"; // Tell pc to send beep sound
    Sleep(200);   // pause for 200 milliseconds
    cout << "\a"; // Tell pc to send beep sound

    for(int index=0; index<3; index++){ //generate number of minutes from 5 to 60
    random_beep = lowest+int(range*rand()/(RAND_MAX + 1.0));
    cout << random_beep << "\n";
    }
    
    random_beep = (random_beep*1000)*60;
    Sleep(random_beep); //pause for the last random number of minutes before re-starting beep loop
    goto beeper;
}


This post has been edited by badjava: 06 December 2008 - 08:45 AM

Was This Post Helpful? 0
  • +
  • -

#7 ILIKECPP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 14-October 08

Re: Hiding the console window

Posted 06 December 2008 - 09:32 AM

Thanks for the replies guys, they were really helpful ;)

Also, after a couple more hours Googling about my complier (Dev-C++) I found that I can just force the compiler to not make a console window, and really pissed off my mom by putting this in her startup folder :D

But thanks for the replies, it's good to know how to do stuff by the code and not just compiler-depndant.


:wub:
Was This Post Helpful? 0
  • +
  • -

#8 badjava  Icon User is offline

  • Lux Ex Tenebris
  • member icon

Reputation: 14
  • View blog
  • Posts: 540
  • Joined: 30-October 08

Re: Hiding the console window

Posted 07 December 2008 - 12:36 AM

View PostILIKECPP, on 6 Dec, 2008 - 08:32 AM, said:

Thanks for the replies guys, they were really helpful ;)

Also, after a couple more hours Googling about my complier (Dev-C++) I found that I can just force the compiler to not make a console window, and really pissed off my mom by putting this in her startup folder :D

But thanks for the replies, it's good to know how to do stuff by the code and not just compiler-depndant.


Aw come on, after my jazzing up the sneakiness factor did u try it?

[edit: found something useful]

Hey I just happened to run across an easier way to remove the console window. I found it here in another DIC thread.

The command specifically is: FreeConsole(), if you test the code in that link you might want to first comment out the line that has the freeconsole call. :P

This post has been edited by badjava: 07 December 2008 - 12:54 AM

Was This Post Helpful? 0
  • +
  • -

#9 ILIKECPP  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 14-October 08

Re: Hiding the console window

Posted 07 December 2008 - 09:15 AM

Ya I tried yours, too :P Yours is sweet how it does it randomly and I'm using that code to also learn about rand() and stuff.

Thanks :D :^:
Was This Post Helpful? 0
  • +
  • -

#10 tuannb89  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 1
  • Joined: 28-March 12

Re: Hiding the console window

Posted 28 March 2012 - 12:05 AM

You can make it become a user-defined service. Link:
Make an app become a service: ***REMOVED LINK***
Make an app become a service example: ***REMOVED LINK***
Was This Post Helpful? -1
  • +
  • -

Page 1 of 1