[35963] | 1 | /* $Id: VBoxSkeletonMain.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * Skeleton main module.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2010-2023 Oracle and/or its affiliates.
|
---|
[35963] | 8 | *
|
---|
| 9 | * Permission is hereby granted, free of charge, to any person
|
---|
| 10 | * obtaining a copy of this software and associated documentation
|
---|
| 11 | * files (the "Software"), to deal in the Software without
|
---|
| 12 | * restriction, including without limitation the rights to use,
|
---|
| 13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
| 14 | * copies of the Software, and to permit persons to whom the
|
---|
| 15 | * Software is furnished to do so, subject to the following
|
---|
| 16 | * conditions:
|
---|
| 17 | *
|
---|
| 18 | * The above copyright notice and this permission notice shall be
|
---|
| 19 | * included in all copies or substantial portions of the Software.
|
---|
| 20 | *
|
---|
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
---|
| 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
---|
| 23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
---|
[69279] | 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
---|
[35963] | 25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
---|
| 26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
---|
| 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
| 28 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 |
|
---|
[57358] | 32 | /*********************************************************************************************************************************
|
---|
| 33 | * Header Files *
|
---|
| 34 | *********************************************************************************************************************************/
|
---|
[35963] | 35 | #include <VBox/ExtPack/ExtPack.h>
|
---|
| 36 |
|
---|
[76474] | 37 | #include <iprt/errcore.h>
|
---|
[35963] | 38 | #include <VBox/version.h>
|
---|
| 39 | #include <iprt/string.h>
|
---|
| 40 | #include <iprt/param.h>
|
---|
| 41 | #include <iprt/path.h>
|
---|
| 42 |
|
---|
| 43 |
|
---|
[57358] | 44 | /*********************************************************************************************************************************
|
---|
| 45 | * Global Variables *
|
---|
| 46 | *********************************************************************************************************************************/
|
---|
[35963] | 47 | /** Pointer to the extension pack helpers. */
|
---|
| 48 | static PCVBOXEXTPACKHLP g_pHlp;
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | // /**
|
---|
| 52 | // * @interface_method_impl{VBOXEXTPACKREG,pfnInstalled}
|
---|
| 53 | // */
|
---|
[68828] | 54 | // static DECLCALLBACK(void) vboxSkeletonExtPack_Installed(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, PRTERRINFO pErrInfo);
|
---|
| 55 | //
|
---|
[35963] | 56 | // /**
|
---|
| 57 | // * @interface_method_impl{VBOXEXTPACKREG,pfnUninstall}
|
---|
| 58 | // */
|
---|
| 59 | // static DECLCALLBACK(int) vboxSkeletonExtPack_Uninstall(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
|
---|
| 60 | //
|
---|
| 61 | // /**
|
---|
| 62 | // * @interface_method_impl{VBOXEXTPACKREG,pfnVirtualBoxReady}
|
---|
| 63 | // */
|
---|
| 64 | // static DECLCALLBACK(void) vboxSkeletonExtPack_VirtualBoxReady(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox);
|
---|
| 65 | //
|
---|
| 66 | // /**
|
---|
| 67 | // * @interface_method_impl{VBOXEXTPACKREG,pfnUnload}
|
---|
| 68 | // */
|
---|
| 69 | // static DECLCALLBACK(void) vboxSkeletonExtPack_Unload(PCVBOXEXTPACKREG pThis);
|
---|
[68828] | 70 | //
|
---|
[35963] | 71 | // /**
|
---|
| 72 | // * @interface_method_impl{VBOXEXTPACKREG,pfnVMCreated}
|
---|
| 73 | // */
|
---|
[68828] | 74 | // static DECLCALLBACK(int) vboxSkeletonExtPack_VMCreated(PCVBOXEXTPACKREG pThis, VBOXEXTPACK_IF_CS(IVirtualBox) *pVirtualBox, VBOXEXTPACK_IF_CS(IMachine) *pMachine);
|
---|
[35963] | 75 | //
|
---|
| 76 | // /**
|
---|
[68828] | 77 | // * @interface_method_impl{VBOXEXTPACKREG,pfnQueryObject}
|
---|
[35963] | 78 | // */
|
---|
[68828] | 79 | // static DECLCALLBACK(int) vboxSkeletonExtPack_QueryObject(PCVBOXEXTPACKREG pThis, PCRTUUID pObjectId);
|
---|
[35963] | 80 |
|
---|
| 81 |
|
---|
| 82 | static const VBOXEXTPACKREG g_vboxSkeletonExtPackReg =
|
---|
| 83 | {
|
---|
| 84 | VBOXEXTPACKREG_VERSION,
|
---|
[59337] | 85 | /* .uVBoxFullVersion = */ VBOX_FULL_VERSION,
|
---|
[91312] | 86 | /* .pszNlsBaseName = */ NULL,
|
---|
[35963] | 87 | /* .pfnInstalled = */ NULL,
|
---|
| 88 | /* .pfnUninstall = */ NULL,
|
---|
| 89 | /* .pfnVirtualBoxReady =*/ NULL,
|
---|
| 90 | /* .pfnUnload = */ NULL,
|
---|
| 91 | /* .pfnVMCreated = */ NULL,
|
---|
| 92 | /* .pfnQueryObject = */ NULL,
|
---|
[59337] | 93 | /* .pfnReserved1 = */ NULL,
|
---|
| 94 | /* .pfnReserved2 = */ NULL,
|
---|
| 95 | /* .pfnReserved3 = */ NULL,
|
---|
| 96 | /* .pfnReserved4 = */ NULL,
|
---|
| 97 | /* .pfnReserved5 = */ NULL,
|
---|
| 98 | /* .pfnReserved6 = */ NULL,
|
---|
[92222] | 99 | /* .uReserved7 = */ 0,
|
---|
[35963] | 100 | VBOXEXTPACKREG_VERSION
|
---|
| 101 | };
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | /** @callback_method_impl{FNVBOXEXTPACKREGISTER} */
|
---|
| 105 | extern "C" DECLEXPORT(int) VBoxExtPackRegister(PCVBOXEXTPACKHLP pHlp, PCVBOXEXTPACKREG *ppReg, PRTERRINFO pErrInfo)
|
---|
| 106 | {
|
---|
| 107 | /*
|
---|
| 108 | * Check the VirtualBox version.
|
---|
| 109 | */
|
---|
| 110 | if (!VBOXEXTPACK_IS_VER_COMPAT(pHlp->u32Version, VBOXEXTPACKHLP_VERSION))
|
---|
| 111 | return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
|
---|
| 112 | "Helper version mismatch - expected %#x got %#x",
|
---|
| 113 | VBOXEXTPACKHLP_VERSION, pHlp->u32Version);
|
---|
| 114 | if ( VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MAJOR
|
---|
| 115 | || VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion) != VBOX_VERSION_MINOR)
|
---|
| 116 | return RTErrInfoSetF(pErrInfo, VERR_VERSION_MISMATCH,
|
---|
| 117 | "VirtualBox version mismatch - expected %u.%u got %u.%u",
|
---|
| 118 | VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR,
|
---|
| 119 | VBOX_FULL_VERSION_GET_MAJOR(pHlp->uVBoxFullVersion),
|
---|
| 120 | VBOX_FULL_VERSION_GET_MINOR(pHlp->uVBoxFullVersion));
|
---|
| 121 |
|
---|
| 122 | /*
|
---|
| 123 | * We're good, save input and return the registration structure.
|
---|
| 124 | */
|
---|
| 125 | g_pHlp = pHlp;
|
---|
| 126 | *ppReg = &g_vboxSkeletonExtPackReg;
|
---|
| 127 |
|
---|
| 128 | return VINF_SUCCESS;
|
---|
| 129 | }
|
---|
| 130 |
|
---|