It is currently Wed May 22, 2013 12:55 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: forcable fail dll load?
PostPosted: Sat Mar 03, 2012 8:16 am 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 974
Location: Anderson Island, WA
From within a dll

during "attach process" -- under certain conditions, I want the dll to "fail to load" -- is there a way to do that?

EDIT:
it appears if I raise an error in AttachProcess() this causes the dll to not load...
Is this the best approach?


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Sat Mar 03, 2012 10:05 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri Jan 21, 2011 8:25 am
Posts: 548
It might be enough just to return false in AttachProcess...at least that's how you'd do it in the native WinAPI DllMain function...
Check this out, it might help: http://msdn.microsoft.com/en-us/windows ... 87379.aspx

_________________
Image
ImageImageImage
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Sun Mar 04, 2012 12:49 am 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 974
Location: Anderson Island, WA
Shield wrote:
It might be enough just to return false in AttachProcess...at least that's how you'd do it in the native WinAPI DllMain function...
Check this out, it might help: http://msdn.microsoft.com/en-us/windows ... 87379.aspx


I thought that might be -- but a function w/o a specific "procedurereturn" does return 0/false

So by default, attachprocess procedure returns false.


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Sun Mar 04, 2012 9:35 am 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1024
You could try using DllMain instead of AttachProcess and DetachProcess.
It has a return value that indicates if it was successfull.

http://msdn.microsoft.com/en-us/library ... 82583.aspx


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Sun Mar 04, 2012 10:19 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 2507
Location: Lyon - France
I don't know if i have good understand the question :oops:
But there are a long time FREAK give to me this little jewel 8)
I use it for not give acces of my DLL if the key of the EXE is not good :D
Code:
 !ADD esp, 8     ; remove Instance variable and return address from stack
 !MOV eax, 0     ; set returnvalue to 0
 !RET 12         ; return from DllEntryPoint

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Mon Mar 05, 2012 1:11 am 
Offline
Addict
Addict
User avatar

Joined: Wed Feb 17, 2010 12:00 am
Posts: 974
Location: Anderson Island, WA
Kwaï chang caïne wrote:
I don't know if i have good understand the question :oops:
But there are a long time FREAK give to me this little jewel 8)
I use it for not give acces of my DLL if the key of the EXE is not good :D
Code:
 !ADD esp, 8     ; remove Instance variable and return address from stack
 !MOV eax, 0     ; set returnvalue to 0
 !RET 12         ; return from DllEntryPoint


Thanks -- I was looking for a "proper way" -- but it seems there are many ways. Personally, I like the simple
Code:
RaiseError(#ERROR_DLL_INIT_FAILED)


Error returned to calling program is meaningful...


Top
 Profile  
 
 Post subject: Re: forcable fail dll load?
PostPosted: Mon Mar 05, 2012 7:11 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 2507
Location: Lyon - France
Cool i never see this function :shock: :oops:
Thanks jassing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye