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?
forcable fail dll load?
Re: forcable fail dll load?
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
Check this out, it might help: http://msdn.microsoft.com/en-us/windows ... 87379.aspx
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"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
Re: forcable fail dll load?
I thought that might be -- but a function w/o a specific "procedurereturn" does return 0/falseShield 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
So by default, attachprocess procedure returns false.
Re: forcable fail dll load?
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
It has a return value that indicates if it was successfull.
http://msdn.microsoft.com/en-us/library ... 82583.aspx
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: forcable fail dll load?
I don't know if i have good understand the question 
But there are a long time FREAK give to me this little jewel
I use it for not give acces of my DLL if the key of the EXE is not good
But there are a long time FREAK give to me this little jewel
I use it for not give acces of my DLL if the key of the EXE is not good
Code: Select all
!ADD esp, 8 ; remove Instance variable and return address from stack
!MOV eax, 0 ; set returnvalue to 0
!RET 12 ; return from DllEntryPoint
The happiness is a road...Not a destination
Re: forcable fail dll load?
Thanks -- I was looking for a "proper way" -- but it seems there are many ways. Personally, I like the simpleKwaï chang caïne wrote:I don't know if i have good understand the question
But there are a long time FREAK give to me this little jewel![]()
I use it for not give acces of my DLL if the key of the EXE is not good![]()
Code: Select all
!ADD esp, 8 ; remove Instance variable and return address from stack !MOV eax, 0 ; set returnvalue to 0 !RET 12 ; return from DllEntryPoint
Code: Select all
RaiseError(#ERROR_DLL_INIT_FAILED)- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: forcable fail dll load?
Cool i never see this function
Thanks jassing
Thanks jassing
The happiness is a road...Not a destination
