Leaderboard
Popular Content
Showing content with the highest reputation on 11/19/2025 in all areas
-
1 point
-
Spawning a process with reduced privileges
Nine reacted to WildByDesign for a topic
This is pure gold! The IsProcessElevated() function is also fantastic. Thank you so much. As you said, it works perfectly on x86 and x64. By the way, related to this, I was able to integrate your WCD_IPC UDF into my engine script which is actually a multi-process engine. Your UDF was the only one light enough and fast enough to do the job. I actually ended up creating a "broker" process for my multi-process engine and that is where I put your IPC server function. And now with the help of your RunLow() function, I can drop the privileges of the GUI and the GUI can still control the elevated "broker" process and therefore also control the various processes. Your willingness to help combined with your abilities to educate others on this forum are absolutely top-notch!1 point -
Version 2.0
17 downloads
HardwareMonitor AutoIt UDF A comprehensive hardware monitoring library for AutoIt with 65 read-only functions to monitor CPU, GPU, RAM, Storage, Battery, and Motherboard sensors. 🎯 Features 100% Read-Only - Safe monitoring without hardware control Cross-Platform Compatible - Works on different Windows systems Exception Handling - Crash-free operation with graceful fallbacks Multi-GPU Support - NVIDIA and AMD Radeon GPUs Extensive Sensor Coverage - Temperature, clocks, voltages, fan speeds, and more 📦 Package Contents HardwareMonitor.dll - Native C++ monitoring library (Only x64) HardwareMonitor.au3 - AutoIt UDF wrapper with 65 functions test_udf.au3 - Comprehensive test script demonstrating all features 🔧 Requirements AutoIt 3.3.14.0+ (x64 version recommended) Windows 7/8/10/11 (x64) Administrator Rights - Required for low-level hardware access Optional: PawnIO driver for enhanced motherboard monitoring 🚀 Quick Start 1. Basic Usage #RequireAdmin #include "HardwareMonitor.au3" ; Initialize library If Not _HWMon_Initialize() Then MsgBox(16, "Error", "Failed to initialize: " & _HWMon_GetLastError()) Exit EndIf ; Get hardware information Local $aModuleInfo = _HWMon_GetModuleInfo() If @error Then MsgBox(16, "Error", "Failed to get module info") _HWMon_Shutdown() Exit EndIf ; Check available modules ConsoleWrite("Intel CPU: " & ($aModuleInfo[2] ? "Yes" : "No") & @CRLF) ConsoleWrite("AMD Radeon GPU: " & ($aModuleInfo[7] ? "Yes" : "No") & @CRLF) ConsoleWrite("Storage: " & ($aModuleInfo[9] ? "Yes" : "No") & @CRLF) ; Cleanup _HWMon_Shutdown() 2. CPU Temperature Monitoring #RequireAdmin #include "HardwareMonitor.au3" _HWMon_Initialize() ; Get Intel CPU temperatures Local $coreCount = _HWMon_IntelCPU_GetCoreCount() ConsoleWrite("CPU Cores: " & $coreCount & @CRLF) For $i = 0 To $coreCount - 1 Local $temp = _HWMon_IntelCPU_GetCoreTemperature($i) ConsoleWrite("Core " & $i & ": " & $temp & "°C" & @CRLF) Next _HWMon_Shutdown() 3. GPU Monitoring #RequireAdmin #include "HardwareMonitor.au3" _HWMon_Initialize() ; AMD Radeon GPU Local $gpuCount = _HWMon_AMDRadeon_EnumerateGPUs() If $gpuCount > 0 Then _HWMon_AMDRadeon_SelectGPU(0) _HWMon_AMDRadeon_Update() ConsoleWrite("GPU: " & _HWMon_AMDRadeon_GetGPUName() & @CRLF) ConsoleWrite("Temperature: " & _HWMon_AMDRadeon_GetGPUTemperature() & "°C" & @CRLF) ConsoleWrite("Core Clock: " & _HWMon_AMDRadeon_GetCoreClock() & " MHz" & @CRLF) ConsoleWrite("Memory Clock: " & _HWMon_AMDRadeon_GetMemoryClock() & " MHz" & @CRLF) EndIf _HWMon_Shutdown() 📚 Available Modules Core Functions (3) _HWMon_Initialize() - Initialize library _HWMon_GetModuleInfo() - Get available hardware modules _HWMon_Shutdown() - Cleanup and shutdown Intel CPU Monitor (4) _HWMon_IntelCPU_GetCoreCount() - Number of CPU cores _HWMon_IntelCPU_GetPackageTemperature() - Package temperature _HWMon_IntelCPU_GetCoreTemperature($core) - Individual core temperature _HWMon_IntelCPU_GetTjMax() - Maximum junction temperature AMD CPU Monitor (3) _HWMon_AMDCPU_GetCoreCount() - Number of CPU cores _HWMon_AMDCPU_GetCoreTemperature($core) - Core temperature _HWMon_AMDCPU_GetCCDTemperature($ccd) - CCD temperature (Zen 2+) NVIDIA GPU Monitor (13) _HWMon_NVIDIAGPU_EnumerateGPUs() - Count NVIDIA GPUs _HWMon_NVIDIAGPU_SelectGPU($index) - Select GPU _HWMon_NVIDIAGPU_Update() - Update sensor readings _HWMon_NVIDIAGPU_GetGPUName() - GPU name _HWMon_NVIDIAGPU_GetGPUTemperature() - GPU temperature _HWMon_NVIDIAGPU_GetCoreClock() - Core clock (MHz) _HWMon_NVIDIAGPU_GetMemoryClock() - Memory clock (MHz) _HWMon_NVIDIAGPU_GetShaderClock() - Shader clock (MHz) _HWMon_NVIDIAGPU_GetFanSpeed() - Fan speed (RPM) _HWMon_NVIDIAGPU_GetFanSpeedPercent() - Fan speed (%) _HWMon_NVIDIAGPU_GetGPUUsage() - GPU usage (%) _HWMon_NVIDIAGPU_GetMemoryUsage() - Memory usage (MB) _HWMon_NVIDIAGPU_GetPowerUsage() - Power usage (W) AMD Radeon GPU Monitor (13) _HWMon_AMDRadeon_EnumerateGPUs() - Count AMD GPUs _HWMon_AMDRadeon_SelectGPU($index) - Select GPU _HWMon_AMDRadeon_Update() - Update sensor readings _HWMon_AMDRadeon_GetGPUName() - GPU name _HWMon_AMDRadeon_GetGPUTemperature() - GPU temperature _HWMon_AMDRadeon_GetHotspotTemperature() - Hotspot temperature _HWMon_AMDRadeon_GetMemoryTemperature() - Memory temperature _HWMon_AMDRadeon_GetCoreClock() - Core clock (MHz) _HWMon_AMDRadeon_GetMemoryClock() - Memory clock (MHz) _HWMon_AMDRadeon_GetFanSpeed() - Fan speed (RPM) _HWMon_AMDRadeon_GetFanSpeedPercent() - Fan speed (%) _HWMon_AMDRadeon_GetGPUUsage() - GPU usage (%) _HWMon_AMDRadeon_GetPowerUsage() - Power usage (W) Storage Monitor (4) _HWMon_Storage_EnumerateDrives() - Count storage drives _HWMon_Storage_GetDriveName($index) - Drive name _HWMon_Storage_GetDriveType($index) - Drive type (SSD/HDD) _HWMon_Storage_GetTemperature($index) - Drive temperature RAM Monitor (10) _HWMon_RAM_Initialize() - Initialize RAM monitoring _HWMon_RAM_GetTotalMemory() - Total RAM (GB) _HWMon_RAM_GetUsedMemory() - Used RAM (GB) _HWMon_RAM_GetAvailableMemory() - Available RAM (GB) _HWMon_RAM_GetMemoryLoad() - Memory load (%) _HWMon_RAM_GetMemorySpeed() - RAM speed (MHz) _HWMon_RAM_GetMemoryVoltage() - RAM voltage (V) _HWMon_RAM_GetModuleCount() - Number of RAM modules _HWMon_RAM_GetModuleSize($index) - Module size (GB) _HWMon_RAM_GetModuleSpeed($index) - Module speed (MHz) Battery Monitor (15) _HWMon_Battery_Initialize() - Initialize battery monitoring _HWMon_Battery_IsPresent() - Check if battery present _HWMon_Battery_GetStatus() - Battery status string _HWMon_Battery_GetChargeLevel() - Charge level (%) _HWMon_Battery_GetVoltage() - Voltage (V) _HWMon_Battery_GetChargeCurrent() - Charge current (mA) _HWMon_Battery_GetDischargeCurrent() - Discharge current (mA) _HWMon_Battery_GetChargeRate() - Charge rate (W) _HWMon_Battery_GetDischargeRate() - Discharge rate (W) _HWMon_Battery_GetRemainingCapacity() - Remaining capacity (mWh) _HWMon_Battery_GetFullChargeCapacity() - Full charge capacity (mWh) _HWMon_Battery_GetDesignCapacity() - Design capacity (mWh) _HWMon_Battery_GetHealth() - Battery health (%) _HWMon_Battery_GetEstimatedTime() - Estimated time (minutes) _HWMon_Battery_GetCycleCount() - Charge cycle count Motherboard Monitor (14) _HWMon_Motherboard_Initialize() - Initialize motherboard monitoring _HWMon_Motherboard_IsChipDetected() - Check if Super I/O chip detected _HWMon_Motherboard_GetChipName() - Super I/O chip name _HWMon_Motherboard_GetTemperatureCount() - Number of temperature sensors _HWMon_Motherboard_GetTemperature($index) - Temperature sensor value _HWMon_Motherboard_GetTemperatureName($index) - Temperature sensor name _HWMon_Motherboard_GetVoltageCount() - Number of voltage sensors _HWMon_Motherboard_GetVoltage($index) - Voltage sensor value _HWMon_Motherboard_GetVoltageName($index) - Voltage sensor name _HWMon_Motherboard_GetFanCount() - Number of fan sensors _HWMon_Motherboard_GetFanSpeed($index) - Fan speed (RPM) _HWMon_Motherboard_GetFanName($index) - Fan name _HWMon_Motherboard_GetFanControlPercent($index) - Fan control (%) _HWMon_Motherboard_Update() - Update all sensor readings 🔍 Hardware Detection Module Info Array Structure Local $aModuleInfo = _HWMon_GetModuleInfo() ; [0] = Library Initialized (1/0) ; [1] = PawnIO Available (1/0) ; [2] = Intel CPU (1/0) ; [3] = AMD CPU (1/0) ; [4] = AMD CPU Family ; [5] = NVIDIA GPU (1/0) ; [6] = NVIDIA GPU Count ; [7] = AMD Radeon GPU (1/0) ; [8] = AMD Radeon GPU Count ; [9] = Storage (1/0) ; [10] = Storage Count AMD GPU Detection The library uses a 3-tier fallback system for AMD GPU detection: ADL2 API (Primary) - Full monitoring support with temperature, clocks, fan, etc. ADL1 API (Fallback) - Legacy driver support WMI (Final Fallback) - Detection only, limited monitoring Note: Some AMD GPUs may be detected but not fully monitorable due to driver limitations. If ADL fails, the GPU will be detected via WMI but monitoring functions will return 0. 🛠️ Supported Hardware CPUs Intel Core (all generations with DTS support) AMD Ryzen (Zen, Zen+, Zen 2, Zen 3, Zen 4) GPUs NVIDIA: GeForce GTX/RTX series (NVAPI support required) AMD: Radeon RX series (ADL or WMI detection) Motherboards Supports 71 Super I/O chips from: ITE: IT8705F, IT8712F, IT8716F, IT8718F, IT8720F, IT8721F, IT8728F, IT8792E Nuvoton: NCT6775F, NCT6776F, NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D, NCT6797D, NCT6798D Winbond: W83627HF, W83627DHG, W83627EHF, W83667HG Fintek: F71858, F71862, F71869, F71882, F71889ED, F71889AD SMSC: SCH5027 ⚠️ Important Notes Administrator Rights All hardware monitoring requires administrator privileges. Always use #RequireAdmin in your scripts. Error Handling Always check for errors after function calls: Local $result = _HWMon_SomeFunction() If @error Then ConsoleWrite("Error: " & _HWMon_GetLastError() & @CRLF) EndIf Update Functions Some modules require calling Update() before reading sensors: _HWMon_NVIDIAGPU_Update() _HWMon_AMDRadeon_Update() _HWMon_Motherboard_Update() Cleanup Always call _HWMon_Shutdown() before exiting to properly cleanup resources. 🐛 Troubleshooting "Library not initialized" Ensure you called _HWMon_Initialize() first Check if DLL is in the same folder as your script Verify you're running as administrator "Module not available" Check _HWMon_GetModuleInfo() to see which modules are detected Some hardware may not be supported (e.g., laptop motherboards) AMD GPU may be detected but not monitorable (driver limitation) Crashes or Unexpected Behavior Ensure you're using the x64 version of AutoIt Update your GPU drivers to the latest version Check _HWMon_GetLastError() for detailed error messages 📄 License This library is provided as-is for hardware monitoring purposes only. No hardware control or modification is performed. 🙏 Credits Built using: NVAPI - NVIDIA GPU monitoring ADL - AMD GPU monitoring WMI - Windows Management Instrumentation fallback PawnIO - Low-level I/O access for motherboard monitoring 📞 Support For issues, questions, or feature requests, please check: This README for common solutions test_udf.au3 for usage examples Error messages from _HWMon_GetLastError() Status: Production Ready ✅1 point -
Here (tested both x86 and x64) ; From Nine #RequireAdmin #AutoIt3Wrapper_UseX64=y #include <WinAPI.au3> Example() Func Example() Local $iPID = RunLow(@ComSpec, " /k Title Low") ConsoleWrite($iPID & " : " & IsProcessElevated($iPID) & @CRLF) EndFunc ;==>Example Func IsProcessElevated($iPID) Local $aRet, $iError = 0 Local $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_LIMITED_INFORMATION, False, $iPID, True) If Not $hProcess Then Return SetError(1, 0, False) Local $hToken = _WinAPI_OpenProcessToken($TOKEN_QUERY, $hProcess) If Not $hToken Then $iError = 2 Else $aRet = DllCall('advapi32.dll', 'bool', 'GetTokenInformation', 'handle', $hToken, 'uint', 20, 'uint*', 0, 'dword', 4, 'dword*', 0) ; TOKEN_ELEVATION If @error Or Not $aRet[0] Then $iError = 3 EndIf _WinAPI_CloseHandle($hToken) _WinAPI_CloseHandle($hProcess) If $iError Then Return SetError($iError, 0, False) Return $aRet[3] = 1 EndFunc ;==>IsProcessElevated Func RunLow($sPath, $sCmd = "") Local $hProcess = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION, False, ProcessExists("explorer.exe")) Local $hToken = _WinAPI_OpenProcessToken($TOKEN_DUPLICATE, $hProcess) Local $hDupToken = _WinAPI_DuplicateTokenEx($hToken, $TOKEN_ALL_ACCESS, $SECURITYIMPERSONATION) Local $tSTARTUPINFO = DllStructCreate($tagSTARTUPINFO) $tSTARTUPINFO.Size = DllStructGetSize($tSTARTUPINFO) Local $tPROCESS = DllStructCreate($tagPROCESS_INFORMATION) _WinAPI_CreateProcessWithToken($sPath, $sCmd, 0, $tSTARTUPINFO, $tPROCESS, $hDupToken) _WinAPI_CloseHandle($hDupToken) _WinAPI_CloseHandle($hToken) _WinAPI_CloseHandle($hProcess) Return $tPROCESS.ProcessID EndFunc ;==>RunLow1 point
-
I have removed the redundant - or, non-essential lines...which are implemented in "other" scripts...but of which are NOT required here. Thanks for the clarification....1 point
-
It could be something like this. #include <AutoItConstants.au3> Opt("MustDeclareVars", 1) Global $iTimeOut = 100 ; **** Preset Configuration Array **** ; This is a 2D array holding all the data that changes between presets. ; Column 0: Preset Name - e.g. "Preset 002" ; Column 1: AmpSimView MouseClick Y-coordinate - e.g. 544 or 564 ; Column 2: Mouse positioning X-coordinate - e.g. 885 ; Column 3: Mouse positioning Y-coordinate - e.g. 222 Global $aPresets[2][4] = [ _ ["Preset 002", 544, 885, 222], _ ["Preset 003", 564, 885, 222] _ ] CallPresetScene($aPresets[0][0], $aPresets[0][1], $aPresets[0][2], $aPresets[0][3]) ; 🔔 Preset 002 ;~ CallPresetScene($aPresets[1][0], $aPresets[1][1], $aPresets[1][2], $aPresets[1][3]) ; 🔔 Preset 003 ; ... ; ------------------------------------------------------------------------------ Func CallPresetScene($sPresetName, $iAmpSimY, $iMPosX, $iMPosY) ConfigureAmpSimView($sPresetName, $iAmpSimY) ConfigureFMixerView() UpdateScenesView($sPresetName, $iMPosX, $iMPosY) UpdateSceneProperties($iMPosX, $iMPosY) EndFunc ;==>CallPresetScene ; ------------------------------------------------------------------------------ Func ConfigureAmpSimView($sPresetName, $iMPosY) Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 534, $iMPosY, 2, 0) EndFunc ;==>ConfigureAmpSimView ; ------------------------------------------------------------------------------ Func ConfigureFMixerView() Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 50, 120, 1, 0) ; Select: Channel Label [ZMixer] EndFunc ;==>ConfigureFMixerView ; ------------------------------------------------------------------------------ Func UpdateScenesView($sPresetName, $iMPosX, $iMPosY) Local $hSAC_SCENES = "[CLASS:SAC_SCENES]" WinActivate($hSAC_SCENES) Send("{End}") ; Select: [End Of List] Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 0) ; Select: [New] Sleep($iTimeOut) ClipPut($sPresetName) ; Copy the variable Preset Name ; Paste text Send("{CTRLDOWN}") Send("v") Send("{CTRLUP}") Send("{ENTER}") ; Select: [Ok] EndFunc ;==>UpdateScenesView ; ------------------------------------------------------------------------------ Func UpdateSceneProperties($iMPosX, $iMPosY) Local $hSAC_SCENEPROPERTIES = "[CLASS:SAC_SCENEPROPERTIES]" Sleep(1500) Send("{ENTER}") ; Select: [OK] EndFunc ;==>UpdateSceneProperties ; ------------------------------------------------------------------------------ Edit: It reflects the idea more. Because it has some problems, which stem from your examples. Like Func UpdatePreset002SceneProperties($iX, $iY) Func UpdatePreset003SceneProperties($iX, $iY) there are parameters $iX, $iY, but you don't use them anywhere in the function Func UpdatePreset002ScenesView($iX, $iY) Func UpdatePreset003ScenesView($iX, $iY) there are parameters $iX, $iY, but you don't use them anywhere in the function1 point
-
Added this UDF to the Wiki1 point
-
Avoid "AutoIt Error" message box in unknown errors
argumentum reacted to Jos for a topic
I am just supporting the au3stripper questions in this thread. So without looking at the details it is pretty simple to me: Does the original script work?: if Yes: Does au3stripper run cleanly without any warnings? if Yes: The stripped script should work as the original if No: You are responsible and "don't come crying to me" when you override the default to continue with force! 😉1 point -
Now it is. Thanks. So here is my solution for this script: ;~ https://www.autoitscript.com/forum/topic/154081-avoid-autoit-error-message-box-in-unknown-errors/page/4/#findComment-1547476 #Region - AutoIt3Wrapper directives section ; General section #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Compression=4 ; Au3Check section #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 6 -w 7 ; Au3Stripper section #AutoIt3Wrapper_Run_Au3Stripper=y ;~ #Au3Stripper_Parameters=/SO /PE #Au3Stripper_Parameters=/SO /PE /RM #AutoIt3Wrapper_Au3Stripper_OnError=f ;~ #Au3Stripper_Ignore_Funcs=Intercept_MessageBoxW ;~ #Au3Stripper_Ignore_Funcs=__AddHookApi_DllCallbackRegister_wrapper #EndRegion - AutoIt3Wrapper directives section #include <WinApi.au3> #Region - exmaple ;~ AddHookApi("user32.dll", "MessageBoxW", "Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint") AddHookApi("user32.dll", "MessageBoxW", FuncName(Intercept_MessageBoxW), "int", "hwnd;wstr;wstr;uint") MsgBox(0, 'Test', 'Some normal MsgBox text') DllStructCreate("byte[123456789097]") ; This is a deliberate action intended to display an error, as this script demonstrates how to change error handling - interact with MsgBox's title and text. #EndRegion - exmaple #Region @trancexx - https://www.autoitscript.com/forum/topic/154081-avoid-autoit-error-message-box-in-unknown-errors/#findComment-1111917 Func Intercept_MessageBoxW($hWnd, $sText, $sTitle, $iType) If $sTitle = 'AutoIt' Then $sTitle = 'TESTING: ' & StringReplace($sTitle, "AutoIt", @ScriptName) Local $aCall = DllCall("user32.dll", "int", "MessageBoxW", _ "hwnd", $hWnd, _ "wstr", $sText, _ "wstr", $sTitle, _ "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 #Region ; the #Au3Stripper_Off/#Au3Stripper_On directives, used in this place will lead to errors as /RM is used and all variables was changed in entire script but not within this region ;~ #Au3Stripper_Off ;~ DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams))) ;~ #Au3Stripper_On #EndRegion ; the #Au3Stripper_Off/#Au3Stripper_On directives, used in this place will lead to errors as /RM is used and all variables was changed in entire script but not within this region ; for this reason __AddHookApi_DllCallbackRegister_wrapper() was added and enclosed within #Au3Stripper_Off >>> #Au3Stripper_On section __AddHookApi_DllCallbackRegister_wrapper($tFunctionOffset, $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 #Au3Stripper_Off Func __AddHookApi_DllCallbackRegister_wrapper($tFunctionOffset__Wrapped, $vNewFunction__Wrapped, $sRet__Wrapped, $sParams__Wrapped) DllStructSetData($tFunctionOffset__Wrapped, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction__Wrapped, $sRet__Wrapped, $sParams__Wrapped))) EndFunc ;==>__AddHookApi_DllCallbackRegister_wrapper #Au3Stripper_On 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 #EndRegion @trancexx - https://www.autoitscript.com/forum/topic/154081-avoid-autoit-error-message-box-in-unknown-errors/#findComment-1111917 Explanations: Using @trancexx code, in order to use: #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe #AutoIt3Wrapper_Au3Stripper_OnError=f there is also a need to use: #Au3Stripper_Ignore_Funcs=Intercept_MessageBoxW Because in other way: #Au3Stripper_Parameters=/so /pe Will strip down the function as she is not called directly. Only the function name is used but as a string and not directly like a "pointer" To prevent using: #Au3Stripper_Ignore_Funcs=Intercept_MessageBoxW The Intercept_MessageBoxW can be called as a parameter for FuncName(Intercept_MessageBoxW) this way: ;~ AddHookApi("user32.dll", "MessageBoxW", "Intercept_MessageBoxW", "int", "hwnd;wstr;wstr;uint") AddHookApi("user32.dll", "MessageBoxW", FuncName(Intercept_MessageBoxW), "int", "hwnd;wstr;wstr;uint") In such case Au3Stripper knows that Intercept_MessageBoxW was used and should not be stripped. REMARK: You can also notice that I used: #Au3Stripper_Parameters=/SO /PE /RM I mean the the most demanding/restrictive option /RM For this reason this following mod was added: ..... #Region ; the #Au3Stripper_Off/#Au3Stripper_On directives, used in this place will lead to errors as /RM is used and all variables was changed in entire script but not within this region ;~ #Au3Stripper_Off ;~ DllStructSetData($tFunctionOffset, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction, $sRet, $sParams))) ;~ #Au3Stripper_On #EndRegion ; the #Au3Stripper_Off/#Au3Stripper_On directives, used in this place will lead to errors as /RM is used and all variables was changed in entire script but not within this region ; for this reason __AddHookApi_DllCallbackRegister_wrapper() was added and enclosed within #Au3Stripper_Off >>> #Au3Stripper_On section __AddHookApi_DllCallbackRegister_wrapper($tFunctionOffset, $vNewFunction, $sRet, $sParams) ..... #Au3Stripper_Off Func __AddHookApi_DllCallbackRegister_wrapper($tFunctionOffset__Wrapped, $vNewFunction__Wrapped, $sRet__Wrapped, $sParams__Wrapped) DllStructSetData($tFunctionOffset__Wrapped, 1, DllCallbackGetPtr(DllCallbackRegister($vNewFunction__Wrapped, $sRet__Wrapped, $sParams__Wrapped))) EndFunc ;==>__AddHookApi_DllCallbackRegister_wrapper #Au3Stripper_On ..... The reason that I do not must to use: ;~ #Au3Stripper_Ignore_Funcs=__AddHookApi_DllCallbackRegister_wrapper is because __AddHookApi_DllCallbackRegister_wrapper() is used/called before the #Au3Stripper_Off / #Au3Stripper_Off sections occurs so Au3Stripper already dit the /RM action on the function name in entire script but at this moment do not touched $******__Wrapped variables. @Jos Does this example cover the whole topic of using Au3Stripper with this @trancexx script, I mean all releated with the /SO /PE /RM parameters? btw. I wonder whether, for the correctness of "code reading" and protection against possible changes in Au3Stripper, I should still use: #Au3Stripper_Ignore_Funcs=__AddHookApi_DllCallbackRegister_wrapper1 point