From a23ac2d5876998a74bd56ce44d64614efb7ad4fd Mon Sep 17 00:00:00 2001 From: David Hall Date: Thu, 15 Aug 2019 00:16:05 -0700 Subject: [PATCH] Fixed bug when handling enums --- Core/InteropServices/IntPtrConverter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/InteropServices/IntPtrConverter.cs b/Core/InteropServices/IntPtrConverter.cs index c245a15a..27fe8213 100644 --- a/Core/InteropServices/IntPtrConverter.cs +++ b/Core/InteropServices/IntPtrConverter.cs @@ -98,6 +98,8 @@ namespace Vanara.InteropServices object GetBlittable(Type retType) { + if (retType.IsEnum && Marshal.SizeOf(Enum.GetUnderlyingType(retType)) <= sz) + return Enum.ToObject(retType, Marshal.PtrToStructure(ptr, Enum.GetUnderlyingType(retType))); if (Marshal.SizeOf(retType) <= sz) return Marshal.PtrToStructure(ptr, retType); throw SizeExc();