ComObjectBase.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include "gc/GCHandle.h"
  3. #include "il2cpp-string-types.h"
  4. #include "os/WindowsRuntime.h"
  5. #include "vm/Atomic.h"
  6. #include "vm/COM.h"
  7. #include "vm/Exception.h"
  8. #include "vm/MarshalAlloc.h"
  9. #include "vm/WindowsRuntime.h"
  10. #include "utils/Memory.h"
  11. #include "utils/StringUtils.h"
  12. struct Il2CppObject;
  13. struct Il2CppIUnknown;
  14. namespace il2cpp
  15. {
  16. namespace vm
  17. {
  18. struct LIBIL2CPP_CODEGEN_API NOVTABLE ComObjectBase : Il2CppIInspectable, Il2CppIMarshal, Il2CppIManagedObjectHolder
  19. {
  20. private:
  21. Il2CppIMarshal* m_FreeThreadedMarshaler;
  22. Il2CppObject* m_ManagedObject;
  23. public:
  24. inline ComObjectBase(Il2CppObject* obj) :
  25. m_ManagedObject(obj),
  26. m_FreeThreadedMarshaler(NULL)
  27. {
  28. IL2CPP_ASSERT(obj != NULL);
  29. }
  30. inline ~ComObjectBase()
  31. {
  32. if (m_FreeThreadedMarshaler)
  33. m_FreeThreadedMarshaler->Release();
  34. }
  35. virtual il2cpp_hresult_t STDCALL GetRuntimeClassName(Il2CppHString* className) IL2CPP_OVERRIDE;
  36. virtual il2cpp_hresult_t STDCALL GetTrustLevel(int32_t* trustLevel) IL2CPP_OVERRIDE;
  37. virtual Il2CppObject* STDCALL GetManagedObject() IL2CPP_OVERRIDE;
  38. virtual il2cpp_hresult_t STDCALL GetUnmarshalClass(const Il2CppGuid& iid, void* object, uint32_t context, void* reserved, uint32_t flags, Il2CppGuid* clsid) IL2CPP_OVERRIDE;
  39. virtual il2cpp_hresult_t STDCALL GetMarshalSizeMax(const Il2CppGuid& iid, void* object, uint32_t context, void* reserved, uint32_t flags, uint32_t* size) IL2CPP_OVERRIDE;
  40. virtual il2cpp_hresult_t STDCALL MarshalInterface(Il2CppIStream* stream, const Il2CppGuid& iid, void* object, uint32_t context, void* reserved, uint32_t flags) IL2CPP_OVERRIDE;
  41. virtual il2cpp_hresult_t STDCALL UnmarshalInterface(Il2CppIStream* stream, const Il2CppGuid& iid, void** object) IL2CPP_OVERRIDE;
  42. virtual il2cpp_hresult_t STDCALL ReleaseMarshalData(Il2CppIStream* stream) IL2CPP_OVERRIDE;
  43. virtual il2cpp_hresult_t STDCALL DisconnectObject(uint32_t reserved) IL2CPP_OVERRIDE;
  44. FORCE_INLINE Il2CppObject* GetManagedObjectInline() const
  45. {
  46. return m_ManagedObject;
  47. }
  48. protected:
  49. FORCE_INLINE Il2CppIInspectable* GetIdentity()
  50. {
  51. return this;
  52. }
  53. private:
  54. ComObjectBase(const ComObjectBase&);
  55. ComObjectBase& operator=(const ComObjectBase&);
  56. il2cpp_hresult_t GetFreeThreadedMarshalerNoAddRef(Il2CppIMarshal** destination);
  57. };
  58. } /* namespace vm */
  59. } /* namespace il2cpp */