View previous topic :: View next topic |
Author |
Message |
Arko How do I cheat? Reputation: 0
Joined: 16 Feb 2015 Posts: 3
|
Posted: Mon Feb 16, 2015 4:05 pm Post subject: Help with using Kernel32.dll in C# for DLL injection |
|
|
I am trying to make a DLL injector for my project using C# but I have run into an issue when trying to use the Kernel32.dll inside of C#, the problem I am having is I don't know how to. I have googled about this issue and have found examples but they aren't explained or give any information on how they do it. What I am trying to do is inject a DLL into another process using C#.
|
|
Back to top |
|
|
atom0s Moderator Reputation: 199
Joined: 25 Jan 2006 Posts: 8518 Location: 127.0.0.1
|
Posted: Mon Feb 16, 2015 6:06 pm Post subject: |
|
|
Use DllImport to handle the importing of the needed API, like this:
Code: | /// <summary>
/// kernel32!GetProcAddress
/// </summary>
/// <param name="hModule"></param>
/// <param name="procName"></param>
/// <returns></returns>
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetProcAddress(
IntPtr hModule,
string procName
);
/// <summary>
/// kernel32!LoadLibraryA
/// </summary>
/// <param name="lpFileName"></param>
/// <returns></returns>
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr LoadLibraryA(
string lpFileName
); |
_________________
- Retired. |
|
Back to top |
|
|
Arko How do I cheat? Reputation: 0
Joined: 16 Feb 2015 Posts: 3
|
Posted: Mon Feb 16, 2015 6:43 pm Post subject: |
|
|
atom0s wrote: | Use DllImport to handle the importing of the needed API, like this:
Code: | /// <summary>
/// kernel32!GetProcAddress
/// </summary>
/// <param name="hModule"></param>
/// <param name="procName"></param>
/// <returns></returns>
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetProcAddress(
IntPtr hModule,
string procName
);
/// <summary>
/// kernel32!LoadLibraryA
/// </summary>
/// <param name="lpFileName"></param>
/// <returns></returns>
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
public static extern IntPtr LoadLibraryA(
string lpFileName
); |
|
Could you tell me how I would get the API from Kernel32? Like the method and such
|
|
Back to top |
|
|
atom0s Moderator Reputation: 199
Joined: 25 Jan 2006 Posts: 8518 Location: 127.0.0.1
|
Posted: Mon Feb 16, 2015 8:00 pm Post subject: |
|
|
pinvoke's website has nearly all of the Win32 API done here:
http://www.pinvoke.net/
_________________
- Retired. |
|
Back to top |
|
|
Arko How do I cheat? Reputation: 0
Joined: 16 Feb 2015 Posts: 3
|
Posted: Tue Feb 17, 2015 1:26 pm Post subject: |
|
|
Thanks for the help.
|
|
Back to top |
|
|
|