private void button2_Click(object sender, EventArgs e) { IntPtr hMod = LoadLibrary(tbDllPath.Text); if (rbManualMap.Checked) { if (hMod != IntPtr.Zero) { IntPtr InjectDllPtr = GetProcAddress(hMod, "InjectDll"); InjectDllFunc = (InjectDll)Marshal.GetDelegateForFunctionPointer(InjectDllPtr, typeof(InjectDll)); } if (InjectDllFunc != null) { foreach (Process proc in Process.GetProcessesByName(tbProcessName.Text)) { Int32 rval = InjectDllFunc(this.Handle, tbDllPath.Text, proc.Id); Log(string.Format("Injected {0} into process {1}. rval = {2}\n", tbDllPath.Text, proc.Id, rval)); } button2.Enabled = false; } } else if (rbWindowHook.Checked) { if (hMod != IntPtr.Zero) { IntPtr InstallHookPtr = GetProcAddress(hMod, "InstallHook"); IntPtr ReleaseHookPtr = GetProcAddress(hMod, "ReleaseHook"); InstallHookFunc = (InstallHook)Marshal.GetDelegateForFunctionPointer(InstallHookPtr, typeof(InstallHook)); ReleaseHookFunc = (ReleaseHook)Marshal.GetDelegateForFunctionPointer(ReleaseHookPtr, typeof(ReleaseHook)); } if (InstallHookFunc != null) { InstallHookFunc(this.Handle, tbProcessName.Text); button2.Enabled = false; Log("Created global window hook. Launch the target process now...\n"); } } }
private void button2_Click(object sender, EventArgs e) { IntPtr hMod = LoadLibrary(tbDllPath.Text); if (rbManualMap.Checked) { if (hMod != IntPtr.Zero) { IntPtr InjectDllPtr = GetProcAddress(hMod, "InjectDll"); InjectDllFunc = (InjectDll)Marshal.GetDelegateForFunctionPointer(InjectDllPtr, typeof(InjectDll)); } if (InjectDllFunc != null) { foreach( Process proc in Process.GetProcessesByName(tbProcessName.Text) ) { Int32 rval = InjectDllFunc(this.Handle, tbDllPath.Text, proc.Id); Log(string.Format("Injected {0} into process {1}. rval = {2}\n", tbDllPath.Text, proc.Id, rval)); } button2.Enabled = false; } } else if (rbWindowHook.Checked) { if (hMod != IntPtr.Zero) { IntPtr InstallHookPtr = GetProcAddress(hMod, "InstallHook"); IntPtr ReleaseHookPtr = GetProcAddress(hMod, "ReleaseHook"); InstallHookFunc = (InstallHook)Marshal.GetDelegateForFunctionPointer(InstallHookPtr, typeof(InstallHook)); ReleaseHookFunc = (ReleaseHook)Marshal.GetDelegateForFunctionPointer(ReleaseHookPtr, typeof(ReleaseHook)); } if (InstallHookFunc != null) { InstallHookFunc(this.Handle, tbProcessName.Text); button2.Enabled = false; Log("Created global window hook. Launch the target process now...\n"); } } }