// 初始化采样 // native层直接采样camera数据 public static void InitDetection() { NativeBridge.InvokeCall("NativeEmotion", "InitDetection"); }
// 开始采样 // native层直接采样camera数据 public static void OpenDetection() { NativeBridge.InvokeCall("NativeEmotion", "OpenDetection"); }
// Start is called before the first frame update private void Start() { var stuff = NativeBridge.DoSomething("GetStuff"); _text.text = $"Got: {stuff}"; }
/// <summary> /// Creates the property page handle. /// </summary> public void CreatePropertyPageHandle(NativeBridge.NativeBridge nativeBridge) { Logging.DebugLog("Creating property page handle via bridge."); // Create a prop sheet page structure. var psp = new PROPSHEETPAGE(); // Set the key properties. psp.dwSize = (uint)Marshal.SizeOf(psp); psp.hInstance = nativeBridge.GetInstanceHandle(); psp.dwFlags = PSP.PSP_DEFAULT | PSP.PSP_USETITLE | PSP.PSP_USECALLBACK; psp.pTemplate = nativeBridge.GetProxyHostTemplate(); psp.pfnDlgProc = dialogProc; psp.pcRefParent = 0; psp.pfnCallback = callbackProc; psp.lParam = IntPtr.Zero; // If we have a title, set it. if (!string.IsNullOrEmpty(Target.PageTitle)) { psp.dwFlags |= PSP.PSP_USETITLE; psp.pszTitle = Target.PageTitle; } // If we have an icon, set it. if (Target.PageIcon != null && Target.PageIcon.Handle != IntPtr.Zero) { psp.dwFlags |= PSP.PSP_USEHICON; psp.hIcon = Target.PageIcon.Handle; } // Create a the property sheet page. HostWindowHandle = Comctl32.CreatePropertySheetPage(ref psp); }
public static void UpstreamCallHandler(string id, string args) { Debug.Log("up stream call SUCCESS!"); NativeBridge.UpstreamCallReturn(id, "result"); }
public static void CallReturn(string callId, string result) { Log("-> call [" + callId + "] returns " + result); NativeBridge.OnCallReturn(callId, result); }
public void Awake() { try { // Makes LOD ignore GameDatabase's "force reload all", especially since tihs kinda breaks the KspAddon(..., true) if (System.Threading.Interlocked.Exchange(ref didRun, 1) != 0) { return; } //printPathRecursive(GameDatabase.Instance.root); NativeBridge.Setup(Config.Current.GetCacheDirectory()); #if DISABLED_DEBUG foreach (var file in System.IO.Directory.GetFiles(Config.Current.GetCacheDirectory())) { try { System.IO.File.Delete(file); } catch (Exception) { } } #endif Managers.InternalManager.Setup(processAndGetInternals()); StartupDelayed.PartsToManage = processAndGetParts().ToList(); // Delay removal from file"system" till all are resolved, so we don't have problems with textures that are used multiple times... // we have to remove it, or GameDatabase would reload it... foreach (var ft in createdTextures) { ft.parent.files.Remove(ft); } ("LoadOnDemand.Startup done.").Log(); /* * - The following updates GameDatabase's "last loaded at" to "Now", to prevent files changed before that to be force-reloaded. * - KSP should do that anyway, since there isn't any drawback & any file has to be loaded initially, but this allows us to do it for them. * - ATM hasn't found a way without using reflection as well, and this one is way less invasiv. * - Todo: ForceReload (eg changing file and using Debug-UI's "reload all") will break LOD, since it can't handle refs becoming invalid. Fixable, though and rearely matters anyway. */ typeof(GameDatabase) .GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .Single(field => field.FieldType == typeof(DateTime)) .SetValue(GameDatabase.Instance, DateTime.Now); foreach (var el in GameDatabase.Instance.databaseTexture) { if (el.texture == null) { ("NULLTEX FOUND: " + el.name).Log(); } } foreach (var imgs in GameDatabase.Instance.root.AllFiles.Where(isFileATexture)) { ("REM_IMG: " + imgs.fullPath).Log(); // Todo: Details about them incl their meta-data & size would be nice... } } catch (Exception err) { ActivityGUI.SetWarning(err); throw; } }
static void Main(string[] args) { try { bool show_help = false; HashSet <string> typeFilter = new HashSet <string>(); HashSet <int> pidFilter = new HashSet <int>(); HashSet <string> nameFilter = new HashSet <string>(); bool noquery = false; GroupingMode mode = GroupingMode.Pid; ShareMode shareMode = ShareMode.None; bool showsd = false; OptionSet opts = new OptionSet() { { "t|type=", "An object type to filter on, can be repeated", v => typeFilter.Add(v.Trim().ToLower()) }, { "p|pid=", "A PID to filter on, can be repeated", v => pidFilter.Add(int.Parse(v.Trim())) }, { "n|name=", "Specify a process by name", v => nameFilter.Add(v.ToLower()) }, { "q|noquery", "Don't query for names/typenames", v => noquery = v != null }, { "g|group=", "Specify a grouping, defaults to pid, can be object,name,type", v => mode = (GroupingMode)Enum.Parse(typeof(GroupingMode), v, true) }, { "s|share=", "When grouping, filter on shared, can be none,partial or all", v => shareMode = (ShareMode)Enum.Parse(typeof(ShareMode), v, true) }, { "sd", "Display the security descriptor associated with the kernel object", v => showsd = v != null }, { "h|help", "show this message and exit", v => show_help = v != null }, }; opts.Parse(args); if (show_help) { ShowHelp(opts); } else { List <ProcessEntry> pss = ProcessEntry.GetProcesses(); IEnumerable <ProcessEntry> filtered = pss; if (pidFilter.Count > 0) { filtered = filtered.Where(ps => pidFilter.Contains(ps.Pid)); } if (nameFilter.Count > 0) { filtered = filtered.Where(ps => nameFilter.Contains(ps.Name, StringComparer.OrdinalIgnoreCase)); } HashSet <int> pids = new HashSet <int>(filtered.Select(process => process.Pid)); Dictionary <int, string> pidToName = filtered.ToDictionary(pk => pk.Pid, pv => pv.Name); List <HandleEntry> totalHandles = new List <HandleEntry>(); foreach (int pid in pids) { if (pid == Process.GetCurrentProcess().Id) { continue; } IEnumerable <HandleEntry> handles = NativeBridge.GetHandlesForPid(pid, noquery).Where(ent => (typeFilter.Count == 0) || typeFilter.Contains(ent.TypeName.ToLower())); totalHandles.AddRange(handles); if (mode == GroupingMode.Pid) { Console.WriteLine("Process ID: {0} - Name: {1}", pid, pidToName[pid]); foreach (HandleEntry ent in handles) { Console.WriteLine("{0:X04}: {1:X016} {2:X08} {3,20} {4}", ent.Handle.ToInt32(), ent.Object.ToInt64(), ent.GrantedAccess, ent.TypeName, ent.ObjectName); if (showsd && !String.IsNullOrWhiteSpace(ent.StringSecurityDescriptor)) { Console.WriteLine("SDDL: {0}", ent.StringSecurityDescriptor); } } Console.WriteLine(); } } switch (mode) { case GroupingMode.Type: PrintGrouping(totalHandles.GroupBy(f => f.TypeName), pidToName, k => String.Format("Type: {0}", k), e => String.Format("{0:X08} {1:X08} {2}", e.Object.ToInt64(), e.GrantedAccess, e.ObjectName), shareMode, pids.Count, showsd); break; case GroupingMode.Object: PrintGrouping(totalHandles.GroupBy(f => f.Object), pidToName, k => String.Format("Object: {0:X08}", k.ToInt64()), e => String.Format("{0,20} {1:X08} {2}", e.TypeName, e.GrantedAccess, e.ObjectName), shareMode, pids.Count, showsd); break; case GroupingMode.Name: PrintGrouping(totalHandles.GroupBy(f => f.ObjectName), pidToName, k => String.Format("Name: {0:X08}", k), e => String.Format("{0:X08} {1,20} {2:X08} {2}", e.Object.ToInt64(), e.TypeName, e.GrantedAccess), shareMode, pids.Count, showsd); break; } } } catch (Exception ex) { Console.WriteLine(ex); } }
internal Remote(string name, Guid identifier) { this.name = name; this.identifier = identifier; this.menuButton = new RemoteButtonInput(); this.homeButton = new RemoteButtonInput(); this.trigger = new RemoteButtonInput(); this.touchPad = new RemoteTouchPadInput(); this.motion = new RemoteMotionInput(); /* Inputs */ // Buttons NativeBridge.RemoteButtonInputAddListener(this, "menuButton", (pressed) => { this.menuButton.isPressed = pressed; }); NativeBridge.RemoteButtonInputAddListener(this, "homeButton", (pressed) => { this.homeButton.isPressed = pressed; }); NativeBridge.RemoteButtonInputAddListener(this, "trigger", (pressed) => { this.trigger.isPressed = pressed; }); // Touch Pad NativeBridge.RemoteTouchPadInputAddListener(this, "touchPad", (active) => { this.touchPad.isActive = active; }); // TODO: Determine if code above is still necessary NativeBridge.RemoteTouchPadInputAddListener(this, "touchPad", (active) => { this.touchPad.touchActive.isPressed = active; }); NativeBridge.RemoteButtonInputAddListener(this, "touchPad.button", (pressed) => { this.touchPad.button.isPressed = pressed; }); NativeBridge.RemoteAxisInputAddListener(this, "touchPad.xAxis", (value) => { this.touchPad.xAxis.value = value; }); NativeBridge.RemoteAxisInputAddListener(this, "touchPad.yAxis", (value) => { this.touchPad.yAxis.value = value; }); NativeBridge.RemoteTouchInputAddListener(this, "touchPad.up", (active) => { this.touchPad.up.isActive = active; }); NativeBridge.RemoteTouchInputAddListener(this, "touchPad.down", (active) => { this.touchPad.down.isActive = active; }); NativeBridge.RemoteTouchInputAddListener(this, "touchPad.left", (active) => { this.touchPad.left.isActive = active; }); NativeBridge.RemoteTouchInputAddListener(this, "touchPad.right", (active) => { this.touchPad.right.isActive = active; }); // Motion NativeBridge.RemoteMotionInputAddListener(this, "motion", () => { this.motion.update(); }); NativeBridge.RemoteMotionSensorInputAddListener(this, "motion.acceleration", (x, y, z) => { this.motion.acceleration.setMotionSensorValues(x, y, z); }); NativeBridge.RemoteMotionSensorInputAddListener(this, "motion.rotationRate", (x, y, z) => { this.motion.rotationRate.setMotionSensorValues(x, y, z); }); NativeBridge.RemoteOrientationInputAddListener(this, "motion.orientation", (pitch, yaw, roll) => { this.motion.orientation.setOrientationValues(pitch, yaw, roll); }); /* Notifications */ NativeBridge.RegisterForRemoteDidRefreshNotification((r) => { if (r.identifier != this.identifier) { return; } this.UpdateWithRemote(r); }); }
public void FetchButtonClicked() { #if UNITY_ANDROID dataText.text = NativeBridge.RetreiveData(); #endif }
public void Refresh(Action <MiraRemoteException> action) { NativeBridge.RemoteRefresh(this, action); }
public DownstreamCall(string clazz, string method, string arg = null) { this.wait = true; NativeBridge.InvokeCall(clazz, method, arg, OnResult); }
static void Main(string[] args) { try { bool show_help = false; string typeFilter = ""; bool show_all = false; OptionSet p = new OptionSet() { { "t|type=", "An object type to filter on", v => typeFilter = v.Trim() }, { "a|all", "Show all handles shared by at least one process", v => show_all = v != null }, { "h|help", "show this message and exit", v => show_help = v != null }, }; List <int> pids = p.Parse(args).Select(e => int.Parse(e)).ToList(); if (show_help || pids.Count < 2) { ShowHelp(p); } else { HashSet <IntPtr> sharedObjects = new HashSet <IntPtr>(); Dictionary <IntPtr, List <HandleEntry> > entries = new Dictionary <IntPtr, List <HandleEntry> >(); foreach (int pid in pids) { foreach (HandleEntry entry in NativeBridge.GetHandlesForPid(pid)) { if (!entries.ContainsKey(entry.Object)) { entries[entry.Object] = new List <HandleEntry>(); } entries[entry.Object].Add(entry); } } int limit = show_all ? 2 : pids.Count; var output = entries.Where(x => x.Value.GroupBy(y => y.ProcessId).Count() >= limit); foreach (KeyValuePair <IntPtr, List <HandleEntry> > pair in output) { if (String.IsNullOrWhiteSpace(typeFilter) || pair.Value[0].TypeName.Equals(typeFilter, StringComparison.OrdinalIgnoreCase)) { Console.WriteLine("{0:X} {1} {2}", pair.Key.ToInt64(), pair.Value[0].TypeName, pair.Value[0].ObjectName); foreach (HandleEntry entry in pair.Value) { Console.WriteLine("\t{0}/0x{0:X} {1}/0x{1:X} 0x{2:X08}", entry.ProcessId, entry.Handle.ToInt32(), entry.GrantedAccess); } } } } } catch (Exception ex) { Console.WriteLine(ex); } }
// 停止采样 // native层直接采样camera数据 public static void CloseDetection() { NativeBridge.InvokeCall("NativeEmotion", "CloseDetection"); }
static void Main(string[] args) { bool show_help = false; uint standard_filter = 0; int pid = Process.GetCurrentProcess().Id; OptionSet opts = new OptionSet() { { "r", "Recursive tree directory listing", v => _recursive = v != null }, { "sddl", "Print full SDDL security descriptors", v => _print_sddl = v != null }, { "p|pid=", "Specify a PID of a process to impersonate when checking", v => pid = int.Parse(v.Trim()) }, { "w", "Show only write permissions granted", v => _show_write_only = v != null }, { "f=", String.Format("Filter on a specific file right [{0}]", String.Join(",", Enum.GetNames(typeof(FileAccessRights)))), v => _file_filter |= ParseRight(v, typeof(FileAccessRights)) }, { "d=", String.Format("Filter on a specific directory right [{0}]", String.Join(",", Enum.GetNames(typeof(FileDirectoryAccessRights)))), v => _dir_filter |= ParseRight(v, typeof(FileDirectoryAccessRights)) }, { "s=", String.Format("Filter on a standard right [{0}]", String.Join(",", Enum.GetNames(typeof(StandardAccessRights)))), v => standard_filter |= ParseRight(v, typeof(StandardAccessRights)) }, { "x=", "Specify a base path to exclude from recursive search", v => _walked.Add(v.ToLower()) }, { "q", "Don't print errors", v => _quiet = v != null }, { "onlydirs", "Only check the permissions of directories", v => _only_dirs = v != null }, { "h|help", "show this message and exit", v => show_help = v != null }, }; List <string> paths = opts.Parse(args); if (show_help || (paths.Count == 0)) { ShowHelp(opts); } else { try { _type = ObjectTypeInfo.GetTypeByName("file"); _token = NativeBridge.OpenProcessToken(pid); _file_filter |= standard_filter; _dir_filter |= standard_filter; foreach (string path in paths) { if ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory) { DumpDirectory(new DirectoryInfo(path)); } else { DumpFile(new FileInfo(path)); } } } catch (Exception e) { //Console.WriteLine(e.Message); Console.WriteLine(e); } } }
// 设置是否检脸部朝向 // 禁用可提高性能,默认禁用 public static void SetDirectionCheck(bool b) { NativeBridge.InvokeCall("NativeEmotion", "SetDirectionCheck", b ? "true" : "false"); }
public static void UpstreamNotify(string clazz, string method, string arg = null) { Log("-> upstream notify " + clazz + "." + method + " " + arg); NativeBridge.OnNotify(clazz, method, arg); }
static void SetupNative(TextureData texture) { ("SetupNative on texture: " + texture.Info.name).Log(); if (texture.Info.texture == null) { throw new Exception("Texture null. Todo21: Probably related."); } /*if ("ThunderAerospace/TacLifeSupportContainers/FoodTexture" == texture.Info.name) * { * (texture.Info== null ? "INFO NULL": "INFO OK").Log(); * (texture.Info.texture == null ? "TEX NULL" : "TEX OK").Log(); * (texture.Info.texture.name).Log(); * (texture.Info.texture.format.ToString()).Log(); * texture.Info.texture.width.ToString().Log(); * }*/ texture.UnloadedTexture = texture.Info.texture.GetNativeTexturePtr(); /*bool isNormal = false; * var tex = Legacy.LegacyLoader.LoadImage(new System.IO.FileInfo(texture.File.fullPath), ref isNormal, texture.Info.isNormalMap); * System.IO.File.WriteAllBytes( * texture.File.fullPath + ".png.stock", * tex.EncodeToPNG()); * * //using (var text = System.IO.File.CreateText(texture.File.fullPath + ".stock.txt")) * using (var text2 = System.IO.File.CreateText(texture.File.fullPath + ".stockbyte.txt")) * { * for (int y = tex.height - 1; y >= 0; y--) // Unity textures are upside down. * { * for (int x = 0; x < tex.width; x++) * { * var c = tex.GetPixel(x, y); * Color32 c2 = c; * //text.Write("{" + c.a + "|" + c.r + "|" + c.g + "|" + c.b + "}"); * text2.Write("{" + c2.a + "|" + c2.r + "|" + c2.g + "|" + c2.b + "}"); * } * //text.WriteLine(); * text2.WriteLine(); * } * }*/ /* * var oldUnloadedPtr = texture.Info.texture.GetNativeTexturePtr(); * texture.Info.texture.UpdateExternalTexture(tex.GetNativeTexturePtr()); * tex.UpdateExternalTexture(oldUnloadedPtr); * return;*/ var imgConfig = Config.Current.GetImageConfig(texture.File); var imgSettings = ImageSettings.Combine(imgConfig.ImageSettings, Config.Current.DefaultImageSettings); Logic.ActivityGUI.PrepareStarting(); ("Sending img settings for texture: {HRC=" + imgSettings.HighResCompress + ", TC=" + imgSettings.ThumbnailCompress + ", TE=" + imgSettings.ThumbnailEnabled + ",TW=" + imgSettings.ThumbnailWidth + ",TH=" + imgSettings.ThumbnailHeight + "}").Log(); texture.NativeId = NativeBridge.RegisterTextureAndRequestThumbLoad( new System.IO.FileInfo(texture.File.fullPath).FullName, imgConfig.CacheKey, //texture.UnloadedTexture, texture.Info.isNormalMap, imgSettings ); if (!imgSettings.HighResEnabled.Value) { texture.File = null; } texture.Info.isReadable = false; ("Native ID received: " + texture.NativeId + " for " + texture.Info.name).Log(); }
public void OnButtonClick() { NativeBridge.ExitUnity(); }