Biblioteka dll nie ładuje się 1343 0

O temacie

Autor Paser

Zaczęty 22.12.2012 roku

Wyświetleń 1343

Odpowiedzi 0

Paser

Paser

Użytkownicy
Crazy Diamond
posty281
Propsy119
ProfesjaNierób
  • Użytkownicy
  • Crazy Diamond

Paser

Biblioteka dll nie ładuje się
2012-12-22, 16:51(Ostatnia zmiana: 2012-12-22, 19:00)
Witam, stworzyłem sobie mały programik który wstrzykuje do Gothic2 własną bibliotekę korzystającą z klas gothica2.Na początek miał po prostu włączać i wyłączać marvin mode.
Po skończeniu launchera i dllki połączyłem całość.
I niestety nie działa, to znaczy odpala gothica 2, w niema żadnego błędu ale dllki nie wstrzykuje tak jak by kodu za to odpowiedzialnego wcale nie było (wydaje mi się że źle go zrobiłem).
O to kod launchera (aplikacja konsolowa):
Link do pastebin
using System.IO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using WinApi;
using WinApi.Kernel;
using WinApi.FileFormat;

namespace gothic_2_edit
{
    class Program
    {  
        public static void Main(string[] args)
        {

           
            Console.WriteLine("Kliknij ENTER by rozpocząć grę");
            Console.ReadLine();


            String dll = "NetInject.dll";

            if (!System.IO.File.Exists(dll))
                throw new Exception("Elementu " + dll + " nie znaleziono");


            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
            psi.WorkingDirectory = Environment.CurrentDirectory;


            psi.Arguments = "-zwindow";


            psi.FileName = "Gothic2.exe";
            WinApi.Process process = WinApi.Process.Start(psi);

            if (process.LoadLibary(dll) == IntPtr.Zero)
                Error.GetLastError();
            Console.ReadLine();

        }
    }
}
A to kod wstrzykiwanej dllki za pośrednictwem NetInject.dll(NetInject.dll na pewno działa dobrze):
Link do pastebin
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using WinApi;
using System.Threading;
using Gothic.zClasses;
using Gothic.zTypes;
using WinApi.User;
using WinApi.User.Enumeration;
using Gothic.mClasses;
using Gothic.mClasses.Elements;
using Gothic.zStruct;

namespace marvinenabler
{
    public class Program
    {
        public static Int32 InjectedMain(String message)
        {
            try
            {
                Process Process = Process.ThisProcess();

                AddHooks();
                MarvinModeEnable();
                while (true)
                {
                    Thread.Sleep(10000);
                }
            }
            catch (System.Exception ex)
            {
                zERROR.GetZErr(Process.ThisProcess()).Report(4, 'G', ex.ToString(), 0, "Program.cs", 0);
            }
            return 11;
        }

        public static void AddHooks()
        {
            Process Process = Process.ThisProcess();

            Process.Hook("GUC.dll", typeof(Program).GetMethod("ocGameUpdate"), 0x006C8AB2, 5, 0);
        }
        //(That will add a hook at the end of the render function)

        public static Int32 ocGameUpdate(String message)
        {
            Process Process = Process.ThisProcess();
            //each time when gothic renders the game this function will be called
            return 0;
        }
        //Functions
        static byte[] mmenable;
        public static void MarvinModeEnable()
        {
            Process Process = Process.ThisProcess();
            Process.Write(mmenable, 0x006CBF60);
        }

        public static void MarvinModeDisable()
        {
            Process Process = Process.ThisProcess();
            Process.VirtualProtect(0x006CBF60, 25);
            mmenable = Process.ReadBytes(0x006CBF60, 25);
            byte[] arr = new byte[25];
            for (int i = 0; i < arr.Length; i++)
                arr[i] = 0x90;
            Process.Write(arr, 0x006CBF60);


            arr = new byte[] { 0xC3 };
            Process.Write(arr, 0x00432EC0);//Eventhandle marvin mode


        }
    }

}
Prosiłbym o szybką pomoc ;)
EDIT:Problem rozwiązany , po prostu jeden z użytych libów korzystał z frameworka 2 a ja miałem 4, wystarczyło zmienić w properties dll.
 


0 użytkowników i 1 Gość przegląda ten wątek.
0 użytkowników
Do góry