-raymond-
Известный
- 110
- 9
поподробнее можн?Регай колбек и там меняй парметр листбокса
поподробнее можн?Регай колбек и там меняй парметр листбокса
если по адресу функции, которую хукаешь, уже записан jmp (e9, addr)- то выполнить его после отработки твоеего хука
Забей хуй Ты все равно не поймёшьУже какой день пытаюсь это сделать,нечего не выходит,то крашит,то игра намертво виснет,уже хз что делать
Функция keybd_event(http://www.vsokovikov.narod.ru/New_MSDN_API/Keyb_input/fn_keybd_event.htm)как сымитировать нажатие клавишы на клавиатуре?
std::string businnes_name[45][] =
{
"Alhambra",
"PigPen",
"Misty Club",
"Casino Bellagio",
"Grove Street Bar",
"Sobrino de Botin",
"Vinewood Burger",
"Marina Burger",
"Idlewood Pizza",
"Downtown Cluc",
"Marina Cluc",
"Idelwood 24/7",
"Flint 24/7",
"Easter 24/7",
"Mullholand 24/7",
"Jizzy",
"Redsands West 24/7",
"Julius 24/7",
"Lil\"Probe\"inn",
"Idelwood Gas",
"Mullholang Gas",
"Whetstone 24/7",
"East Cluc",
"WillowField Cluc",
"Flats Cluc",
"Financial Pizza",
"Come-A-Lot Gas",
"FortCarson Gas",
"BoneCountry Gas",
"Julius Gas",
"PricklePine Gas",
"Flint Gas",
"Easter Gas",
"Doherty Gas",
"Juniper 24/7",
"Juniper Gas",
"Emerald Isle 24/7",
"Emerald Isle Gas",
"Redsands-West Gas",
"ElGuebrabos Gas",
"TierraRobada Gas",
"AngelPine Gas",
"WhetStone Gas",
"Dilimore Gas",
"Montgomery Gas",
};
void CALLBACK biz_check(std::string param)
{
for (int i = 0; i <= 45; i++)
{
SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "%s", businnes_name[i]);
}
}
void CALLBACK biz_check(std::string param)
{
char str[45][30] =
{
"Alhambra",
"PigPen",
"Misty Club",
"Casino Bellagio",
"Grove Street Bar",
"Sobrino de Botin",
"Vinewood Burger",
"Marina Burger",
"Idlewood Pizza",
"Downtown Cluc",
"Marina Cluc",
"Idelwood 24/7",
"Flint 24/7",
"Easter 24/7",
"Mullholand 24/7",
"Jizzy",
"Redsands West 24/7",
"Julius 24/7",
"Lil\"Probe\"inn",
"Idelwood Gas",
"Mullholang Gas",
"Whetstone 24/7",
"East Cluc",
"WillowField Cluc",
"Flats Cluc",
"Financial Pizza",
"Come-A-Lot Gas",
"FortCarson Gas",
"BoneCountry Gas",
"Julius Gas",
"PricklePine Gas",
"Flint Gas",
"Easter Gas",
"Doherty Gas",
"Juniper 24/7",
"Juniper Gas",
"Emerald Isle 24/7",
"Emerald Isle Gas",
"Redsands-West Gas",
"ElGuebrabos Gas",
"TierraRobada Gas",
"AngelPine Gas",
"WhetStone Gas",
"Dilimore Gas",
"Montgomery Gas"
};
for (int i = 0; i <= 45; i++)
{
SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "%s", str[i]);
}
}
vector<string> Strings =
{
"Alhambra",
"PigPen",
"Misty Club",
"Casino Bellagio",
"Grove Street Bar",
"Sobrino de Botin",
"Vinewood Burger",
"Marina Burger",
"Idlewood Pizza",
"Downtown Cluc",
"Marina Cluc",
"Idelwood 24/7",
"Flint 24/7",
"Easter 24/7",
"Mullholand 24/7",
"Jizzy",
"Redsands West 24/7",
"Julius 24/7",
"Lil\"Probe\"inn",
"Idelwood Gas",
"Mullholang Gas",
"Whetstone 24/7",
"East Cluc",
"WillowField Cluc",
"Flats Cluc",
"Financial Pizza",
"Come-A-Lot Gas",
"FortCarson Gas",
"BoneCountry Gas",
"Julius Gas",
"PricklePine Gas",
"Flint Gas",
"Easter Gas",
"Doherty Gas",
"Juniper 24/7",
"Juniper Gas",
"Emerald Isle 24/7",
"Emerald Isle Gas",
"Redsands-West Gas",
"ElGuebrabos Gas",
"TierraRobada Gas",
"AngelPine Gas",
"WhetStone Gas",
"Dilimore Gas",
"Montgomery Gas"
};
for(auto it : Strings){
chat->AddChatMessage(-1, it.c_str());
}
Ему же явно нужен неизменяемый C массив строк, он не использовал new, а значит все возможности аллокатора попросту не нужны. Более того, при каждом вызове функции будет вызываться конструктор на кучу элементов и забирать много рантаймаЮзай вектора, они удобнее.
#if __cplusplus > 201402L
#include <iterator>
#else
#include <cstdio>
namespace std {
template <class Type, std::size_t Num>
constexpr std::size_t size(const Type (&input_array)[Num]) noexcept {
return Num;
}
}
#endif
void CALLBACK biz_check(std::string param) {
static const char str[][50] {
"Alhambra",
"PigPen",
"Misty Club",
"Casino Bellagio",
"Grove Street Bar",
"Sobrino de Botin",
"Vinewood Burger",
"Marina Burger",
"Idlewood Pizza",
"Downtown Cluc",
"Marina Cluc",
"Idelwood 24/7",
"Flint 24/7",
"Easter 24/7",
"Mullholand 24/7",
"Jizzy",
"Redsands West 24/7",
"Julius 24/7",
"Lil\"Probe\"inn",
"Idelwood Gas",
"Mullholang Gas",
"Whetstone 24/7",
"East Cluc",
"WillowField Cluc",
"Flats Cluc",
"Financial Pizza",
"Come-A-Lot Gas",
"FortCarson Gas",
"BoneCountry Gas",
"Julius Gas",
"PricklePine Gas",
"Flint Gas",
"Easter Gas",
"Doherty Gas",
"Juniper 24/7",
"Juniper Gas",
"Emerald Isle 24/7",
"Emerald Isle Gas",
"Redsands-West Gas",
"ElGuebrabos Gas",
"TierraRobada Gas",
"AngelPine Gas",
"WhetStone Gas",
"Dilimore Gas",
"Montgomery Gas"
};
for (auto i = 0; i < std::size(str); i ++)
SF->getSAMP()->getChat()->AddChatMessage(COLOR_GREY, "-> %s", str[i]);
}
#define SAMP_HOOKENTER_HANDLE_RPC 0x3743D
#define SAMP_HOOKENTER_HANDLE_RPC2 0x373C9
#define SAMP_HOOKEXIT_HANDLE_RPC 0x37443
#define SAMP_HOOKEXIT_HANDLE_RPC2 0x37451
void HandleRPCPacketFunc(unsigned char id, RPCParameters *rpcParams, void(*callback) (RPCParameters *))
{
if (rpcParams != nullptr && rpcParams->numberOfBitsOfData >= 8)
{
BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
switch (id)
{
case RPC_DeathMessage:
{
pSAMP->addMessageToChat(-1, "plugin ONE");
int16_t plaerid, killerid;
int8_t resaon;
bsData.ResetReadPointer();
bsData.Read(killerid);
bsData.Read(plaerid);
bsData.Read(resaon);
break;
}
}
}
callback(rpcParams);
}
void _declspec (naked) hook_handle_rpc_packet(void)
{
static RPCParameters *pRPCParams = nullptr;
static RPCNode *pRPCNode = nullptr;
static DWORD dwTmp = 0;
__asm pushad;
__asm mov pRPCParams, eax;
__asm mov pRPCNode, edi;
HandleRPCPacketFunc(pRPCNode->uniqueIdentifier, pRPCParams, pRPCNode->staticFunctionPointer);
dwTmp = pSAMP->getSAMPAddr() + SAMP_HOOKEXIT_HANDLE_RPC;
__asm popad;
__asm add esp, 4
__asm jmp dwTmp;
}
void _declspec (naked) hook_handle_rpc_packet2(void)
{
static RPCParameters *pRPCParams = nullptr;
static RPCNode *pRPCNode = nullptr;
static DWORD dwTmp = 0;
__asm pushad;
__asm mov pRPCParams, ecx;
__asm mov pRPCNode, edi;
HandleRPCPacketFunc(pRPCNode->uniqueIdentifier, pRPCParams, pRPCNode->staticFunctionPointer);
dwTmp = pSAMP->getSAMPAddr() + SAMP_HOOKEXIT_HANDLE_RPC2;
__asm popad;
__asm jmp dwTmp;
}
void InstallAllHooks()
{
static int iSAMPHooksInstalled;
if (!iSAMPHooksInstalled)
{
if (pSAMP->getInfo() == NULL)
return;
/*
https://github.com/sr-tream/UniLib/blob/master/UniLib/CHooks.hpp
*/
HookRPC1 = new CHookJmp(pSAMP->getSAMPAddr() + SAMP_HOOKENTER_HANDLE_RPC, hook_handle_rpc_packet, 6); //
HookRPC2 = new CHookJmp(pSAMP->getSAMPAddr() + SAMP_HOOKENTER_HANDLE_RPC2, hook_handle_rpc_packet2, 8);
iSAMPHooksInstalled = 1;
}
}
Парсишь адрес функции которую вызывает хук и вызываешь в своём хуке (работает только если твой плагин грузится после первого), или ставишь хук в другом местеПовторюсь с вопросом,так как уже заебался...
Происходит конфликт двух плагинов,а то есть перезапись хука HandleRPCPacketFunc,как исправить данную хурму?
Код:#define SAMP_HOOKENTER_HANDLE_RPC 0x3743D #define SAMP_HOOKENTER_HANDLE_RPC2 0x373C9 #define SAMP_HOOKEXIT_HANDLE_RPC 0x37443 #define SAMP_HOOKEXIT_HANDLE_RPC2 0x37451 void HandleRPCPacketFunc(unsigned char id, RPCParameters *rpcParams, void(*callback) (RPCParameters *)) { if (rpcParams != nullptr && rpcParams->numberOfBitsOfData >= 8) { BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false); switch (id) { case RPC_DeathMessage: { pSAMP->addMessageToChat(-1, "plugin ONE"); int16_t plaerid, killerid; int8_t resaon; bsData.ResetReadPointer(); bsData.Read(killerid); bsData.Read(plaerid); bsData.Read(resaon); break; } } } callback(rpcParams); } void _declspec (naked) hook_handle_rpc_packet(void) { static RPCParameters *pRPCParams = nullptr; static RPCNode *pRPCNode = nullptr; static DWORD dwTmp = 0; __asm pushad; __asm mov pRPCParams, eax; __asm mov pRPCNode, edi; HandleRPCPacketFunc(pRPCNode->uniqueIdentifier, pRPCParams, pRPCNode->staticFunctionPointer); dwTmp = pSAMP->getSAMPAddr() + SAMP_HOOKEXIT_HANDLE_RPC; __asm popad; __asm add esp, 4 __asm jmp dwTmp; } void _declspec (naked) hook_handle_rpc_packet2(void) { static RPCParameters *pRPCParams = nullptr; static RPCNode *pRPCNode = nullptr; static DWORD dwTmp = 0; __asm pushad; __asm mov pRPCParams, ecx; __asm mov pRPCNode, edi; HandleRPCPacketFunc(pRPCNode->uniqueIdentifier, pRPCParams, pRPCNode->staticFunctionPointer); dwTmp = pSAMP->getSAMPAddr() + SAMP_HOOKEXIT_HANDLE_RPC2; __asm popad; __asm jmp dwTmp; } void InstallAllHooks() { static int iSAMPHooksInstalled; if (!iSAMPHooksInstalled) { if (pSAMP->getInfo() == NULL) return; /* https://github.com/sr-tream/UniLib/blob/master/UniLib/CHooks.hpp */ HookRPC1 = new CHookJmp(pSAMP->getSAMPAddr() + SAMP_HOOKENTER_HANDLE_RPC, hook_handle_rpc_packet, 6); // HookRPC2 = new CHookJmp(pSAMP->getSAMPAddr() + SAMP_HOOKENTER_HANDLE_RPC2, hook_handle_rpc_packet2, 8); iSAMPHooksInstalled = 1; } }