-1

I have looked around other forums and can't find the answer anywhere. Can anyone help me?

static void Main(string[] args) {
    csProcess = Process.GetProcessesByName("notepad").FirstOrDefault();
    if (csProcess == null) { return; } // notepad isn't running
    modules = csProcess.Modules;
    foreach(ProcessModule module in modules) {
        if (module.ModuleName == "client.dll") {
            int ClientDLL = Mem.Module("client.dll");
        }

        int LocalPlayer = ReadProcessMemory(ClientDLL + m_dwLocalPlayer);
        int LocalTeam = ReadProcessMemory(LocalPlayer + m_iTeamNum);
        int CrossHairID = ReadProcessMemory(LocalPlayer + m_iCrossHairID);
        int EmemyinCrossHair = ReadProcessMemory(ClientDLL + m_dwEntityList +
            ((CrossHairID - 1) * EntLoopDist));
        int EnemyTeam = ReadProcessMemory(EnemyInCrossHair + m_iTeamNum);
        int EnemyHealth = ReadProcessMemory(EnemyinCrossHair + m_iHealth);

        if (EnemyHealth > 0 && EnemyTeam != LocalTeam) {
            mouse_event(MOUSEEVENTF_LEFTDOWN, Control.MousePosition.X,
                Control.MousePosition.Y, 0, 0);
            mouse_event(MOUSEEVENTF_LEFTUP, Control.MousePosition.X,
                Control.MousePosition.Y, 0, 0);
        }
    }
}

I need step by step instructions please.

Dovydas Šopa
  • 2,282
  • 8
  • 26
  • 34
  • Check `Build Action` & `Output Type` on project properties, then check availability of `App.xaml` file. Which one you want to build: a WinForms app, console app or class library? – Tetsuya Yamamoto Feb 27 '17 at 03:23
  • I want to export as dll so... console? – Luke McFall Feb 27 '17 at 03:31
  • Try using class library option as output type in Project => Properties menu (note that by default it may build as console app). Console app requires `STAThreadAttribute` to run with `Main` method (see similar issue: http://stackoverflow.com/questions/9607702/does-not-contain-a-static-main-method-suitable-for-an-entry-point). – Tetsuya Yamamoto Feb 27 '17 at 03:34

1 Answers1

1

What you want to get? Dll-library, or standalone application (.exe-file, console app e.g.)?
If you want to get exe-application, try to add public modifier for Main method - public static void Main(string[] args)
For dll-library:
1. Create New Project, "Class Library" type.
2. You already have a file Class1.cs. Replace the text in the Class1.cs:

namespace ClassLibrary1
{
    public static class Class1
    {
        static void MyMethod()
        {
            csProcess = Process.GetProcessesByName("notepad").FirstOrDefault();
            //Your another code
        }
    }
}

3. Build project and use ClassLibrary1.dll from bin->Debug or bin-Release folder by adding this dll as Reference in Console/WinForm/Wpf applications.
4. Use your dll-class like this - ClassLibrary1.Class1.MyMethod();

Artem
  • 487
  • 1
  • 8
  • 19