DLLCall und Absturz: Exit Code -1073741819

  • Hi,
    diese Zeile hier verursacht den Absturz:

    [autoit]

    DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "InstallClient")), 1))

    [/autoit]

    Habe mir den Rest gespart, weil ich das Problem gefunden habe, glaube ich. Wenn ich nämlich die Länge des chars verändere, klappt es. z.B. klappt es bei "WCHAR [64]", die Frage ist nur wieso? Ich habe bisher alle Daten des Typs PCWSTR mit WCHAR [260] definiert und es hat nie Probleme gemacht. Hat jemand eine Idee?

    Danke jungs!

    Einmal editiert, zuletzt von Trolleule1337 (27. September 2013 um 20:08)

    • Offizieller Beitrag

    Probier doch mal so:

    [autoit]

    $ptr = DllStructGetData($PackageInfo_struct, "InstallClient")
    If Not IsPtr($ptr) Then Exit MsgBox(0, 'FEHLER', '"InstallClient" ist kein Pointer')
    $struct = DllStructCreate("WCHAR[260]", $ptr)
    ConsoleWrite( DllStructGetData($struct, 1)) & @LF)

    [/autoit]
  • Den Pointer zu checken hatte ich auch schon versucht. Also was du sagst, alpines, ist das Ergebnis von BugFix. Habe es nochmal versucht. Das ConsolWrite führt er nicht aus, weil AutoIt vorher abstürzt und auf die Abfrage springt er nicht an weil der pointer ok ist.
    Das Problem ist:

    [autoit]

    $struct = DllStructCreate("WCHAR[260]", $ptr)

    [/autoit]
  • Ja bin sicher: Hier der Aufbau des structs

    Link: http://msdn.microsoft.com/en-us/library/…p/hh824774.aspx


    siehe InstallClient

    • Offizieller Beitrag

    Dann zeig mal das AutoIt-Pendant dazu. Ich habe bisher immer Stress gehabt, wenn Enumerationen in der Struktur enthalten sind, weil AutoIt Enumeration als Datentyp nicht kennt. Ich vermute mal, dass auch in diesem Fall dort der Fehler entsteht.

  • oki hier die main:

    [autoit]

    Func _DISM_GetPackageInfo($Session, $Identifier, ByRef $CustomProperty, ByRef $Feature, $PackageIdentifier = $DismPackageName, $OutputFormat = 0)

    [/autoit][autoit][/autoit][autoit]

    Local $aResult = DllCall($ghdismapi, "LONG", "DismGetPackageInfo", _
    "PTR", $Session, _
    "WSTR", $Identifier, _
    "INT", $PackageIdentifier, _
    "PTR*", 0 _ ; out
    )
    If @error Then Return SetError(@error, @extended, 0)
    If IsArray($aResult) = 1 Then
    If $aResult[0] <> $S_OK Then Return SetError(@error, @extended, $aResult[0])
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Local $PackageInfo = $aResult[4] ; get pointer to struct
    If $PackageInfo <> 0 Then ; if pointer not empty
    ; create DismPackageInfo Structure
    Local $PackageInfo_struct = DllStructCreate($tagDismPackageInfo, $PackageInfo)

    [/autoit][autoit][/autoit][autoit]

    Local $oPackageInfo_dict = ObjCreate("Scripting.Dictionary") ; store package info data in dictionay

    [/autoit][autoit][/autoit][autoit]

    ; get package info data
    $oPackageInfo_dict.add("PackageName", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "PackageName")), 1))
    $oPackageInfo_dict.add("PackageState", _DISM_GetPackageFeatureState(DllStructGetData($PackageInfo_struct, "PackageState")))
    $oPackageInfo_dict.add("ReleaseType", _DISM_GetReleaseType(DllStructGetData($PackageInfo_struct, "ReleaseType")))

    [/autoit][autoit][/autoit][autoit]

    Local $InstallTime_struct = DllStructCreate($tagSYSTEMTIME, DllStructGetPtr($PackageInfo_struct, 4)) ; index = 4

    [/autoit][autoit][/autoit][autoit]

    $oPackageInfo_dict.add("InstallTime", _Date_Time_SystemTimeToDateTimeStr($InstallTime_struct, 1))
    $oPackageInfo_dict.add("Applicable", DllStructGetData($PackageInfo_struct, "Applicable"))
    $oPackageInfo_dict.add("Copyright", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "Copyright")), 1))
    $oPackageInfo_dict.add("Company", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "Company")), 1))

    [/autoit][autoit][/autoit][autoit]

    Local $CreationTime_struct = DllStructCreate($tagSYSTEMTIME, DllStructGetPtr($PackageInfo_struct, 15)) ; index = 15

    [/autoit][autoit][/autoit][autoit]

    $oPackageInfo_dict.add("CreationTime", _Date_Time_SystemTimeToDateTimeStr($CreationTime_struct, 1))
    $oPackageInfo_dict.add("DisplayName", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "DisplayName")), 1))
    $oPackageInfo_dict.add("Description", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "Description")), 1))
    $oPackageInfo_dict.add("InstallClient", DllStructGetData(DllStructCreate("WCHAR [64]", DllStructGetData($PackageInfo_struct, "InstallClient")), 1))

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ;~ Local $ptr = DllStructGetData($PackageInfo_struct, "InstallClient")
    ;~ If Not IsPtr($ptr) Then Exit MsgBox(0, 'FEHLER', "InstallClient ist kein Pointer")
    ;~ Local $struct = DllStructCreate("WCHAR[260]", $ptr)
    ;~ ConsoleWrite( DllStructGetData($struct, 1) & @LF)

    [/autoit][autoit][/autoit][autoit]

    $oPackageInfo_dict.add("InstallPackageName", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "InstallPackageName")), 1))

    [/autoit][autoit][/autoit][autoit]

    Local $LastUpdateTime_struct = DllStructCreate($tagSYSTEMTIME, DllStructGetPtr($PackageInfo_struct, 27)) ; index = 27

    [/autoit][autoit][/autoit][autoit]

    $oPackageInfo_dict.add("LastUpdateTime", _Date_Time_SystemTimeToDateTimeStr($LastUpdateTime_struct, 1))
    $oPackageInfo_dict.add("ProductName", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "ProductName")), 1))
    $oPackageInfo_dict.add("ProductVersion", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "ProductVersion")), 1))
    $oPackageInfo_dict.add("RestartRequired", _DISM_GetRestartType(DllStructGetData($PackageInfo_struct, "RestartRequired")))
    $oPackageInfo_dict.add("FullyOffline", _DISM_GetFullyOfflineInstallableType(DllStructGetData($PackageInfo_struct, "FullyOffline")))
    $oPackageInfo_dict.add("SupportInformation", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($PackageInfo_struct, "SupportInformation")), 1))

    [/autoit][autoit][/autoit][autoit]

    ; get custom property data
    Local $CustomPropertyCount = DllStructGetData($PackageInfo_struct, "CustomPropertyCount")
    If $CustomPropertyCount <> 0 Then
    Local $oCustomProperty_list = ObjCreate("System.Collections.ArrayList")
    For $properties = 1 To $CustomPropertyCount
    Local $oCustomProperty_dict = ObjCreate("Scripting.Dictionary") ; store custom property data in dictionay
    ; create DismCustomProperty Structure
    Local $CustomProperty_struct = DllStructCreate($tagDismCustomProperty, DllStructGetPtr($PackageInfo_struct, DetermineLocation($tagDismCustomProperty, 1, 1))) ; offset = 1
    ; get custom property data
    $oCustomProperty_dict.add("Name", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($CustomProperty_struct, "Name")), 1))
    $oCustomProperty_dict.add("Value", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($CustomProperty_struct, "Value")), 1))
    $oCustomProperty_dict.add("Path", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($CustomProperty_struct, "Path")), 1))
    $oCustomProperty_list.add($oCustomProperty_dict) ; add dict to list
    Next

    [/autoit][autoit][/autoit][autoit]

    ; free resources
    _DISM_Delete($CustomProperty_struct)

    [/autoit][autoit][/autoit][autoit]

    Local $CustomProperty_array[$CustomPropertyCount+1][3], $j = 1
    #Region - Create 2d-array
    For $property in $oCustomProperty_list.add
    Local $i = 0
    For $keys in $property.Keys
    If $j = 1 Then $CustomProperty_array[0][$i] = $keys ; array title
    $CustomProperty_array[$j][$i] = $property($keys)
    $i+=1
    Next
    $j+=1
    Next

    [/autoit][autoit][/autoit][autoit]

    $CustomProperty = $CustomProperty_array
    EndIf

    [/autoit][autoit][/autoit][autoit]

    ; get feature data
    Local $FeatureCount = DllStructGetData($PackageInfo_struct, "FeatureCount")
    If $FeatureCount <> 0 Then
    Local $oFeature_list = ObjCreate("System.Collections.ArrayList")
    For $features = 1 To $FeatureCount
    Local $oFeature_dict = ObjCreate("Scripting.Dictionary") ; store feature data in dictionay
    ; create DismFeature Structure
    Local $Feature_struct = DllStructCreate($tagDismFeature, DllStructGetPtr($PackageInfo_struct, DetermineLocation($tagDismFeature, 1, 1))) ; offset = 1
    ; get feature data
    $oFeature_dict.add("FeatureName", DllStructGetData(DllStructCreate("WCHAR [260]", DllStructGetData($Feature_struct, "FeatureName")), 1))
    $oFeature_dict.add("State", _DISM_GetPackageFeatureState(DllStructGetData($Feature_struct, "State")))
    $oFeature_list.add($oFeature_dict) ; add dict to list
    Next

    [/autoit][autoit][/autoit][autoit]

    ; free resources
    _DISM_Delete($Feature_struct)

    [/autoit][autoit][/autoit][autoit]

    Local $Feature_array[$FeatureCount+1][2], $j = 1
    #Region - Create 2d-array
    For $feature in $oFeature_list
    Local $i = 0
    For $keys in $feature.Keys
    If $j = 1 Then $Feature_array[0][$i] = $keys ; array title
    $Feature_array[$j][$i] = $feature($keys)
    $i+=1
    Next
    $j+=1
    Next

    [/autoit][autoit][/autoit][autoit]

    $Feature = $Feature_array
    EndIf

    [/autoit][autoit][/autoit][autoit]

    ; free resources
    _DISM_Delete($PackageInfo_struct)
    _DISM_Delete($InstallTime_struct)
    _DISM_Delete($CreationTime_struct)
    _DISM_Delete($LastUpdateTime_struct)

    [/autoit][autoit][/autoit][autoit]

    If $OutputFormat = 1 Then
    Local $PackageInfo_array[2][18], $i = 0
    #Region - Create 2d-array
    For $keys in $oPackageInfo_dict.Keys
    $PackageInfo_array[0][$i] = $keys ; array title
    $PackageInfo_array[1][$i] = $oPackageInfo_dict($keys)
    $i+=1
    Next
    #EndRegion - Create 2d-array
    Return SetExtended(_WinAPI_GetLastError(), $PackageInfo_array)
    EndIf

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Return SetExtended(_WinAPI_GetLastError(), $oPackageInfo_dict)
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Return SetExtended(_WinAPI_GetLastError(), $aResult[0])
    EndFunc ;==>_DISM_GetPackageInfo

    [/autoit]

    Hier die Enus:

    [autoit]

    ; #ENUMS# =======================================================================================================================
    ; DismLogLevel
    Global Enum _
    $DismLogErrors, _
    $DismLogErrorsWarnings, _
    $DismLogErrorsWarningsInfo

    [/autoit][autoit][/autoit][autoit]

    ; DismImageIdentifier
    Global Enum _
    $DismImageIndex, _
    $DismImageName

    [/autoit][autoit][/autoit][autoit]

    ; DismMountMode
    Global Enum _
    $DismReadWrite, _
    $DismReadOnly

    [/autoit][autoit][/autoit][autoit]

    ; DismImageType
    Global Enum _
    $DismImageTypeUnsupported = -1, _
    $DismImageTypeWim, _
    $DismImageTypeVhd

    [/autoit][autoit][/autoit][autoit]

    ; DismImageBootable
    Global Enum _
    $DismImageBootableYes, _
    $DismImageBootableNo, _
    $DismImageBootableUnknown

    [/autoit][autoit][/autoit][autoit]

    ; DismMountStatus
    Global Enum _
    $DismMountStatusOk, _
    $DismMountStatusNeedsRemount, _
    $DismMountStatusInvalid

    [/autoit][autoit][/autoit][autoit]

    ; DismImageHealthState
    Global Enum _
    $DismImageHealthy, _
    $DismImageRepairable, _
    $DismImageNonRepairable

    [/autoit][autoit][/autoit][autoit]

    ; DismPackageIdentifier
    Global Enum _
    $DismPackageNone, _
    $DismPackageName, _
    $DismPackagePath

    [/autoit][autoit][/autoit][autoit]

    ; DismPackageFeatureState
    Global Enum _
    $DismStateNotPresent, _
    $DismStateUninstallPending, _
    $DismStateStaged, _
    $DismStateResolved, _
    $DismStateRemoved = $DismStateResolved, _
    $DismStateInstalled, _
    $DismStateInstallPending, _
    $DismStateSuperseded, _
    $DismStatePartiallyInstalled

    [/autoit][autoit][/autoit][autoit]

    ; DismReleaseType
    Global Enum _
    $DismReleaseTypeCriticalUpdate, _
    $DismReleaseTypeDriver, _
    $DismReleaseTypeFeaturePack, _
    $DismReleaseTypeHotfix, _
    $DismReleaseTypeSecurityUpdate, _
    $DismReleaseTypeSoftwareUpdate, _
    $DismReleaseTypeUpdate, _
    $DismReleaseTypeUpdateRollup, _
    $DismReleaseTypeLanguagePack, _
    $DismReleaseTypeFoundation, _
    $DismReleaseTypeServicePack, _
    $DismReleaseTypeProduct, _
    $DismReleaseTypeLocalPack, _
    $DismReleaseTypeOther

    [/autoit][autoit][/autoit][autoit]

    ; DismRestartType
    Global Enum _
    $DismRestartNo, _
    $DismRestartPossible, _
    $DismRestartRequired

    [/autoit][autoit][/autoit][autoit]

    ; DismDriverSignature
    Global Enum _
    $DismDriverSignatureUnknown, _
    $DismDriverSignatureUnsigned, _
    $DismDriverSignatureSigned

    [/autoit][autoit][/autoit][autoit]

    ; DismFullyOfflineInstallableType
    Global Enum _
    $DismFullyOfflineInstallable, _
    $DismFullyOfflineNotInstallable, _
    $DismFullyOfflineInstallableUndetermined
    ; ===============================================================================================================================

    [/autoit]

    Und hier die Übersetzung:

    [autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _DISM_GetPackageFeatureState
    ; Description ...: Converts a DismPackageFeatureState Enumeration Value to its Constant Name
    ; Syntax.........: _DISM_GetPackageFeatureState($PackageState)
    ; Parameters ....: $PackageState - Specifies the state of a package or a feature.
    ; | 0 - $DismStateNotPresent
    ; | 1 - $DismStateUninstallPending
    ; | 2 - $DismStateStaged
    ; | 3 - $DismStateResolved
    ; | 3 - $DismStateRemoved
    ; | 4 - $DismStateInstalled
    ; | 5 - $DismStateInstallPending
    ; | 6 - $DismStateSuperseded
    ; | 7 - $DismStatePartiallyInstalled
    ; Return values .: Success - Returns $PackageState
    ; | NotPresent - The package or feature is not present.
    ; | UninstallPending - An uninstall process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully uninstalled.
    ; | Staged - The package or feature is staged.
    ; | Resolved - Metadata about the package or feature has been added to the system, but the package or feature is not present.
    ; | Removed - Same as StateResolved
    ; | Installed - The package or feature is installed.
    ; | InstallPending - The install process for the package or feature is pending. Additional processes are pending and must be completed before the package or feature is successfully installed.
    ; | Superseded - The package or feature has been superseded by a more recent package or feature.
    ; | PartiallyInstalled - The package or feature is partially installed. Some parts of the package or feature have not been installed.
    ; Failure - Not implemented
    ; Author(s) .....: André Cut
    ; Modified.......:
    ; Remarks .......:
    ; Related .......: _DISM_GetReleaseType, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType
    ;
    ; ===============================================================================================================================
    Func _DISM_GetPackageFeatureState($PackageState)
    Switch $PackageState
    Case $DismStateNotPresent
    $PackageState = "NotPresent"
    Case $DismStateUninstallPending
    $PackageState = "UninstallPending"
    Case $DismStateStaged
    $PackageState = "Staged"
    Case $DismStateRemoved, $DismStateResolved
    $PackageState = "Resolved"
    Case $DismStateInstalled
    $PackageState = "Installed"
    Case $DismStateInstallPending
    $PackageState = "InstallPending"
    Case $DismStateSuperseded
    $PackageState = "Superseded"
    Case $DismStatePartiallyInstalled
    $PackageState = "PartiallyInstalled"
    EndSwitch
    Return $PackageState
    EndFunc ;==>_DISM_GetPackageFeatureState

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _DISM_GetReleaseType
    ; Description ...: Converts a DismPackageFeatureState Enumeration Value to its Constant Name
    ; Syntax.........: _DISM_GetReleaseType($ReleaseType)
    ; Parameters ....: $ReleaseType - Specifies the release type of a package.
    ; | 0 - $DismReleaseTypeCriticalUpdate
    ; | 1 - $DismReleaseTypeDriver
    ; | 2 - $DismReleaseTypeFeaturePack
    ; | 3 - $DismReleaseTypeHotfix
    ; | 4 - $DismReleaseTypeSecurityUpdate
    ; | 5 - $DismReleaseTypeSoftwareUpdate
    ; | 6 - $DismReleaseTypeUpdate
    ; | 7 - $DismReleaseTypeUpdateRollup
    ; | 8 - $DismReleaseTypeLanguagePack
    ; | 9 - $DismReleaseTypeFoundation
    ; | 10 - $DismReleaseTypeServicePack
    ; | 11 - $DismReleaseTypeProduct
    ; | 12 - $DismReleaseTypeLocalPack
    ; | 13 - $DismReleaseTypeOther
    ; Return values .: Success - Returns $ReleaseType
    ; | CriticalUpdate - The package is a critical update.
    ; | Driver - The package is a driver.
    ; | FeaturePack - The package is a feature pack.
    ; | Hotfix - The package is a hotfix.
    ; | SecurityUpdate - The package is a security update.
    ; | SoftwareUpdate - The package is a software update.
    ; | Update - The package is a general update.
    ; | UpdateRollup - The package is an update rollup.
    ; | LanguagePack - The package is a language pack.
    ; | Foundation - The package is a foundation package.
    ; | ServicePack - The package is a service pack.
    ; | Product - The package is a product release.
    ; | LocalPack - The package is a local pack.
    ; | Other - The package is another type of release.
    ; Failure - Not implemented
    ; Author(s) .....: André Cut
    ; Modified.......:
    ; Remarks .......:
    ; Related .......: _DISM_GetPackageFeatureState, _DISM_GetRestartType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType
    ;
    ; ===============================================================================================================================
    Func _DISM_GetReleaseType($ReleaseType)
    Switch $ReleaseType
    Case $DismReleaseTypeCriticalUpdate
    $ReleaseType = "CriticalUpdate"
    Case $DismReleaseTypeDriver
    $ReleaseType = "Driver"
    Case $DismReleaseTypeFeaturePack
    $ReleaseType = "FeaturePack"
    Case $DismReleaseTypeHotfix
    $ReleaseType = "HotFix"
    Case $DismReleaseTypeSecurityUpdate
    $ReleaseType = "SecurityUpdate"
    Case $DismReleaseTypeSoftwareUpdate
    $ReleaseType = "SoftwareUpdate"
    Case $DismReleaseTypeUpdate
    $ReleaseType = "Update"
    Case $DismReleaseTypeUpdateRollup
    $ReleaseType = "UpdateRollup"
    Case $DismReleaseTypeLanguagePack
    $ReleaseType = "LanguagePack"
    Case $DismReleaseTypeFoundation
    $ReleaseType = "Foundation"
    Case $DismReleaseTypeServicePack
    $ReleaseType = "ServicePack"
    Case $DismReleaseTypeProduct
    $ReleaseType = "Product"
    Case $DismReleaseTypeLocalPack
    $ReleaseType = "LocalPack"
    Case $DismReleaseTypeOther
    $ReleaseType = "Other"
    EndSwitch
    Return $ReleaseType
    EndFunc ;==>_DISM_GetReleaseType

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _DISM_GetRestartType
    ; Description ...: Converts a DismRestartType Enumeration Value to its Constant Name
    ; Syntax.........: _DISM_GetRestartType($RestartType)
    ; Parameters ....: $RestartType - Specifies whether a restart is required after enabling a feature or installing a package.
    ; | 0 - $DismRestartNo
    ; | 1 - $DismRestartPossible
    ; | 2 - $DismRestartRequired
    ; Return values .: Success - Returns $RestartType
    ; | No - No restart is required.
    ; | Possible - This package or feature might require a restart.
    ; | Required - This package or feature always requires a restart.
    ; Failure - Not implemented
    ; Author(s) .....: André Cut
    ; Modified.......:
    ; Remarks .......:
    ; Related .......: _DISM_GetPackageFeatureState, _DISM_GetReleaseType, _DISM_GetFullyOfflineInstallableType, _DISM_GetMountStatus, _DISM_GetMountMode, _DISM_GetImageBootable, _DISM_GetImageType
    ;
    ; ===============================================================================================================================
    Func _DISM_GetRestartType($RestartType)
    Switch $RestartType
    Case $DismRestartNo
    $RestartType = "No"
    Case $DismRestartPossible
    $RestartType = "Possible"
    Case $DismRestartRequired
    $RestartType = "Required"
    EndSwitch
    Return $RestartType
    EndFunc ;==>_DISM_GetRestartType

    [/autoit]


    Alles da?

  • Das ist übrigens nicht die einzige Funktion der API bei der das Problem auftritt. Und was ich noch beobachtet habe. Manchmal klappt es auch problemlos, aber es stürzt häufiger ab als es funktioniert.

  • Hmm also die Enumerationen geben als Wert ganze Zahlen zurück, dafür habe ich int gewählt, wenn ich dann noch für den PackageName WCHAR [64] oder WCHAR [96] verwende klappt es. Wenn ich Byte statt int nehme stürzt es ab, wenn ich int als Array nehme bekomme ich Müll.

    Also den Datentyp als Array zu übergeben halte ich für falsch... ne iDee?

  • Hi,
    dein Problem ist, dass du auf 260 Byte Speicher mit

    [autoit]

    $struct = DllStructCreate("WCHAR[260]", $ptr)

    [/autoit]

    zugreifen willst, aber garnicht weisst, wie groß deine Struct wirklich ist....
    Angenommen, die Struct hat eine Länge von 53 Bytes, und ab dem 54.Byte fängt eine (vom Speichermanagement geschützte) andere Struct an, dann bekommst du eine Zugriffsverletzung, also Absturz.

    Also musst du für die Struct die GENAUE Anzahl Bytes herausfinden!
    Ich mache das immer so, dass ich die entsprechenden *.h-Dateien bzw. Projekte in das VisualStudio lade und mir dann "rückwärts" die genaue Definition (Datentyp) von bspw. "DismRestartType" hole.
    Dann kommt bspw. heraus, dass jeder Member in dieser Struct ein UINT ist, dann weiss ich, das sind 4 Bytes.....Summe aller Bytes sind bspw. 53.
    Damit erstelle ich dann eine Struct, welche ich an die Position des Startpointers schreibe und somit mit "meiner" Struct die Daten auslesen (und prüfen!!!) kann!

    Wenn man im Falle eines PCWSTR also eines Pointers auf einen string unbekannter länge nicht weiss, wie lang der string ist, dann ist

    [autoit]

    $struct = DllStructCreate("WCHAR[260]", $ptr)

    [/autoit]

    suboptimal! Entweder die 260 Bytes (Unicode^^ ) sind zu groß, dann Absturz s.o., oder der angezeigte String ist in der Mitte abgeschnitten...

    Also etwa so:

    [autoit]

    ;wir bekommen den Pointer von einem "unbekannten" String
    $struct = DllStructCreate("WCHAR[260]") ;platz für string reservieren...viel zu viel
    DllStructSetData($struct, 1, "Hallo AutoIt!" & Chr(0)) ;"unbekannten" unicodestring schreiben

    [/autoit][autoit][/autoit][autoit]

    $ptr = DllStructGetPtr($struct) ;pointer bekommen

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    ;ab hier gehts los
    $i = $ptr ;zeichenzähler
    Do ;jede speicherstelle im string durchlaufen, bis stringende
    $char_struct = DllStructCreate("WCHAR", $i) ;speicherstelle auswählen
    $i += 1 ;Zeichenzähler
    $char = DllStructGetData($char_struct, 1) ;char an dieser Position lesen
    Until $char = Chr(0) ;string ende

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    $stringstruct = DllStructCreate("WCHAR[" & Int($i - $ptr) & "]", $ptr);struct an stringposition mit genauer anzahl bytes erstellen
    $string = DllStructGetData($stringstruct, 1)
    MsgBox(262144, 'Debug line ~' & @ScriptLineNumber, 'Selection:' & @LF & '$string' & @LF & @LF & 'Return:' & @LF & $string) ;### Debug MSGBOX

    [/autoit]
  • Zitat

    ber wie erklärst du dir den Umstand, das es manchmal klappt egal welchen datentyp ich mit welcher size auch immer verwende?


    Mist gemacht und trotzdem Glück gehabt....

    Bei jedem Programmstart werden Speicherbereiche reserviert+wieder freigegeben. Manchmal hat man Glück und "hintendran" ist unused Memory. Hat man kein Glück und Windows hat die Struct in irgendeinen fragmentierten Speicherbereich gequetscht, dann ist das nächste Byte "hinter" deiner Struct von einem anderen Programm oder Daten belegt und damit geschützt. Wenn du trotzdem darauf zugreifen willst, Exception wg. Speicherverletzung.
    Das kannst du übrigens mit einem herkömmlichen Debugger prüfen, der statt der AutoIt-Fehlermeldung im System aktiviert wird...Die Botter haben den OllyDbg alle, der kann das auch^^

  • super danke für deine Hilfe und auch danke an die anderen! habe versucht einen error handler zu registrieren, habs aber net auf die reihe bekommen. Da kam nie eine besondere Ausgabe, nur der standard autoit text exit code...

    was meinst du mit botter und ollydbg, ok ollydbg für gamehack, ist das ein "must have". Was käme denn dann für ne special Meldung raus wenn ich das habe?

  • Zitat

    was meinst du mit botter und ollydbg, ok ollydbg für gamehack, ist das ein "must have"

    :rofl:
    made my day...
    Einen Debugger fürs gamehack zu verwenden ist in etwa so, als ob man seinen Zeigefinger ausschliesslich fürs Nasebohren verwendet!
    Dabei kann man den auch fürs Klavierspielen benutzen, fürs Malen, fürs Telefonieren, zum Arbeiten....

    Zitat

    Was käme denn dann für ne special Meldung raus wenn ich das habe?

    Falsche Frage!
    Die richtige wäre gewesen:"Wozu braucht man einen Debugger?" 8|

  • gern geschehen!

    AutoIt hat doch einen Debugger, also für mich ist die console schon debug genug, naja außer in diesem Fall, eine genauere Fehlermeldung wäre echt ne feine sache, aber übermäßig dafür mein Gehirn zu benutzen hab ich nicht vor, dann mach ich lieber traditionell weiter. Hast mal ne Anleitung wie man den einsetzt, ist der schwer zu benutzen? Wenns nicht einfach ist, dann egal....

    Danke Andy!

  • Hi,

    Zitat

    AutoIt hat doch einen Debugger, also für mich ist die console schon debug genug,

    wenn du mit den AutoIt-internen Debug-Möglichkeiten zurecht kommst, dann reicht das imho auch völlig!

    Einen "echten" Debugger braucht man dann, wenn man tief in die Eingeweide des Source-codes und in die davon aufgerufenen Funktionen eintauchen MUSS! Muss deshalb, weil es in anderen Sprachen Möglichkeiten der fehlerhaften Programmierung gibt, die bei AutoIt "so einfach" garnicht vorkommen können. Ausnahme sind extern aufgerufene Funktionen bspw. dll-calls, aber für den 08/15-Programmierer ist es auch da egal wo in der dll der code abschmiert....ich gehe mal davon aus, dass für die dll eine Beschreibung der Funktionen und Parameter existiert und der 08/15-Programmierer sich einfach daran hält und alles klappt!
    Tut es das nicht und er hat auch keine Ahnung wie und warum ein Fehler auftritt und kennt sich weiterhin auch nicht mit dem Debuggen externer Anwendungen aus, dann nützt "auf die Schnelle" auch kein Youtube-Tutorial und die Installation eines Debuggers...fehlendes KnowHow ist immer problematisch :D