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 


[Solved]Calling thread from DLL

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

Joined: 03 Oct 2006
Posts: 671

PostPosted: Mon Mar 03, 2008 6:44 pm    Post subject: [Solved]Calling thread from DLL Reply with quote

So basically I have a thread in my dll and a checkbox in my C# gui. I want it to call the thread from the dll when the checkbox is checked.

Something like this:
Code:
if (mycheckbox.Checked == true)
{
//this is in C++: CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&ThreadNAME, 0, 0, 0);
}


Would I be able to do that? And if I use DllImport for my dll, would there be no parameters?


Last edited by Henley on Mon Mar 03, 2008 7:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Mar 03, 2008 6:52 pm    Post subject: Reply with quote

That woudnt work.

If you made a sepearte dll in C++ then u would DllImport it first, get the function that u wanna use.

then do

Code:
if ( myCheckBox.Checked == true )
{
    CallMyFunction(); // function name that u imported.
}


and in your C++ Dll

Code:
void __declspec(dllexport) CallMyFunction()
{
     hTheadHandle = CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)&ThreadNameInCDll, 0, 0, 0 );
}

_________________
Back to top
View user's profile Send private message
Henley
Grandmaster Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 671

PostPosted: Mon Mar 03, 2008 7:20 pm    Post subject: Reply with quote

lurc wrote:
That woudnt work.

If you made a sepearte dll in C++ then u would DllImport it first, get the function that u wanna use.

then do

Code:
if ( myCheckBox.Checked == true )
{
    CallMyFunction(); // function name that u imported.
}


and in your C++ Dll

Code:
void __declspec(dllexport) CallMyFunction()
{
     hTheadHandle = CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)&ThreadNameInCDll, 0, 0, 0 );
}


Thanks thats exactly what I needed lol
forgot to mention that the dll was made in C++ o.o
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Mon Mar 03, 2008 7:26 pm    Post subject: Reply with quote

Code:
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("lol.dll"), "ohhai"), 0, 0, 0);
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Mar 03, 2008 7:33 pm    Post subject: Reply with quote

Flyte wrote:
Code:
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("lol.dll"), "ohhai"), 0, 0, 0);


He Said that he's Calling it from a C# GUI, and he wants to call the function to create the thread within his dll.

C# doesnt even have CreateThread unless you Import it.

_________________
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: Mon Mar 03, 2008 9:13 pm    Post subject: Reply with quote

lurc wrote:
Flyte wrote:
Code:
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("lol.dll"), "ohhai"), 0, 0, 0);


He Said that he's Calling it from a C# GUI, and he wants to call the function to create the thread within his dll.

C# doesnt even have CreateThread unless you Import it.


Bullshit.

Thread t = new Thread(new ThreadStart(VoidMethod_NoParamsHere));
t.Start();

_________________
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
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Mon Mar 03, 2008 9:33 pm    Post subject: Reply with quote

samuri25404 wrote:
lurc wrote:
Flyte wrote:
Code:
CreateThread( 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle("lol.dll"), "ohhai"), 0, 0, 0);


He Said that he's Calling it from a C# GUI, and he wants to call the function to create the thread within his dll.

C# doesnt even have CreateThread unless you Import it.


Bullshit.

Thread t = new Thread(new ThreadStart(VoidMethod_NoParamsHere));
t.Start();


I meant The API Function, not the C# Threading.

_________________
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: Tue Mar 04, 2008 5:21 pm    Post subject: Reply with quote

Oh, my bad.

Seemed like you were saying that you couldn't create threads in C# (which I disproved above).

_________________
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