#include #include #include Local $sStruct = 'dword Length;short State;uint Flags;handle hBitmap;hwnd hDC;long Rect[4];byte[14];int Reserved[10];wchar Text[80]' Local $tStruct = DllStructCreate($sStruct) DllStructSetData($tStruct, 1, 80) DllStructSetData($tStruct, 2, 6) DllStructSetData($tStruct, 3, 1) DllStructSetData($tStruct, 4, 0x00010014) DllStructSetData($tStruct, 5, 0x01010057) DllStructSetData($tStruct, 6, 20, 1) DllStructSetData($tStruct, 6, 20, 2) DllStructSetData($tStruct, 6, 60, 3) DllStructSetData($tStruct, 6, 80, 4) DllStructSetData($tStruct, 7, Binary('0x656A6D633835206C6A6764206200')) DllStructSetData($tStruct, 8, 0) DllStructSetData($tStruct, 9, 'Simple Text') Local $aStruct = _Winapi_PrintStruct($tStruct, $sStruct) Local $sCTable = _ArrayToCTable($aStruct, '#|Member|Offset|Type|Size|Value', 1) ConsoleWrite($sCTable & @CRLF) ;~ Local $sTable = _ArrayToTable($aStruct, '#|Member|Offset|Type|Size|Value', 2,15) ;~ ConsoleWrite($sTable & @CRLF) ; #FUNCTION# ==================================================================================================================== ; Name ..........: __Winapi_PrintStruct ; Description ...: Taken staight from _WinAPI_DisplayStruct only it prints it to the console and also returns structure as 2d array ; Syntax ........: __Winapi_PrintStruct($tStruct[, $sStruct = ''[, $sTitle = ''[, $iItem = 0[, $iSubItem = 0[, $iFlags = 0]]]]]) ; Return values .: 2d array of structure ; Author ........: Yashied ; Modified ......: Beege ; =============================================================================================================================== Func _Winapi_PrintStruct($tStruct, $sStruct = '', $sTitle = '', $iItem = 0, $iSubItem = 0, $iFlags = 0) Local $aStruct[1][6] $sStruct = StringRegExpReplace(StringStripWS($sStruct, $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES), ';+\Z', '') Local $pData If IsDllStruct($tStruct) Then $pData = DllStructGetPtr($tStruct) If Not $sStruct Then $sStruct = 'byte[' & DllStructGetSize($tStruct) & ']' $iFlags = BitOR($iFlags, 64) EndIf Else $pData = $tStruct If Not $sStruct Then Return SetError(10, 0, 0) EndIf Local $tData = DllStructCreate($sStruct, $pData) Local $iData = DllStructGetSize($tData) If (Not BitAND($iFlags, 512)) And (_WinAPI_IsBadReadPtr($pData, $iData)) Then If Not BitAND($iFlags, 256) Then Exit (ConsoleWrite('!The memory range allocated to a given structure could not be read.' & @CRLF & Ptr($pData) & ' - ' & Ptr($pData + $iData - 1))) EndIf EndIf ;~ _ArrayAdd($aStruct, '#|Member|Offset|Type|Size|Value') ;~ Local $idLV = GUICtrlCreateListView('#|Member|Offset|Type|Size|Value', 0, 0, 570, 620, 0x0000800D, (($__WINVER < 0x0600) ? 0x00010031 : 0x00010030)) Local $aVal[101] = [0] If Not BitAND($iFlags, 1) Then __Inc($aVal) $aVal[$aVal[0]] = '' _ArrayAdd($aStruct, '-|-|' & $pData & '||0|-', 0) ;~ GUICtrlCreateListViewItem('-|-|' & $pData & '||0|-', $idLV) EndIf Local $aData = StringSplit($sStruct, ';') Local $aItem, $vItem, $sItem, $iMode, $iIndex, $iCount = 0, $iPrev = 0 Local $aSel[2] = [0, 0] Local $aType[28][2] = _ [['BYTE', 1], _ ['BOOLEAN', 1], _ ['CHAR', 1], _ ['WCHAR', 2], _ ['short', 2], _ ['USHORT', 2], _ ['WORD', 2], _ ['int', 4], _ ['long', 4], _ ['BOOL', 4], _ ['UINT', 4], _ ['ULONG', 4], _ ['DWORD', 4], _ ['INT64', 8], _ ['UINT64', 8], _ ['ptr', (@AutoItX64 ? 8 : 4)], _ ['HWND', (@AutoItX64 ? 8 : 4)], _ ['HANDLE', (@AutoItX64 ? 8 : 4)], _ ['float', 4], _ ['double', 8], _ ['INT_PTR', (@AutoItX64 ? 8 : 4)], _ ['LONG_PTR', (@AutoItX64 ? 8 : 4)], _ ['LRESULT', (@AutoItX64 ? 8 : 4)], _ ['LPARAM', (@AutoItX64 ? 8 : 4)], _ ['UINT_PTR', (@AutoItX64 ? 8 : 4)], _ ['ULONG_PTR', (@AutoItX64 ? 8 : 4)], _ ['DWORD_PTR', (@AutoItX64 ? 8 : 4)], _ ['WPARAM', (@AutoItX64 ? 8 : 4)]] For $i = 1 To $aData[0] $aItem = StringSplit(StringStripWS($aData[$i], $STR_STRIPLEADING + $STR_STRIPTRAILING), ' ') Switch $aItem[1] Case 'ALIGN', 'STRUCT', 'ENDSTRUCT' ContinueLoop Case Else EndSwitch $iCount += 1 $iMode = 1 $sItem = $iCount & '|' If $aItem[0] > 1 Then $vItem = StringRegExpReplace($aItem[2], '\[.*\Z', '') $sItem &= $vItem & '|' If (Not BitAND($iFlags, 16)) And (Not StringCompare(StringRegExpReplace($vItem, '[0-9]+\Z', ''), 'RESERVED')) Then $iMode = 0 EndIf If Not IsString($iItem) Then $vItem = $iCount EndIf $iIndex = 2 Else If Not BitAND($iFlags, 4) Then $sItem &= '|' Else $sItem &= '|' EndIf If Not IsString($iItem) Then $vItem = $iCount Else $vItem = 0 EndIf $iIndex = 1 EndIf If (Not $aSel[0]) And ($vItem) And ($iItem) And ($vItem = $iItem) Then $aSel[0] = $iCount EndIf Local $iOffset = Number(DllStructGetPtr($tData, $iCount) - $pData) $iIndex = StringRegExp($aItem[$iIndex], '\[(\d+)\]', $STR_REGEXPARRAYGLOBALMATCH) Local $iSize Do ReDim $aItem[3] $vItem = StringRegExpReplace($aItem[1], '\[.*\Z', '') For $j = 0 To UBound($aType) - 1 If Not StringCompare($aType[$j][0], $vItem) Then $aItem[1] = $aType[$j][0] $aItem[2] = $aType[$j][1] $iSize = $aItem[2] ExitLoop 2 EndIf Next $aItem[1] = '?' $aItem[2] = '?' $iSize = 0 Until 1 $sItem &= $iOffset & '|' If (IsArray($iIndex)) And ($iIndex[0] > '1') Then If $iSize Then $aItem[2] = $aItem[2] * $iIndex[0] EndIf Do Switch $aItem[1] Case 'BYTE', 'BOOLEAN' If Not BitAND($iFlags, 64) Then ContinueCase EndIf Case 'CHAR', 'WCHAR' $sItem &= $aItem[1] & '[' & $iIndex[0] & ']|' & $aItem[2] & '|' $iIndex = 0 ExitLoop Case Else EndSwitch If ($iSize) And ($iMode) Then $sItem &= $aItem[1] & '[' & $iIndex[0] & ']|' & $aItem[2] & ' (' & $iSize & ')' & '|' Else $sItem &= $aItem[1] & '[' & $iIndex[0] & ']|' & $aItem[2] & '|' EndIf If $iMode Then $iIndex = $iIndex[0] Else $iIndex = 0 EndIf Until 1 Else $sItem &= $aItem[1] & '|' & $aItem[2] & '|' $iIndex = 0 EndIf If (Not BitAND($iFlags, 2)) And ($iPrev) And ($iOffset > $iPrev) Then __Inc($aVal) $aVal[$aVal[0]] = '' _ArrayAdd($aStruct, '-|-|-||' & ($iOffset - $iPrev) & '|-') ;~ GUICtrlCreateListViewItem('-|-|-||' & ($iOffset - $iPrev) & '|-', $idLV) EndIf If $iSize Then $iPrev = $iOffset + $aItem[2] Else $iPrev = 0 EndIf Local $idLVItem, $idInit If $iIndex Then Local $sPattern = '[%0' & StringLen($iIndex) & 'd] ' For $j = 1 To $iIndex __Inc($aVal) $aVal[$aVal[0]] = DllStructGetData($tData, $iCount, $j) If BitAND($iFlags, 128) Then $aVal[$aVal[0]] = __WinAPIDiag_Hex($aVal[$aVal[0]], $aItem[1]) EndIf _ArrayAdd($aStruct, $sItem & StringFormat($sPattern, $j) & $aVal[$aVal[0]]) ;~ $idLVItem = GUICtrlCreateListViewItem($sItem & StringFormat($sPattern, $j) & $aVal[$aVal[0]], $idLV) If ($aSel[0] = $iCount) And (Not $aSel[1]) Then If ($iSubItem < 1) Or ($iSubItem > $iIndex) Or ($iSubItem = $j) Then $aSel[1] = $idLVItem EndIf EndIf If (Not $idInit) And ($iCount = 1) Then $idInit = $idLVItem If $iSize Then $sItem = '-|-|' & ($iOffset + $j * $iSize) & '|-|-|' Else $sItem = '-|-|-|-|-|' EndIf Next Else __Inc($aVal) If $iMode Then $aVal[$aVal[0]] = DllStructGetData($tData, $iCount) If BitAND($iFlags, 128) Then $aVal[$aVal[0]] = __WinAPIDiag_Hex($aVal[$aVal[0]], $aItem[1]) EndIf ;~ $idLVItem = GUICtrlCreateListViewItem($sItem & $aVal[$aVal[0]], $idLV) _ArrayAdd($aStruct, $sItem & $aVal[$aVal[0]]) Else $aVal[$aVal[0]] = '' ;~ $idLVItem = GUICtrlCreateListViewItem($sItem & '-', $idLV) _ArrayAdd($aStruct, $sItem & '-') EndIf If ($aSel[0] = $iCount) And (Not $aSel[1]) Then $aSel[1] = $idLVItem EndIf If (Not $idInit) And ($iCount = 1) Then $idInit = $idLVItem EndIf EndIf If (Not BitAND($iFlags, 2)) And (Not $iSize) Then __Inc($aVal) $aVal[$aVal[0]] = '' _ArrayAdd($aStruct, '-|-|-||?|-') ;~ GUICtrlCreateListViewItem('-|-|-||?|-', $idLV) EndIf Next If (Not BitAND($iFlags, 2)) And ($iPrev) And ($iData > $iPrev) Then __Inc($aVal) $aVal[$aVal[0]] = '' _ArrayAdd($aStruct, '-|-|-||' & ($iData - $iPrev) & '|-') ;~ GUICtrlCreateListViewItem('-|-|-||' & ($iData - $iPrev) & '|-', $idLV) EndIf If Not BitAND($iFlags, 1) Then __Inc($aVal) $aVal[$aVal[0]] = '' _ArrayAdd($aStruct, '-|-|' & ($pData + $iData - 0) & '||' & $iData & '|-') ;~ GUICtrlCreateListViewItem('-|-|' & ($pData + $iData - 0) & '||' & $iData & '|-', $idLV) EndIf Local $sFormat = _ArrayToTable($aStruct, '#|Member|Offset|Type|Size|Value', 1) ConsoleWrite($sFormat & @CRLF) Return $aStruct EndFunc ;==>__Winapi_PrintStruct ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayToTable ; Description ...: Converts 2d array into string and formats the columns widths to max length of the longest element in that column ; Syntax ........: _ArrayToTable($a2DArray[, $sHeader = ''[, $iRowStart = 0[, $sDelim = '| '[, $iTrailingColSpace = 3[, $iMaxCol = 500]]]]]) ; Parameters ....: $a2DArray - an array of unknowns. ; $sHeader - [optional] a string value. Default is ''. ; $iRowStart - [optional] an integer value. Default is 0. ; $sDelim - [optional] a string value. Default is '| '. ; $iTrailingColSpace - [optional] an integer value. Default is 3. ; $iMaxCol - [optional] an integer value. Default is 500. ; Return values .: formated string as table ; Author ........: Brian J Christy ; =============================================================================================================================== Func _ArrayToTable($a2DArray, $sHeader = '', $iRowStart = 0, $iRowEnd = -1, $sDelim = '| ', $iTrailingColSpace = 3, $iMaxCol = 500) Local $aColMaxLen[UBound($a2DArray, 2)] If $iRowEnd = -1 Then $iRowEnd = UBound($a2DArray)-1 ;If header then insert into index [0][0] If $sHeader Then Local $aHeader = StringSplit($sHeader, '|', 2) Local $aRedim[(UBound($a2DArray) - $iRowStart) + 1][UBound($aColMaxLen)] For $i = 0 To UBound($aHeader) - 1 $aHeader[$i] = StringStripWS($aHeader[$i], 3) ;remove leading trailing $aRedim[0][$i] = $aHeader[$i] Next For $iR = $iRowStart To $iRowEnd For $iC = 0 To UBound($a2DArray, 2) - 1 $aRedim[($iR - $iRowStart) + 1][$iC] = $a2DArray[$iR][$iC] Next Next $a2DArray = $aRedim $iRowEnd = $iRowEnd - ($iRowStart-1) $iRowStart = 0 EndIf ;establish max length for each coloum. Trim to max col length allowed if needed Local $iLen, $sAbv = '..', $iAbv = StringLen($sAbv) For $iC = 0 To UBound($a2DArray, 2) - 1 For $iR = $iRowStart To $iRowEnd $iLen = StringLen($a2DArray[$iR][$iC]) If $iLen > $iMaxCol+$iAbv Then $a2DArray[$iR][$iC] = StringLeft($a2DArray[$iR][$iC], $iMaxCol) & $sAbv $aColMaxLen[$iC] = $iMaxCol + $iAbv ElseIf $iLen > $aColMaxLen[$iC] Then $aColMaxLen[$iC] = $iLen EndIf Next Next ;loop through each row and format elements according to the column max length Local $sFormatedRow = $sDelim, $sFmText, $sTop, $sBottom, $sLowerHeader = $sDelim For $iR = $iRowStart To $iRowEnd ;add alignment space for each column For $iC = 0 To UBound($a2DArray, 2) - 1 $sFormatedRow &= StringFormat("%-" & $aColMaxLen[$iC] + $iTrailingColSpace & "s" & $sDelim, $a2DArray[$iR][$iC]) Next ; trim line sperator to formated row length minus number of trailing* blanks in delimeter If $iR = 0 Then $sLowerHeader = StringTrimRight(StringRegExpReplace($sFormatedRow, '[^|]', '¯'), 1) $sTop = ' ' & StringReplace(StringFormat("%-" & StringLen($sFormatedRow)-3 & "s", '_'), ' ', '_') $sBottom = StringReplace($sTop, '_', '¯') If $sHeader Then $sFormatedRow &= @LF & $sLowerHeader EndIf $sFmText &= $sFormatedRow & @LF $sFormatedRow = $sDelim Next Return $sTop & @LF & $sFmText & $sBottom EndFunc ;==>__ArrayToTable ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ArrayToCTable ; Description ...: Converts 2d array into string and formats the columns widths to max length of the longest element in that column ; Syntax ........: __Array2DToFormatedStr($aArray[, $sHeader = ''[, $iRowStart = 0]]) ; Parameters ....: $aArray - a 2d array of unknowns. ; $sHeader - [optional] Deliminted header string. Delimeter is "|" ; $iRowStart - [optional] Row to start ; $bLineSep - [optional] - set to 0 if you dont want the extra line seperators ; Return values .: formated string ; Author ........: Brian J Christy ; =============================================================================================================================== Func _ArrayToCTable($a2DArray, $sHeader = '', $iRowStart = 0, $iRowEnd = -1, $sDelim = '¦ ', $sLineSepChars = '-÷', $iTrailingSpace = 3, $iMaxCol = 500); Local $aColMaxLen[UBound($a2DArray, 2)] If $iRowEnd = -1 Then $iRowEnd = UBound($a2DArray)-1 ;If header then insert into index [0][0] If $sHeader Then Local $aHeader = StringSplit($sHeader, '|', 2) Local $aRedim[(UBound($a2DArray) - $iRowStart) + 1][UBound($aColMaxLen)] For $i = 0 To UBound($aHeader) - 1 $aHeader[$i] = StringStripWS($aHeader[$i], 3) ;remove leading trailing $aRedim[0][$i] = $aHeader[$i] Next For $iR = $iRowStart To $iRowEnd For $iC = 0 To UBound($a2DArray, 2) - 1 $aRedim[($iR - $iRowStart) + 1][$iC] = $a2DArray[$iR][$iC] Next Next $a2DArray = $aRedim $iRowEnd = $iRowEnd - ($iRowStart-1) $iRowStart = 0 EndIf ;establish max length for each coloum Local $iLen, $iTotalColMax Local $sAbv = '..', $iAbv = StringLen($sAbv) For $iC = 0 To UBound($a2DArray, 2) - 1 For $iR = $iRowStart To $iRowEnd $iLen = StringLen($a2DArray[$iR][$iC]) If $iLen > $iMaxCol+$iAbv Then $a2DArray[$iR][$iC] = StringLeft($a2DArray[$iR][$iC], $iMaxCol) & $sAbv $aColMaxLen[$iC] = $iMaxCol + $iAbv ElseIf $iLen > $aColMaxLen[$iC] Then $aColMaxLen[$iC] = $iLen EndIf Next $iTotalColMax += $aColMaxLen[$iC] + $iTrailingSpace Next ;create line to go above and below the header If $sLineSepChars Then Local $sLineSep For $i = 1 To $iTotalColMax $sLineSep &= $sLineSepChars & $sLineSepChars ; extra long for now. will trim later Next EndIf ;loop through each row and format elements according to the column max length Local $sFormatedRow = $sDelim, $sFmText For $iR = $iRowStart To $iRowEnd ;add alignment space for each column For $iC = 0 To UBound($a2DArray, 2) - 1 $sFormatedRow &= StringFormat("%-" & $aColMaxLen[$iC] + $iTrailingSpace & "s" & $sDelim, $a2DArray[$iR][$iC]) Next ; trim line sperator to formated row length minus number of trailing* blanks in delimeter If $iR = 0 And $sLineSepChars Then $sLineSep = StringLeft($sLineSep, StringLen($sFormatedRow) - (StringLen($sDelim) - StringLen(StringStripWS($sDelim, 2)))) If $sHeader Then $sFormatedRow &= @LF & $sLineSep EndIf $sFmText &= $sFormatedRow & @LF $sFormatedRow = $sDelim Next Return ($sLineSepChars ? $sLineSep & @LF & $sFmText & $sLineSep : $sFmText) EndFunc ;==>__Array2DToFormatedStr ;~ _____________________________________________________________________________________________________________________ ;~ | Name | Type | Comment | Permissions | Max Conn | Current Con | Local Path | Password | ;~ |¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯| ;~ | ADMIN$ | 2147483648 | Remote Admin | 0 | 4294967295 | 0 | C:\Windows | | ;~ | C$ | 2147483648 | Default share | 0 | 4294967295 | 0 | C:\ | | ;~ | convert | 0 | | 0 | 4294967295 | 0 | F:\convert | | ;~ | E$ | 2147483648 | Default share | 0 | 4294967295 | 0 | E:\ | | ;~ | F$ | 2147483648 | Default share | 0 | 4294967295 | 0 | F:\ | | ;~ | IPC$ | 2147483651 | Remote IPC | 0 | 4294967295 | 1 | | | ;~ | Movies | 0 | | 0 | 4294967295 | 0 | E:\Movies | | ;~ | Movies 2 | 0 | | 0 | 4294967295 | 0 | F:\Movies 2 | | ;~ | Music | 0 | | 0 | 4294967295 | 0 | E:\Music | | ;~ | Share | 0 | | 0 | 4294967295 | 0 | E:\Share | | ;~ | TV Shows | 0 | | 0 | 4294967295 | 0 | E:\TV Shows | | ;~ | TV Shows 2 | 0 | | 0 | 4294967295 | 0 | F:\TV Shows 2 | | ;~ | Users | 0 | | 0 | 4294967295 | 0 | C:\Users | | ;~ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ #CS ; |_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_| ; | Name | Type | Comment | Permissions | Max Conn | Current Con | Local Path | Password | ; |_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_| ; | ADMIN$ | 2147483648 | Remote Admin | 0 | 4294967295 | 0 | C:\Windows | | ; | C$ | 2147483648 | Default share | 0 | 4294967295 | 0 | C:\ | | ; | convert | 0 | | 0 | 4294967295 | 0 | F:\convert | | ; | E$ | 2147483648 | Default share | 0 | 4294967295 | 0 | E:\ | | ; | F$ | 2147483648 | Default share | 0 | 4294967295 | 0 | F:\ | | ; | IPC$ | 2147483651 | Remote IPC | 0 | 4294967295 | 1 | | | ; | Movies | 0 | | 0 | 4294967295 | 0 | E:\Movies | | ; | Movies 2 | 0 | | 0 | 4294967295 | 0 | F:\Movies 2 | | ; | Music | 0 | | 0 | 4294967295 | 0 | E:\Music | | ; | Share | 0 | | 0 | 4294967295 | 0 | E:\Share | | ; | TV Shows | 0 | | 0 | 4294967295 | 0 | E:\TV Shows | | ; | TV Shows 2 | 0 | | 0 | 4294967295 | 0 | F:\TV Shows 2 | | ; | Users | 0 | | 0 | 4294967295 | 0 | C:\Users | | ; |_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_¯_| ; × * « ;175 ¯ ;151 — ;133 … ;166 ¦ #CE