From 52aefc9d31f127b64431a4e4aa2922ec5f4e4f67 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Thu, 19 Jan 2023 17:34:04 +0100 Subject: [PATCH] vbox: Introduce vboxUniformedPFN::GetException() The GetException() method can be used to obtain the latest exception that occurred in VirtualBox. Calling the method does not reset the exception though. For that we'll need to call another method (introduced in following commit). Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/vbox/vbox_common.h | 2 ++ src/vbox/vbox_tmpl.c | 6 ++++++ src/vbox/vbox_uniformed_api.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 1893c280bd..b81b62187c 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -109,6 +109,7 @@ typedef unsigned long PRUword; #define nsnull 0 typedef PRUint32 nsresult; +#define HRESULT nsresult #if defined(__GNUC__) && (__GNUC__ > 2) # define NS_LIKELY(x) (__builtin_expect((x), 1)) @@ -362,6 +363,7 @@ typedef nsISupports IHostNetworkInterface; typedef nsISupports IDHCPServer; typedef nsISupports IKeyboard; typedef nsISupports IVirtualBoxErrorInfo; +typedef struct nsIException nsIException; /* Macros for all vbox drivers. */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 9800b8fceb..d95a2d2dc6 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -481,6 +481,11 @@ static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString); } +static HRESULT _pfnGetException(PCVBOXXPCOM pFuncs, IErrorInfo **ppException) +{ + return pFuncs->pfnGetException(ppException); +} + static void _vboxIIDInitialize(vboxIID *iid) { memset(iid, 0, sizeof(vboxIID)); @@ -2218,6 +2223,7 @@ static vboxUniformedPFN _UPFN = { .Utf8Free = _pfnUtf8Free, .Utf16ToUtf8 = _pfnUtf16ToUtf8, .Utf8ToUtf16 = _pfnUtf8ToUtf16, + .GetException = _pfnGetException, }; static vboxUniformedIID _UIID = { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 5fbc1bf77d..9d55bd0dd7 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -109,6 +109,7 @@ typedef struct { void (*Utf8Free)(PCVBOXXPCOM pFuncs, char *pszString); int (*Utf16ToUtf8)(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString); int (*Utf8ToUtf16)(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString); + HRESULT (*GetException)(PCVBOXXPCOM pFuncs, nsIException **ppException); } vboxUniformedPFN; /* Functions for vboxIID */ -- 2.47.2