Commit 081fd1e9 authored by Vijay Kiran Kamuju's avatar Vijay Kiran Kamuju Committed by Alexandre Julliard

virtdisk: Add stub and tests for OpenVirtualDisk.

Based on patch from Louis Lenders. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45947Signed-off-by: 's avatarVijay Kiran Kamuju <infyquest@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2c42d5ee
......@@ -18,11 +18,13 @@
#include <stdarg.h>
#include "windef.h"
#include "initguid.h"
#include "virtdisk.h"
#include "wine/heap.h"
#include "wine/test.h"
static DWORD (WINAPI *pGetStorageDependencyInformation)(HANDLE,GET_STORAGE_DEPENDENCY_FLAG,ULONG,STORAGE_DEPENDENCY_INFO*,ULONG*);
static DWORD (WINAPI *pOpenVirtualDisk)(PVIRTUAL_STORAGE_TYPE,PCWSTR,VIRTUAL_DISK_ACCESS_MASK,OPEN_VIRTUAL_DISK_FLAG,POPEN_VIRTUAL_DISK_PARAMETERS,PHANDLE);
static void test_GetStorageDependencyInformation(void)
{
......@@ -47,6 +49,38 @@ static void test_GetStorageDependencyInformation(void)
CloseHandle(handle);
}
static void test_OpenVirtualDisk(void)
{
DWORD ret;
HANDLE handle;
VIRTUAL_STORAGE_TYPE stgtype;
OPEN_VIRTUAL_DISK_PARAMETERS param;
static const WCHAR vdisk[] = {'t','e','s','t','.','v','h','d',0};
ret = pOpenVirtualDisk(NULL, NULL, VIRTUAL_DISK_ACCESS_NONE, OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS, NULL, &handle);
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
stgtype.DeviceId = VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN;
stgtype.VendorId = VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN;
ret = pOpenVirtualDisk(&stgtype, NULL, VIRTUAL_DISK_ACCESS_NONE, OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS, NULL, &handle);
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
param.Version = OPEN_VIRTUAL_DISK_VERSION_3;
ret = pOpenVirtualDisk(&stgtype, vdisk, VIRTUAL_DISK_ACCESS_NONE, OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS, &param, &handle);
ok((ret == ERROR_INVALID_PARAMETER) || (ret == ERROR_FILE_NOT_FOUND), "Expected ERROR_INVALID_PARAMETER or ERROR_FILE_NOT_FOUND (>= Win 10), got %d\n", ret);
param.Version = OPEN_VIRTUAL_DISK_VERSION_2;
ret = pOpenVirtualDisk(&stgtype, vdisk, VIRTUAL_DISK_ACCESS_NONE, OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS, &param, &handle);
ok((ret == ERROR_INVALID_PARAMETER) || (ret == ERROR_FILE_NOT_FOUND), "Expected ERROR_INVALID_PARAMETER or ERROR_FILE_NOT_FOUND (>= Win 8), got %d\n", ret);
param.Version = OPEN_VIRTUAL_DISK_VERSION_1;
ret = pOpenVirtualDisk(&stgtype, vdisk, 0xffffff, OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS, &param, &handle);
ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
ret = pOpenVirtualDisk(&stgtype, vdisk, VIRTUAL_DISK_ACCESS_NONE, OPEN_VIRTUAL_DISK_FLAG_NONE, &param, &handle);
todo_wine ok(ret == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", ret);
}
START_TEST(virtdisk)
{
HMODULE module = LoadLibraryA("virtdisk.dll");
......@@ -57,8 +91,15 @@ START_TEST(virtdisk)
}
pGetStorageDependencyInformation = (void *)GetProcAddress( module, "GetStorageDependencyInformation" );
pOpenVirtualDisk = (void *)GetProcAddress( module, "OpenVirtualDisk" );
if (pGetStorageDependencyInformation)
test_GetStorageDependencyInformation();
else
win_skip("GetStorageDependencyInformation is not available\n");
if (pOpenVirtualDisk)
test_OpenVirtualDisk();
else
win_skip("OpenVirtualDisk is not available\n");
}
......@@ -15,7 +15,7 @@
@ stub GetVirtualDiskPhysicalPath
@ stub MergeVirtualDisk
@ stub MirrorVirtualDisk
@ stub OpenVirtualDisk
@ stdcall OpenVirtualDisk(ptr wstr long long ptr ptr)
@ stub ResizeVirtualDisk
@ stub SetVirtualDiskInformation
@ stub SetVirtualDiskMetadata
......@@ -65,3 +65,17 @@ DWORD WINAPI GetStorageDependencyInformation(HANDLE obj, GET_STORAGE_DEPENDENCY_
return ERROR_SUCCESS;
}
DWORD WINAPI OpenVirtualDisk(VIRTUAL_STORAGE_TYPE *type, const WCHAR *path, VIRTUAL_DISK_ACCESS_MASK mask, OPEN_VIRTUAL_DISK_FLAG flags,
OPEN_VIRTUAL_DISK_PARAMETERS *param, HANDLE *handle)
{
FIXME("(%p, %s, %d, 0x%x, %p, %p): stub\n", type, wine_dbgstr_w(path), mask, flags, param, handle);
if (!type || !path || (mask & ~VIRTUAL_DISK_ACCESS_ALL) || (flags & ~(OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS | OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE)) || !param)
return ERROR_INVALID_PARAMETER;
if (param->Version != OPEN_VIRTUAL_DISK_VERSION_1)
return ERROR_INVALID_PARAMETER;
return ERROR_CALL_NOT_IMPLEMENTED;
}
......@@ -27,6 +27,11 @@ extern "C" {
#define VIRTUAL_STORAGE_TYPE_DEVICE_UNKNOWN 0
#define VIRTUAL_STORAGE_TYPE_DEVICE_ISO 1
#define VIRTUAL_STORAGE_TYPE_DEVICE_VHD 2
#define VIRTUAL_STORAGE_TYPE_DEVICE_VHDX 3
#define VIRTUAL_STORAGE_TYPE_DEVICE_VHDSET 4
DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_UNKNOWN, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
DEFINE_GUID(VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT, 0xec984aec, 0xa0f9, 0x47e9, 0x90, 0x1f, 0x71, 0x41, 0x5a, 0x66, 0x34, 0x5b);
typedef enum _ATTACH_VIRTUAL_DISK_FLAG {
ATTACH_VIRTUAL_DISK_FLAG_NONE = 0x00,
......@@ -37,6 +42,26 @@ typedef enum _ATTACH_VIRTUAL_DISK_FLAG {
ATTACH_VIRTUAL_DISK_FLAG_NO_SECURITY_DESCRIPTOR = 0x10
} ATTACH_VIRTUAL_DISK_FLAG;
typedef enum _OPEN_VIRTUAL_DISK_FLAG {
OPEN_VIRTUAL_DISK_FLAG_NONE = 0x00,
OPEN_VIRTUAL_DISK_FLAG_NO_PARENTS = 0x01,
OPEN_VIRTUAL_DISK_FLAG_BLANK_FILE = 0x02,
OPEN_VIRTUAL_DISK_FLAG_BOOT_DRIVE = 0x04,
OPEN_VIRTUAL_DISK_FLAG_CACHED_IO = 0x08,
OPEN_VIRTUAL_DISK_FLAG_CUSTOM_DIFF_CHAIN = 0x10,
OPEN_VIRTUAL_DISK_FLAG_PARENT_CACHED_IO = 0x20,
OPEN_VIRTUAL_DISK_FLAG_VHDSET_FILE_ONLY = 0x40,
OPEN_VIRTUAL_DISK_FLAG_IGNORE_RELATIVE_PARENT_LOCATOR = 0x80,
OPEN_VIRTUAL_DISK_FLAG_NO_WRITE_HARDENING = 0x100
} OPEN_VIRTUAL_DISK_FLAG;
typedef enum _OPEN_VIRTUAL_DISK_VERSION {
OPEN_VIRTUAL_DISK_VERSION_UNSCPECIFIED,
OPEN_VIRTUAL_DISK_VERSION_1,
OPEN_VIRTUAL_DISK_VERSION_2,
OPEN_VIRTUAL_DISK_VERSION_3
} OPEN_VIRTUAL_DISK_VERSION;
typedef enum _ATTACH_VIRTUAL_DISK_VERSION {
ATTACH_VIRTUAL_DISK_VERSION_UNSPECIFIED,
ATTACH_VIRTUAL_DISK_VERSION_1
......@@ -156,6 +181,27 @@ typedef struct _EXPAND_VIRTUAL_DISK_PARAMETERS {
} DUMMYUNIONNAME;
} EXPAND_VIRTUAL_DISK_PARAMETERS, *PEXPAND_VIRTUAL_DISK_PARAMETERS;
typedef struct _OPEN_VIRTUAL_DISK_PARAMETERS
{
OPEN_VIRTUAL_DISK_VERSION Version;
__C89_NAMELESS union {
struct {
ULONG RWDepth;
} Version1;
struct {
BOOL GetInfoOnly;
BOOL ReadOnly;
GUID ResiliencyGuid;
} Version2;
struct {
BOOL GetInfoOnly;
BOOL ReadOnly;
GUID ResiliencyGuid;
GUID SnapshotId;
} Version3;
} DUMMYUNIONNAME;
} OPEN_VIRTUAL_DISK_PARAMETERS, *POPEN_VIRTUAL_DISK_PARAMETERS;
typedef struct _STORAGE_DEPENDENCY_INFO_TYPE_1
{
DEPENDENT_DISK_FLAG DependencyTypeFlags;
......@@ -196,6 +242,9 @@ typedef struct _VIRTUAL_DISK_PROGRESS {
DWORD WINAPI GetStorageDependencyInformation(HANDLE obj, GET_STORAGE_DEPENDENCY_FLAG flags, ULONG size, STORAGE_DEPENDENCY_INFO *info, ULONG *used);
DWORD WINAPI OpenVirtualDisk(VIRTUAL_STORAGE_TYPE *type, const WCHAR *path, VIRTUAL_DISK_ACCESS_MASK mask, OPEN_VIRTUAL_DISK_FLAG flags,
OPEN_VIRTUAL_DISK_PARAMETERS *param, HANDLE *handle);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment