Jump to content

Avoid "AutoIt Error" message box in unknown errors


Go to solution Solved by trancexx,

Recommended Posts

Posted

  On 11/23/2013 at 3:47 PM, PincoPanco said:

in the header of the UDF i read:

; AutoIt Version.: 3.3.8.1++

where have you read that it only works with beta?

I just tried and it did not work in the stable version

Posted

I still think trancexx solution is the best because it's replacing the autoit error messagebox title without any additional "features" that can be raise an error itself.

Imagine the error handler cause an error :P

Her solution would be perfect if it's working with compressors/packers

Posted

Compressors and packers offer almost zero benefit to preventing the decompiling of a script. They're just packers and most of the decompilers can blow right past them. Also, most of the packers, like UPX, are what cause most of the false AV reports.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
  On 11/23/2013 at 4:59 PM, BrewManNH said:

Compressors and packers offer almost zero benefit to preventing the decompiling of a script. They're just packers and most of the decompilers can blow right past them. Also, most of the packers, like UPX, are what cause most of the false AV reports.

 

I understand that none of them safe, but a commercial packer can make it harder to decompile, especially for the newbie one :)

Posted

No it won't.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

  On 11/23/2013 at 4:42 PM, michaelslamet said:

I still think trancexx solution is the best because it's replacing the autoit error messagebox title without any additional "features" that can be raise an error itself.

Imagine the error handler cause an error :P

Her solution would be perfect if it's working with compressors/packers

 

to catch the standard AutoitError popup is OK (as OP was asking. Perfect and best solution in this case)

but if you try to catch other errors, that do not arise that popup, as in this example, it will not be catched

(error from example5 of >this post, where it is catched instead)

are 2 different purposes

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinApi.au3>

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AddHookApi("user32.dll", "MessageBoxW", "Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint")
Func Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType)
    Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _
            "hwnd", $hWnd, _
            "wstr", $sText, _
            "wstr", StringReplace($sTitle, "AutoIt", @ScriptName), _
            "uint", $iType)
    If @error Or Not $aCall[0] Then Return 0
    Return $aCall[0]
EndFunc   ;==>Intercept_MessageBoxW
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Let's try it
; Usual message box
MsgBox(0, 'Test', 'Some text')

; Cause error that would say some AutoIt shit happened, but now it wouldn't say "AutoIt"
; llStructCreate("byte[123456789097]")
; ------- not catched error zone ------------------
Global $iToolTip = 0
_Recursion()

Func _Recursion()
    $iToolTip += 1
    ToolTip("Recursion number: " & $iToolTip, Default, Default, "Recursion")
    ;Sleep(10)
    Return _Recursion()
EndFunc   ;==>_Recursion
; ------- not catched error zone ------------------
; The End
; The magic is down below
Func AddHookApi($sModuleName, $vFunctionName, $vNewFunction, $sRet = "", $sParams = "")
    Local Static $pImportDirectory, $hInstance
    Local Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1
    If Not $pImportDirectory Then
        $hInstance = _WinAPI_GetModuleHandle(0)
        $pImportDirectory = ImageDirectoryEntryToData($hInstance, $IMAGE_DIRECTORY_ENTRY_IMPORT)
        If @error Then Return SetError(1, 0, 0)
    EndIf
    Local $iIsInt = IsInt($vFunctionName)
    Local $iRestore = Not IsString($vNewFunction)
    Local $tIMAGE_IMPORT_MODULE_DIRECTORY
    Local $pDirectoryOffset = $pImportDirectory
    Local $tModuleName
    Local $iInitialOffset, $iInitialOffset2
    Local $iOffset2
    Local $tBufferOffset2, $iBufferOffset2
    Local $tBuffer, $tFunctionOffset, $pOld, $fMatch, $pModuleName, $pFuncName
    Local Const $PAGE_READWRITE = 0x04
    While 1
        $tIMAGE_IMPORT_MODULE_DIRECTORY = DllStructCreate("dword RVAOriginalFirstThunk;" & _
                "dword TimeDateStamp;" & _
                "dword ForwarderChain;" & _
                "dword RVAModuleName;" & _
                "dword RVAFirstThunk", _
                $pDirectoryOffset)
        If Not DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk") Then ExitLoop
        $pModuleName = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAModuleName")
        $tModuleName = DllStructCreate("char Name[" & _WinAPI_StringLenA($pModuleName) & "]", $pModuleName)
        If DllStructGetData($tModuleName, "Name") = $sModuleName Then ; function from this module
            $iInitialOffset = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk")
            $iInitialOffset2 = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAOriginalFirstThunk")
            If $iInitialOffset2 = $hInstance Then $iInitialOffset2 = $iInitialOffset
            $iOffset2 = 0
            While 1
                $tBufferOffset2 = DllStructCreate("dword_ptr", $iInitialOffset2 + $iOffset2)
                $iBufferOffset2 = DllStructGetData($tBufferOffset2, 1)
                If Not $iBufferOffset2 Then ExitLoop
                If $iIsInt Then
                    If BitAND($iBufferOffset2, 0xFFFFFF) = $vFunctionName Then $fMatch = True; wanted function
                Else
                    $pFuncName = $hInstance + $iBufferOffset2 + 2 ; 2 is size od "word", see line below...
                    $tBuffer = DllStructCreate("word Ordinal; char Name[" & _WinAPI_StringLenA($pFuncName) & "]", $hInstance + $iBufferOffset2)
                    If DllStructGetData($tBuffer, "Name") == $vFunctionName Then $fMatch = True; wanted function
                EndIf
                If $fMatch Then
                    $tFunctionOffset = DllStructCreate("ptr", $iInitialOffset + $iOffset2)
                    VirtualProtect(DllStructGetPtr($tFunctionOffset), DllStructGetSize($tFunctionOffset), $PAGE_READWRITE)
                    If @error Then Return SetError(3, 0, 0)
                    $pOld = DllStructGetData($tFunctionOffset, 1)
                    If $iRestore Then
                        DllStructSetData($tFunctionOffset, 1, $vNewFunction)
                    Else
                        DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams)))
                    EndIf
                    Return $pOld
                EndIf
                $iOffset2 += DllStructGetSize($tBufferOffset2)
            WEnd
            ExitLoop
        EndIf
        $pDirectoryOffset += 20 ; size of $tIMAGE_IMPORT_MODULE_DIRECTORY
    WEnd
    Return SetError(4, 0, 0)
EndFunc   ;==>AddHookApi

Func VirtualProtect($pAddress, $iSize, $iProtection)
    Local $aCall = DllCall("kernel32.dll", "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return 1
EndFunc   ;==>VirtualProtect

Func ImageDirectoryEntryToData($hInstance, $iDirectoryEntry)
    ; Get pointer to data
    Local $pPointer = $hInstance
    ; Start processing passed binary data. 'Reading' PE format follows.
    Local $tIMAGE_DOS_HEADER = DllStructCreate("char Magic[2];" & _
            "word BytesOnLastPage;" & _
            "word Pages;" & _
            "word Relocations;" & _
            "word SizeofHeader;" & _
            "word MinimumExtra;" & _
            "word MaximumExtra;" & _
            "word SS;" & _
            "word SP;" & _
            "word Checksum;" & _
            "word IP;" & _
            "word CS;" & _
            "word Relocation;" & _
            "word Overlay;" & _
            "char Reserved[8];" & _
            "word OEMIdentifier;" & _
            "word OEMInformation;" & _
            "char Reserved2[20];" & _
            "dword AddressOfNewExeHeader", _
            $pPointer)
    Local $sMagic = DllStructGetData($tIMAGE_DOS_HEADER, "Magic")
    ; Check if it's valid format
    If Not ($sMagic == "MZ") Then Return SetError(1, 0, 0) ; MS-DOS header missing. Btw 'MZ' are the initials of Mark Zbikowski in case you didn't know.
    ; Move pointer
    $pPointer += DllStructGetData($tIMAGE_DOS_HEADER, "AddressOfNewExeHeader") ; move to PE file header
    ; In place of IMAGE_NT_SIGNATURE structure
    Local $tIMAGE_NT_SIGNATURE = DllStructCreate("dword Signature", $pPointer)
    ; Check signature
    If DllStructGetData($tIMAGE_NT_SIGNATURE, "Signature") <> 17744 Then ; IMAGE_NT_SIGNATURE
        Return SetError(2, 0, 0) ; wrong signature. For PE image should be "PE\0\0" or 17744 dword.
    EndIf
    ; Move pointer
    $pPointer += 4 ; size of $tIMAGE_NT_SIGNATURE structure
    ; In place of IMAGE_FILE_HEADER structure
    ; Move pointer
    $pPointer += 20 ; size of $tIMAGE_FILE_HEADER structure
    ; Determine the type
    Local $tMagic = DllStructCreate("word Magic;", $pPointer)
    Local $iMagic = DllStructGetData($tMagic, 1)
    Local $tIMAGE_OPTIONAL_HEADER
    If $iMagic = 267 Then ; x86 version
        ; Move pointer
        $pPointer += 96 ; size of $tIMAGE_OPTIONAL_HEADER
    ElseIf $iMagic = 523 Then ; x64 version
        ; Move pointer
        $pPointer += 112 ; size of $tIMAGE_OPTIONAL_HEADER
    Else
        Return SetError(3, 0, 0) ; unsupported module type
    EndIf
    ; Validate input by checking available number of structures that are in the module
    Local Const $IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16 ; predefined value that PE modules always use (AutoIt certainly)
    If $iDirectoryEntry > $IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1 Then Return SetError(4, 0, 0) ; invalid input
    ; Calculate the offset to wanted entry (every entry is 8 bytes)
    $pPointer += 8 * $iDirectoryEntry
    ; At place of correst directory entry
    Local $tIMAGE_DIRECTORY_ENTRY = DllStructCreate("dword VirtualAddress; dword Size", $pPointer)
    ; Collect data
    Local $pAddress = DllStructGetData($tIMAGE_DIRECTORY_ENTRY, "VirtualAddress")
    If $pAddress = 0 Then Return SetError(5, 0, 0) ; invalid input
    ; $pAddress is RVA, add it to base address
    Return $hInstance + $pAddress
EndFunc   ;==>ImageDirectoryEntryToData

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted
  On 11/23/2013 at 3:48 PM, gil900 said:

I just tried and it did not work in the stable version

 

it works for me

Autoit 3.3.8.1 stable

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Posted

  On 11/23/2013 at 7:40 PM, PincoPanco said:

it works for me

Autoit 3.3.8.1 stable

ok.

now I installed Autoit 3.3.8.1 on my second laptop and i tested it.

and it is working.. so maybe I screwed something in the AutoIt3Include folder in my first laptop..

good to know that i don't have to use the beta..

thanks very much for this sharing.

It's a lot better than what i found before

Posted

Can it work with obfuscator?

I'm trying using these directives but it keep throwing errors:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_Before=ShowOriginalLine.exe %in%
#AutoIt3Wrapper_Run_After=ShowOriginalLine.exe %in%

#AutoIt3Wrapper_Run_Obfuscator=y
#AutoIt3Wrapper_Icon=Icons\my_icon.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_LegalCopyright=(c) me
#AutoIt3Wrapper_Res_SaveSource=n
#Obfuscator_Parameters=/sf 1
#obfuscator_Ignore_Funcs=Callback
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

 

The error messages are:

- Iteration 1 Strip Functions result: Output  7087 lines and stripped 15954 lines
- Iteration 2 Strip Variables result: Output  7087 lines and stripped 0 lines
- Iteration 3 Start the actual Obfuscation.
Can't open file C:Documents and SettingsWindowsMy DocumentsDropboxExample2_Obfuscated.au3
 

  • 1 month later...
Posted
Is there any possibility to skip the display of this message, but keep the content of this message. 
 
I have tried several different ways, but I've done something wrong. 
 
I could count on a hint?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 1/18/2014 at 12:32 PM, mLipok said:

 

Is there any possibility to skip the display of this message, but keep the content of this message. 
 
I have tried several different ways, but I've done something wrong. 
 
I could count on a hint?

 

 

Can not answering your question, I'm too really need to hide or replace this error message title.

trancexx's solution is perfect except that it doesn't work if the compiled script is packed by any exe packer!

IMHO, any others error handler UDF is not as reliable as trancexx's solution, but how to make it work/compatible with exe packer?

Exe packer modify the PE header.

Posted
I do not use UPX or any other packer. 
So for me it just is not a problem.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 3 years later...
Posted
  On 8/28/2013 at 11:55 AM, trancexx said:

Here, let me then:

 

#include <WinApi.au3>

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AddHookApi("user32.dll", "MessageBoxW", "Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint")
Func Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType)
    Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _
            "hwnd", $hWnd, _
            "wstr", $sText, _
            "wstr", StringReplace($sTitle, "AutoIt", @ScriptName), _
            "uint", $iType)
    If @error Or Not $aCall[0] Then Return 0
    Return $aCall[0]
EndFunc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Let's try it
; Usual message box
MsgBox(0, 'Test', 'Some text')

; Cause error that would say some AutoIt shit happened, but now it wouldn't say "AutoIt"
DllStructCreate("byte[123456789097]")

; The End


; The magic is down below
Func AddHookApi($sModuleName, $vFunctionName, $vNewFunction, $sRet = "", $sParams = "")
    Local Static $pImportDirectory, $hInstance
    Local Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1
    If Not $pImportDirectory Then
        $hInstance = _WinAPI_GetModuleHandle(0)
        $pImportDirectory = ImageDirectoryEntryToData($hInstance, $IMAGE_DIRECTORY_ENTRY_IMPORT)
        If @error Then Return SetError(1, 0, 0)
    EndIf
    Local $iIsInt = IsInt($vFunctionName)
    Local $iRestore = Not IsString($vNewFunction)
    Local $tIMAGE_IMPORT_MODULE_DIRECTORY
    Local $pDirectoryOffset = $pImportDirectory
    Local $tModuleName
    Local $iInitialOffset, $iInitialOffset2
    Local $iOffset2
    Local $tBufferOffset2, $iBufferOffset2
    Local $tBuffer, $tFunctionOffset, $pOld, $fMatch, $pModuleName, $pFuncName
    Local Const $PAGE_READWRITE = 0x04
    While 1
        $tIMAGE_IMPORT_MODULE_DIRECTORY = DllStructCreate("dword RVAOriginalFirstThunk;" & _
                "dword TimeDateStamp;" & _
                "dword ForwarderChain;" & _
                "dword RVAModuleName;" & _
                "dword RVAFirstThunk", _
                $pDirectoryOffset)
        If Not DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk") Then ExitLoop
        $pModuleName = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAModuleName")
        $tModuleName = DllStructCreate("char Name[" & _WinAPI_StringLenA($pModuleName) & "]", $pModuleName)
        If DllStructGetData($tModuleName, "Name") = $sModuleName Then ; function from this module
            $iInitialOffset = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk")
            $iInitialOffset2 = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAOriginalFirstThunk")
            If $iInitialOffset2 = $hInstance Then $iInitialOffset2 = $iInitialOffset
            $iOffset2 = 0
            While 1
                $tBufferOffset2 = DllStructCreate("dword_ptr", $iInitialOffset2 + $iOffset2)
                $iBufferOffset2 = DllStructGetData($tBufferOffset2, 1)
                If Not $iBufferOffset2 Then ExitLoop
                If $iIsInt Then
                    If BitAND($iBufferOffset2, 0xFFFFFF) = $vFunctionName Then $fMatch = True; wanted function
                Else
                    $pFuncName = $hInstance + $iBufferOffset2 + 2 ; 2 is size od "word", see line below...
                    $tBuffer = DllStructCreate("word Ordinal; char Name[" & _WinAPI_StringLenA($pFuncName) & "]", $hInstance + $iBufferOffset2)
                    If DllStructGetData($tBuffer, "Name") == $vFunctionName Then $fMatch = True; wanted function
                EndIf
                If $fMatch Then
                    $tFunctionOffset = DllStructCreate("ptr", $iInitialOffset + $iOffset2)
                    VirtualProtect(DllStructGetPtr($tFunctionOffset), DllStructGetSize($tFunctionOffset), $PAGE_READWRITE)
                    If @error Then Return SetError(3, 0, 0)
                    $pOld = DllStructGetData($tFunctionOffset, 1)
                    If $iRestore Then
                        DllStructSetData($tFunctionOffset, 1, $vNewFunction)
                    Else
                        DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams)))
                    EndIf
                    Return $pOld
                EndIf
                $iOffset2 += DllStructGetSize($tBufferOffset2)
            WEnd
            ExitLoop
        EndIf
        $pDirectoryOffset += 20 ; size of $tIMAGE_IMPORT_MODULE_DIRECTORY
    WEnd
    Return SetError(4, 0, 0)
EndFunc

Func VirtualProtect($pAddress, $iSize, $iProtection)
    Local $aCall = DllCall("kernel32.dll", "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return 1
EndFunc

Func ImageDirectoryEntryToData($hInstance, $iDirectoryEntry)
    ; Get pointer to data
    Local $pPointer = $hInstance
    ; Start processing passed binary data. 'Reading' PE format follows.
    Local $tIMAGE_DOS_HEADER = DllStructCreate("char Magic[2];" & _
            "word BytesOnLastPage;" & _
            "word Pages;" & _
            "word Relocations;" & _
            "word SizeofHeader;" & _
            "word MinimumExtra;" & _
            "word MaximumExtra;" & _
            "word SS;" & _
            "word SP;" & _
            "word Checksum;" & _
            "word IP;" & _
            "word CS;" & _
            "word Relocation;" & _
            "word Overlay;" & _
            "char Reserved[8];" & _
            "word OEMIdentifier;" & _
            "word OEMInformation;" & _
            "char Reserved2[20];" & _
            "dword AddressOfNewExeHeader", _
            $pPointer)
    Local $sMagic = DllStructGetData($tIMAGE_DOS_HEADER, "Magic")
    ; Check if it's valid format
    If Not ($sMagic == "MZ") Then Return SetError(1, 0, 0) ; MS-DOS header missing. Btw 'MZ' are the initials of Mark Zbikowski in case you didn't know.
    ; Move pointer
    $pPointer += DllStructGetData($tIMAGE_DOS_HEADER, "AddressOfNewExeHeader") ; move to PE file header
    ; In place of IMAGE_NT_SIGNATURE structure
    Local $tIMAGE_NT_SIGNATURE = DllStructCreate("dword Signature", $pPointer)
    ; Check signature
    If DllStructGetData($tIMAGE_NT_SIGNATURE, "Signature") <> 17744 Then ; IMAGE_NT_SIGNATURE
        Return SetError(2, 0, 0) ; wrong signature. For PE image should be "PE\0\0" or 17744 dword.
    EndIf
    ; Move pointer
    $pPointer += 4 ; size of $tIMAGE_NT_SIGNATURE structure
    ; In place of IMAGE_FILE_HEADER structure
    ; Move pointer
    $pPointer += 20 ; size of $tIMAGE_FILE_HEADER structure
    ; Determine the type
    Local $tMagic = DllStructCreate("word Magic;", $pPointer)
    Local $iMagic = DllStructGetData($tMagic, 1)
    Local $tIMAGE_OPTIONAL_HEADER
    If $iMagic = 267 Then ; x86 version
        ; Move pointer
        $pPointer += 96 ; size of $tIMAGE_OPTIONAL_HEADER
    ElseIf $iMagic = 523 Then ; x64 version
        ; Move pointer
        $pPointer += 112 ; size of $tIMAGE_OPTIONAL_HEADER
    Else
        Return SetError(3, 0, 0) ; unsupported module type
    EndIf
    ; Validate input by checking available number of structures that are in the module
    Local Const $IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16 ; predefined value that PE modules always use (AutoIt certainly)
    If $iDirectoryEntry > $IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1 Then Return SetError(4, 0, 0) ; invalid input
    ; Calculate the offset to wanted entry (every entry is 8 bytes)
    $pPointer += 8 * $iDirectoryEntry
    ; At place of correst directory entry
    Local $tIMAGE_DIRECTORY_ENTRY = DllStructCreate("dword VirtualAddress; dword Size", $pPointer)
    ; Collect data
    Local $pAddress = DllStructGetData($tIMAGE_DIRECTORY_ENTRY, "VirtualAddress")
    If $pAddress = 0 Then Return SetError(5, 0, 0) ; invalid input
    ; $pAddress is RVA, add it to base address
    Return $hInstance + $pAddress
EndFunc

edit: because this is better than before.

Expand  

 

Can anyone confirm that this still works?
or... Has something changed in Windows ?

I'm surprised that it suddenly stopped working - I do not even know when, but only now I realized.

mLipok

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Which version of Windows do we talk about?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Windows 10 Pro 64 Bit + AutoIt 3.3.14.2

I found that I can make it to work properly by using:

Dim $a[1]
MsgBox(0, '', $a[2])

instead

; Cause error that would say some AutoIt shit happened, but now it wouldn't say "AutoIt"
DllStructCreate("byte[123456789097]")

 

But why this not works with DllStructCreate ?

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Are you sure you have 123456789097 (about 115 Gb) free memory bytes at runtime?
Corollary: what it the maximum process size allowed under your OS version?

Edited by jchd
  Reveal hidden contents

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

No. I do not have such a big space in my PC RAM.

In a meantime I was at home to eat dinner (fortunately, I have only 3 kilometers from home to work/office - 5 minutes by car)
I turn on my home PC and make small test.

I just copy this small one liner snippet:

DllStructCreate("byte[123456789097]")

to my SciTE4AutoIt installation compile them using F7 and just run the compiled exe file.
The sam test I do just few minutes ago on my Office computer.

here is how situation looks:

Runing this exe at home Win10 Pro 64Bit + 4GB RAM
I got error about allocation memory.

Runing this exe (compiled) at my office Win10 Pro 64Bit + 8GB RAM
I do not have any error.

 

So now I'm wondering if I had other AU3 compiler version at home .. will check it later.


Compilation log at office:

  Quote

>Running:(3.3.14.2):Z:\AutoItPortable\App\aut2exe\aut2exe.exe  /in "C:\Users\Szef\Desktop\test.au3" /out "C:\Users\Szef\AppData\Local\AutoIt v3\Aut2exe\~AUA75F.tmp.exe" /nopack /comp 2 /x64

Expand  

 

But the question is why I do not have any Error message when I run compiled script with AU3.3.14.2  ?

 

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

^^Because first you run x86 and then compile and run x64.

The problem is not with this function. AutoIt has "issue" converting string number to number number.

Run this on x64:

$blah = DllStructCreate("byte[" & 2147483647 + 2 & "]")
ConsoleWrite(DllStructGetSize($blah) & @CRLF) ; it should print 2147483649 if your system configuration supports allocating that much

 

  • 2 months later...
Posted (edited)

Here is an example how to translate error message:

#include <Array.au3>
#include <WinApi.au3>
#include <MsgBoxConstants.au3>

If $IDYES = MsgBox($MB_YESNO, 'Make a decision', 'Do you want to inercept error ?') Then
    AddHookApi("user32.dll", "MessageBoxW", "Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint")
EndIf

_Example()

Func _Example()

;~  _ErrorTranslator(Default) ; check your translation

    ; Let's try it
    ; Usual message box
    MsgBox(0, 'Test', 'Some text')

    ; Cause error that would say some AutoIt shit happened, but now it wouldn't say "AutoIt"
    DllStructCreate("byte[123456789097]")

    ; The End
EndFunc   ;==>_Example


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType)
    Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _
            "hwnd", $hWnd, _
            "wstr", _ErrorTranslator($sText), _
            "wstr", StringReplace($sTitle, "AutoIt", 'Error occured in ' & @ScriptName), _
            "uint", $iType)
    If @error Or Not $aCall[0] Then Return 0
    Return $aCall[0]
EndFunc   ;==>Intercept_MessageBoxW
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; The magic is down below
Func AddHookApi($sModuleName, $vFunctionName, $vNewFunction, $sRet = "", $sParams = "")
    Local Static $pImportDirectory, $hInstance
    Local Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1
    If Not $pImportDirectory Then
        $hInstance = _WinAPI_GetModuleHandle(0)
        $pImportDirectory = ImageDirectoryEntryToData($hInstance, $IMAGE_DIRECTORY_ENTRY_IMPORT)
        If @error Then Return SetError(1, 0, 0)
    EndIf
    Local $iIsInt = IsInt($vFunctionName)
    Local $iRestore = Not IsString($vNewFunction)
    Local $tIMAGE_IMPORT_MODULE_DIRECTORY
    Local $pDirectoryOffset = $pImportDirectory
    Local $tModuleName
    Local $iInitialOffset, $iInitialOffset2
    Local $iOffset2
    Local $tBufferOffset2, $iBufferOffset2
    Local $tBuffer, $tFunctionOffset, $pOld, $fMatch, $pModuleName, $pFuncName
    Local Const $PAGE_READWRITE = 0x04
    While 1
        $tIMAGE_IMPORT_MODULE_DIRECTORY = DllStructCreate("dword RVAOriginalFirstThunk;" & _
                "dword TimeDateStamp;" & _
                "dword ForwarderChain;" & _
                "dword RVAModuleName;" & _
                "dword RVAFirstThunk", _
                $pDirectoryOffset)
        If Not DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk") Then ExitLoop
        $pModuleName = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAModuleName")
        $tModuleName = DllStructCreate("char Name[" & _WinAPI_StringLenA($pModuleName) & "]", $pModuleName)
        If DllStructGetData($tModuleName, "Name") = $sModuleName Then ; function from this module
            $iInitialOffset = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAFirstThunk")
            $iInitialOffset2 = $hInstance + DllStructGetData($tIMAGE_IMPORT_MODULE_DIRECTORY, "RVAOriginalFirstThunk")
            If $iInitialOffset2 = $hInstance Then $iInitialOffset2 = $iInitialOffset
            $iOffset2 = 0
            While 1
                $tBufferOffset2 = DllStructCreate("dword_ptr", $iInitialOffset2 + $iOffset2)
                $iBufferOffset2 = DllStructGetData($tBufferOffset2, 1)
                If Not $iBufferOffset2 Then ExitLoop
                If $iIsInt Then
                    If BitAND($iBufferOffset2, 0xFFFFFF) = $vFunctionName Then $fMatch = True ; wanted function
                Else
                    $pFuncName = $hInstance + $iBufferOffset2 + 2 ; 2 is size od "word", see line below...
                    $tBuffer = DllStructCreate("word Ordinal; char Name[" & _WinAPI_StringLenA($pFuncName) & "]", $hInstance + $iBufferOffset2)
                    If DllStructGetData($tBuffer, "Name") == $vFunctionName Then $fMatch = True ; wanted function
                EndIf
                If $fMatch Then
                    $tFunctionOffset = DllStructCreate("ptr", $iInitialOffset + $iOffset2)
                    VirtualProtect(DllStructGetPtr($tFunctionOffset), DllStructGetSize($tFunctionOffset), $PAGE_READWRITE)
                    If @error Then Return SetError(3, 0, 0)
                    $pOld = DllStructGetData($tFunctionOffset, 1)
                    If $iRestore Then
                        DllStructSetData($tFunctionOffset, 1, $vNewFunction)
                    Else
                        DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams)))
                    EndIf
                    Return $pOld
                EndIf
                $iOffset2 += DllStructGetSize($tBufferOffset2)
            WEnd
            ExitLoop
        EndIf
        $pDirectoryOffset += 20 ; size of $tIMAGE_IMPORT_MODULE_DIRECTORY
    WEnd
    Return SetError(4, 0, 0)
EndFunc   ;==>AddHookApi

Func VirtualProtect($pAddress, $iSize, $iProtection)
    Local $aCall = DllCall("kernel32.dll", "bool", "VirtualProtect", "ptr", $pAddress, "dword_ptr", $iSize, "dword", $iProtection, "dword*", 0)
    If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
    Return 1
EndFunc   ;==>VirtualProtect

Func ImageDirectoryEntryToData($hInstance, $iDirectoryEntry)
    ; Get pointer to data
    Local $pPointer = $hInstance
    ; Start processing passed binary data. 'Reading' PE format follows.
    Local $tIMAGE_DOS_HEADER = DllStructCreate("char Magic[2];" & _
            "word BytesOnLastPage;" & _
            "word Pages;" & _
            "word Relocations;" & _
            "word SizeofHeader;" & _
            "word MinimumExtra;" & _
            "word MaximumExtra;" & _
            "word SS;" & _
            "word SP;" & _
            "word Checksum;" & _
            "word IP;" & _
            "word CS;" & _
            "word Relocation;" & _
            "word Overlay;" & _
            "char Reserved[8];" & _
            "word OEMIdentifier;" & _
            "word OEMInformation;" & _
            "char Reserved2[20];" & _
            "dword AddressOfNewExeHeader", _
            $pPointer)
    Local $sMagic = DllStructGetData($tIMAGE_DOS_HEADER, "Magic")
    ; Check if it's valid format
    If Not ($sMagic == "MZ") Then Return SetError(1, 0, 0) ; MS-DOS header missing. Btw 'MZ' are the initials of Mark Zbikowski in case you didn't know.
    ; Move pointer
    $pPointer += DllStructGetData($tIMAGE_DOS_HEADER, "AddressOfNewExeHeader") ; move to PE file header
    ; In place of IMAGE_NT_SIGNATURE structure
    Local $tIMAGE_NT_SIGNATURE = DllStructCreate("dword Signature", $pPointer)
    ; Check signature
    If DllStructGetData($tIMAGE_NT_SIGNATURE, "Signature") <> 17744 Then ; IMAGE_NT_SIGNATURE
        Return SetError(2, 0, 0) ; wrong signature. For PE image should be "PE\0\0" or 17744 dword.
    EndIf
    ; Move pointer
    $pPointer += 4 ; size of $tIMAGE_NT_SIGNATURE structure
    ; In place of IMAGE_FILE_HEADER structure
    ; Move pointer
    $pPointer += 20 ; size of $tIMAGE_FILE_HEADER structure
    ; Determine the type
    Local $tMagic = DllStructCreate("word Magic;", $pPointer)
    Local $iMagic = DllStructGetData($tMagic, 1)
    Local $tIMAGE_OPTIONAL_HEADER
    If $iMagic = 267 Then ; x86 version
        ; Move pointer
        $pPointer += 96 ; size of $tIMAGE_OPTIONAL_HEADER
    ElseIf $iMagic = 523 Then ; x64 version
        ; Move pointer
        $pPointer += 112 ; size of $tIMAGE_OPTIONAL_HEADER
    Else
        Return SetError(3, 0, 0) ; unsupported module type
    EndIf
    ; Validate input by checking available number of structures that are in the module
    Local Const $IMAGE_NUMBEROF_DIRECTORY_ENTRIES = 16 ; predefined value that PE modules always use (AutoIt certainly)
    If $iDirectoryEntry > $IMAGE_NUMBEROF_DIRECTORY_ENTRIES - 1 Then Return SetError(4, 0, 0) ; invalid input
    ; Calculate the offset to wanted entry (every entry is 8 bytes)
    $pPointer += 8 * $iDirectoryEntry
    ; At place of correst directory entry
    Local $tIMAGE_DIRECTORY_ENTRY = DllStructCreate("dword VirtualAddress; dword Size", $pPointer)
    ; Collect data
    Local $pAddress = DllStructGetData($tIMAGE_DIRECTORY_ENTRY, "VirtualAddress")
    If $pAddress = 0 Then Return SetError(5, 0, 0) ; invalid input
    ; $pAddress is RVA, add it to base address
    Return $hInstance + $pAddress
EndFunc   ;==>ImageDirectoryEntryToData


Func _ErrorTranslator($sText = Default)

    Local Static $aErrorMessages = _
            [ _
            [ _
            "(Paused) ", _
            "" _
            ], _
            [ _
            "AutoIt Error", _
            "" _
            ], _
            [ _
            "AutoIt has detected the stack has become corrupt.\n\nStack corruption typically occurs when either the wrong calling convention is used or when the function is called with the wrong number of arguments.\n\nAutoIt supports the __stdcall (WINAPI) and __cdecl calling conventions.  The __stdcall (WINAPI) convention is used by default but __cdecl can be used instead.  See the DllCall() documentation for details on changing the calling convention.", _
            "" _
            ], _
            [ _
            """EndWith"" missing ""With"".", _
            "" _
            ], _
            [ _
            "Badly formatted ""Func"" statement.", _
            "" _
            ], _
            [ _
            """With"" missing ""EndWith"".", _
            "" _
            ], _
            [ _
            "Missing right bracket ')' in expression.", _
            "" _
            ], _
            [ _
            "Missing operator in expression.", _
            "" _
            ], _
            [ _
            "Unbalanced brackets in expression.", _
            "" _
            ], _
            [ _
            "Error in expression.", _
            "" _
            ], _
            [ _
            "Error parsing function call.", _
            "" _
            ], _
            [ _
            "Incorrect number of parameters in function call.", _
            "" _
            ], _
            [ _
            """ReDim"" used without an array variable.", _
            "" _
            ], _
            [ _
            "Illegal text at the end of statement (one statement per line).", _
            "" _
            ], _
            [ _
            """If"" statement has no matching ""EndIf"" statement.", _
            "" _
            ], _
            [ _
            """Else"" statement with no matching ""If"" statement.", _
            "" _
            ], _
            [ _
            """EndIf"" statement with no matching ""If"" statement.", _
            "" _
            ], _
            [ _
            "Too many ""Else"" statements for matching ""If"" statement.", _
            "" _
            ], _
            [ _
            """While"" statement has no matching ""Wend"" statement.", _
            "" _
            ], _
            [ _
            """Wend"" statement with no matching ""While"" statement.", _
            "" _
            ], _
            [ _
            "Variable used without being declared.", _
            "" _
            ], _
            [ _
            "Array variable has incorrect number of subscripts or subscript dimension range exceeded.", _
            "" _
            ], _
            [ _
            "Variable subscript badly formatted.", _
            "" _
            ], _
            [ _
            "Subscript used on non-accessible variable.", _
            "" _
            ], _
            [ _
            "Too many subscripts used for an array.", _
            "" _
            ], _
            [ _
            "Missing subscript dimensions in ""Dim"" statement.", _
            "" _
            ], _
            [ _
            "No variable given for ""Dim"", ""Local"", ""Global"", ""Struct"" or ""Const"" statement.", _
            "" _
            ], _
            [ _
            "Expected a ""="" operator in assignment statement.", _
            "" _
            ], _
            [ _
            "Invalid keyword at the start of this line.", _
            "" _
            ], _
            [ _
            "Array maximum size exceeded.", _
            "" _
            ], _
            [ _
            """Func"" statement has no matching ""EndFunc"".", _
            "" _
            ], _
            [ _
            "Duplicate function name.", _
            "" _
            ], _
            [ _
            "Unknown function name.", _
            "" _
            ], _
            [ _
            "Unknown macro.", _
            "" _
            ], _
            [ _
            "Unable to get a list of running processes.", _
            "" _
            ], _
            [ _
            "Invalid element in a DllStruct.", _
            "" _
            ], _
            [ _
            "Unknown option or bad parameter specified.", _
            "" _
            ], _
            [ _
            "Unable to load the internet libraries.", _
            "" _
            ], _
            [ _
            """Struct"" statement has no matching ""EndStruct"".", _
            "" _
            ], _
            [ _
            "Unable to open file, the maximum number of open files has been exceeded.", _
            "" _
            ], _
            [ _
            """ContinueLoop"" statement with no matching ""While"", ""Do"" or ""For"" statement.", _
            "" _
            ], _
            [ _
            "Invalid file filter given.", _
            "" _
            ], _
            [ _
            "Expected a variable in user function call.", _
            "" _
            ], _
            [ _
            """Do"" statement has no matching ""Until"" statement.", _
            "" _
            ], _
            [ _
            """Until"" statement with no matching ""Do"" statement.", _
            "" _
            ], _
            [ _
            """For"" statement is badly formatted.", _
            "" _
            ], _
            [ _
            """Next"" statement with no matching ""For"" statement.", _
            "" _
            ], _
            [ _
            """ExitLoop/ContinueLoop"" statements only valid from inside a For/Do/While loop.", _
            "" _
            ], _
            [ _
            """For"" statement has no matching ""Next"" statement.", _
            "" _
            ], _
            [ _
            """Case"" statement with no matching ""Select""or ""Switch"" statement.", _
            "" _
            ], _
            [ _
            """EndSelect"" statement with no matching ""Select"" statement.", _
            "" _
            ], _
            [ _
            "Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.", _
            "" _
            ], _
            [ _
            "Cannot make existing variables static.", _
            "" _
            ], _
            [ _
            "Cannot make static variables into regular variables.", _
            "" _
            ], _
            [ _
            "Badly formated Enum statement", _
            "" _
            ], _
            [ _
            "This keyword cannot be used after a ""Then"" keyword.", _
            "" _
            ], _
            [ _
            """Select"" statement is missing ""EndSelect"" or ""Case"" statement.", _
            "" _
            ], _
            [ _
            """If"" statements must have a ""Then"" keyword.", _
            "" _
            ], _
            [ _
            "Badly formated Struct statement.", _
            "" _
            ], _
            [ _
            "Cannot assign values to constants.", _
            "" _
            ], _
            [ _
            "Cannot make existing variables into constants.", _
            "" _
            ], _
            [ _
            "Only Object-type variables allowed in a ""With"" statement.", _
            "" _
            ], _
            [ _
            """long_ptr"", ""int_ptr"" and ""short_ptr"" DllCall() types have been deprecated.  Use ""long*"", ""int*"" and ""short*"" instead.", _
            "" _
            ], _
            [ _
            "Object referenced outside a ""With"" statement.", _
            "" _
            ], _
            [ _
            "Nested ""With"" statements are not allowed.", _
            "" _
            ], _
            [ _
            "Variable must be of type ""Object"".", _
            "" _
            ], _
            [ _
            "The requested action with this object has failed.", _
            "" _
            ], _
            [ _
            "Variable appears more than once in function declaration.", _
            "" _
            ], _
            [ _
            "ReDim array can not be initialized in this manner.", _
            "" _
            ], _
            [ _
            "An array variable can not be used in this manner.", _
            "" _
            ], _
            [ _
            "Can not redeclare a constant.", _
            "" _
            ], _
            [ _
            "Can not redeclare a parameter inside a user function.", _
            "" _
            ], _
            [ _
            "Can pass constants by reference only to parameters with ""Const"" keyword.", _
            "" _
            ], _
            [ _
            "Can not initialize a variable with itself.", _
            "" _
            ], _
            [ _
            "Incorrect way to use this parameter.", _
            "" _
            ], _
            [ _
            """EndSwitch"" statement with no matching ""Switch"" statement.", _
            "" _
            ], _
            [ _
            """Switch"" statement is missing ""EndSwitch"" or ""Case"" statement.", _
            "" _
            ], _
            [ _
            """ContinueCase"" statement with no matching ""Select""or ""Switch"" statement.", _
            "" _
            ], _
            [ _
            "Assert Failed!", _
            "" _
            ], _
            [ _
            "Obsolete function/parameter.", _
            "" _
            ], _
            [ _
            "Invalid Exitcode (reserved for AutoIt internal use).", _
            "" _
            ], _
            [ _
            "Variable cannot be accessed in this manner.", _
            "" _
            ], _
            [ _
            "Func reassign not allowed.", _
            "" _
            ], _
            [ _
            "Func reassign on global level not allowed.", _
            "" _
            ], _
            [ _
            "Unable to parse line.", _
            "" _
            ], _
            [ _
            "Unable to open the script file.", _
            "" _
            ], _
            [ _
            "String missing closing quote.", _
            "" _
            ], _
            [ _
            "Badly formated variable or macro.", _
            "" _
            ], _
            [ _
            "Missing separator character after keyword.", _
            "" _
            ], _
            [ _
            "Error allocating memory.", _
            "Błąd allokacji pamiÄ™ci." _
            ] _
            ]

    Local Static $aErrorMessages2 = _
            [ _
            ["(Paused) ", ""], _
            ["AutoIt Error", ""], _
            ["AutoIt has detected the stack has become corrupt.\n\nStack corruption typically occurs when either the wrong calling convention is used or when the function is called with the wrong number of arguments.\n\nAutoIt supports the __stdcall (WINAPI) and __cdecl calling conventions.  The __stdcall (WINAPI) convention is used by default but __cdecl can be used instead.  See the DllCall() documentation for details on changing the calling convention.", ""], _
            ["""EndWith"" missing ""With"".", ""], _
            ["Badly formatted ""Func"" statement.", ""], _
            ["""With"" missing ""EndWith"".", ""], _
            ["Missing right bracket ')' in expression.", ""], _
            ["Missing operator in expression.", ""], _
            ["Unbalanced brackets in expression.", ""], _
            ["Error in expression.", ""], _
            ["Error parsing function call.", ""], _
            ["Incorrect number of parameters in function call.", ""], _
            ["""ReDim"" used without an array variable.", ""], _
            ["Illegal text at the end of statement (one statement per line).", ""], _
            ["""If"" statement has no matching ""EndIf"" statement.", ""], _
            ["""Else"" statement with no matching ""If"" statement.", ""], _
            ["""EndIf"" statement with no matching ""If"" statement.", ""], _
            ["Too many ""Else"" statements for matching ""If"" statement.", ""], _
            ["""While"" statement has no matching ""Wend"" statement.", ""], _
            ["""Wend"" statement with no matching ""While"" statement.", ""], _
            ["Variable used without being declared.", ""], _
            ["Array variable has incorrect number of subscripts or subscript dimension range exceeded.", ""], _
            ["Variable subscript badly formatted.", ""], _
            ["Subscript used on non-accessible variable.", ""], _
            ["Too many subscripts used for an array.", ""], _
            ["Missing subscript dimensions in ""Dim"" statement.", ""], _
            ["No variable given for ""Dim"", ""Local"", ""Global"", ""Struct"" or ""Const"" statement.", ""], _
            ["Expected a ""="" operator in assignment statement.", ""], _
            ["Invalid keyword at the start of this line.", ""], _
            ["Array maximum size exceeded.", ""], _
            ["""Func"" statement has no matching ""EndFunc"".", ""], _
            ["Duplicate function name.", ""], _
            ["Unknown function name.", ""], _
            ["Unknown macro.", ""], _
            ["Unable to get a list of running processes.", ""], _
            ["Invalid element in a DllStruct.", ""], _
            ["Unknown option or bad parameter specified.", ""], _
            ["Unable to load the internet libraries.", ""], _
            ["""Struct"" statement has no matching ""EndStruct"".", ""], _
            ["Unable to open file, the maximum number of open files has been exceeded.", ""], _
            ["""ContinueLoop"" statement with no matching ""While"", ""Do"" or ""For"" statement.", ""], _
            ["Invalid file filter given.", ""], _
            ["Expected a variable in user function call.", ""], _
            ["""Do"" statement has no matching ""Until"" statement.", ""], _
            ["""Until"" statement with no matching ""Do"" statement.", ""], _
            ["""For"" statement is badly formatted.", ""], _
            ["""Next"" statement with no matching ""For"" statement.", ""], _
            ["""ExitLoop/ContinueLoop"" statements only valid from inside a For/Do/While loop.", ""], _
            ["""For"" statement has no matching ""Next"" statement.", ""], _
            ["""Case"" statement with no matching ""Select""or ""Switch"" statement.", ""], _
            ["""EndSelect"" statement with no matching ""Select"" statement.", ""], _
            ["Recursion level has been exceeded - AutoIt will quit to prevent stack overflow.", ""], _
            ["Cannot make existing variables static.", ""], _
            ["Cannot make static variables into regular variables.", ""], _
            ["Badly formated Enum statement", ""], _
            ["This keyword cannot be used after a ""Then"" keyword.", ""], _
            ["""Select"" statement is missing ""EndSelect"" or ""Case"" statement.", ""], _
            ["""If"" statements must have a ""Then"" keyword.", ""], _
            ["Badly formated Struct statement.", ""], _
            ["Cannot assign values to constants.", ""], _
            ["Cannot make existing variables into constants.", ""], _
            ["Only Object-type variables allowed in a ""With"" statement.", ""], _
            ["""long_ptr"", ""int_ptr"" and ""short_ptr"" DllCall() types have been deprecated.  Use ""long*"", ""int*"" and ""short*"" instead.", ""], _
            ["Object referenced outside a ""With"" statement.", ""], _
            ["Nested ""With"" statements are not allowed.", ""], _
            ["Variable must be of type ""Object"".", ""], _
            ["The requested action with this object has failed.", ""], _
            ["Variable appears more than once in function declaration.", ""], _
            ["ReDim array can not be initialized in this manner.", ""], _
            ["An array variable can not be used in this manner.", ""], _
            ["Can not redeclare a constant.", ""], _
            ["Can not redeclare a parameter inside a user function.", ""], _
            ["Can pass constants by reference only to parameters with ""Const"" keyword.", ""], _
            ["Can not initialize a variable with itself.", ""], _
            ["Incorrect way to use this parameter.", ""], _
            ["""EndSwitch"" statement with no matching ""Switch"" statement.", ""], _
            ["""Switch"" statement is missing ""EndSwitch"" or ""Case"" statement.", ""], _
            ["""ContinueCase"" statement with no matching ""Select""or ""Switch"" statement.", ""], _
            ["Assert Failed!", ""], _
            ["Obsolete function/parameter.", ""], _
            ["Invalid Exitcode (reserved for AutoIt internal use).", ""], _
            ["Variable cannot be accessed in this manner.", ""], _
            ["Func reassign not allowed.", ""], _
            ["Func reassign on global level not allowed.", ""], _
            ["Unable to parse line.", ""], _
            ["Unable to open the script file.", ""], _
            ["String missing closing quote.", ""], _
            ["Badly formated variable or macro.", ""], _
            ["Missing separator character after keyword.", ""], _
            ["Error allocating memory.", "Błąd allokacji pamiÄ™ci."] _
            ]

    ConsoleWrite("! $sText= " & $sText & @CRLF)
    For $iError_idx = 0 To UBound($aErrorMessages) - 1
        If $aErrorMessages[$iError_idx][0] = $sText Then
            $sText = $aErrorMessages[$iError_idx][1]
        EndIf
    Next

    If Not @Compiled And $sText = Default Then _ArrayDisplay($aErrorMessages)
    If Not @Compiled And $sText = Default Then _ArrayDisplay($aErrorMessages2)
    Return $sText
EndFunc   ;==>_ErrorTranslator

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 years later...
Posted

Another example how to use this with:

#AutoIt3Wrapper_Change2CUI=Y

 

can be found here:

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

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