private static IntPtr GetGameEffectInstance(NWEffect Effect)
{
//
// Obtain the SharedPtr<EngineStructure> pointer from the NWEffect
// wrapper (and underlying NWScriptEngineStructure).
//
IntPtr EngineStructurePtr = (IntPtr)ObtainGetEngineStructurePtr(Effect)(Effect.m_EngineStructure);
//
// Read SharedPtr<EngineStructure>.T, obtaining the
// NWScript Accelerator's EngineStructureBridge pointer.
//
IntPtr EngineStructureBridgePtr = (IntPtr)Marshal.ReadIntPtr(EngineStructurePtr, Marshal.SizeOf(typeof(IntPtr)));
//
// Read EngineStructureBridge.m_Representation, obtaining the
// CGameEffect instance.
//
// void * __VFN_table;
// int m_EngineStructureType;
// CNWVirtualMachineCmdImplementer * m_CmdImplementer;
// void * m_Representation;
//
IntPtr GameEffectInstance = (IntPtr)Marshal.ReadIntPtr(EngineStructureBridgePtr, Marshal.SizeOf(typeof(IntPtr)) + sizeof(int) + Marshal.SizeOf(typeof(IntPtr)));
return GameEffectInstance;
}