Home > Net >  C # DLL cannot execute after injection, seek help from god.
C # DLL cannot execute after injection, seek help from god.

Time:12-31

Recently to do the final class design computer program, the topic is a DLL and c # development to explorer. Exe and perform, very not easy corruption could have injected a black finish, but cannot be automatically after the injection, all kinds of baidu also not line, see the corner really have no way to, looking at various great god help, thank you!
With c # DLL injection source code (XP can run under (32-bit)) :

using System;
using System.Collections.Generic;
using System.Text;
Using System. The Runtime. InteropServices;
Using System. Diagnostics;

The namespace DllInjectA
{
Class Program
{
[DllImport (" kernel32. DLL)]//statement of API
Public static extern int VirtualAllocEx (IntPtr HWND, int lpaddress, int size, int type, int tect);

[DllImport (" kernel32. DLL)]
Public static extern int WriteProcessMemory (IntPtr HWND, int baseaddress, string buffer, int nsize, int filewriten);

[DllImport (" kernel32. DLL)]
Public static extern int GetProcAddress call (int HWND, string lpname);

[DllImport (" kernel32. DLL)]
Public static extern int GetModuleHandleA (string name);

[DllImport (" kernel32. DLL)]
Public static extern int CreateRemoteThread (IntPtr HWND, int attrib, int size, int address, int par, int flags, int threadid);

The static void Main (string [] args)
{
Int ok1;
Int baseaddress;
Int temp=0;
Int hack;
Int yan;
String dllname;

Dllname="c: \ \ test DLL";
Int dlllength;
Dlllength=dllname. Length + 1;
Process [] pname=Process. GetProcesses ();//get all processes

Foreach (Process name in pname)//traversal Process
{
//MessageBox. Show (name) ProcessName) ToLower ());
If (name) ProcessName) ToLower (). The IndexOf (" svchost ")!=1)//notepad, as is shown in the following start injection
{
Baseaddress=VirtualAllocEx (name. Handle, 0, dlllength, 4096, 4);//the application memory space
If (baseaddress==0)//return 0 operation fails
{
Console. WriteLine (" application memory space failure!!!!! ");
return;
}

Ok1=WriteProcessMemory (name, Handle, baseaddress, dllname, dlllength, temp);//write memory
If (ok1==0)
{
Console. WriteLine (" write memory failure!!!!! ");
return;
}

Hack=GetProcAddress call (GetModuleHandleA (" Kernel32 "), "LoadLibraryA");//loadlibarary in kernek32. DLL address

If (hack==0)
{
Console. WriteLine (" cannot obtain function entry point!!!! ");
return;
}

Yan=CreateRemoteThread (name. Handle, 0, 0, hack, baseaddress, 0, temp);//create a remote thread

If (yan==0)
{
Console. WriteLine (" failed to create the remote thread!!!!! ");
return;
}
The else
{
Console. WriteLine (" has been successfully injected DLL!" );
Console.ReadKey();
return;
}
}
}
}
}
}

CodePudding user response:

This problem we could not answer, afraid of into "the little black house"
Do you want to get other, technically the ans chat

To make the explorer. Exe, we can't say what

CodePudding user response:

Is your teacher let you so write code injection managed DLL to unmanaged process? Did you confirm the teacher test personally?

The main managed DLL will not be executed, unless you are written in c + +/CLR
  •  Tags:  
  • C#
  • Related