Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[?] Passing multple parameters with CreateThread()

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
talkerzero
Grandmaster Cheater
Reputation: 1

Joined: 24 Jul 2008
Posts: 560
Location: California

PostPosted: Sun Mar 22, 2009 3:38 pm    Post subject: [?] Passing multple parameters with CreateThread() Reply with quote

How can I do this?
Back to top
View user's profile Send private message Visit poster's website
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Sun Mar 22, 2009 3:45 pm    Post subject: Reply with quote

Allocate a piece of memory for the stack, Write all your parameters onto that and set it as the stack parameter? I haven't tried so Im just guessing.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Sun Mar 22, 2009 4:20 pm    Post subject: Reply with quote

make a structure or an array of the info you want to pass. then pass a pointer to that structure/array
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sun Mar 22, 2009 10:46 pm    Post subject: Reply with quote

Slugsnack wrote:
make a structure or an array of the info you want to pass. then pass a pointer to that structure/array


Exactly.

Code:

typedef struct _THREAD_PARAMETER {
    int nFirstParam;
    char *szSecondParam;
    char *szThirdParam;
    double FourthParam[100];
} THREAD_PARAMETER, *LPTHREAD_PARAMETER;

void ThreadFunction( LPVOID lpParam );

void StartThread( int *tID, int nFirstParam, char *szSecondParam, char *szThirdParam, double FourthParam[ ] ) {
    THREAD_PARAMETER ThreadParam;
    ThreadParam.nFirstParam = nFirstParam;
    strcpy( ThreadParam.szSecondParam, szSecondParam );
    strcpy( ThreadParam.szThirdParam, szThirdParam );
    memcpy( ThreadParam.FourthParam, FourthParam, sizeof( double ) * 100 );

    CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE )ThreadFunction, &ThreadParam, 0, tID );
}

void ThreadFunction( LPVOID lpParam ) {
    THREAD_PARAMETER ThreadParam = *( LPTHREAD_PARAM )lpParam;
   
    std::cout << ThreadParam.nFirstParam << std::endl;
    std::cout << ThreadParam.szSecondParam << std::endl;
    std::cout << ThreadParam.szThirdParam << std::endl;
    for( int i = 0; i < 100; i++ )
        std::cout << ThreadParam.FourthParam[ i ] << std::endl;
}

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites