Jump to content

Problem with Obfuscator and timers


Recommended Posts

I raised something similar to this some time ago, but got nowhere and now have a nice concrete example.

If you try to compile the _Timer_SetTimer() example from the help file with 'Run Obfuscator before compilation' option checked the compilation fails and you get this:

-### 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")

-###2 Obfuscation Error: Found Execute() statement which will lead to problems running your obfuscated script.

>### current Func: _WinAPI_SetLayeredWindowAttributes

C:\Program Files\AutoIt3\include\WinAPI.au3(5364,1) Warning for line:$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))

-#############################################################################################

-#### Obfuscator Found 2 Error(s)!!!! This means your script could have problems running properly. ####

-#############################################################################################

As I don't know how to fix it, I've raised it here. Can somebody fix this please?

4Eyes

Edited by 4Eyes
Link to comment
Share on other sites

The Execute() function is not used in the current version of Timers.au3. What version of AutoIt are you using?

That error was for DllCallbackRegister(), not Execute(). Doh! :idea:

:)

P.S. Execute() is used in the current WinAPI.au3 for _WinAPI_SetLayeredWindowAttributes(), but I don't know why it was chosen. You can replace lines 5362 thru 5365 with this:

If Not $isColorRef Then
    ;   $i_transcolor = Hex(String($i_transcolor), 6)
    ;   $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
        $i_transcolor = Binary("0x00" & Hex(String($i_transcolor), 6))
        $i_transcolor = Int(BinaryMid($i_transcolor, 2, 1) & BinaryMid($i_transcolor, 3, 1) & BinaryMid($i_transcolor, 4, 1))   
    EndIf

So updating to the current version, and applying that tweak to _WinAPI_SetLayeredWindowAttributes() inside WinAPI.au3 should get you past that.

:(

P.P.S. Add ticket #1623 for this change.

:)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

PsaltyDS,

Thanks for your reply.

I'm using version 3.3.6.1. I've just uninstalled and reinstalled but things don't add up. The winapi.au3 file has this id stuff:

; #INDEX# =======================================================================================================================
; Title .........: Windows API
; AutoIt Version : 3.2
; Description ...: Windows API calls that have been translated to AutoIt functions.
; Author(s) .....: Paul Campbell (PaulIA), gafrost, Siao, Zedna, arcker, Prog@ndy, PsaltyDS, Raik, jpm
; Dll ...........: kernel32.dll, user32.dll, gdi32.dll, comdlg32.dll, shell32.dll, ole32.dll, winspool.drv
; ===============================================================================================================================

Also the _WinAPI_SetLayeredWindowAttributes() does use Execute() as can be seen here:

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_SetLayeredWindowAttributes
; Description ...: Sets Layered Window Attributes
; Syntax.........: _WinAPI_SetLayeredWindowAttributes($hWnd, $i_transcolor[, $Transparency = 255[, $dwFlags = 0x03[, $isColorRef = False]]])
; Parameters ....: $hwnd - Handle of GUI to work on
;                  $i_transcolor - Transparent color
;                  $Transparency - Set Transparancy of GUI
;                  $dwFlags - Flags.
;                  $isColorRef - If True, $i_transcolor is a COLORREF( 0x00bbggrr ), else an RGB-Color
; Return values .: Success - 1
;                  @Error - 0
;                  |@error: 1 to 3 - Error from DllCall
;                  |@error: 4 - Function did not succeed - use _WinAPI_GetLastErrorMessage to get more information
; Author ........: Prog@ndy
; Modified.......:
; Remarks .......:
; Related .......: _WinAPI_GetLayeredWindowAttributes, _WinAPI_GetLastError
; Link ..........: @@MsdnLink@@ SetLayeredWindowAttributes
; Example .......: Yes
; ===============================================================================================================================
Func _WinAPI_SetLayeredWindowAttributes($hWnd, $i_transcolor, $Transparency = 255, $dwFlags = 0x03, $isColorRef = False)
    If $dwFlags = Default Or $dwFlags = "" Or $dwFlags < 0 Then $dwFlags = 0x03
    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $aResult = DllCall("user32.dll", "bool", "SetLayeredWindowAttributes", "hwnd", $hWnd, "dword", $i_transcolor, "byte", $Transparency, "dword", $dwFlags)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0]
EndFunc   ;==>_WinAPI_SetLayeredWindowAttributes

I'm willing to concede that something may be screwy at my end, but I can't see what. Maybe the release code of 3.3.6.1 is not quite right. Just for the record the 3.3.6.1 release file I downloaded is 8,406,664 bytes long and the winapi.au3 file is 380,043 bytes long.

I haven't yet tried your alternative code and may hold off until we work out if the release file is wrong or there's something more basic wrong. Your help is really appreciated.

Regards,

4Eyes

Edited by 4Eyes
Link to comment
Share on other sites

PsaltyDS,

Thanks for your reply.

I'm using version 3.3.6.1. I've just uninstalled and reinstalled but things don't add up. The winapi.au3 file has this id stuff:

<snip>

I'm willing to concede that something may be screwy at my end, but I can't see what. Maybe the release code of 3.3.6.1 is not quite right. Just for the record the 3.3.6.1 release file I downloaded is 8,406,664 bytes long and the winapi.au3 file is 380,043 bytes long.

I haven't yet tried your alternative code and may hold off until we work out if the release file is wrong or there's something more basic wrong. Your help is really appreciated.

Regards,

4Eyes

The Timers.au3 thang was an error on my part. Obfuscator is calling out the use of DllCallbackRegister(), not Execute(). Don't have a work around to make that OK with Obfuscator. Maybe Jos knows a trick.

Your WinAPI.au3 matches mine, and the tweak I posted should get rid of that hit from Obfuscator.

:idea:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The Timers.au3 thang was an error on my part. Obfuscator is calling out the use of DllCallbackRegister(), not Execute(). Don't have a work around to make that OK with Obfuscator. Maybe Jos knows a trick.

Your WinAPI.au3 matches mine, and the tweak I posted should get rid of that hit from Obfuscator.

:idea:

PsaltyDS,

Thanks again. I'll try your workaround and report.

Regards,

4Eyes

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Sorry to raise this oldish thread but I'm still having problems with Obfuscator and DLLCallbackRegister() as used in the _Timer_SetTimer example.

When I attempt to compile the example I get this from obfuscator:

-### 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(276,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.28.7 finished obfuscating 4723 lines, stripped 8779 comment lines. created:C:\Program Files\AutoIt3\Examples\Helpfile\_Timer_SetTimer_Obfuscated.au3

and yes, it does break the example, plus another simply test prog I used.

To try to fix this I have:

1) searched the forums and found other threads where this issue has been raised, but not resolved.

2) Looked into the #obfuscator_ignore_funcs directive but as DllCallbackRegister is a built-in func it's uneffected by this directive.

3) I scanned some includes that use DLLCallbackRegister and saw that they didn't have the 2nd parameter as "none" so

I tried using a mod'ed version of the Timers.au3 include with line 275 changed from this:

$hCallBack = DllCallbackRegister($sTimerFunc, "none", "hwnd;int;uint_ptr;dword")

to this:

$hCallBack = DllCallbackRegister($sTimerFunc, "int", "hwnd;int;uint_ptr;dword")

and yes, I understand full well that changing a parameter like that is dumb, but it was a test to see if it would compile, not run.

4) I looked for the 26 page thread that KaFu said is in his sig but can't find that either.

- correction, I found this:

http://www.autoitscript.com/forum/index.php?showtopic=43853&st=440&p=702102&#entry702102

and it's 28 pages now... reading...

5) Read this: http://www.autoitscript.com/autoit3/scite/docs/Obfuscator_doc.htm but it didn't help

I'm out of options. Can anybody (Jos?) help me with this please?

Regards,

4Eyes

Edited by 4Eyes
Link to comment
Share on other sites

It's dumb to answer my own post but I have a workaround for this problem. It's ugly, but it works.

Step 1) Make a copy of the Timers.au3 include file... call it Timers2.au3

Step 2) Mod line 275 in Timers2.au3 from this:

$hCallBack = DllCallbackRegister($sTimerFunc, "none", "hwnd;int;uint_ptr;dword")

to this:

$hCallBack = DllCallbackRegister("MyCallbackFunc", "none", "hwnd;int;uint_ptr;dword")

where "MyCallbackFunc" is the name of your callback func. As Jos has said many times, Obfuscator can't predict the name of the func that will be passed so it makes sense that it would report this.

Step 3) Cut the whole Func _Timer_SetTimer() code and paste it into a test script

Step 4) Make as many mod'ed copies of the func as you need to suit each different timer. I use 5.

Link to comment
Share on other sites

  • 4 weeks later...

Add ticket #1623 for this change.

I'm just curious, since this is heading towards production...

Is there a functional difference between:

$i_transcolor = Int(BinaryMid($i_transcolor, 2, 1) & BinaryMid($i_transcolor, 3, 1) & BinaryMid($i_transcolor, 4, 1))

and

$i_transcolor = Int(BinaryMid($i_transcolor, 2, 3))

Thanks.

Link to comment
Share on other sites

Other than some readability functionality, No.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

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...