Jump to content

WinAPIEx UDF


Yashied
 Share

Recommended Posts

@Yashied

Don't forget that MyProg.exe is detected by some AV to be a TR/Crypt.XPACK.Gen, or a UnclassifiedMalware, or a Trojan.Crypt!IK, and Heuristic.LooksLike.Win32.Suspicious.J.

I know that is a false positive, but it was just to said that before some users do it on another way. :oops:

Best Regards.Thierry

Link to comment
Share on other sites

The library has been updated, version remains unchanged.

Changes

  • Added Row Input functions.

    _WinAPI_DefRawInputProc

    _WinAPI_EnumRawInputDevices

    _WinAPI_GetRawInputBuffer

    _WinAPI_GetRawInputBufferLength

    _WinAPI_GetRawInputData

    _WinAPI_GetRawInputDeviceInfo

    _WinAPI_GetRegisteredRawInputDevices

    _WinAPI_RegisterRawInputDevices

  • Added conversion functions.

    _WinAPI_ShortToWord

    _WinAPI_WordToShort

  • Updated documentation.

Link to comment
Share on other sites

Here are two functions which should be twice as fast as your versions with DLLStructs:

Func _ShortToWord($iValue)
    Return BitAND(0x0000FFFF, $iValue) ; cut sign bits, relys on AutoIts BitAnd handling all numbers as 32bit
EndFunc
Func _WordToShort($iValue)
    If BitAND($iValue, 0x00008000) Then Return BitOR(0xFFFF8000, $iValue) ; extend sign bit, relys on AutoIt always using 32bit in BitOr
    Return BitAND($iValue, 0x00007FFF) ; cut 32bit to 16 bit.
EndFunc
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

:oops: Thanx a lot for this UDF, Yashied. The additional WINAPI and GDI functions were very helpful to me for my apps, and as said by DXRW4E, I am eager as well to see DISM API functions integrated in the UDF.

:bye: Good luck ahead.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

One suggestion. Since you do frequent updates, could you include the Html Help Toc and Index files in the download if the docs have been updated? It would just save a decompile to add the latest WinAPIEx.chm to the AutoIt.chm master merge. I finally figured out how to add to the master AutoIt.chm merge after downloading the AutoIt doc source for 3.3.8.0.

For example, I just did this yesterday with the March 24 Help files. Thanks for the functions. Most times I start to think about doing DllCall I look in your help and find out I don't have to. :oops:

Link to comment
Share on other sites

@Champak: Look here:

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

  • 4 weeks later...

Hmm, I thought I had already mentioned this but apparently I didn't.

Is it just me or is there a bug in _WinAPI_EnumProcessHandles on x64 systems? Or does that function just not work for x64 systems?

I've tested it on vista x64 and guinness also reported its possible failure on Windows 7 x64 in a thread where I used the function for a script that unlocks files using code from your udf.

Long story short, I didn't see any mention of the function not intended for x64 systems so I'm assuming it's a bug because I also didn't see anything about it on MSDN which leads me te the conclusion that it's something wrong with the function.

ZwQuerySystemInformation

NtQuerySystemInformation

Edited by ApudAngelorum
Link to comment
Share on other sites

Try this.

Func _WinAPI_EnumProcessHandles($PID = 0, $iType = 0)

    If Not $PID Then
        $PID = @AutoItPID
    EndIf

    Local $tSHI, $tHandle, $pData, $Ret, $Length = __Iif(@AutoItX64, 20, 16)
    Local $Result[101][4] = [[0]]

    $tSHI = DllStructCreate('ulong;byte[4194304]')
    $Ret = DllCall('ntdll.dll', 'uint', 'ZwQuerySystemInformation', 'uint', 16, 'ptr', DllStructGetPtr($tSHI), 'ulong', DllStructGetSize($tSHI), 'ulong*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $Ret[0] Then
            Return SetError(1, $Ret[0], 0)
        EndIf
    EndIf
    $pData = DllStructGetPtr($tSHI, 2)
    For $i = 1 To DllStructGetData($tSHI, 1)
        $tHandle = DllStructCreate('ulong;ubyte;ubyte;ushort;ptr;ulong', $pData + ($i - 1) * $Length)
        If (DllStructGetData($tHandle, 1) = $PID) And ((Not $iType) Or ($iType = DllStructGetData($tHandle, 2))) Then
            __Inc($Result)
            $Result[$Result[0][0]][0] = Ptr(DllStructGetData($tHandle, 4))
            $Result[$Result[0][0]][1] = DllStructGetData($tHandle, 2)
            $Result[$Result[0][0]][2] = DllStructGetData($tHandle, 3)
            $Result[$Result[0][0]][3] = DllStructGetData($tHandle, 6)
        EndIf
    Next
    If Not $Result[0][0] Then
        Return SetError(1, 0, 0)
    EndIf
    __Inc($Result, -1)
    Return $Result
EndFunc   ;==>_WinAPI_EnumProcessHandles
Link to comment
Share on other sites

Just tested on vista x64.

It seems to return the appropriate number of handles in the process used for the "for-to" loop but everything in the $tHandle structure is composed of zeros when trying to get info from it.

I even checked the structure that returns the PID and it always returns zero for any index.

Edited by ApudAngelorum
Link to comment
Share on other sites

  • 3 weeks later...

This should work for both 32- and 64-bit.

Func _WinAPI_EnumProcessHandles($PID = 0, $iType = 0)

    If Not $PID Then
        $PID = @AutoItPID
    EndIf

    Local $tSHI, $tHandle, $pData, $Ret
    Local $Result[101][4] = [[0]]

    $tSHI = DllStructCreate('ulong;byte[4194304]')
    $Ret = DllCall('ntdll.dll', 'uint', 'ZwQuerySystemInformation', 'uint', 16, 'ptr', DllStructGetPtr($tSHI), 'ulong', DllStructGetSize($tSHI), 'ulong*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $Ret[0] Then
            Return SetError(1, $Ret[0], 0)
        EndIf
    EndIf
    $pData = DllStructGetPtr($tSHI, 2)
    For $i = 1 To DllStructGetData($tSHI, 1)
        $tHandle = DllStructCreate('align 4;ulong;ubyte;ubyte;ushort;ptr;ulong', $pData + __Iif(@AutoItX64, 4 + ($i - 1) * 24, ($i - 1) * 16))
        If (DllStructGetData($tHandle, 1) = $PID) And ((Not $iType) Or ($iType = DllStructGetData($tHandle, 2))) Then
            __Inc($Result)
            $Result[$Result[0][0]][0] = Ptr(DllStructGetData($tHandle, 4))
            $Result[$Result[0][0]][1] = DllStructGetData($tHandle, 2)
            $Result[$Result[0][0]][2] = DllStructGetData($tHandle, 3)
            $Result[$Result[0][0]][3] = DllStructGetData($tHandle, 6)
        EndIf
    Next
    If Not $Result[0][0] Then
        Return SetError(1, 0, 0)
    EndIf
    __Inc($Result, -1)
    Return $Result
EndFunc   ;==>_WinAPI_EnumProcessHandles
Link to comment
Share on other sites

Thanks Yashied.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

The library has been updated.

v3.8

  • Added the following functions.

    _WinAPI_CLSIDFromProgID

    _WinAPI_CreateBufferFromStruct

    _WinAPI_CreateFontEx

    _WinAPI_DwmDefWindowProc

    _WinAPI_DwmGetColorizationParameters

    _WinAPI_DwmSetColorizationParameters

    _WinAPI_EnumFontFamilies

    _WinAPI_FileIconInit

    _WinAPI_GetBrushOrg

    _WinAPI_GetEffectiveClientRect

    _WinAPI_GetFontName

    _WinAPI_GetMUILanguage

    _WinAPI_GetPEType

    _WinAPI_GetTabbedTextExtent

    _WinAPI_OpenFileDlg

    _WinAPI_InitMUILanguage

    _WinAPI_IsNameInExpression

    _WinAPI_IsPathShared

    _WinAPI_MirrorIcon

    _WinAPI_ProgIDFromCLSID

    _WinAPI_SaveFileDlg

    _WinAPI_SearchPath

    _WinAPI_SetBrushOrg

    _WinAPI_SetFileValidData

    _WinAPI_SetSearchPathMode

    _WinAPI_ShellCreateDirectory

    _WinAPI_ShellExecuteEx

    _WinAPI_ShellFlushSFCache

    _WinAPI_ShellGetIconOverlayIndex

    _WinAPI_ShellGetImageList

    _WinAPI_ShellGetKnownFolderIDList

    _WinAPI_ShellSetKnownFolderPath

    _WinAPI_ShellUpdateImage

    _WinAPI_TabbedTextOut

    _WinAPI_TerminateJobObject

    _WinAPI_TerminateProcess

    _WinAPI_UpdateLayeredWindowIndirect

    _WinAPI_UserHandleGrantAccess

  • Added examples for the functions above.
  • Added few constants and structures.
  • Added the NTErrors.au3 (optional) that contains the constants of all NTSTATUS error codes.
  • The _WinAPI_EnumDllProc() function now works in Windows XP (required dbghelp.dll version 5.1 or later).
  • The _WinAPI_EnumProcessHandles() functions now works for both 32- and 64-bit systems.
  • The _WinAPI_GetProcAddress() function now works with ordinal values (3.3.6.1).
  • Fixed memory leak in _WinAPI_AssocGetPerceivedType() function.
  • Some internal change of the code.
  • Updated documentation.

This is an illative updated of this UDF. Since the library will be integrated into future versions of AutoIt, the project is closed as a separate thread. All future changes will be made through the AutoIt Issue Tracker. Please do not ask here about adding new functions. Only critical bugs (if any) for a quick update.

Due to space constraints, I moved all the files on my site. So if the server is unavailable, please let me know about it.

Thanks to all who participated in the development of this library.

Project closed.

Edited by Yashied
Link to comment
Share on other sites

As it's part of the AutoIt UDFs it should pass #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

_WinAPI_GetEffectiveClientRect - $Ret declared but not used.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Link to comment
Share on other sites

@ptrex

WinAPIEx UDF is written for two versions of AutoIt. Please download the appropriate version from the first post:

AutoIt 3.3.6.1 => WinAPIEx_3.8_3361.zip

or

AutoIt 3.3.8.x => WinAPIEx_3.8_3380.zip

Edited by Yashied
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...