Jump to content
Tuts 4 You

MSIL in DllMain?


high6

Recommended Posts

I currently am getting around it by doing

CreateThread(0, 0, (LPTHREAD_START_ROUTINE)Init, 0, 0, 0);

But from what I understand, when you create a thread in DllMain it queues it up to be executed after DllMain executes. So how can I have a MSIL DeInit function? Creating a thread wont work because it will execute after the dll is no longer in memory.

Link to comment

you could possibly try using createremotethread on yourself... createremotethread behaves somewhat differently

Link to comment
you could possibly try using createremotethread on yourself... createremotethread behaves somewhat differently

CreateThread uses CreateRemoteThread :P . I may try opening the current process and doing that but I think it would queue every new thread.

Link to comment

yep, but with slightly different parameters...

for example...

make 2 exe's, one is a launcher, the other a dumb program that prints some output

program 1 -> launch and suspend program 2

program 1 -> createremotethread on the now suspended program...

what happens?

well, the thread actually runs, even though the process its 'attached' to is suspended

thus createthread != createremotethread

which is why i suggested trying it

Link to comment
yep, but with slightly different parameters...

for example...

make 2 exe's, one is a launcher, the other a dumb program that prints some output

program 1 -> launch and suspend program 2

program 1 -> createremotethread on the now suspended program...

what happens?

well, the thread actually runs, even though the process its 'attached' to is suspended

thus createthread != createremotethread

which is why i suggested trying it

I am talking about DllMain though. Which when it is executing there is a lock in place.

http://blogs.msdn.com/oldnewthing/archive/...04/4731478.aspx

http://download.microsoft.com/download/a/f...LL_bestprac.doc

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...