Advertisement
Guest User

inASM

a guest
Dec 22nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Runtime.InteropServices;
  5. using RGiesecke.DllExport;
  6.  
  7. namespace InASM
  8. {
  9.    internal static class UnmanagedExports
  10.    {
  11.       [DllExport("DLLMain", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
  12.       static void DLLMain()
  13.       {
  14.          //multiclient-test inline ASM
  15.           int[] addr = { 0x0040CD4A, 0x0040CD5C, 0x0040CD61 };
  16.  
  17.  
  18.           IntPtr baseaddr = advanced.GetModuleBaseAddress("KERNELBASE.dll");
  19.           IntPtr module = advanced.GetProcAddress(baseaddr, "CreateMutexA");
  20.  
  21.           MessageBox(0, "Program will write inline ASM\nPress OK to continue.", "Info", 0);
  22.           /*
  23.            * Writing inline ASM into memory...
  24.            * */
  25.           try
  26.           {
  27.               //6 - bytes
  28.               ASM.Nop();//1
  29.               ASM.Nop();//2
  30.               ASM.Nop();//3
  31.               ASM.Nop();//4
  32.               ASM.Nop();//5
  33.               ASM.Nop();//6
  34.               ASM.RunAsm(addr[0]);
  35.  
  36.               //2 - bytes
  37.               ASM.Mov_EAX(0xB7);
  38.               ASM.RunAsm(addr[1]);
  39.  
  40.               //1 - byte
  41.               ASM.JMP();
  42.               ASM.RunAsm(addr[2]);
  43.  
  44.               //3 - bytes
  45.               ASM.RetB(0x0C);
  46.               ASM.RunAsm((int)module);
  47.           }
  48.           catch (Exception Exc){
  49.               MessageBox(0, "An Exception occured!\n" + Exc.Message, "Error", 0);
  50.               Environment.Exit(7331);
  51.           }
  52.           MessageBox(0, "OK", "Info", 0);
  53.  
  54.       }
  55.  
  56.       [DllImport("user32", CharSet = CharSet.Auto)]
  57.       static extern int MessageBox(int hwnd, String text, String caption, int options);
  58.    }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement