private void btnInject_Click(object sender, RoutedEventArgs e) { string dll = textBoxDLL.Text.Trim(); string func = textBoxFunction.Text.Trim(); string args = textBoxArguments.Text.Trim(); if (dll == string.Empty || !File.Exists(dll)) { UpdateStatus("You must select a dll to inject"); return; } InjectorLib lib = new InjectorLib(); bool isManaged = lib.IsDllManaged(dll) == 1; if (isManaged && func == string.Empty) { UpdateStatus("You must specify a class method when injecting managed DLLs", false); return; } if (isManaged && !func.Contains('.')) { UpdateStatus("Class method should be in the form of 'namespace.classname.methodname'"); return; } uint pid = 0; try { ComboBoxItem cbi = (ComboBoxItem)comboBoxProcesses.SelectedItem; pid = uint.Parse(cbi.Tag.ToString()); } catch { UpdateStatus("You must select a process to inject to"); return; } UInt32 retCode = 0; bool b = lib.InjectAndRun(pid, dll, func, args, ref retCode); if (!b) { // See InjectorLib sources to understand what the error codes mean.. UpdateStatus("Injection failed. Error code " + retCode); } else { UpdateStatus("Injection successful. Return value: " + retCode, false); } }
private void btnLaunch_Click(object sender, RoutedEventArgs e) { string exe = textBoxProcess.Text.Trim(); string dll = textBoxDLL.Text.Trim(); string func = textBoxFunction.Text.Trim(); string args = textBoxArguments.Text.Trim(); if (dll == string.Empty || !File.Exists(dll)) { UpdateStatus("You must select a dll to inject"); return; } InjectorLib lib = new InjectorLib(); bool isManaged = lib.IsDllManaged(dll) == 1; if (isManaged && func == string.Empty) { UpdateStatus("You must specify a class method when injecting managed DLLs", false); return; } if (isManaged && !func.Contains('.')) { UpdateStatus("Class method should be in the form of 'namespace.classname.methodname'"); return; } if (exe == string.Empty) { UpdateStatus("You must select an exe file to launch"); return; } UInt32 retCode = 0; bool b = lib.LaunchAndInject(exe, dll, func, args, ref retCode); if (!b) { // See InjectorLib sources to understand what the error codes mean.. UpdateStatus("Injection failed. Error code " + retCode); } else { UpdateStatus("Injection successful. Return value: " + retCode, false); } }