Jump to content

Code doesn't work if obfuscated and compiled


Recommended Posts

Folks,

I don't understand why, but this code does not work ("Can't create timer") if obfuscated when compiled. Works fine intepreted and works fine if not obfuscated. Before anybody says... yes, I could simply not obfuscate it, however, I wish to do this. Can anybody offer a suggestion please?

BTW, running AutoIT 3.3.6.0.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Timers.au3>

Global $MyTimerID, $SecondCounter

;******************************************

$MyTimerID = _Timer_SetTimer(WinGetHandle(AutoitWinGetTitle()), 1000, "CountSeconds") ; create timer - this works in compiled & interpreted mode

If $MyTimerID = 0 Then
    MsgBox(0, "Debug", "Failed to create timer")
    Exit
Else
    MsgBox(0, "Debug", "$MyTimerID = " & $MyTimerID)
EndIf

;******************************************

; This is the callback func for the timer.

Func CountSeconds($hWnd, $Msg, $iIDTimer, $dwTime)
    #forceref $hWnd, $Msg, $iIDTimer, $dwTime
    
    $SecondCounter += 1

    ConsoleWrite("$SecondCounter = " & $SecondCounter & @CRLF)
    
EndFunc     ; End of Func CountSeconds()

;******************************************

Regards,

4Eyes

Edited by 4Eyes
Link to comment
Share on other sites

Are you compiling this code inside the SciTE window with the newest version of AutoIt? When I do it, it gives me an error because of DLLCallbackRegister. This would be my best guess on why it won't work. Are you getting this error when you compile?

Link to comment
Share on other sites

Hmm... Thats odd. When I compile it with the obfuscator option, I get this error:

-### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script.
>### current Func: _Timer_SetTimer
C:\Program Files\AutoIt3\include\Timers.au3(275,1) Warning for line:$hCallBack = DllCallbackRegister($sTimerFunc, "none", "hwnd;int;uint_ptr;dword") 

-#############################################################################################
-#### Obfuscator Found 1 Error(s)!!!!   This means your script could have problems running properly. ####
-#############################################################################################
+> Obfuscator v1.0.27.0 finished obfuscating 199 lines, stripped 203 comment lines. created:C:\Documents and Settings\Owner\Desktop\New AutoIt v3 Script_Obfuscated.au3

Can anyone else confirm or deny this?

Link to comment
Share on other sites

dantay9,

The output of your attempted compilation shows that you are running Obfuscator v1.0.27.0. I was running 1.0.25.something. Now with very latest 1.0.28.7 and the complete source code to the project I see the error you mentioned and a whole bunch more... isn't that just peachey! :(

Thanks for your help. I don't think I would have resolved this found this quickly otherwise.

This appears to be caused by using code that is not compatible with the current AutoIT version. I see probs with Execute(), (I'm not using it but is used by WinAPI which is being 'include'd), ObjEvent() and DllCallbackRegister() which is used internally by _Timer_SetTimer(). I won't complain as I'll bet that all of these have been doc'ed as changes between versions, and I have skimmed them. Now I need to consider going back to an earlier AutoIT version for this project or trying to find fixes.

Nah, I will have a whinge... Surely, WinAPI is commonly used. Has anybody else found issues here?

Regards,

4Eyes

Edited by 4Eyes
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...