// method to call for setting up the renderer public CharmResult CharmInit(CallbackManaged m_callbackManaged, string processName) { // Get all processes by the inputted name, then check that only one exists Process[] processes = Process.GetProcessesByName(processName); if (processes.Length < 1) { return(CharmResult.CHARM_NATIVE_NONE); } if (processes.Length > 1) { return(CharmResult.CHARM_PROCESS_MANy); } Process process = processes[0]; // Get the main window of the module, then verify it's valid IntPtr targetWindow = process.MainWindowHandle; if (targetWindow == IntPtr.Zero) { return(CharmResult.CHARM_WINDOW_NONE); } // set the current instances this.callbackManaged = Charm.StaticCallbackManaged = m_callbackManaged; // set up RPM this.rpm = new RPM(process.Id, this.fastWrite); // set up renderer this.renderer = new Renderer(); // create the callback this.callbackUnmanaged = Charm.StaticCallbackUnmanaged = new CallbackUnmanaged(CharmCallback); // call the native function DirectOverlaySetup(callbackUnmanaged, targetWindow); // return successful return(CharmResult.CHARM_SUCCESS); }
private static extern void DirectOverlaySetup([MarshalAs(UnmanagedType.FunctionPtr)] CallbackUnmanaged callBackUnmanaged, IntPtr hWnd);