Advertisement
expired6978

Untitled

Jul 8th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.36 KB | None | 0 0
  1. // BSScript::Internal::VirtualMachine: ??_7VirtualMachine@Internal@BSScript@@6B@
  2. class VirtualMachine
  3. {
  4. public:
  5.     VirtualMachine();
  6.     virtual ~VirtualMachine();
  7.  
  8.     virtual void    Unk_01();   // take m_lockC0 and then calls this+C8
  9.     virtual void    Unk_02(UInt64 unk); // take m_lockC0 and then sets m_unkE8
  10.     virtual void    Unk_03();
  11.     virtual void    Unk_04();
  12.     virtual void    Unk_05(UInt8 unk);  // set m_unk82BC
  13.     virtual bool    Unk_06();   // take m_lockBDC4, return m_BDF4 & 2
  14.     virtual void    RegisterForm(UInt32 typeID, const char * papyrusClassName);
  15.     virtual void    Unk_08();
  16.     virtual bool    GetObjectTypeInfo(UInt32 formType, VMObjectTypeInfo ** outTypeInfo);    // Must release outTypeInfo explicitly
  17.     virtual bool    GetObjectTypeInfoByName(const BSFixedString * name, VMObjectTypeInfo ** outTypeInfo); // Must release outTypeInfo explicitly
  18.     virtual void    Unk_0B();
  19.     virtual bool    Unk_0C(BSFixedString * typeName0, UInt32 * unk);
  20.     virtual void    Unk_0D();
  21.     virtual void    Unk_0E();
  22.     virtual void    Unk_0F();
  23.     virtual void    Unk_10();
  24.     virtual void    Unk_11();
  25.     virtual void    Unk_12();
  26.     virtual bool    GetStructTypeInfo(const BSFixedString * name, VMStructTypeInfo ** outTypeInfo); // Must release outTypeInfo explicitly
  27.     virtual void    Unk_14();
  28.     virtual void    Unk_15();
  29.     virtual void    Unk_16();
  30.     virtual bool    CreateObjectIdentifier(const BSFixedString * className, VMIdentifier ** identifier);
  31.     virtual bool    CreateStruct(const BSFixedString * name, VMValue::StructData ** value);
  32.     virtual bool    CreateArray(VMValue * value, UInt32 size, VMValue::ArrayData ** data);
  33.     virtual void    Unk_1A();
  34.     virtual void    RegisterFunction(IFunction * fn);
  35.     virtual void    SetFunctionFlagsEx(const char * className, UInt32 unk0, const char * fnName, UInt32 flags);
  36.     virtual void    SetFunctionFlags(const char * className, const char * fnName, UInt32 flags);
  37. #if _MSC_VER == 1700
  38.     virtual void    ForEachIdentifier(UInt64 handle, const std::function<UInt32(VMIdentifier*)> & functor); // return 1 to continue
  39. #else
  40.     virtual void    ForEachIdentifier(UInt64 handle, void * stdFunction);
  41. #endif
  42.     virtual bool    GetObjectIdentifier(UInt64 handle, const char * typeName, UInt64 unk1, VMIdentifier ** identifier, UInt8 unk2);
  43.     virtual void    Unk_20();
  44.     virtual void    Unk_21();
  45.     virtual void    CastAs(VMIdentifier** idInOut, VMObjectTypeInfo ** typeAs, UInt64 unk1); // checks (typeAs->unk40 & 3) == 3 first
  46.     virtual bool    SetPropertyValue(VMIdentifier** identifier, const char* propertyName, VMValue* newValue, UInt64* unk4);
  47.     virtual bool    GetPropertyValue(VMIdentifier** identifier, const char* propertyName, VMValue * result);
  48.     virtual bool    GetPropertyValueByIndex(VMIdentifier** identifier, SInt32 idx, VMValue* outValue);
  49.     virtual void    Unk_26();
  50.     virtual void    Unk_27();
  51.     virtual void    Unk_28();
  52.     virtual void    Unk_29();
  53.     virtual void    Unk_2A();
  54.     virtual void    QueueEvent(UInt64 handle, BSFixedString * eventName, void * unk1);
  55.     virtual void    Unk_2C();
  56.     virtual void    Unk_2D();
  57.     virtual void    Unk_2E();
  58.     virtual void    Unk_2F();
  59.     virtual void    Unk_30();
  60.     virtual void    ResumeStack(UInt32 stackId, VMValue* result);
  61.     virtual void    Unk_32();
  62.     virtual IObjectHandlePolicy *   GetHandlePolicy(void);
  63.     virtual void    Unk_34();
  64.     virtual IObjectBindPolicy *     GetObjectBindPolicy(void);
  65.     virtual void    Unk_36();
  66.     virtual void    Unk_37();
  67.     virtual void    Unk_38();
  68.     virtual void    Unk_39();
  69.     virtual void    Unk_3A();
  70.     virtual void    Unk_3B();
  71.     virtual void    Unk_3C();
  72.     virtual void    Unk_3D();
  73.  
  74. private:
  75.  
  76. //  void    ** _vtbl;                   // 00
  77.     UInt64  pad08[(0xC0 - 0x08) >> 3];  // 08
  78.     Lock    m_lockC0;                   // C0
  79.     UInt64  padC8[(0xE8 - 0xC8) >> 3];  // C8
  80.     UInt64  m_unkE8;                    // E8
  81.     UInt64  unkF0[(0x168 - 0xF0) >> 3];
  82.  
  83. public:
  84.     class ComplexTypeInfoItem
  85.     {
  86.     public:
  87.         BSFixedString       name;           // 00
  88.         IComplexType        * typeInfo;     // 08
  89.  
  90.         bool operator==(const ComplexTypeInfoItem & rhs) const  { return name == rhs.name; }
  91.         bool operator==(const BSFixedString a_name) const   { return name == a_name; }
  92.         operator UInt64() const                             { return (UInt64)name.data->Get<char>(); }
  93.  
  94.         static inline UInt32 GetHash(BSFixedString * key)
  95.         {
  96.             UInt32 hash;
  97.             CalculateCRC32_64(&hash, (UInt64)key->data, 0);
  98.             return hash;
  99.         }
  100.  
  101.         void Dump(void)
  102.         {
  103.             _MESSAGE("\t\tname: %s", name.data->Get<char>());
  104.             _MESSAGE("\t\tinstance: %08X", typeInfo);
  105.         }
  106.     };
  107.     class FormTypeName
  108.     {
  109.     public:
  110.         UInt32              typeId;         // 00
  111.         BSFixedString       name;           // 08
  112.  
  113.         bool operator==(const FormTypeName & rhs) const { return typeId == rhs.typeId; }
  114.         operator UInt32() const { return typeId; }
  115.  
  116.         static inline UInt32 GetHash(UInt32 * key)
  117.         {
  118.             UInt32 hash;
  119.             CalculateCRC32_32(&hash, (UInt32)*key, 0);
  120.             return hash;
  121.         }
  122.  
  123.         void Dump(void)
  124.         {
  125.             _MESSAGE("\t\ttypeId: %d", typeId);
  126.             _MESSAGE("\t\tname: %s", name.c_str());
  127.         }
  128.     };
  129.  
  130.     class StackTableItem
  131.     {
  132.     public:
  133.         UInt32              stackId;
  134.         void                *   data;
  135.  
  136.         bool operator==(const StackTableItem & rhs) const   { return stackId == rhs.stackId; }
  137.         operator UInt32() const { return stackId; }
  138.  
  139.         static inline UInt32 GetHash(UInt32* pStackId)
  140.         {
  141.             UInt32 hash;
  142.             CalculateCRC32_32(&hash, (UInt32)*pStackId, 0);
  143.             return hash;
  144.         }
  145.  
  146.         void Dump(void)
  147.         {
  148.             _MESSAGE("\t\tstack: %d", stackId);
  149.             _MESSAGE("\t\tdata: %016I64X", data);
  150.         }
  151.     };
  152.  
  153.     class IdentifierItem
  154.     {
  155.     public:
  156.         UInt64                  handle; // 00
  157.         UInt32                  count;  // 08
  158.         UInt32                  pad0C;  // 0C
  159.         union
  160.         {
  161.             VMIdentifier * one;
  162.             VMIdentifier ** many;
  163.         } identifier;
  164.  
  165.         class IScriptVisitor
  166.         {
  167.         public:
  168.             virtual ~IScriptVisitor() { }
  169.  
  170.             virtual bool Visit(VMIdentifier * obj) = 0;
  171.         };
  172.  
  173.         inline VMIdentifier * GetScriptObject(VMIdentifier * identifier)
  174.         {
  175.             return reinterpret_cast<VMIdentifier*>(reinterpret_cast<uintptr_t>(identifier) & ~1LL);
  176.         }
  177.  
  178.         void ForEachScript(IScriptVisitor * visitor)
  179.         {
  180.             if(count == 1)
  181.             {
  182.                 visitor->Visit(GetScriptObject(identifier.one));
  183.             }
  184.             else
  185.             {
  186.                 for(UInt32 i = 0; i < count; ++i)
  187.                 {
  188.                     if(!visitor->Visit(GetScriptObject(identifier.many[i])))
  189.                         return;
  190.                 }
  191.             }
  192.         }
  193.  
  194.         bool operator==(const IdentifierItem & rhs) const   { return handle == rhs.handle; }
  195.         operator UInt64() const { return handle; }
  196.  
  197.         static inline UInt64 GetHash(UInt64* pHandle)
  198.         {
  199.             UInt32 hash;
  200.             CalculateCRC32_64(&hash, (UInt64)*pHandle, 0);
  201.             return hash;
  202.         }
  203.  
  204.         void Dump(void)
  205.         {
  206.             _MESSAGE("\t\thandle: %016I64X", handle);
  207.             _MESSAGE("\t\tscripts:");
  208.            
  209.             class DumpVisitor : public IScriptVisitor
  210.             {
  211.             public:
  212.                 virtual bool Visit(VMIdentifier* obj)
  213.                 {
  214.                     _MESSAGE("\t\t\t%s", obj->m_typeInfo->m_typeName.c_str());
  215.                     return true;
  216.                 }
  217.             };
  218.             DumpVisitor visitor;
  219.             ForEachScript(&visitor);
  220.         }
  221.     };
  222.  
  223.     tHashSet<ComplexTypeInfoItem, BSFixedString> m_objectTypes;     // 168
  224.     tHashSet<ComplexTypeInfoItem, BSFixedString> m_structTypes;     // 198
  225.     tHashSet<FormTypeName, UInt32> m_typeNames; // 1C8
  226.  
  227.     bool HasStack(UInt32 stackId);
  228.  
  229.     UInt64  unk1F8[(0xBD58 - 0x1F8) >> 3];
  230.     BSReadWriteLock stackLock;                      // BD58
  231.     tHashSet<StackTableItem, UInt32> m_allStacks;   // BD60
  232.     tHashSet<StackTableItem, UInt32> m_waitStacks;  // BD90
  233.     UInt64  unkBDC0[(0xBDF8 - 0xBDC0) >> 3];        // BDC0
  234.     BSReadWriteLock scriptsLock;                    // BDF8
  235.     tHashSet<IdentifierItem, UInt64> m_attachedScripts; // BE00
  236. };
  237. STATIC_ASSERT(offsetof(VirtualMachine, m_objectTypes) == 0x168);
  238. STATIC_ASSERT(offsetof(VirtualMachine, m_structTypes) == 0x198);
  239. STATIC_ASSERT(offsetof(VirtualMachine, m_typeNames) == 0x1C8);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement