Jump to content
  • 0

Hex Ragexe to call a program.


Question

10 answers to this question

Recommended Posts

  • 0
Posted

Not that I know of, but you can make your patcher or your launcher to call a .bat or a similar program to run both programs you want and the client.

  • 0
Posted (edited)

sader1992 is there sample dll source code to call a program? i have a console program that automatically kill a program in process that i don't want. the problem is how to make a ragexe as it execute it will launch that application too and it will automatically kill itself when ragexe not in process.

Edited by lynxpravoka
  • 0
Posted
#include <windows.h>
#include <tchar.h>

DWORD CALLBACK RunMyApp(LPVOID lpParam)
{
    STARTUPINFO Si = { sizeof(Si) };
    PROCESS_INFORMATION Pi = { 0 };

    if(CreateProcess(_T("myapp.exe"), _T("myapp.exe param1 param2"), NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi))
    {
        CloseHandle(Pi.hThread);
        CloseHandle(Pi.hProcess);
    }
  
    return 0;
}

BOOL CALLBACK DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
{
    switch(dwReason)
    {
        case DLL_PROCESS_ATTACH:
        {
            DWORD dwThreadId;
            HANDLE hThread = CreateThread(NULL, 0, &RunMyApp, NULL, 0, &dwThreadId);
          
            if(hThread)
            {
                CloseHandle(hThread);
            }
          
            break;
        }
    }
  
    return TRUE;
}

Here's your sample code. Error handling has been omitted for brevity.

  • 0
Posted

by the way i try your code i change value myapp.exe to cmd.exe and param 1 param 2 to ver.

so the code like this

 

#include <windows.h>
#include <tchar.h>

DWORD CALLBACK RunMyApp(LPVOID lpParam)
{
    STARTUPINFO Si = { sizeof(Si) };
    PROCESS_INFORMATION Pi = { 0 };

    if(CreateProcess(_T("cmd.exe"), _T("cmd.exe ver"), NULL, NULL, FALSE, 0, NULL, NULL, &Si, &Pi))
    {
        CloseHandle(Pi.hThread);
        CloseHandle(Pi.hProcess);
    }
  
    return 0;
}

BOOL CALLBACK DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
{
    switch(dwReason)
    {
        case DLL_PROCESS_ATTACH:
        {
            DWORD dwThreadId;
            HANDLE hThread = CreateThread(NULL, 0, &RunMyApp, NULL, 0, &dwThreadId);
          
            if(hThread)
            {
                CloseHandle(hThread);
            }
          
            break;
        }
    }
  
    return TRUE;
}

and try to execute it directly from cmd.exe. the dll not call new cmd.exe with value ver to check ver cmd.exe.

whats going on?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...