// anticheat patch
struct patch_set fuckAC =
{
"Anticheat patch", 0, 0,
{
{ 1, (void *)( g_dwSAMP_Addr + 0x61430 ), NULL, (uint8_t *)"\xC3", 0 },
{ 1, (void *)( g_dwSAMP_Addr + 0x5B68B ), NULL, (uint8_t *)"\xEB", 0 },
{ 1, (void *)( g_dwSAMP_Addr + 0x71410 ), NULL, (uint8_t *)"\xEB", 0 }
}
};
patcher_install( &fuckAC );
DWORD ACPatchOffsets[] =
{
0x5B681, 0x219F66
};
DWORD ACPatchOffsets2[] =
{
0x225798
};
static DWORD ACC[2] = { 0, 0 };
DWORD *pACC[] = { &ACC[0], &ACC[2] };
for ( int i = 0; i < _countof( ACPatchOffsets ); i++ )
memcpy_safe( ( void * )( g_dwSAMP_Addr + ACPatchOffsets[i] ), &pACC[0], 4 );
for ( int i = 0; i < _countof( ACPatchOffsets2 ); i++ )
memcpy_safe( (void *)( g_dwSAMP_Addr + ACPatchOffsets2[i] ), &pACC[1], 4 );
The Patches above should do the trick, are you sure that the patches get applied?mrT101 link said:Thanks 0x688!, I have used all of the above patches but my game continues to occasionally freeze when I call functions from samp.dll from my injected dll.
Should doing the above patches stop my game from freezing or do i have to do more than just patch the AC?
What do you mean by "freezing", does the game crash, or your player just cannot move anymore?. have you checked the function that you're calling is it right or wrong? post more details we might be able to help you...mrT101 link said:[member=2]0x688[/member] I use memcmp() after i apply the patches to check if they applied. My debug output shows that all 6 patches get applied when my dll attaches. I also reapply the patch immediately before calling the ShowPlayerDialog() function. My game still freezes occasionally when i call the ShowPlayerDialog function.
void __cdecl showSampDialog (int send, int dialogID, int typedialog, char * caption, char * text, char * button1, char * button2)
{
patchAC(); //Apply the 6 patches as above
uint32_t func = pSAMP + SAMP_DIALOG_SHOW;
uint32_t data = pSAMP + SAMP_DIALOG_INFO_OFFSET;
__asm pushad
__asm mov eax, dword ptr [data]
__asm mov ecx, dword ptr [eax] //mov to offset
__asm push send //0 - No send response, 1 - Send response
__asm push button2
__asm push button1
__asm push text
__asm push caption
__asm push typedialog
__asm push dialogID
__asm call func
__asm popad
return;
}
mrT101 link said:I mean that the game stops working without crashing. Its as if the game is replaced by a screenshot of the game when i call the function. Not just the player freezes, the whole screen does and I don't get the stack/address information like you would in a normal crash. The only way i can find to exit the game after it "freezes" is to sign out of windows account as task manager does come on but alt-tabbing to other windows doesn't work.
I think the function i am using is correct as it works correctly about 70% of the time.
Code:void __cdecl showSampDialog (int send, int dialogID, int typedialog, char * caption, char * text, char * button1, char * button2) { patchAC(); //Apply the 6 patches as above uint32_t func = pSAMP + SAMP_DIALOG_SHOW; uint32_t data = pSAMP + SAMP_DIALOG_INFO_OFFSET; __asm pushad __asm mov eax, dword ptr [data] __asm mov ecx, dword ptr [eax] //mov to offset __asm push send //0 - No send response, 1 - Send response __asm push button2 __asm push button1 __asm push text __asm push caption __asm push typedialog __asm push dialogID __asm call func __asm popad return; }
void showSampDialog (int send, int dialogID, int typedialog, char * caption, char * text, char * button1, char * button2)
{
uint32_t func = pSAMP + SAMP_DIALOG_SHOW;
uint32_t data = pSAMP + SAMP_DIALOG_INFO_OFFSET;
__asm mov eax, dword ptr [data]
__asm mov ecx, dword ptr [eax] //mov to offset
__asm push send //0 - No send response, 1 - Send response
__asm push button2
__asm push button1
__asm push text
__asm push caption
__asm push typedialog
__asm push dialogID
__asm call func
}
It really doesn't matter if you patch the anti cheat or not, because, SAMP is really stupid, i mean just look at how it is easy to bypass that simple air-brake anti-cheat, so this clearly proves that it's not going to go everywhere and intercept calls to samp.dll or somethingmrT101 link said:Thx T3K!, I'll try with the new function and see if i freeze anymore.
I have patchAC() at the start of my first created thread but tried putting it in the showSampDialog function aswell after i kept crashing.
if(GetASyncKeyState ......) { ShowSampDialog() }
std::string List = "12345678";
showSampDialog(0, 0 ,2,"LIST",(char *)List.c_str(),"OK","CLOSE");
Why would you use string in the first place??mrT101 link said:[member=2]0x688[/member]
I'm still trying to fix this bug with my program. Do you think it could be because I am typecasting a std::string to a (char *)?
my code is similar to:
Code:std::string List = "12345678"; showSampDialog(0, 0 ,2,"LIST",(char *)List.c_str(),"OK","CLOSE");
char * List = "123456789";
showSampDialog(0, 0 ,2,"LIST",List,"OK","CLOSE");
T3K link said:Why would you use string in the first place??
and it is a really horrible thing to do lol that's not how you convert a const char* to char*
just:
Code:char * List = "123456789"; showSampDialog(0, 0 ,2,"LIST",List,"OK","CLOSE");
mrT101 link said:could that possibly be the cause of my random samp freezes, possibly due to memory corruption / leak?
The reason I'm using string is because I am creating a new string on runtime that contains the player's name and other dynamic variables and a std::string allows me to use append() etc..
I'm then showing the string in the dialog and since the dialog function requires "char * text" i was typecasting my std::string to a char
void showSampDialog (int send, int dialogID, int typedialog, char * caption, const char * text, char * button1, char * button2)
{
uint32_t func = pSAMP + SAMP_DIALOG_SHOW;
uint32_t data = pSAMP + SAMP_DIALOG_INFO_OFFSET;
__asm mov eax, dword ptr [data]
__asm mov ecx, dword ptr [eax] //mov to offset
__asm push send //0 - No send response, 1 - Send response
__asm push button2
__asm push button1
__asm push text
__asm push caption
__asm push typedialog
__asm push dialogID
__asm call func
}
///
std::string List = "12345678";
showSampDialog(0, 0 ,2,"LIST",List.c_str(),"OK","CLOSE");