Loading VCMP via command line

Started by habi2, Sep 02, 2024, 01:48 PM

Previous topic - Next topic

habi2

Hi friends, i made a program to load VCMP via command-line.
Load.exe "D:\Grand Theft Auto Vice City\gta-vc.exe" "-c -h 127.0.0.1 -c -p 8192 -n habi " "D:\Grand Theft Auto Vice City" "C:\Users\YOUR_USERNAME\AppData\Local\Vice City Multiplayer\0.4.7.1\vcmp-game.dll" is the example syntax.
Replace 127.0.0.1 by your Server IP. habi is my name
Add -z password if there is password for Server.

Load.exe(28.5 KB Mediafire)

Virus Total Result. Only 1 in 75 antivirus flagged as virus (don't know why).
#include <Windows.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    STARTUPINFO startupinfo = {};
    startupinfo.cb = sizeof(startupinfo);
    PROCESS_INFORMATION processinformation = {};

    // Ensure that required arguments are provided
    if (argc < 5) {
        printf("Usage: %s <Executable> <CommandLine> <WorkingDirectory> <DLLPath>\n", argv[0]);
        return 1;
    }

    // Create the process in a suspended state
    BOOL s = CreateProcessA(argv[1], argv[2], NULL, NULL, 0, CREATE_SUSPENDED,
        NULL, argv[3], &startupinfo, &processinformation);
    if (!s) {
        printf("Failed to create process. Error: %d\n", GetLastError());
        return 1;
    }

    int len = (int)strlen(argv[4]) + 1;
    // Allocate memory in the target process
    LPVOID base = VirtualAllocEx(processinformation.hProcess, NULL, len, MEM_COMMIT, PAGE_READWRITE);
    if (!base) {
        printf("VirtualAllocEx failed. Error: %d\n", GetLastError());
        TerminateProcess(processinformation.hProcess, 0);
        CloseHandle(processinformation.hProcess);
        return 2;
    }

    // Write the DLL path to the allocated memory
    SIZE_T no_bytes_written;
    BOOL r = WriteProcessMemory(processinformation.hProcess, base, argv[4], len, &no_bytes_written);
    if (!r) {
        printf("WriteProcessMemory failed. Error: %d\n", GetLastError());
        VirtualFreeEx(processinformation.hProcess, base, 0, MEM_RELEASE);
        TerminateProcess(processinformation.hProcess, 0);
        CloseHandle(processinformation.hProcess);
        return 3;
    }

    HMODULE module = GetModuleHandle("kernel32");
    if (!module) {
        printf("Could not get handle to kernel32. Error: %d\n", GetLastError());
        VirtualFreeEx(processinformation.hProcess, base, 0, MEM_RELEASE);
        TerminateProcess(processinformation.hProcess, 0);
        CloseHandle(processinformation.hProcess);
        return 4;
    }

    FARPROC fnLoadLibraryA = GetProcAddress(module, "LoadLibraryA");
    if (!fnLoadLibraryA) {
        printf("Error occurred in GetProcAddress. Error: %d\n", GetLastError());
        VirtualFreeEx(processinformation.hProcess, base, 0, MEM_RELEASE);
        TerminateProcess(processinformation.hProcess, 0);
        CloseHandle(processinformation.hProcess);
        return 5;
    }

    // Create a remote thread to load the DLL
    DWORD ThreadId;
    HANDLE injectedThread = CreateRemoteThread(processinformation.hProcess, NULL, 0,
        (LPTHREAD_START_ROUTINE)fnLoadLibraryA,
        base, 0, &ThreadId);
    if (!injectedThread) {
        printf("CreateRemoteThread failed. Error: %d\n", GetLastError());
        VirtualFreeEx(processinformation.hProcess, base, 0, MEM_RELEASE);
        TerminateProcess(processinformation.hProcess, 0);
        CloseHandle(processinformation.hProcess);
        return 6;
    }

    DWORD retcode = WaitForSingleObject(injectedThread, 10000);  // 10000 ms
    if (retcode == WAIT_OBJECT_0) {
        DWORD exitCode;
        if (GetExitCodeThread(injectedThread, &exitCode)) {
            if (exitCode != 0) {
                printf("Resuming thread\n");
                ResumeThread(processinformation.hThread);
            }
            else {
                printf("Terminating thread. Exit code was %d\n", exitCode);
                TerminateProcess(processinformation.hProcess, 0);
            }
        }
        else {
            printf("GetExitCodeThread failed. Error: %d\n", GetLastError());
        }
    }
    else {
        printf("Thread not signaled. Error: %d\n", GetLastError());
    }

    // Clean up resources
    VirtualFreeEx(processinformation.hProcess, base, 0, MEM_RELEASE);
    CloseHandle(injectedThread);
    CloseHandle(processinformation.hThread);
    CloseHandle(processinformation.hProcess);

    printf("Done.\n");
    return 0;
}

Credits: I made it from some older project of ysc3839.

MEGAMIND

Load.exe "D:\Grand Theft Auto Vice City\gta-vc.exe" "-c -h 127.0.0.1 -c -p 8192 -n habi " "D:\Grand Theft Auto Vice City" "C:\Users\YOUR_USERNAME\AppData\Local\Vice City Multiplayer\0.4.7.1\vcmp-game.dll"127.0.0.1 if we connect to other server ip does it work? or works for localhost? just curious havent tested
;D

habi2

Quote from: MEGAMIND on Sep 02, 2024, 02:43 PMLoad.exe "D:\Grand Theft Auto Vice City\gta-vc.exe" "-c -h 127.0.0.1 -c -p 8192 -n habi " "D:\Grand Theft Auto Vice City" "C:\Users\YOUR_USERNAME\AppData\Local\Vice City Multiplayer\0.4.7.1\vcmp-game.dll"127.0.0.1 if we connect to other server ip does it work? or works for localhost? just curious havent tested
;D
you can connect to outside servers

AroliS^

does this works with steam-game.dll? did you ever try it out habi?
@habi2 contact me on discord if can username arolisg
Lemme love ya

MEGAMIND

Quote from: AroliS^ on Sep 23, 2024, 07:00 PMdoes this works with steam-game.dll? did you ever try it out habi?
@habi2 contact me on discord if can username arolisg
it will work if u still have a steam game

habi2

Quote from: AroliS^ on Sep 23, 2024, 07:00 PMdoes this works with steam-game.dll? did you ever try it out habi?
@habi2 contact me on discord if can username arolisg
Hi arolis, i have not tried it with steam. But there is a steam.dll exact name i do not remember. As megamind told, it might work. Instead of vcmp-game.dll, you have to give path to steam dll.

PSL

Hi Habi this function is good, but can you add a configuration file, set the IP and path in the configuration file, and then click exe directly into the server, ha ha ha, but this is my fantasy, I do not know can not want to achieve, but this is really convenient.