AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DllCall and ShellExecuteA will crash sometimes a script

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed Jan 09, 2008 9:19 pm    Post subject: DllCall and ShellExecuteA will crash sometimes a script Reply with quote

Hi,

it's really hard to explain and I can't reproduce it myself.

At my script ac'tivAid there's a function called AppLauncher which is similar to Rajats 320MPh. It is used to search through the start menu and quickly launch the selected item. It also can optionally launch the selected item with the RunAs command from ShellExecuteA of shell32.dll.

Code:
DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, SelectedCommandOrShortcut, str, "" , str, WorkingDir, int, 1)


Some users reported that after this DllCall the AutoHotkey may crash on simple Send commands assigned to a hotkey. It doesn't happen If DllCall is replaced with Run. I also created a helper script which just contains the DllCall which executes the Command specified in the command line. If I call this extra script instead of DllCall, everything is working ok.

What could be the Reason of this crash? Could it be that DllCall produces a memory hole or an overflow in rare situations?

It tried some things like LoadLibrary or Sleep, 0 after the DllCall or using a different thread with SetTimer, but the crash comes if DllCall has 'prepared' it.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu Jan 10, 2008 7:10 am    Post subject: Reply with quote

Now a user reported that my simple helper script will also crash AutoHotkey if the runas dialog will be cancelled.

Code:
#Notrayicon
#Persistent
Detecthiddenwindows, On

Command = %1%

ShellExecResult := DllCall("shell32\ShellExecuteA", uint, 0, str, "RunAs", str, Command,str, "", str, A_WorkingDir, int, 1)  ; Last parameter: SW_SHOWNORMAL = 1
ExitApp, %ShellExecResult%


The error message tells, that "read" could not operate to the memory: fehler_in_anwendung.png
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
DerRaphael



Joined: 23 Nov 2007
Posts: 379
Location: Heidelberg, Germany

PostPosted: Thu Jan 10, 2008 10:41 am    Post subject: Reply with quote

a quick google scan showed that runas combined with shellexec used in vista starts UAC [found here], but i didnt find any other informations ...

why dont you use the standard build in runas command from autohotkey instead?

if the dllcall is used for UAC, u might want to check os version and use standard autohotkey runas command if no vista found

greets
derRaphael
_________________
Code:
If ((myWish="post in forum") && (!(haveAccount) || !(loggedIn))) {
    MsgBox, 64, Forum Hint, It's a good idea to sign up and/or login to post in forum!
} else if ((RTFM) && (searchedForum) && (usesBrain)) {
    Send, %Request%
}
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu Jan 10, 2008 10:50 am    Post subject: Reply with quote

Yes I use it for UAC, but also to ask for the User in XP. The RunAs command does not work as I don't know the admin name and password and I don't want handle with passwords in the script itself.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
DerRaphael



Joined: 23 Nov 2007
Posts: 379
Location: Heidelberg, Germany

PostPosted: Thu Jan 10, 2008 11:21 am    Post subject: Reply with quote

running win2k and cant provoke any error here even with malforming the script parameter such as
Code:

ShellExecResult := DllCall("shell32\ShellExecuteA"
   , uint, 0
   , str, "RunAs"
   , str, "cmd.exe /?"
   , str, ""
   , str, A_WorkingDir
   , int, 1)

in this case its simply not working ... thus setting value to 2
are any command parameter used and how are these passed?

sorry
_________________
Code:
If ((myWish="post in forum") && (!(haveAccount) || !(loggedIn))) {
    MsgBox, 64, Forum Hint, It's a good idea to sign up and/or login to post in forum!
} else if ((RTFM) && (searchedForum) && (usesBrain)) {
    Send, %Request%
}
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu Jan 10, 2008 11:31 am    Post subject: Reply with quote

I also can't reproduce it myself. There are no command line parameters used and most time there will be shurtcuts (lnk-Files) executed with RunAs.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group