3 * Simple VBox HDD container test utility.
7 * Copyright (C) 2006-2007 innotek GmbH
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
25 int dotest(const char *pszBaseFilename
, const char *pszDiffFilename
)
27 PVDIDISK pVdi
= VDIDiskCreate();
32 printf("%s rc=%i\n", str, rc); \
33 if (VBOX_FAILURE(rc)) \
35 VDIDiskCloseAllImages(pVdi); \
41 int rc
= VDIDiskOpenImage(pVdi
, pszBaseFilename
, VDI_OPEN_FLAGS_NORMAL
);
42 printf("openImage() rc=%i\n", rc
);
45 rc
= VDICreateBaseImage(pszBaseFilename
, VDI_IMAGE_TYPE_NORMAL
,
47 (1000 * 1024 * 1024UI
64),
49 (1000 * 1024 * 1024ULL),
51 "Test image", NULL
, NULL
);
52 CHECK("createImage()");
54 rc
= VDIDiskOpenImage(pVdi
, pszBaseFilename
, VDI_OPEN_FLAGS_NORMAL
);
58 void *pvBuf
= RTMemAlloc(1*1124*1024);
60 memset(pvBuf
, 'V', 1*1124*1024);
61 rc
= VDIDiskWrite(pVdi
, 20*1024*1024 + 594040, pvBuf
, 1024*1024);
64 memset(pvBuf
, 'D', 1*1124*1024);
65 rc
= VDIDiskWrite(pVdi
, 30*1024*1024 + 594040, pvBuf
, 1024*1024);
68 memset(pvBuf
, 'I', 1*1124*1024);
69 rc
= VDIDiskWrite(pVdi
, 30*1024*1024 + 594040, pvBuf
, 1024*1024);
72 char buf
[30] = "hello world";
73 rc
= VDIDiskWrite(pVdi
, 0x0, buf
, 30); // Reparem que aqui ele salva no endereço 0x00401200
77 for (int i
= 0; i
< 20; i
++) buf
[i
] = '\0';
78 VDIDiskRead(pVdi
, 0x0, buf
, 11);
82 VDIDiskCloseAllImages(pVdi
);
90 RTFileDelete("tstVdiBase.vdi");
91 RTFileDelete("tstVdiDiff.vdi");
93 int rc
= dotest("tstVdiBase.vdi", "tstVdiDiff.vdi");
95 printf("tstVDI: SUCCESS\n");
97 printf("tstVDI: FAILURE\n");
99 // RTFileDelete("tstVdiBase.vdi");
100 // RTFileDelete("tstVdiDiff.vdi");