unsafe static int get_ManagedThreadId(byte *thread) { if (thread == null) { return(1); } int tid_offset = ClassOperations.GetFieldOffset("_ZW18System#2EThreading6Thread", "m_ManagedThreadId"); return(*(int *)(thread + tid_offset)); }
private void CancelAllEdits() { ClassAttributes.CancelEdit(); ClassOperations.CancelEdit(); txtClassName.myEditable = false; }
unsafe static void SetStart(byte *thread, void *d, int max_stack) { int delegate_offset = ClassOperations.GetFieldOffset("_ZW18System#2EThreading6Thread", "m_Delegate"); *(void **)(thread + delegate_offset) = d; }
static unsafe void *InternalInvoke(void *maddr, int pcnt, void **parameters, void **types, void *ret_vtbl, uint flags) { /* Modify the types array to contain the call locations of each parameter * * 0 - INTEGER (pass as-is) * 1 - INTEGER (unbox in asm) * 2 - SSE (unbox in asm) * 3 - MEMORY (upper 24 bits give length of object) * 4 - INTEGER (unbox low 32 bits in asm) * 5 - INTEGER (unbox to byref in asm) */ for (int i = 0; i < pcnt; i++) { // handle this pointer if (i == 0 && ((flags & TysosMethod.invoke_flag_instance) != 0)) { if ((flags & TysosMethod.invoke_flag_vt) != 0) { // we need to unbox the this pointer to a managed pointer types[i] = (void *)5; } else { types[i] = (void *)0; } } else { // the type we need is encoded in the vtable var vtbl = types[i]; var cur_class = *((byte *)vtbl + 0x1 + ClassOperations.GetVtblTargetFieldsOffset()); types[i] = (void *)cur_class; } } var ret = asm_invoke(maddr, pcnt, parameters, types); // See if we have to box the return type if (ret_vtbl != null && ((flags & TysosMethod.invoke_flag_vt_ret) != 0)) { // Get the size of the return type var tsize = *(int *)((byte *)ret_vtbl + ClassOperations.GetVtblTypeSizeOffset()) - ClassOperations.GetBoxedTypeDataOffset(); /* TODO: handle VTypes that don't fit in a register */ if (tsize > 8) { throw new NotImplementedException("InternalInvoke: return type not supported (size " + tsize.ToString() + ")"); } // Build a new boxed version of the type var obj = (void **)MemoryOperations.GcMalloc(tsize + ClassOperations.GetBoxedTypeDataOffset()); * obj = ret_vtbl; *(int *)((byte *)obj + ClassOperations.GetMutexLockOffset()) = 0; System.Diagnostics.Debugger.Log(0, "libsupcs", "x86_64_invoke: returning boxed type of size " + tsize.ToString()); if (tsize > 4) { *(long *)((byte *)obj + ClassOperations.GetBoxedTypeDataOffset()) = (long)ret; } else { *(int *)((byte *)obj + ClassOperations.GetBoxedTypeDataOffset()) = (int)((long)ret & 0xffffffff); } return(obj); } else if (ret_vtbl == null) { System.Diagnostics.Debugger.Log(0, "libsupcs", "x86_64_invoke: returning void"); return(ret); } else { System.Diagnostics.Debugger.Log(0, "libsupcs", "x86_64_invoke: returning object"); return(ret); } }