Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to create thread on windows?

how to create thread on windows?

Scheduled Pinned Locked Moved C / C++ / MFC
c++visual-studioquestioncsharpcom
15 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U User 11155094

    i use ncrack and in installed all this(visual studio 2005,2008,2010,2013) so ncrack working with visual c++. im wondering how can i create more threads?i foudn this but i don't know how to apply!I must open visual c++?create project? Creating Threads (Windows)[^]

    S Offline
    S Offline
    Software_Developer
    wrote on last edited by
    #3

    Try this:

    #include "stdafx.h"

    #define _MT
    #include
    #include /* _beginthread, _endthread */
    #include
    #include
    #include
    #include

    #pragma comment(lib, "user32.lib")
    #pragma comment(lib, "libcmt.lib")
    #pragma comment(linker, "/NODEFAULTLIB:libcd.lib")

    void ThreadFunction1(void *ch);
    void ThreadFunction2(void *dummy);

    BOOL repeat = TRUE; /* Global repeat flag */

    int main(){
    printf("\nMultithreading with two threads.\n\n");
    printf("Thread Function 2 listens for key strokes. \n");
    printf("Thread Function 1 does all the other work \n");
    printf(" \n");
    CHAR ch = 'A';

    /\* Launch ThreadFunction2 thread to check for terminating keystroke. \*/
    \_beginthread(ThreadFunction2, 0, NULL);
    
    /\* Loop until ThreadFunction2 terminates program. \*/
    while (repeat){
    	/\* On first loops, launch character threads. \*/
    	\_beginthread(ThreadFunction1, 0, (void \*)(ch++));
    
    	/\* Wait one second between loops. \*/
    	Sleep(1000L);
    }
    
    printf("  \\n");
    return 0;
    

    }

    /* ThreadFunction2 - Thread to wait for a keystroke, then end program. */
    void ThreadFunction2(void *dummy){
    _getch();
    repeat = 0; /* _endthread implied */

    }

    /* ThreadFunction2 - Thread to do work */
    void ThreadFunction1(void *ch){

    while (repeat){
    
    	/\* Pause between loops. \*/
    	Sleep(100L);
    
    }
    /\* \_endthread given to terminate \*/
    \_endthread();
    

    }

    U J 2 Replies Last reply
    0
    • S Software_Developer

      Try this:

      #include "stdafx.h"

      #define _MT
      #include
      #include /* _beginthread, _endthread */
      #include
      #include
      #include
      #include

      #pragma comment(lib, "user32.lib")
      #pragma comment(lib, "libcmt.lib")
      #pragma comment(linker, "/NODEFAULTLIB:libcd.lib")

      void ThreadFunction1(void *ch);
      void ThreadFunction2(void *dummy);

      BOOL repeat = TRUE; /* Global repeat flag */

      int main(){
      printf("\nMultithreading with two threads.\n\n");
      printf("Thread Function 2 listens for key strokes. \n");
      printf("Thread Function 1 does all the other work \n");
      printf(" \n");
      CHAR ch = 'A';

      /\* Launch ThreadFunction2 thread to check for terminating keystroke. \*/
      \_beginthread(ThreadFunction2, 0, NULL);
      
      /\* Loop until ThreadFunction2 terminates program. \*/
      while (repeat){
      	/\* On first loops, launch character threads. \*/
      	\_beginthread(ThreadFunction1, 0, (void \*)(ch++));
      
      	/\* Wait one second between loops. \*/
      	Sleep(1000L);
      }
      
      printf("  \\n");
      return 0;
      

      }

      /* ThreadFunction2 - Thread to wait for a keystroke, then end program. */
      void ThreadFunction2(void *dummy){
      _getch();
      repeat = 0; /* _endthread implied */

      }

      /* ThreadFunction2 - Thread to do work */
      void ThreadFunction1(void *ch){

      while (repeat){
      
      	/\* Pause between loops. \*/
      	Sleep(100L);
      
      }
      /\* \_endthread given to terminate \*/
      \_endthread();
      

      }

      U Offline
      U Offline
      User 11155094
      wrote on last edited by
      #4

      For windows right?so this source will work for ncrack force bruter right?I don't know how to sue this code?must open visual c++ ?

      L 1 Reply Last reply
      0
      • U User 11155094

        For windows right?so this source will work for ncrack force bruter right?I don't know how to sue this code?must open visual c++ ?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #5

        See Ncrack Reference Guide (Man Page)[^].

        U 1 Reply Last reply
        0
        • L Lost User

          See Ncrack Reference Guide (Man Page)[^].

          U Offline
          U Offline
          User 11155094
          wrote on last edited by
          #6

          yes i use 20-30 threads if i use more i receive errors,nsock timeouts! nsock errors! etc...so i need to put that code somewhere but i don't know how?

          L 1 Reply Last reply
          0
          • U User 11155094

            yes i use 20-30 threads if i use more i receive errors,nsock timeouts! nsock errors! etc...so i need to put that code somewhere but i don't know how?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            Member 11189357 wrote:

            i need to put that code somewhere but i don't know how?

            And you think maybe we can guess? We have no idea what your code is supposed to be doing, or what you are trying to achieve with these threads.

            U 1 Reply Last reply
            0
            • L Lost User

              Member 11189357 wrote:

              i need to put that code somewhere but i don't know how?

              And you think maybe we can guess? We have no idea what your code is supposed to be doing, or what you are trying to achieve with these threads.

              U Offline
              U Offline
              User 11155094
              wrote on last edited by
              #8

              ncrack -vv -d7 --user admin -P list1.txt 81.196.251.12:3389,CL=20,cd=320ms -oN good.txt -f CL=means maximum threads 20 , becouse if i use more...i receive nsock errors tools i use are ( ncrack +visual c++)

              L D 2 Replies Last reply
              0
              • U User 11155094

                ncrack -vv -d7 --user admin -P list1.txt 81.196.251.12:3389,CL=20,cd=320ms -oN good.txt -f CL=means maximum threads 20 , becouse if i use more...i receive nsock errors tools i use are ( ncrack +visual c++)

                L Offline
                L Offline
                leon de boer
                wrote on last edited by
                #9

                So you are trying a brute force attack on a site via the remote desktop access (port 3389) as user admin with a set dictionary of passwords, and you want us to help you?????? There is no good or legal reason you would need to do such a thing, so that leaves only illegal. Not going to happen :-) Interesting target: RIPE Network Coordination Centre descr: RCS & RDS Residential descr: City: Bucuresti

                In vino veritas

                U L 2 Replies Last reply
                0
                • L leon de boer

                  So you are trying a brute force attack on a site via the remote desktop access (port 3389) as user admin with a set dictionary of passwords, and you want us to help you?????? There is no good or legal reason you would need to do such a thing, so that leaves only illegal. Not going to happen :-) Interesting target: RIPE Network Coordination Centre descr: RCS & RDS Residential descr: City: Bucuresti

                  In vino veritas

                  U Offline
                  U Offline
                  User 11155094
                  wrote on last edited by
                  #10

                  i use a sock 5 to connect so that's not my real IP, what ur tryng to proove?that ur superman?

                  L 1 Reply Last reply
                  0
                  • U User 11155094

                    i use a sock 5 to connect so that's not my real IP, what ur tryng to proove?that ur superman?

                    L Offline
                    L Offline
                    leon de boer
                    wrote on last edited by
                    #11

                    Good to see you aren't stupid enough to be trying to develop something illegal and give up your own IP ... gratz you get a +1 for IQ in my books and the the authorities may not kick in your door one evening.

                    In vino veritas

                    U 1 Reply Last reply
                    0
                    • L leon de boer

                      Good to see you aren't stupid enough to be trying to develop something illegal and give up your own IP ... gratz you get a +1 for IQ in my books and the the authorities may not kick in your door one evening.

                      In vino veritas

                      U Offline
                      U Offline
                      User 11155094
                      wrote on last edited by
                      #12

                      ok man

                      1 Reply Last reply
                      0
                      • L leon de boer

                        So you are trying a brute force attack on a site via the remote desktop access (port 3389) as user admin with a set dictionary of passwords, and you want us to help you?????? There is no good or legal reason you would need to do such a thing, so that leaves only illegal. Not going to happen :-) Interesting target: RIPE Network Coordination Centre descr: RCS & RDS Residential descr: City: Bucuresti

                        In vino veritas

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        I had a feeling that was the case, but could not be certain. Thanks for your comments.

                        1 Reply Last reply
                        0
                        • U User 11155094

                          ncrack -vv -d7 --user admin -P list1.txt 81.196.251.12:3389,CL=20,cd=320ms -oN good.txt -f CL=means maximum threads 20 , becouse if i use more...i receive nsock errors tools i use are ( ncrack +visual c++)

                          D Offline
                          D Offline
                          David Crow
                          wrote on last edited by
                          #14

                          It sounds like you are wanting to know how to use a network authentication cracker. :rolleyes: How exactly is this a C / C++ / MFC question? :confused:

                          "One man's wage rise is another man's price increase." - Harold Wilson

                          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                          1 Reply Last reply
                          0
                          • S Software_Developer

                            Try this:

                            #include "stdafx.h"

                            #define _MT
                            #include
                            #include /* _beginthread, _endthread */
                            #include
                            #include
                            #include
                            #include

                            #pragma comment(lib, "user32.lib")
                            #pragma comment(lib, "libcmt.lib")
                            #pragma comment(linker, "/NODEFAULTLIB:libcd.lib")

                            void ThreadFunction1(void *ch);
                            void ThreadFunction2(void *dummy);

                            BOOL repeat = TRUE; /* Global repeat flag */

                            int main(){
                            printf("\nMultithreading with two threads.\n\n");
                            printf("Thread Function 2 listens for key strokes. \n");
                            printf("Thread Function 1 does all the other work \n");
                            printf(" \n");
                            CHAR ch = 'A';

                            /\* Launch ThreadFunction2 thread to check for terminating keystroke. \*/
                            \_beginthread(ThreadFunction2, 0, NULL);
                            
                            /\* Loop until ThreadFunction2 terminates program. \*/
                            while (repeat){
                            	/\* On first loops, launch character threads. \*/
                            	\_beginthread(ThreadFunction1, 0, (void \*)(ch++));
                            
                            	/\* Wait one second between loops. \*/
                            	Sleep(1000L);
                            }
                            
                            printf("  \\n");
                            return 0;
                            

                            }

                            /* ThreadFunction2 - Thread to wait for a keystroke, then end program. */
                            void ThreadFunction2(void *dummy){
                            _getch();
                            repeat = 0; /* _endthread implied */

                            }

                            /* ThreadFunction2 - Thread to do work */
                            void ThreadFunction1(void *ch){

                            while (repeat){
                            
                            	/\* Pause between loops. \*/
                            	Sleep(100L);
                            
                            }
                            /\* \_endthread given to terminate \*/
                            \_endthread();
                            

                            }

                            J Offline
                            J Offline
                            Joe Woodbury
                            wrote on last edited by
                            #15

                            Note: prefer _beginthreadex over _beginthread. If using C++11, you could use the std::thread class.

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups