0

so I'm trying to create a DLL Injector for minecraft, below is my attempt along with some online resources on making a DLL Injector. I have the following errors and can't work out why they are present:

'Inject DLL Identifier is not found' 'strcat is unsafe'

Sorry if this is a noob mistake, I am learning :(

Also, would I have to use a Java injector for Minecraft seeming as Java is the language its ran in?

Thanks for any answers!

using namespace std;

char FileToInject[] = "37gHsZ.dll";
char ProcessName[] = "javaw.exe";
typedef HINSTANCE(*fpLoadLibrary)(char*);

int main()
{
    DWORD processId = NULL;

    PROCESSENTRY32 pe32 = { sizeof(PROCESSENTRY32) };
    HANDLE hProcSnap;

    while (!processId)
    {
        system("cls");
        cout << "(!) Locating the process: " << ProcessName << "... (!)\n";
        cout << "(!) Ensure Minecraft 1.7.10 is running (!)" << endl;
        hProcSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

        if (Process32First(hProcSnap, &pe32))
        {
            do
            {
                if (!strcmp(pe32.szExeFile, ProcessName))
                {
                    processId = pe32.th32ProcessID;
                    break;
                }

            } 
            while (Process32Next(hProcSnap, &pe32));
        }
        Sleep(1000);
    }
    cout << "Located process: " << ProcessName << endl;

    while (!InjectDLL(processId))
    {
        system("cls");
        cout << "Classes failed to inject" << endl;
        Sleep(1000);
    }
    cout << "Classes loaded succesfuly\n" << endl;
    Sleep(500);
    cout << "Closing in 3 seconds" << endl;

    CloseHandle(hProcSnap);
    Sleep(5000);
    return 0;

}

bool InjectDLL(DWORD ProcessID)
{
    HANDLE hProc;
    LPVOID paramAddr;

    HINSTANCE hDLL = LoadLibrary("KERNEL32");

    fpLoadLibrary LoadLibraryAddr = (fpLoadLibrary)GetProcAddress(hDLL, "LoadLibraryA");

    hProc = OpenProcess(PROCESS_ALL_ACCESS, false, ProcessID);

    char dllPath[250] = "C:\\Recorder\\";

    strcat(dllPath, FileToInject);

    paramAddr = VirtualAllocEx(hProc, 0, strlen(dllPath) + 1, MEM_COMMIT, PAGE_READWRITE);
    bool memoryWritten = WriteProcessMemory(hProc, paramAddr, dllPath, strlen(dllPath) + 1, NULL);

    CreateRemoteThread(hProc, 0, 0, (LPTHREAD_START_ROUTINE)LoadLibraryAddr, paramAddr, 0, 0);

    CloseHandle(hProc);

    return memoryWritten;
}
RAD140
  • 61
  • 2
  • 7
  • There's a good list of C++ books [here](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – molbdnilo Mar 30 '17 at 17:15
  • It would be easier to make a mod for MC and use [JNI](https://en.wikipedia.org/wiki/Java_Native_Interface) from there. Directly injecting DLLs probably won't work without some work. – Pokechu22 Mar 30 '17 at 17:50

1 Answers1

1

You define InjectDLL() below main(), the compiler goes from top to bottom, it can't compile main() because it doesn't know what InjectDLL() is.

To fix, define InjectDLL() above main()

strcat is unsafe, use strcat_s instead, unsafe functions are deprecated and you're not supposed to use them anymore.

GuidedHacking
  • 3,628
  • 1
  • 9
  • 59