Sign in to follow this  
Followers 0
4Eyes

Code doesn't work if obfuscated and compiled

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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?


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

dantay9,

Thanks for your reply, but yes I'm compiling from within Scite, but no, I see no error.

4Eyes

Share this post


Link to post
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?


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0