Jump to content

Wrong DLLCall Return - problems with PCWSTR


Recommended Posts

Hey peoplez,

i am tyring to run this function properly: http://msdn.microsoft.com/en-us/library/windows/desktop/hh824745.aspx

On success, DLLCall returns "S_OK" -> 0

That's returned properly. Also

A pointer to the address of an array of DismMountedImageInfo Structure objects

and

The number of DismMountedImageInfo structures that are returned.

The number of mounted images is returned properly too. But the returned struct is wrong. I got following output:

0x0011CDC0

0x03AB09A0

0

0

0

$Return[2] have to be 3 (ImageIndex). I mounted an image with the DismMountImage Function...that works fine. So the entire struct i created must be wrong. :(

Can someone help me please!

; Function Call
;~ HRESULT WINAPI DismGetMountedImageInfo(
;~ _Outptr_result_buffer_(*Count) DismMountedImageInfo** MountedImageInfo,
;~ _Out_ UINT* Count
;~ );


Func DismGetMountedImageInfo()
ConsoleWrite("--------------------------------" & "DismGetMountedImageInfo" & @CRLF)

Global Const $DismReadWrite = 0
Global Const $DismReadOnly = 1

Global Const $DismMountStatusOk = 0
Global Const $DismMountStatusNeedsRemount = 1
Global Const $DismMountStatusInvalid = 2

Local $Count
Local $Return[7]

;~ $wchar = DllStructCreate("WCHAR[260]")
;~ $ptrwchar = DllStructGetPtr($wchar)
;~
;~ $wchar2 = DllStructCreate("WCHAR[260]")
;~ $ptrwchar2 = DllStructGetPtr($wchar2)

Local $wchar = DllStructCreate("WCHAR[260]")
Local $ptrwchar = DllStructGetPtr($wchar)

Local $wchar2 = DllStructCreate("WCHAR[260]")
Local $ptrwchar2 = DllStructGetPtr($wchar2)


;~ Global Const $tagDismMountedImageInfo = "ptr " & $ptrwchar & ";" & "ptr " & $ptrwchar2 & ";UINT ImageIndex;Int DismMountMode;Int MountStatus"
;~ ConsoleWrite($tagDismMountedImageInfo & @CRLF)

;~ Local $tWIM_MOUNT_LIST = DllStructCreate($tagDismMountedImageInfo) ; & ";" & $tagDismMountedImageInfo)
;~ Local $pWIM_MOUNT_LIST = DllStructGetPtr($tWIM_MOUNT_LIST)
;~
;~ MsgBox(0, "sadfaf", $tagDismMountedImageInfo)

Global Const $tagDismMountedImageInfo = "ptr MountPath;ptr ImageFilePath;UINT ImageIndex;Int DismMountMode;Int MountStatus"

;~ HRESULT hr = S_OK;
;~ DismMountedImageInfo* ImageInfo;
;~ UINT& ImageInfoCount;
;~ hr = DismGetMountedImageInfo(&ImageInfo, &ImageInfoCount);


Local $tDismMountedImageInfo = DllStructCreate($tagDismMountedImageInfo)
DllStructSetData($tDismMountedImageInfo, "MountPath", $ptrwchar)
DllStructSetData($tDismMountedImageInfo, "ImageFilePath", $ptrwchar2)
Local $pDismMountedImageInfo = DllStructGetPtr($tDismMountedImageInfo)

Local $aResult = DllCall($ghdismapi, "long", "DismGetMountedImageInfo", _
"ptr", $pDismMountedImageInfo, _
"uint*", $Count _
)
ConsoleWrite("DismGetMountedImageInfo error: " & @error & @CRLF)


;~ _ArrayDisplay($aResult, "DismGetMountedImageInfo aResult")


ConsoleWrite("DismGetMountedImageInfo returns: " & $aResult[0] & @CRLF)
ConsoleWrite("Mounted Image Count: " & $aResult[2] & @CRLF)



$Return[0] = DllStructGetData($tDismMountedImageInfo, 1)
$Return[1] = DllStructGetData($tDismMountedImageInfo, 2)
$Return[2] = DllStructGetData($tDismMountedImageInfo, 3)
$Return[3] = DllStructGetData($tDismMountedImageInfo, 4)
$Return[4] = DllStructGetData($tDismMountedImageInfo, 5)
$Return[5] = DllStructGetData($wchar, 1)
$Return[6] = DllStructGetData($wchar2, 1)
_ArrayDisplay($Return, "DismGetMountedImageInfo aReturn")


;~ ConsoleWrite("---" & @CRLF)
;~ ConsoleWrite($Return[0] & @CRLF) ; MountPath
;~ ConsoleWrite($Return[1] & @CRLF) ; ImageFilePath
;~ ConsoleWrite($Return[2] & @CRLF) ; ImageIndex
;~ ConsoleWrite($Return[3] & @CRLF) ; DismMountMode
;~ ConsoleWrite($Return[4] & @CRLF) ; MountStatus
;~ ConsoleWrite($Return[5] & @CRLF)
;~ ConsoleWrite($Return[6] & @CRLF)

EndFunc
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...