Другое С/С++ Вопрос - Ответ

0x73616D

Активный
140
43
How I can write this values in c++? I took it from one .lua script.

Lua:
memory.hex2bin("E865041C00", 0x53C136, 5)
memory.write(12697552, 1, 1, false)--
 

kin4stat

mq-team · kin4@naebalovo.team
Всефорумный модератор
2,757
4,895
How I can write this values in c++? I took it from one .lua script.

Lua:
memory.hex2bin("E865041C00", 0x53C136, 5)
memory.write(12697552, 1, 1, false)--
C++:
void set_raw(std::uintptr_t address, const char* RawData, std::size_t size, bool protect) {
    DWORD oldProt;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), size, PAGE_READWRITE, &oldProt);
    memcpy(reinterpret_cast<void*>(address), RawData, size);
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), size, oldProt, &oldProt);
}

template <typename T>
inline void write_memory(std::uintptr_t address, T value, bool protect = true) {
    unsigned long oldProt;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), sizeof(T), PAGE_READWRITE, &oldProt);
    *reinterpret_cast<T*>(address) = value;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), sizeof(T), oldProt, &oldProt);
}

set_raw(0x53C136, "\xE8\x65\x04\x1C\x00", 5, true);
set_raw(0xC1BFD0, "\x01", 1, true); // or WriteMemory(0xC1BFD0, char(1), true);

It is also bad form to write addresses not in hex
 
Последнее редактирование:
  • Влюблен
  • Нравится
Реакции: etereon и 0x73616D
15
11
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
How I can write this values in c++? I took it from one .lua script.

Lua:
memory.hex2bin("E865041C00", 0x53C136, 5)
memory.write(12697552, 1, 1, false)--


C++:
#include "llmo/include/rwe.hpp"

llmo::rwe::Copy(0x53C136, "\xE8\x65\x04\x1C\x00", 5);
llmo::rwe::Set(0xC1BFD0, 0x01, 1);


C++:
void set_raw(std::uintptr_t address, const char* RawData, std::size_t size, bool protect) {
    DWORD oldProt;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), size, PAGE_READWRITE, &oldProt);
    memcpy(reinterpret_cast<void*>(address), RawData, size);
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), size, oldProt, &oldProt);
}

template <typename T>
inline void write_memory(std::uintptr_t address, T value, bool protect = true) {
    unsigned long oldProt;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), sizeof(T), PAGE_READWRITE, &oldProt);
    *reinterpret_cast<T*>(address) = value;
    if (protect) VirtualProtect(reinterpret_cast<void*>(address), sizeof(T), oldProt, &oldProt);
}

set_raw(0x53C136, "\xE8\x65\x04\x1C\x00", 5, true);
set_raw(0xC1BFD0, "\x01", 1, true); // or WriteMemory(0xC1BFD0, char(1), true);

It is also bad form to write addresses not in hex
Исправился, 🐞 аннулирую
 
Последнее редактирование:
  • Bug
Реакции: legendabrn

0x73616D

Активный
140
43
how can i register a command without using sampfuncs? (.ASI)

как я могу зарегистрировать команду без использования sampfuncs? (.ASI)
===========================================================

How can I write this snippet taken from .lua in C++?

Lua:
function samp.onRemoveBuilding()
    return false
end
 
Последнее редактирование:

F0RQU1N and

Известный
1,292
502
how can i register a command without using sampfuncs? (.ASI)
Как эмулировать зажатие/нажатие клавиши?
 

0x73616D

Активный
140
43
how i can write this snippet tooked from .lua script without sampfuncs?

Lua:
sendEmptyPacket(PACKET_DISCONNECTION_NOTIFICATION)

function sendEmptyPacket(id)
    local bs = raknetNewBitStream()
    raknetBitStreamWriteInt8(bs, id)
    raknetSendBitStream(bs)
    raknetDeleteBitStream(bs)
end
 

Daurin

Потрачен
10
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Всем привет,такой вопрос,через что можно сделать поиск картинки?
 

ARMOR

God has forsaken us
Модератор
5,060
7,467
1655398263508.png

Стандартный код из SampFuncs 5.4.1
Не понимаю в чём ошибка

C++:
#include <Windows.h>
#include "main.h"

SAMPFUNCS* SF = new SAMPFUNCS();

void __stdcall mainloop()
{
    static bool initialized = false;
    if (!initialized)
    {
        if (GAME && GAME->GetSystemState() == eSystemState::GS_PLAYING_GAME && SF->getSAMP()->IsInitialized())
        {
            initialized = true;
            SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 0xAA, 0), "SAMPFUNCS Plugin loaded.");
        }
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    if (dwReasonForCall == DLL_PROCESS_ATTACH)
        SF->initPlugin(mainloop, hModule);
    return TRUE;
}
 

sizeoftrickster

Известный
Проверенный
139
595
Посмотреть вложение 152702
Стандартный код из SampFuncs 5.4.1
Не понимаю в чём ошибка

C++:
#include <Windows.h>
#include "main.h"

SAMPFUNCS* SF = new SAMPFUNCS();

void __stdcall mainloop()
{
    static bool initialized = false;
    if (!initialized)
    {
        if (GAME && GAME->GetSystemState() == eSystemState::GS_PLAYING_GAME && SF->getSAMP()->IsInitialized())
        {
            initialized = true;
            SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 0xAA, 0), "SAMPFUNCS Plugin loaded.");
        }
    }
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
    if (dwReasonForCall == DLL_PROCESS_ATTACH)
        SF->initPlugin(mainloop, hModule);
    return TRUE;
}
Установи DirectX SDK
 
  • Нравится
Реакции: ARMOR