Czy wiesz, że... rejestracja trwa tylko 20 sekund?
Strona główna forum Szukaj Rejestracja
Witaj, nieznajomy!
Poprzedni 1 Następny
Postów: 24 Dołączył: 2013-04-03
#
Witam!!!
Jak w temacie wie ktoś jaka jest składnia plików asi w c++.
Albo jakiś kod źrudłowy C++ do popbrania np. cleo.cpp czy coś w tym rodzaju.
Jak by ktoś pytał, to w pisaniu w c i c++ mam 2 letnie doświadczenie.
Najlepiej do gta sa.
Postów: 878 Dołączył: 2009-01-20
#
Pytasz o GTA SA, a założyłeś temat w dziale GTA VC...

Pluginy ASI to zwykłe biblioteki *.dll wczytujące się razem z GTA. W samą grę możesz ingerować przez adresy pamięci.

Adresy pamięci w GTA SA.

___________________
Administrator
Postów: 24 Dołączył: 2013-04-03
#
Wie ktoś gdzie morzna pobrać jakiś przykładowy plik.cpp( np. cleo.cpp )
Postów: 24 Dołączył: 2013-04-03
#
Napisałem prosty asi ale gdy go odpalam to gra się wyłącza i wyświetla się raport o błędzie

Kod:
#include <windows.h>

#define KEY_JEDEN 0x31

DWORD WINAPI Start(LPVOID);

typedef void( *fun_type_00 )(BYTE);

extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD Reason, LPVOID Reserved)
{
    switch (Reason)
    {
        case DLL_PROCESS_ATTACH:
         CreateThread(NULL, NULL, &Start, NULL, NULL, NULL);
            break;
            
        case DLL_PROCESS_DETACH:
            break;
    }
    return TRUE;
}

DWORD WINAPI Start(LPVOID)
{
fun_type_00 snieg =( fun_type_00 )0x969138;

while(true)
{
if(GetAsyncKeyState(KEY_JEDEN))
{
snieg(1);
}
Sleep(300);
}

return 0;
}
Postów: 37 Dołączył: 2012-12-25
#
a co chcesz wykonać w gta?? Też jestem zainteresowany tym tematem, ale nie wiem jak nadpisywać adresy pamięci. Natomiast wiem że .asi dają ogromne możliwości. Mam taki kod, może Ci się do czegoś przyda, aczkolwiek nie jest to mój kod

/////////////////////////////////////////////////////////////////////
//
// A better exception handler for GTA3 and GTA:Vice City
// By kyeman (and eAi) 9/13/2004.
//
// compile as .dll in msvc++6.0 and rename as .asi
// place in vc root
//
// 9/15/2004: (eAi) Added loads of features, mainly the new scm
// view that allows you to see a trace of the last scm
// functions called. Also now outputs to a file (in your
// game folder in a sub folder called "Crash Logs".
// Rewritten lots of things to work better with the new
// scm view. EFLAGS is now shown as binary.
// 9/14/2004: (eAi) Added GTA3 1.0 and 1.1 support. Changed some small
// things, such as the byte value for vc 1.0. Also added floats
// to output message, and "bad version" error message.
// Fixed: Double EDX output (meaning EFlags was lost)
// 9/14/2004: (me) Added 1.1 support, register display and scm thread.
//
/////////////////////////////////////////////////////////////////////

#include "resource.h"
#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <direct.h>
#include "exceptions.h"

/////////////////////////////////////////////////////////////////////
// Using many globals to avoid stack alteration in naked hooks.

HANDLE hInstance =0;

// Addresses (defaulted to Vice 1.0)
DWORD opcodeint_hook_storage = 0x44FC3C;
DWORD opcodeint_proc_hook = 0x44FC1B;
DWORD opcodeint_ret_addr = 0x44FC21;

DWORD get_params_hook_storage = 0x44FD69;
DWORD get_params_ret_addr = 0x451017;
DWORD get_params_proc_hook = 0x451010;

DWORD exceptbox_hook_storage = 0x44FC6A;
DWORD exceptbox_proc_hook = 0x677E72;
DWORD exceptbox_ret_addr = 0x677EA9;

DWORD scm_parameters = 0x7D7438;
DWORD scm_script_base = 0x821280;

PDWORD pdwScmParams = (PDWORD)0x7D7438;

PGAME_SCRIPT_THREAD pLastScriptThread;
PCONTEXT pContextRecord;

DWORD dwSavedESP = 0;
DWORD dwSavedEBP = 0;
WORD _last_opcode = 0;
CHAR _opcode_info_string[BIG_STR_BUFFER];
DWORD _opcode_params = 0;

SCRIPT_LOG dwScriptLog[SCRIPT_LOG_SIZE] = { '' };
DWORD dwScriptLogPosition = 0;

BOOL boolIsVice = FALSE;
OPCODE_DEF odLoadedOpcodes[1500] = { '' };

/////////////////////////////////////////////////////////////////////

BOOL CALLBACK GuiDlgProcMain( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
DWORD i = 0;
CHAR sOpcodeInformation[255] = { '' };
CHAR _error_string[BIG_STR_BUFFER] = { '' };
CHAR _error_string_scm[HUGE_STR_BUFFER] = { '' };
CHAR sCurrentWorkingDirectory[255] = { '' };
CHAR sErrorLogPath[255] = { '' };
CHAR sOutputToFile[HUGE_STR_BUFFER] = { '' };
CHAR sBinaryOutput[31] = { '' };
CHAR game_version_string[25] = { '' };
CHAR dialog_caption[50] = { '' };

HFONT hFont = 0;
HMENU hSystemMenu = 0;
DWORD dwMenuItemCount = 0;
MENUITEMINFO miiNewMenu = { '' };

BYTE bNewValue = 1;

time_t tm;
struct tm *ltime;

FILE * fDebugLog;

switch( uMsg )
{
case WM_MOUSEMOVE:
ShowCursor(1);
break;
case WM_COMMAND:
switch( LOWORD(wParam) )
{
case IDC_OK_BUTTON:
EndDialog( hDlg, TRUE );
ExitProcess(0);
break;
case IDC_OK_DEBUG:
EndDialog( hDlg, TRUE );
break;
}
break;

case WM_SYSCOMMAND:
if(wParam == 1)
{
MessageBox(hDlg,"GTA Exception Handlern--------------------nCreated by Kyeman & eAinnFor more information see www.gtaforums.com","About",64);
return TRUE;
}
return FALSE;
break;
case WM_INITDIALOG:

OutputDebugString("-----------------------------------------------------------------------------");

GetOpcodeName(_last_opcode, sOpcodeInformation);

// cat address and SCM info.
sprintf(_error_string,"Exception at address:t0x%08XrnLast SCM executed:t%04X %srnIn thread:tt%srnrn",
pContextRecord->Eip,_last_opcode,sOpcodeInformation,pLastScriptThread->strName);

// cat register info
sprintf(_error_string+strlen(_error_string),
"Registers -----------------------------------------------------------------------------rn"
"EAX: 0x%08XtEBX: 0x%08XtECX: 0x%08XtEDX: 0x%08Xrn"
"ESI: 0x%08XtEDI: 0x%08XtEBP: 0x%08XtESP: 0x%08Xrn"
"EFLAGS: %srn",
pContextRecord->Eax,
pContextRecord->Ebx,
pContextRecord->Ecx,
pContextRecord->Edx,
pContextRecord->Esi,
pContextRecord->Edi,
pContextRecord->Ebp,
pContextRecord->Esp,
itoa(pContextRecord->EFlags, sBinaryOutput, 2)
);

SetDlgItemText(hDlg,IDC_ERROR_AREA, _error_string);

OutputDebugString(_error_string);
OutputDebugString("-----------------------------------------------------------------------------");

for(i = dwScriptLogPosition; i >= 1; i--)
{
if(dwScriptLog[i].dwScriptIP != 0)
{
OutputOpcodeFromSIP(&dwScriptLog[i], sOpcodeInformation);
sprintf(_error_string_scm+strlen(_error_string_scm),
"%srn", sOpcodeInformation);
}
}

for(i = SCRIPT_LOG_SIZE; i > dwScriptLogPosition; i--)
{
if(dwScriptLog[i].dwScriptIP != 0)
{
OutputOpcodeFromSIP(&dwScriptLog[i], sOpcodeInformation);
sprintf(_error_string_scm+strlen(_error_string_scm),
"%srn", sOpcodeInformation);
}
}

hFont = CreateFont(9, 0, 0, 0 ,0, FALSE, FALSE, 0, 0, 0, 0, 0, 0, "FixedSys");

SendMessage(GetDlgItem(hDlg,IDC_ERROR_AREA2),WM_SETFONT, (WPARAM)hFont, TRUE);

SetDlgItemText(hDlg,IDC_ERROR_AREA2, _error_string_scm);

// play a beep so that the user knows the error has happened
MessageBeep(MB_ICONASTERISK);

// now hide the window
if(boolIsVice == TRUE)
ShowWindow(FindWindow(NULL,"GTA: Vice City"), SW_MINIMIZE);
else
ShowWindow(FindWindow(NULL,"GTA3"), SW_MINIMIZE);

OutputDebugString(_error_string_scm);
OutputDebugString("-----------------------------------------------------------------------------");

// write it to a file
getcwd(sCurrentWorkingDirectory,255);
sprintf(sCurrentWorkingDirectory, "%s\%s", sCurrentWorkingDirectory, "Crash Logs");

if(chdir(sCurrentWorkingDirectory))
{
mkdir(sCurrentWorkingDirectory);
chdir(sCurrentWorkingDirectory);
}

time( &tm );

ltime = localtime( &tm );
ltime->tm_mon++;
ltime->tm_year += 1900;

memset(sOpcodeInformation, 0, strlen(sOpcodeInformation));
GetOpcodeName(_last_opcode, sOpcodeInformation);

sprintf(sErrorLogPath,"%s\log_%s_%02i_%02i_%04i-%02i_%02i_%02i.log",sCurrentWorkingDirectory, sOpcodeInformation, ltime->tm_mday, ltime->tm_mon, ltime->tm_year, ltime->tm_hour, ltime->tm_min, ltime->tm_sec);
fDebugLog = fopen(sErrorLogPath,"w");

switch(DetermineGTAVersion())
{
case VICE_10: strcpy(game_version_string,"Vice City 1.0"); break;
case VICE_11: strcpy(game_version_string,"Vice City 1.1"); break;
case GTA3_10: strcpy(game_version_string,"Grand Theft Auto 3 1.0"); break;
case GTA3_11: strcpy(game_version_string,"Grand Theft Auto 3 1.1"); break;
}

sprintf(dialog_caption, "GTA Exception Handler - %s", game_version_string);
SetWindowText(hDlg,dialog_caption);

sprintf(sOutputToFile, "%srn###################################################################################rnScm Output follows, top line was last line executed before the unhandled exception.rn###################################################################################rnrn%srnrn%s", _error_string, _error_string_scm, game_version_string);

if(fDebugLog)
{
fwrite(sOutputToFile,1,strlen(sOutputToFile),fDebugLog);
fclose(fDebugLog);
}
// add our About menu
hSystemMenu = GetSystemMenu(hDlg,FALSE);
dwMenuItemCount = GetMenuItemCount(hSystemMenu);
miiNewMenu.cbSize = sizeof(MENUITEMINFO);
miiNewMenu.fMask = MIIM_ID | MIIM_TYPE;
miiNewMenu.fType = MFT_SEPARATOR;
miiNewMenu.wID = 0;
InsertMenuItem(hSystemMenu,dwMenuItemCount,1, &miiNewMenu);

miiNewMenu.fState = MFS_ENABLED;
miiNewMenu.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
miiNewMenu.fType = MFT_STRING;
miiNewMenu.wID = 1;
miiNewMenu.dwTypeData = "&About";
miiNewMenu.cch = strlen("&About");

InsertMenuItem(hSystemMenu,dwMenuItemCount + 1,1, &miiNewMenu);

break;
case WM_CLOSE:
case WM_DESTROY:
EndDialog( hDlg, TRUE );
break;
}

return FALSE;
}

/////////////////////////////////////////////////////////////////////

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if(DLL_PROCESS_ATTACH==fdwReason)
{
hInstance = hinstDLL;
switch(DetermineGTAVersion())
{
case VICE_10:
boolIsVice = TRUE; // used for a hook
InstallOpcodeInterpreterHook();
InstallExceptionBoxHook();

break;
case VICE_11:
boolIsVice = TRUE; // used for a hook
exceptbox_proc_hook = 0x677EC2;
exceptbox_ret_addr = 0x677EF9;
pdwScmParams = (PDWORD)0x7D7440;

InstallOpcodeInterpreterHook();
InstallExceptionBoxHook();

break;
case GTA3_10:
opcodeint_proc_hook = 0x43953B;
opcodeint_hook_storage = 0x43955C;
opcodeint_ret_addr = 0x439541;

exceptbox_proc_hook = 0x5D8DF2;
exceptbox_ret_addr = 0x5D8E29;
exceptbox_hook_storage = 0x4395BA;

scm_parameters = 0x6ED460;
scm_script_base = 0x74B248;

pdwScmParams = (PDWORD)0x6ED460;

InstallOpcodeInterpreterHookGta3();
InstallExceptionBoxHookGta3();

break;
case GTA3_11:
opcodeint_proc_hook = 0x43953B;
opcodeint_hook_storage = 0x43955C;
opcodeint_ret_addr = 0x439541;

exceptbox_proc_hook = 0x5D90B2;
exceptbox_ret_addr = 0x05D90E9;
exceptbox_hook_storage = 0x4395BA;

scm_parameters = 0x6ED460;
scm_script_base = 0x74B248;

pdwScmParams = (PDWORD)0x6ED460;

InstallOpcodeInterpreterHookGta3();
InstallExceptionBoxHookGta3();

break;
case UNKNOWN_VERSION:
MessageBox(0,"Unknown GTA version, exception handler not installed", "Error", 0);
return FALSE;
break;
}

LoadOpcodes();
}

return TRUE;
}

/////////////////////////////////////////////////////////////////////
// From Spooky's code on gtaforums

int DetermineGTAVersion()
{
BYTE* VerCheck = (BYTE*)0x608578; // Byte at 0x608578 = 0x81 in VC 1.1, 0x5D in VC 1.0, 0x38 GTA3 1.1, 0x57 GTA3 1.0

switch (*VerCheck)
{
case 0x81: return VICE_11;
case 0x5D: return VICE_10; // I've changed this to 0x5D as thats what I see it as - was 0x5B (eAi)
case 0x38: return GTA3_11;
case 0x57: return GTA3_10;
}

return UNKNOWN_VERSION;
}

/////////////////////////////////////////////////////////////////////

VOID LoadOpcodes()
{
PCHAR equ_pos;
PCHAR comma_pos;

INT equ_array_pos=0;
CHAR opcode_string[10];
CHAR split_string[LITTLE_STR_BUFFER];
CHAR scm_name_string[LITTLE_STR_BUFFER];

UINT test_opcode=0;
UINT num_params;
UINT x=0;

FILE * fileScmIni;

CHAR line_buffer[BIG_STR_BUFFER];

float fScmParam = 0.0f;

if(DetermineGTAVersion() == VICE_11 || DetermineGTAVersion() == VICE_10)
{
fileScmIni = fopen("scm_vice.ini","r");
if(!fileScmIni)
{
MessageBox(0,"The required file 'scm_vice.ini' could not be found.","Error - File not found",0);
ExitProcess(0);
return;
}
}
else
{
fileScmIni = fopen("scm_gta3.ini","r");
if(!fileScmIni)
{
MessageBox(0,"The required file 'scm_gta3.ini' could not be found.","Error - File not found",0);
ExitProcess(0);
return;
}
}

while(!feof(fileScmIni))
{
fgets(line_buffer,LITTLE_STR_BUFFER,fileScmIni);
line_buffer[strlen(line_buffer)-1] = '';

if(NULL!=(equ_pos=strchr(line_buffer,'=')))
{

equ_array_pos = equ_pos - line_buffer;
memcpy(opcode_string, line_buffer, equ_array_pos);
opcode_string[equ_array_pos]='';

test_opcode = (UINT)strtoul(opcode_string,NULL,16);


strncpy(split_string,equ_pos+1,LITTLE_STR_BUFFER);

comma_pos=strchr(split_string,',');
if(!comma_pos) return;

*comma_pos = '';
strcpy(scm_name_string,comma_pos+1);

strcpy(odLoadedOpcodes[test_opcode].bName, scm_name_string);

num_params = atoi(split_string);

odLoadedOpcodes[test_opcode].dwParameterCount = num_params;
}
}
fclose(fileScmIni);
}

/////////////////////////////////////////////////////////////////////

BOOL GetOpcodeName(WORD dwOpcode, PCHAR ret_buffer)
{
if(strlen(odLoadedOpcodes[dwOpcode].bName))
{
strcpy(ret_buffer,odLoadedOpcodes[dwOpcode].bName);
return TRUE;
}
else
{
sprintf(ret_buffer,"unknown_%X", dwOpcode);
return FALSE;
}
}

/////////////////////////////////////////////////////////////////////

VOID OutputOpcodeFromSIP(PSCRIPT_LOG pScripLog, PCHAR ret_buffer)
{
// we minus two as this is the parameter pointer,
// not the opcode pointer (params are two bytes
// after the opcode start)
DWORD dwOpcodeOrigin = scm_script_base + pScripLog->dwScriptIP - 2;
WORD wOpcode = *(PWORD)dwOpcodeOrigin;
char wszOpcodeName[255] = { '' };
char wszOpcodeParams[255] = { '' };
char wszPadding[50] = { '' };
DWORD dwPaddingSize = 0;

GetOpcodeName(wOpcode,wszOpcodeName);
GetOpcodeParameters(pScripLog, odLoadedOpcodes[wOpcode].dwParameterCount, wszOpcodeParams);

dwPaddingSize = 30 - strlen(wszOpcodeName);
if(dwPaddingSize)
memset(wszPadding,32,dwPaddingSize);

if(!strcmp(wszOpcodeName,"jump") || !strcmp(wszOpcodeName,"jt") || !strcmp(wszOpcodeName,"jf") || !strcmp(wszOpcodeName,"gosub"))
sprintf(ret_buffer, "%s %s @%s", wszOpcodeName, wszPadding, wszOpcodeParams);
else
sprintf(ret_buffer, "%s %s %s", wszOpcodeName, wszPadding, wszOpcodeParams);
}

/////////////////////////////////////////////////////////////////////

VOID GetOpcodeParameters(PSCRIPT_LOG pScripLog, DWORD dwParamCount, PCHAR ret_buffer)
{
DWORD dwSIP = pScripLog->dwScriptIP;
BYTE bCurrentParameter = 0;
BYTE bParameterDataType = 0;
DWORD bCurrentParameterType = 0;
DWORD dwParameterAddress = dwSIP + scm_script_base;
DWORD dwVariableID = 0;

DWORD perm1,perm2;

VirtualProtect((LPVOID)dwParameterAddress,1000,PAGE_EXECUTE_READWRITE,&perm1);

while(bCurrentParameter < dwParamCount)
{
bCurrentParameter++;
bCurrentParameterType = *(BYTE *)dwParameterAddress;
dwParameterAddress += 1;
switch(bCurrentParameterType)
{
case DATA_TYPE_DWORD:

sprintf(ret_buffer+strlen(ret_buffer),"%d", *(DWORD *)dwParameterAddress);
dwParameterAddress += 4;
break;

case DATA_TYPE_VARIABLE:

/* HERE BE A PROBLEM
dwVariableID = (*(WORD *)dwParameterAddress - 12); // we ignore the first 12 bytes (if you set $var000c to 23, the script storage start + 0x18 = 23 (bit))
sprintf(ret_buffer+strlen(ret_buffer),"$var%04x = %d", dwVariableID, pScripLog->dwGlobalVariables[dwVariableID / sizeof(DWORD)]);
*/

sprintf(ret_buffer+strlen(ret_buffer),"$var%04X", *(WORD *)dwParameterAddress);
dwParameterAddress += 2;
break;

case DATA_TYPE_WORD:

sprintf(ret_buffer+strlen(ret_buffer),"%d", *(WORD *)dwParameterAddress);
dwParameterAddress += 2;
break;

case DATA_TYPE_BYTE:

sprintf(ret_buffer+strlen(ret_buffer),"%d", *(BYTE *)dwParameterAddress);
dwParameterAddress += 1;
break;

case DATA_TYPE_WORD_2:
sprintf(ret_buffer+strlen(ret_buffer),"%d", *(WORD *)dwParameterAddress);
dwParameterAddress += 2;
break;

case DATA_TYPE_FLOAT:
if(boolIsVice)
{
sprintf(ret_buffer+strlen(ret_buffer),"%.4f", *(float *)dwParameterAddress);
dwParameterAddress += 4;
}
else
{
sprintf(ret_buffer+strlen(ret_buffer),"%.4f", ((float)(*(short *)dwParameterAddress) / 16));
dwParameterAddress += 2;
}

break;

default:

dwParameterAddress -= 1; // strings start at the first byte
sprintf(ret_buffer+strlen(ret_buffer),""%s"", (CHAR *)dwParameterAddress);
dwParameterAddress += strlen((CHAR *)dwParameterAddress);
break;

}
sprintf(ret_buffer+strlen(ret_buffer),", ");
}

if(strlen(ret_buffer))
memset(ret_buffer+strlen(ret_buffer)-2,0,2);

dwParameterAddress = dwSIP + scm_script_base;

VirtualProtect((LPVOID)dwParameterAddress,1000,perm1,&perm2);

}

/////////////////////////////////////////////////////////////////////

void _declspec(naked) OpcodeInterpreterHook()
{
_asm mov pLastScriptThread, ecx
_asm and edx, 7FFFh
_asm mov _last_opcode, dx
_asm mov dwSavedESP, esp
_asm mov dwSavedEBP, ebp

_asm pushad

// save the last lot of scm parameters
memcpy(dwScriptLog[dwScriptLogPosition].dwParameters, &scm_parameters, sizeof(DWORD)*SCM_PARAM_COUNT);
memcpy(dwScriptLog[dwScriptLogPosition].dwGlobalVariables, &scm_script_base + 12, sizeof(DWORD)*SCM_GLOBALS_COUNT);

dwScriptLogPosition++;
dwScriptLog[dwScriptLogPosition].dwScriptIP = pLastScriptThread->dwScriptIP;
if(dwScriptLogPosition > SCRIPT_LOG_SIZE)
dwScriptLogPosition = 0;

_asm popad
_asm jmp opcodeint_ret_addr
}

/////////////////////////////////////////////////////////////////////

void _declspec(naked) ExceptionBoxHook()
{
_asm mov pContextRecord, esi
_asm pushad

DialogBox( hInstance, MAKEINTRESOURCE(IDD_EXCEPTION_DIALOG), NULL, (DLGPROC)GuiDlgProcMain );

_asm popad
_asm jmp exceptbox_ret_addr
}

/////////////////////////////////////////////////////////////////////

void InstallOpcodeInterpreterHook()
{
BYTE instructions[] = {OPCODEINT_HOOK_INSTRUCTIONCODE};

DWORD perm1,perm2;

VirtualProtect((LPVOID)opcodeint_hook_storage,sizeof(DWORD),PAGE_EXECUTE_READWRITE,&perm1);
*(PDWORD)opcodeint_hook_storage = (DWORD)OpcodeInterpreterHook;
VirtualProtect((LPVOID)opcodeint_hook_storage,sizeof(DWORD),perm1,&perm2);

VirtualProtect((LPVOID)opcodeint_proc_hook,sizeof(instructions),PAGE_EXECUTE_READWRITE,&perm1);
memcpy((PVOID)opcodeint_proc_hook,instructions,sizeof(instructions));
VirtualProtect((LPVOID)opcodeint_proc_hook,sizeof(instructions),perm1,&perm2);
}

/////////////////////////////////////////////////////////////////////

void InstallOpcodeInterpreterHookGta3()
{
BYTE instructions[] = {GTA3_OPCODEINT_HOOK_INSTRUCTIONCODE};

DWORD perm1,perm2;

VirtualProtect((LPVOID)opcodeint_hook_storage,sizeof(DWORD),PAGE_EXECUTE_READWRITE,&perm1);
*(PDWORD)opcodeint_hook_storage = (DWORD)OpcodeInterpreterHook;
VirtualProtect((LPVOID)opcodeint_hook_storage,sizeof(DWORD),perm1,&perm2);

VirtualProtect((LPVOID)opcodeint_proc_hook,sizeof(instructions),PAGE_EXECUTE_READWRITE,&perm1);
memcpy((PVOID)opcodeint_proc_hook,instructions,sizeof(instructions));
VirtualProtect((LPVOID)opcodeint_proc_hook,sizeof(instructions),perm1,&perm2);
}

/////////////////////////////////////////////////////////////////////

void InstallExceptionBoxHook()
{
BYTE instructions[] = {EXCEPTBOX_HOOK_INSTRUCTIONCODE};

DWORD perm1,perm2;

VirtualProtect((LPVOID)exceptbox_hook_storage,sizeof(DWORD),PAGE_EXECUTE_READWRITE,&perm1);
*(PDWORD)exceptbox_hook_storage = (DWORD)ExceptionBoxHook;
VirtualProtect((LPVOID)exceptbox_hook_storage,sizeof(DWORD),perm1,&perm2);

VirtualProtect((LPVOID)exceptbox_proc_hook,sizeof(instructions),PAGE_EXECUTE_READWRITE,&perm1);
memcpy((PVOID)exceptbox_proc_hook,instructions,sizeof(instructions));
VirtualProtect((LPVOID)exceptbox_proc_hook,sizeof(instructions),perm1,&perm2);
}

/////////////////////////////////////////////////////////////////////

void InstallExceptionBoxHookGta3()
{
BYTE instructions[] = {GTA3_EXCEPTBOX_HOOK_INSTRUCTIONCODE};

DWORD perm1,perm2;

VirtualProtect((LPVOID)exceptbox_hook_storage,sizeof(DWORD),PAGE_EXECUTE_READWRITE,&perm1);
*(PDWORD)exceptbox_hook_storage = (DWORD)ExceptionBoxHook;
VirtualProtect((LPVOID)exceptbox_hook_storage,sizeof(DWORD),perm1,&perm2);

VirtualProtect((LPVOID)exceptbox_proc_hook,sizeof(instructions),PAGE_EXECUTE_READWRITE,&perm1);
memcpy((PVOID)exceptbox_proc_hook,instructions,sizeof(instructions));
VirtualProtect((LPVOID)exceptbox_proc_hook,sizeof(instructions),perm1,&perm2);
}

/////////////////////////////////////////////////////////////////////

___________________
GTA Big Day - największy polski mod do Vice City
Postów: 24 Dołączył: 2013-04-03
#
Dzięki przeanalizuje kod, jak coś znajde to dam znać.

Jakiego IDE używasz ja Dev C++, Virsual C++, Code::Block.
Najlepiek ktureś z tych

Jak by ktoś miał jakieś kody jeszce to piszcie morze być w asmie, java i inne.

Ps. #include "resource.h" #include "exceptions.h" masz mrze te pliki.
Postów: 37 Dołączył: 2012-12-25
#
z tego co pamiętam obiłem się o te aplikacje, ale były to początki, interesowało mnie też Delphi
Na stronie Moomappera - dawnego programiku do tworzenia map jest kod źródłowy tego programu, obecne już odbiegają od tej wersji. Ja tam sobie przetłumaczyłem program, lekko modyfikowałem :p
moomapper

/////////////////////////////////////////////////////////////////////
//
// exceptions.h
//
// A better exception handler for GTA:3 and GTA:VC
// By kyeman and eAi (2004)
//
/////////////////////////////////////////////////////////////////////

// Instruction overwrites.
#define GTA3_OPCODEINT_HOOK_INSTRUCTIONCODE 0xFF,0x25,0x5C,0x95,0x43,0x00
#define GTA3_EXCEPTBOX_HOOK_INSTRUCTIONCODE 0xFF,0x25,0xBA,0x95,0x43,0x00
#define GTA3_GETPARAMETERS_HOOK_INSTRUCTIONCODE 0xFF,0x25,0x43,0x96,0x43,0x00 // 0x439643

#define OPCODEINT_HOOK_INSTRUCTIONCODE 0xFF,0x25,0x3C,0xFC,0x44,0x00
#define EXCEPTBOX_HOOK_INSTRUCTIONCODE 0xFF,0x25,0x6A,0xFC,0x44,0x00
#define GETPARAMETERS_HOOK_INSTRUCTIONCODE 0xFF,0x25,0x69,0xFD,0x44,0x00 // 0x44FD69

#define HUGE_STR_BUFFER 8192
#define BIG_STR_BUFFER 1024
#define LITTLE_STR_BUFFER 256

#define SCRIPT_LOG_SIZE 256 // number of scm instructions saved
#define SCM_PARAM_COUNT 15
#define SCM_GLOBALS_COUNT 50

#define UNKNOWN_VERSION 0
#define VICE_10 1
#define VICE_11 2
#define GTA3_10 3
#define GTA3_11 4

enum _DATATYPES {
DATA_TYPE_DWORD = 1,
DATA_TYPE_VARIABLE = 2,
DATA_TYPE_WORD = 3,
DATA_TYPE_BYTE = 4,
DATA_TYPE_WORD_2 = 5,
DATA_TYPE_FLOAT = 6
};

/////////////////////////////////////////////////////////////////////
// struct defs

// found @ gtaforums.com
typedef struct _GAME_SCRIPT_THREAD // 0x88 bytes total.
{
void *pNext; // 0x00
void *pPrev; // 0x04
char strName[8]; // 0x08
DWORD dwScriptIP; // 0x10
BYTE xUnknown14[101]; // 0x14 (0x65 bytes unknown)
BYTE nJumpFlag; // 0x79
BYTE xUnknown7A[2]; // 0x7a (0x2 bytes unknown)
DWORD dwWaitUntil; // 0x7C
BYTE xUnknown7D[8]; // 0x80 (0x0A bytes unknown)

} *PGAME_SCRIPT_THREAD,GAME_SCRIPT_THREAD;

typedef struct _SCRIPT_LOG
{
DWORD dwScriptIP;
DWORD dwParameterCount;
DWORD dwParameters[SCM_PARAM_COUNT];
DWORD dwGlobalVariables[SCM_GLOBALS_COUNT];
} *PSCRIPT_LOG,SCRIPT_LOG;

typedef struct _OPCODE_DEF
{
DWORD dwParameterCount;
CHAR bName[50];
} *POPCODE_DEF,OPCODE_DEF;

///////////////////////////////////////////////////////////////////////
// forwards

BOOL CALLBACK GuiDlgProcMain( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
VOID InstallOpcodeInterpreterHook();
VOID InstallExceptionBoxHook();
VOID InstallOpcodeInterpreterHookGta3();
VOID InstallExceptionBoxHookGta3();

BOOL DoesOpcodeMatchIniOpcode(PCHAR scm_ini_line, WORD opcode);
int DetermineGTAVersion();
VOID GetOpcodeInfo(PCHAR ret_buffer);
VOID GetOpcodeParameters(PSCRIPT_LOG pScripLog, DWORD dwParamCount, PCHAR ret_buffer);
VOID OutputOpcodeFromSIP(PSCRIPT_LOG pScripLog, PCHAR ret_buffer);
BOOL GetOpcodeName(WORD dwOpcode, PCHAR ret_buffer);
VOID LoadOpcodes();

///////////////////////////////////////////////////////////////////////


resource.h też jednak mam:

//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
#define IDI_ICON1 102
#define IDD_EXCEPTION_DIALOG 103
#define IDC_OK_BUTTON 1007
#define IDC_ERROR_AREA 1008
#define IDC_OK_DEBUG 1009
#define IDC_ERROR_AREA2 1010

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

___________________
GTA Big Day - największy polski mod do Vice City
Postów: 24 Dołączył: 2013-04-03
#
Wielkie dzięki jak tylko coś znajdę to dam znać.
Sprubuje też napisać coś w rodzaju szablonu, jak skończe to dam na forum.
Postów: 24 Dołączył: 2013-04-03
#
Zna ktoś adresów tych zmiennych do san andreas

Kod:
opcodeint_proc_hook
opcodeint_hook_storage
opcodeint_ret_addr

exceptbox_proc_hook
exceptbox_ret_addr
exceptbox_hook_storage

scm_parameters
scm_script_base


te zmienne są kluczowe dla plików asi wynika to z kodu od diwona tylko ten kod jest do vice city i gta III ale główna składnia jest taka sama tylko inne adresy.
Informacje którę zgromadzę opublikuje jako oficjalny tutorial.
Postów: 24 Dołączył: 2013-04-03
#
Potrzebuje w tym pomocy kogoś kto taki plugin kiedyś napisał, dresy pamięci których szukam niema na liście od MakG.
Poprzedni 1 Następny
Zaloguj się lub zarejestruj się, żeby pisać na forum.
Created & Powered by MakG