[solved] Crash on EndProcedure
Posted: Mon Nov 19, 2012 3:04 pm
Hi guys,
I'm currently trying to convert this code Native Solution to PB.
Think I'm getting closer, but now it always crash on EndProcedure
What exactly I'm doing wrong?
BTW: You need Windows 7 or later with admin rights for this
I'm currently trying to convert this code Native Solution to PB.
Think I'm getting closer, but now it always crash on EndProcedure

What exactly I'm doing wrong?
BTW: You need Windows 7 or later with admin rights for this
Code: Select all
#VDS_QUERY_SOFTWARE_PROVIDERS = 1
#VDS_QUERY_HARDWARE_PROVIDERS = 2
#VDS_QUERY_VIRTUALDISK_PROVIDERS = 4
Structure _VDS_DISK_PROP
id.i
status.i
ReserveMode.i
health.i
dwDeviceType.l
dwMediaType.l
ullSize.q
ulBytesPerSector.l
ulSectorsPerTrack.l
ulTracksPerCylinder.l
ulFlags.l
BusType.i
PartitionStyle.i
StructureUnion
dwSignature.l
DiskGuid.i
EndStructureUnion
pwszDiskAddress.s
pwszName.s
pwszFriendlyName.s
pwszAdaptorName.s
pwszDevicePath.s
EndStructure
Structure _VDS_VDISK_PROPERTIES
Id.i
State.i
VirtualDeviceType.i
VirtualSize.q
PhysicalSize.q
pPath.s
pDeviceName.s
DiskFlag.i
bIsChild.l
pParentPath.s
EndStructure
Interface IVdsServiceLoader Extends IUnknown
LoadService.i(Null.i, pService.i)
EndInterface
Interface IVdsService Extends IUnknown
IsServiceReady.i()
WaitForServiceReady.i()
GetProperties.i(*pServiceProp)
QueryProviders.i(masks.l, *ppEnum)
QueryMaskedDisks.i()
QueryUnallocatedDisks.i(*ppEnum)
GetObject.i(VDS_OBJECT_ID.i, VDS_OBJECT_TYPE.i, *ppObjectUnk)
QueryDriveLetters.i(wcFirstLetter.s, count.l,*pDriveLetterPropArray)
QueryFileSystemTypes.i(*ppFileSystemTypeProps, *plNumberOfFileSystems.l)
Reenumerate.i()
Refresh.i()
CleanupObsoleteMountPoints.i()
Advise.i(*IVdsAdviseSink, *pdwCookie.l)
Unadvise.i(dwCookie.l)
Reboot.i()
SetFlags.i(ulFlags.l)
ClearFlags.i(ulFlags.l)
EndInterface
Interface IEnumVdsObject Extends IUnknown
Next.i(celt.l, *ppObjectArray, *pcFetched)
Skip.i(celt.l)
Reset.i()
Clone.i(*ppEnum)
EndInterface
Interface IVdsVdProvider Extends IUnknown
QueryVDisks.i(*ppEnum)
CreateVDisk.i(VirtualDeviceType.i, pPath.s, pStringSecurityDescriptor.s, Flags.l, ProviderSpecificFlags.l, Reserved.l, *pCreateDiskParameters, *ppAsync)
AddVDisk.i(VirtualDeviceType.i, pPath.s, *ppVDisk)
GetDiskFromVDisk.i(*pVDisk, *ppDisk)
GetVDiskFromDisk.i(*pVDisk, *ppDisk)
EndInterface
Interface IVdsVDisk Extends IUnknown
Open.i(AccessMask.l, Flags.l, ReadWriteDepth.l, *ppOpenVDisk)
GetProperties.i(pDiskProperties.i)
GetHostVolume.i(*ppVolume)
GetDeviceName.i(*ppDeviceName)
EndInterface
Interface IVdsDisk Extends IUnknown
GetPartitionFileSystemProperties.i(ullOffset.l, *pFileSystemProp)
GetPartitionFileSystemTypeName.i(ullOffset.l, *ppwszFileSystemTypeName)
QueryPartitionFileSystemFormatSupport.i(ullOffset.l, *ppFileSystemSupportProps, *plNumberOfFileSystems)
FormatPartitionEx.i(ullOffset.l, pwszFileSystemTypeName.s, usFileSystemRevision.w, ulDesiredUnitAllocationSize.l, pwszLabel.s, bForce.l, bQuickFormat.l, bEnableCompression.l, *ppAsync)
EndInterface
Interface IVdsVolume Extends IUnknown
GetProperties.i(*pVolumeProperties)
GetPack.i(*ppPack)
QueryPlexes.i(*ppEnum)
Extend.i(*pInputDiskArray, lNumberOfDisks.l, *ppAsync)
Shrink.i(ullNumberOfBytesToRemove.l, *ppAsync)
AddPlex.i(VolumeId.i, *ppAsync)
BreakPlex.i(plexId.i, *ppAsync)
RemovePlex.i(plexId.i, *ppAsync)
Delete.i(bForce.i)
SetFlags.i(ulFlags.l, bRevertOnClose.l)
ClearFlags.i(ulFlags.l)
EndInterface
CoInitialize_(0)
pLoader.IVdsServiceLoader
pService.IVdsService
pProviderEnum.IEnumVdsObject
pUnknown.IUnknown
pVdProvider.IVdsVdProvider
CLSCTX_LOCAL_SERVER.i = 4
HRESULT.i = 0
ulFetched.l = 0
bDone.l = 0
Procedure exploreVDiskProvider(pVdProvider.IVdsVdProvider)
Protected ulFetched.l, HRESULT.i
Protected bDone.l
Protected pVDiskEnum.IEnumVdsObject
Protected pVDisk.IVdsVDisk
Protected pDisk.IVdsDisk
Protected pVolume.IVdsVolume
Protected vdiskProperties._VDS_VDISK_PROPERTIES
Protected pUnknown.IUnknown
HRESULT = pVdProvider\QueryVDisks(@pVDiskEnum)
If HRESULT = 0
Debug "Querying virtual disks"
While 1
ulFetched = 0
HRESULT = pVDiskEnum\Next(1, @pUnknown, @ulFetched)
If HRESULT = 1
Break
ElseIf HRESULT <> 0
End
EndIf
hResult = pUnknown\QueryInterface(?IID_IVdsVDisk, @pVDisk)
If hResult = 0
Debug "Virtual disk Found"
hResult = pVDisk\GetProperties(@vdiskProperties)
If hResult = 0
Debug vdiskProperties\pDeviceName
Else
Debug Hex(hResult)
EndIf
Else
Break
EndIf
Wend
EndIf
EndProcedure
If CoCreateInstance_(?CLSID_VdsLoader, 0, CLSCTX_LOCAL_SERVER, ?CLSID_IID_VdsLoader, @pLoader) = 0
HRESULT = pLoader\LoadService(#Null, @pService)
If HRESULT = 0
Debug "pService: " + Str(pService)
pLoader\Release()
HRESULT = pService\WaitForServiceReady()
If HRESULT = 0
Debug "VDS initialized successfully."
HRESULT = pService\QueryProviders(#VDS_QUERY_VIRTUALDISK_PROVIDERS, @pProviderEnum)
If HRESULT = 0
Debug "Querying providers..."
While 1
ulFetched = 0
HRESULT = pProviderEnum\Next(1, @pUnknown, @ulFetched)
If HRESULT <> 0
Break
EndIf
HRESULT = pUnknown\QueryInterface(?IID_IVdsVdProvider, @pVdProvider)
If HRESULT <> 0
Break
EndIf
Debug "VDS Virtual Disk Provider Found"
exploreVDiskProvider(pVdProvider)
Break
Wend
EndIf
Else
Debug "VDS failed to initialize."
EndIf
EndIf
EndIf
DataSection
CLSID_VdsLoader:
Data.L $9C38ED61
Data.W $D565, $4728
Data.B $AE, $EE, $C8, $09, $52, $F0, $EC, $DE
CLSID_IID_VdsLoader:
Data.L $E0393303
Data.W $90D4, $4A97
Data.B $AB, $71, $E9, $B6, $71, $EE, $27, $29
IID_IVdsVdProvider:
Data.L $B481498C
Data.W $8354, $45F9
Data.B $84, $A0, $0B, $DD, $28, $32, $A9, $1F
IID_IVdsVDisk:
Data.L $1E062B84
Data.W $E5E6, $4B4B
Data.B $8A, $25, $67, $B8, $1E, $8F, $13, $E8
EndDataSection