Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial NOP in C#
#1
Hi guys im here to bring to you an easy way to make a NOP in C#.

N.O.P. = No Operation (computer processor instruction)

CSHARP Code
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Diagnostics;
  10. using System.Runtime.InteropServices;
  11. using System.Threading;
  12.  
  13. namespace mw3_t
  14. {
  15. public partial class Form1 : Form
  16. {
  17. private static int ProcessID = -1;
  18. private static IntPtr ProcessHandle = IntPtr.Zero;
  19.  
  20. [DllImport("kernel32.dll", EntryPoint = "WriteProcessMemory")]
  21. private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, [Out] int lpNumberOfBytesWritten);
  22.  
  23.  
  24. [DllImport("kernel32.dll", EntryPoint = "ReadProcessMemory")]
  25. private static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, [Out] int lpNumberOfBytesRead);
  26.  
  27. [DllImport("kernel32.dll", EntryPoint = "OpenProcess")]
  28. private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  29.  
  30. public Form1()
  31. {
  32. InitializeComponent();
  33. }
  34.  
  35. private void Form1_Load(object sender, EventArgs e)
  36. {
  37. System.Diagnostics.Process[] myprocesses = System.Diagnostics.Process.GetProcessesByName("iw5sp");
  38. if (myprocesses.Length != 0)
  39. {
  40. Process[] processes = Process.GetProcessesByName("iw5sp"); // in the "iw5sp" is the name of the process
  41. ProcessID = processes[0].Id;
  42. ProcessHandle = OpenProcess(0x001F0FFF/*PROCESS_ALL_ACCESS*/, false, ProcessID);
  43. byte[] nop = { 0x90, 0x90, 0x90, 0x90, 0x90 };// 5 bytes
  44. WriteProcessMemory(ProcessHandle, (IntPtr)0x004ECF46, nop, 5/*amount of bytes written(5)*/, 0);
  45. }
  46. }
  47. }
  48. }


I think this might help someone, anyway...

Credits: itsmods.com for some help Fuck yea!

Thanks Barata...

Don't worry if things aren't the way you planned, in the end everything will solve itself...
Reply

#2
cool, but what does a NOP do?
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#3
(01-31-2012, 17:10)iAegle Wrote: cool, but what does a NOP do?

For example, nukems ammo plugin uses it. It makes it so that the function that checks if ammo needs to be decreased stops working.
[Image: MaEIQ.png]
Reply

#4
(01-31-2012, 17:11)Pozzuh Wrote:
(01-31-2012, 17:10)iAegle Wrote: cool, but what does a NOP do?

For example, nukems ammo plugin uses it. It makes it so that the function that checks if ammo needs to be decreased stops working.

So basicly it disables the thing that changes the value to default?
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#5
No. For example, the code could be like

Code:
DecreaseAmmo()
{
    ammo--;
}

and after the NOPs
the function will be
Code:
DecreaseAmmo()
{
}
It does nothing anymore
[Image: MaEIQ.png]
Reply

#6
(01-31-2012, 17:16)iAegle Wrote:
(01-31-2012, 17:11)Pozzuh Wrote:
(01-31-2012, 17:10)iAegle Wrote: cool, but what does a NOP do?

For example, nukems ammo plugin uses it. It makes it so that the function that checks if ammo needs to be decreased stops working.

So basicly it disables the thing that changes the value to default?

Basicaly, yes...

NOP = no operation...

Thanks Barata...

Don't worry if things aren't the way you planned, in the end everything will solve itself...
Reply

#7
"an int is 5 bytes in size"

Good.
Reply

#8
I didnt know you can NOP in real-time
Reply

#9
(02-01-2012, 01:17)kokole Wrote: I didnt know you can NOP in real-time

Indeed you can...

Thanks Barata...
Don't worry if things aren't the way you planned, in the end everything will solve itself...
Reply



Forum Jump:


Users browsing this thread:
3 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.