killaz219 Posted October 24, 2005 Share Posted October 24, 2005 I'm new to DLLCALLs because I have never had a use for them before. I made this test with one of the few calls I knew, can anyone tell me if it works? DllOpen("Kernel32.dll") While 1 If DllCall("Kernel32.dll", "int", "IsDebuggerPresent") = 1 then ExitLoop If @error then ExitLoop Sleep(1) WEnd DllClose("Kernel32.dll") Link to comment Share on other sites More sharing options...
/dev/null Posted October 24, 2005 Share Posted October 24, 2005 I'm new to DLLCALLs because I have never had a use for them before. I made this test with one of the few calls I knew, can anyone tell me if it works? DllOpen("Kernel32.dll") While 1 If DllCall("Kernel32.dll", "int", "IsDebuggerPresent") = 1 then ExitLoop If @error then ExitLoop Sleep(1) WEnd DllClose("Kernel32.dll")should work (exept for the DllOpen/DllClose part). See: http://msdn.microsoft.com/library/default....ggerpresent.aspYou should read the help file section for DllOpen(). That function returns a handle, which can be used by DllCall() and must be used by DllClose().CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
killaz219 Posted October 24, 2005 Author Share Posted October 24, 2005 should work (exept for the DllOpen/DllClose part). See: http://msdn.microsoft.com/library/default....ggerpresent.aspYou should read the help file section for DllOpen(). That function returns a handle, which can be used by DllCall() and must be used by DllClose().CheersKurtThanks didnt notice that Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted October 24, 2005 Share Posted October 24, 2005 DLLCall returns an array, where [0] is the return value of the function call Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
/dev/null Posted October 24, 2005 Share Posted October 24, 2005 DLLCall returns an array, where [0] is the return value of the function callUps, I overlooked that. You're of course right !!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2005 Share Posted October 24, 2005 If the current process is running in the context of a debugger, the return value is nonzero. If the current process is not running in the context of a debugger, the return value is zero. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
/dev/null Posted October 24, 2005 Share Posted October 24, 2005 If the current process is running in the context of a debugger, the return value is nonzero.If the current process is not running in the context of a debugger, the return value is zero.argh.... I need some sleep .... @killaz219: You can only test if the return value is nonzero, as you cannot expect it to be 1 (see first statement above).CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
killaz219 Posted October 24, 2005 Author Share Posted October 24, 2005 (edited) So it would be this right? $dll = DllOpen("Kernel32.dll") While 1 $dll2 = DllCall($dll, "int", "IsDebuggerPresent") If @error then ExitLoop If $dll2[0] <> 0 Then ExitLoop Sleep(1) WEnd DllClose($dll) Edited October 24, 2005 by killaz219 Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2005 Share Posted October 24, 2005 should be correct but only if:The IsDebuggerPresent function determines whether the calling process is being debugged by a user-mode debugger. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
/dev/null Posted October 24, 2005 Share Posted October 24, 2005 (edited) So it would be this right?If @error then ExitLoopactually your error handling is not O.K. You treat a general DllCall error (@error is set) in the same way as if your program is beeing debugged. I guess that could cause problems...EDIT: And the sleep() could be a bit longer ...CheersKurt Edited October 24, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 24, 2005 Share Posted October 24, 2005 Wow, confusing. Why do you want to see if AutoIt is being debugged? Or was that just an example/test? Link to comment Share on other sites More sharing options...
killaz219 Posted October 24, 2005 Author Share Posted October 24, 2005 Wow, confusing. Why do you want to see if AutoIt is being debugged? Or was that just an example/test?Just a test Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2005 Share Posted October 24, 2005 actually your error handling is not O.K. You treat a general DllCall error (@error is set) in the same way as if your program is beeing debugged. I guess that could cause problems...CheersKurt Yep, getting late, @error should only be set if the dllcall failed, if that doesn't fail then you need to check your return value. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
LxP Posted October 24, 2005 Share Posted October 24, 2005 When you're only performing a single DLLCall() on any DLL, you don't need to open and close it. You can have this done automatically during the call and can therefore use:Local $Ret = DLLCall('Kernel32.dll', 'Int', 'IsDebuggerPresent')instead of:Local $DLL = DLLOpen('Kernel32.dll') Local $Ret = DLLCall($DLL, 'Int', 'IsDebuggerPresent') DLLClose($DLL) Link to comment Share on other sites More sharing options...
killaz219 Posted October 24, 2005 Author Share Posted October 24, 2005 When you're only performing a single DLLCall() on any DLL, you don't need to open and close it. You can have this done automatically during the call and can therefore use:Local $Ret = DLLCall('Kernel32.dll', 'Int', 'IsDebuggerPresent')instead of:Local $DLL = DLLOpen('Kernel32.dll') Local $Ret = DLLCall($DLL, 'Int', 'IsDebuggerPresent') DLLClose($DLL)But I had the call in a loop, wouldn't it have to keep opening and closing it after every call if I didn't use DllOpen and DllClose? Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted October 24, 2005 Share Posted October 24, 2005 (edited) If you're using it in a loop, that is the way to do it (or if you're calling multiple functions from the same DLL). Local $DLL = DLLOpen('Kernel32.dll'), $Ret Do $Ret = DLLCall($DLL, 'Int', 'IsDebuggerPresent') Until $Ret[0];Do...Until there is something in $Ret[0] ;Until Not $Ret[0];Do...Until $Ret[0] = 0 DLLClose($DLL) Edited October 24, 2005 by MSLx Fanboy Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now