Quantcast

Jump to content

» «
Photo

[SA] How to make ASI mods?

6 replies to this topic
iFarbod
  • iFarbod

    PAWN & PHP Coder!

  • Members
  • Joined: 17 Dec 2013
  • None

#1

Posted 28 January 2014 - 12:36 PM

Hi Every one.

i have a question how to make asi mods.

some guys telled me must know c++

i know this language. what should i do?

thanks.  :santa:

  • TommyCJFaann likes this

BnB
  • BnB

    #OGAY_2014

  • The Yardies
  • Joined: 28 Jun 2010
  • Greece

#2

Posted 28 January 2014 - 12:54 PM

Create a dll rename it to .asi and put it into the SA folder, also make sure you have an asi loader. Basically, it's a dll injection.

  • iFarbod likes this

343 guilty spark
  • 343 guilty spark

    Player Hater

  • Members
  • Joined: 26 Nov 2013

#3

Posted 16 February 2014 - 12:10 AM Edited by 343 guilty spark, 16 February 2014 - 12:19 AM.

 you can only use memory addresses dont expect and API or and SDK! 

i gave you some examples (kill player and get current play car)

you can compile this using wxDev-c++ as a dll then rename it to .asi and place it is the same folder as your GTA_SA.EXE, then it wont work.

i mean you still need asi loader, fool!

#include <windows.h>

BOOL running;

DWORD getCar(){ return *((DWORD *)0xBA18FC);} 

void setMoney(DWORD dw){ 
    *(DWORD *)0xB7CE50 = dw;  
    *(DWORD *)0xB7CE54 = dw;  
};

BOOL inMenu(){
    return *(byte *) 0xB7CB49 != 0;   
}

DWORD getPlayerPointer(){
    return *(DWORD *)(0xB6F5F0);
}

BOOL playerAlive(){
    DWORD ptr = getPlayer();
    if(ptr > 0){
        ptr += 0x540;
        return *(float*) ptr > 0.f;
    }
    return false;
}

BOOL playerDefined(){
    return getPlayer() > 0;   
}

float getPlayerAngle(){
    return *(float *)(getPlayer() + 0x558);    
}

void killPlayer(){
        DWORD playerPtr = getPlayer();
        if(playerPtr > 0){
            playerPtr += 0x540;
            *(float *) playerPtr = 0.0f;
        }
}

void run(){
    running = true;
    // declare vars here and do things that need to be done only one time!
    while(running){
         //----------------------------------------------------------
         // do it here! (i did not mean poop here! DAMN IT! i meant code here what every you want)
        
        // joke
        Sleep(60000);
        killPlayer();
        // this is not funny! what kind of gangster gets a heart-attack every minute?

         //----------------------------------------------------------
        Sleep(250); // dont not remove this you can use a smaller number for faster execution
    }
    /* this is the end, do what you need to do before you quit, quitter! but i dont think 
                   asi loader will get you here, i never tried it.*/
}

DWORD WINAPI callable(void *parameter){ run();}

extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
switch (fdwReason)
{

 case DLL_PROCESS_ATTACH:
  CreateThread(0, 0, callable, 0, 0, 0);
  break;

 case DLL_PROCESS_DETACH:
        running = false;
   break;

 case DLL_THREAD_ATTACH:
 case DLL_THREAD_DETACH:
  break;
}
return TRUE;
}


_DK
  • _DK

    gta3 cleo

  • Feroci Racing
  • Joined: 12 Apr 2009
  • None

#4

Posted 16 February 2014 - 10:51 AM Edited by _DK, 16 February 2014 - 10:52 AM.

dont expect and API or and SDK!

False.
#include "plugin\plugin.h"
#include "game_sa\common.h"
#include "game_sa\CTimer.h"

using namespace plugin;

void MyProcess();
unsigned int myTimer = 0;

BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved)
{
    if(reason == DLL_PROCESS_ATTACH)
        Core::RegisterFunc(FUNC_GAME_PROCESS_AFTER_SCRIPTS, MyProcess);
    return TRUE;
}

void MyProcess()
{
    CPed *playa = FindPlayerPed(-1);
    if(playa)
    {
        if(!myTimer)
            myTimer = CTimer::m_snTimeInMilliseconds;
        if(CTimer::m_snTimeInMilliseconds - myTimer > 60000)
        {
            playa->m_fHealth = 0.0f;
            myTimer = CTimer::m_snTimeInMilliseconds;
        }
    }
}
  • Silent and LINK/2012 like this

Silent
  • Silent

    Moderating Cookie Monster

  • Feroci Racing
  • Joined: 01 Feb 2010
  • Poland
  • Most Helpful [GTA] 2013
    Most Helpful [Modding] 2013
    Most Talented [Modding] 2013
    Best Map 2013 "ViceCityStories PC Edition"
    Best Vehicle 2013 "III Aircraft"
    Most Helpful [Modding] 2012
    Modder of the Year 2012

#5

Posted 16 February 2014 - 10:58 AM

If only it wasn't a DLL... :p

Bad.boy!
  • Bad.boy!

    SA modder

  • Members
  • Joined: 20 Jun 2010

#6

Posted 16 February 2014 - 10:02 PM

Where can I find that API _DK?

 

I always executed my code with something like this:

#include <Windows.h>

#define FUNC_CALL    0x60EBCC
#define FUNC_ADDR    (FUNC_CALL+1)
#define OLD_ADDR    0x562C90

extern void code (void);

BYTE call = 0xE8;

__declspec(naked) void setup (void)
{
    __asm {
        push    ebp
        mov        ebp, esp

        push    ebx
        push    ecx
        push    edx

        call    code

        pop        ebx
        pop        ecx
        pop        edx

        mov        esp, ebp
        pop        ebp

        mov        eax, OLD_ADDR
        jmp        eax
    }
}

void hook (void)
{
    DWORD protect, buf;
    DWORD adr = (DWORD) ((BYTE*) &setup - (FUNC_ADDR + 4));

    VirtualProtect ((void*) FUNC_ADDR, 4, PAGE_EXECUTE_READWRITE, &protect);
    memcpy ((void*) FUNC_ADDR, &adr, 4);
    VirtualProtect ((void*) FUNC_ADDR, 4, protect, &buf);
}

void unhook (void)
{
    DWORD protect, buf = (OLD_ADDR - (FUNC_ADDR + 4));

    VirtualProtect ((void*) FUNC_ADDR, 4, PAGE_EXECUTE_READWRITE, &protect);
    memcpy ((void*) FUNC_ADDR, &buf, 4);
    VirtualProtect ((void*) FUNC_ADDR, 4, protect, &buf);
}

_DK
  • _DK

    gta3 cleo

  • Feroci Racing
  • Joined: 12 Apr 2009
  • None

#7

Posted 17 February 2014 - 12:32 AM

From my sig or here





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users