|
11 | 11 | namespace REFrameworkNET {
|
12 | 12 | value struct InvokeRet;
|
13 | 13 |
|
14 |
| -// Native objects are objects that are NOT managed objects |
15 |
| -// However, they still have reflection information associated with them |
16 |
| -// So this intends to be the "ManagedObject" class for native objects |
17 |
| -// So we can easily interact with them in C# |
| 14 | +/// <summary> |
| 15 | +// Native objects are objects that are NOT managed objects <br/> |
| 16 | +// However, they still have reflection information associated with them <br/> |
| 17 | +// So this intends to be the "ManagedObject" class for native objects <br/> |
| 18 | +// So we can easily interact with them in C# <br/> |
| 19 | +/// </summary> |
18 | 20 | public ref class NativeObject : public REFrameworkNET::UnifiedObject
|
19 | 21 | {
|
20 | 22 | public:
|
@@ -48,22 +50,40 @@ public ref class NativeObject : public REFrameworkNET::UnifiedObject
|
48 | 50 | m_object = nullptr;
|
49 | 51 | }
|
50 | 52 |
|
| 53 | + /// <returns>The type of the object</returns> |
51 | 54 | virtual TypeDefinition^ GetTypeDefinition() override {
|
52 | 55 | return m_type;
|
53 | 56 | }
|
54 | 57 |
|
| 58 | + /// <returns>The address of the object as a void* pointer</returns> |
55 | 59 | virtual void* Ptr() override {
|
56 | 60 | return m_object;
|
57 | 61 | }
|
58 | 62 |
|
| 63 | + /// <returns>The address of the object</returns> |
59 | 64 | virtual uintptr_t GetAddress() override {
|
60 | 65 | return (uintptr_t)m_object;
|
61 | 66 | }
|
62 | 67 |
|
63 | 68 | generic <typename T>
|
64 | 69 | virtual T As() override;
|
65 | 70 |
|
66 |
| -private: |
| 71 | + /// <summary> |
| 72 | + /// Creates a NativeObject wrapper over the given address |
| 73 | + /// </summary> |
| 74 | + /// <remarks> |
| 75 | + /// This function can be very dangerous if used incorrectly. <br/> |
| 76 | + /// Always double check that you are feeding the correct address <br/> |
| 77 | + /// and type to this function. <br/> |
| 78 | + /// </remarks> |
| 79 | + /// <param name="obj">The address of the object</param> |
| 80 | + /// <param name="t">The type of the object</param> |
| 81 | + /// <returns>A NativeObject wrapper over the given address</returns> |
| 82 | + static NativeObject^ FromAddress(uintptr_t obj, TypeDefinition^ t) { |
| 83 | + return gcnew NativeObject(obj, t); |
| 84 | + } |
| 85 | + |
| 86 | +protected: |
67 | 87 | void* m_object{};
|
68 | 88 | TypeDefinition^ m_type{};
|
69 | 89 | };
|
|
0 commit comments