Git Product home page Git Product logo

tinyjithook's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working in the IT education industry.
  • ๐ŸŒฑ Iโ€™m currently improving my skills in web development and general ts/js/react.
  • ๐Ÿ“ซ How to reach me: my website, on the left!
  • ๐Ÿ˜„ Pronouns: she/her.
  • โšก Fun fact: you're cute, no matter what anyone says!

tinyjithook's People

Contributors

elliesaur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tinyjithook's Issues

How to load a wpf exe and start it by reflection in the same process and appdomain?

I'm using TinyJitHook https://github.com/Elliesaur/TinyJitHook to patch a compiled executable file.

I want to load a wpf exe file and run it in a c# console program;

The wpf program is the default empty window of visual studio.

The main program is a console program;

When I run the main program, I get a "Cannot locate resource 'mainwindow.xaml'" error.

What should I do.

Thanks to the people who made the "Process.Start("WpfApp1.exe")" comments, this starts the program, but that doesn't seem to make them in one process or AppDomain.

mainApp

public static void Main(string[] args)
{
    string filePath = @"WpfApp1.exe";

    Assembly asm = Assembly.LoadFrom(filePath);
    MainJitHook hook = new MainJitHook(asm, IntPtr.Size == 8);
    hook.OnCompileMethod += ChangeExample;

    hook.Hook();
    try
    {
        MethodInfo method = asm.EntryPoint;
        method.Invoke(null, new object[] { });
    }
    catch (Exception extInfo)
    {
        Console.WriteLine(extInfo.ToString());
    }

    hook.Unhook();
    Console.WriteLine("DONE");
    Console.ReadKey();
}


private static unsafe void ChangeExample(MainJitHook.RawArguments args, Assembly relatedAssembly, uint methodToken, ref byte[] ilBytes1, ref byte[] ehBytes1)
{
    try
    {
        var methodBase = relatedAssembly.ManifestModule.ResolveMethod((int) methodToken);
        Console.WriteLine("###################### cur method is " + methodBase.Name + " asm fiel is " + relatedAssembly.GetName());
    } catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
    }
}

App.xaml

<Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfApp1"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>

MainWindow.xaml

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        
    </Grid>
</Window>

Error

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.IOException: Cannot locate resource 'mainwindow.xaml'.
   at MS.Internal.AppModel.ResourcePart.GetStreamCore(FileMode mode, FileAccess access)

    ...
    ...

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at WpfApp1.App.Main()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at TinyJitHook.Program.Main(String[] args) in E:\download\TinyJitHook-master\TinyJitHook\Program.cs:line 42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.