Jump to content

_WinAPI calls not working


Recommended Posts

SCITE version 4.4.6, 32 bit

I have a small script that uses Semaphores to synchronize access to a file.

It used to work great for everyone.  A few months ago, I changed PCs and reinstalled AutoIT (version above).

Since then, .exe files I compile... "some" folks.. maybe 20%, get unhandled errors (.exe program just dies) when calling a WINAPI (seems like any of them).

Trying the CreateSemaphore call via DLLCall didn't work.. program just dies.. no returned status or anything.

Any idea what is causing this?  As I say, the program used to work fine until I reinstalled AutoIT and recompiled.

Thank you

Link to comment
Share on other sites

Post the code you have (make it runable to us, if you want help).  Also Scite version is somewhat useless to us.  What is the AutoIt version ?  It is shown in the help file.

 

Link to comment
Share on other sites

Link to comment
Share on other sites

I wasn't trying to be funny.  I brought up the SCITE and hit F1 and this is what it said:

v3.3.16.1

© 1999-2022 Jonathan Bennett & AutoIt Team

AutoIt v3 Homepage

 

If there is another place to look, please let me know... maybe I"m not looking in the right place...

 

I'll work up a little program that shows the problem and send it.  I believe any WINAPI call will do the same.

Please note that it only fails for about 20% of the users..... 

Anyway, thank you for your help... i truly woudl like it. no intent to be problematic.

Thank you.... stand by for a simple coding example.

 

Link to comment
Share on other sites

Here is a little program that shows the problem..  again, when run by the users that it doen't work on, the .exe just terminates.. no return code or possible error handling.

Thank you again

 

#include <Constants.au3>
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
;#include <WinAPIHObj.au3>
#include <WinAPIProc.au3>
#include <WindowsConstants.au3>

Local $hSemaphore = _WinAPI_CreateSemaphore("HRDBSync", 1, 1, 0)
if $hSemaphore = 0 Then
    MsgBox(0, "error", "CreateSemaphore returnedf: " & $hSemaphore)
    Exit
EndIf

If _WinAPI_WaitForSingleObject($hSemaphore) = -1 Then
    MsgBox(1, "error", "WaitForSingleObject Returned: " & _WINAPI_GetLastError())
EndIf

MsgBox(1, "OK", "... here we are doing something with a semaphore lock...")

_WinAPI_ReleaseSemaphore($hSemaphore)
_WinAPI_CloseHandle($hSemaphore)

 Exit

Link to comment
Share on other sites

When you post code, please use the method shown in the link.

Ok, it is lot of infos to manage for you.

The code is so basic, that I can find anything to say.  Maybe the problem is you AV.  Or other security gates.

Ask yourself, if you were me, how would you be facing such a code, how would you deal with it...

Link to comment
Share on other sites

That's the issue.. it's so basic it shouldn't fail.

If you and your team are not aware of any WINAPI type failures.. such as "I know, it's xxxx.. people have seen that before...".. then I'll look elsewhere.  It's something pretty basic, I have to believe.

Thank you for looking at it...  I'll continue to look at what might be causing it.

Take care

Link to comment
Share on other sites

All AutoIt _WinAPI_* functions are just wrappers to the Windows Win32 API.  Nothing more nothing less.  

You did not tell me what is exactly happening to those who fail using this code.  Again you should check AV log.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...