Comment utiliser une dll sensée faire un hook ? Joyeux Noël
Bonjour, voila mon problème, j'ai une dll et ses sources c++, qui est sensée faire un hook de winsock. On m'a passé aussi la source c# d'un exemple utilisant cette dll pour lancer le hook, le problème c'est que je n'arrive pas à le transformer en c++, voici la source:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Net.Sockets;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
[DllImport("detoursdll.dll")]
public static extern bool SetHook();
[DllImport("detoursdll.dll")]
public static extern bool UnsetHook();
public Form1()
{
InitializeComponent();
button1.Enabled = true;
button2.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
if (!SetHook())
return;
button1.Enabled = false;
button2.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
if (!UnsetHook())
return;
button1.Enabled = true;
button2.Enabled = false;
}
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace WindowsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
} |
Voila ca à l'air simple mais je ne connais pas le c# et je ne connais rien à propos des dlls en c++ donc si quelqu'un pouvait me donner le code le plus simple possible pour je lancer le hook au lancement et l'enlever à la fermeture ou convertir se code en c++, je lui en serais infiniment reconnaissant.
Merci d'avance. Et joyeux Noël !