Skip to content

Instantly share code, notes, and snippets.

View WPMGPRoSToTeMa's full-sized avatar

Artem Golubikhin WPMGPRoSToTeMa

View GitHub Profile
@WPMGPRoSToTeMa
WPMGPRoSToTeMa / source_and_asm_output.txt
Last active August 6, 2018 22:58
Declaring variable in for-loop initializer vs. for-loop body comparison in AMXX Pawn (see revision difference)
public func(const players[], playersCount) {
for (new i = 0; i < playersCount; i++) {
new player = players[i];
server_print("%d", player);
}
}
; frm+0x10 playersCount
; frm+0xC players
; frm+0x8 argscount*cellsize (2*4=8)
@WPMGPRoSToTeMa
WPMGPRoSToTeMa / SprayFix.cxx
Created June 9, 2018 02:50
6xxx spray fix metamod plugin for HLDS
// g++ -std=c++11 SprayFix.cxx -shared -ldl
#include <dlfcn.h>
#include <sys/mman.h>
#include <unistd.h>
#include <cstring>
enum PLUG_LOADTIME
{
PT_NEVER,
PT_STARTUP, // should only be loaded/unloaded at initial hlds execution
#include <amxmodx>
#include <engine>
#include <fakemeta>
public plugin_init() {
register_clcmd("say /test", "Test");
}
public Test(client) {
// Antenna on cs_assault
@WPMGPRoSToTeMa
WPMGPRoSToTeMa / info.cpp
Last active April 3, 2018 11:29
Info_IsValid state machine
constexpr bool Info_IsValid(char const* info) noexcept {
constexpr auto maxKeyValueSize{ MAX_KV_LEN };
constexpr auto maxKeyValueLength{ maxKeyValueSize - 1 };
enum class State {
Start,
ReadingKey,
ReadingValue
};
cmake_minimum_required(VERSION 3.5)
project(Test)
add_library(${PROJECT_NAME} SHARED ${CMAKE_SOURCE_DIR}/Test.c)
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE OFF)
artem@DESKTOP-772DMBE:~$ strace -ff qemu-i386 testqemupthread
execve("/usr/bin/qemu-i386", ["qemu-i386", "testqemupthread"], [/* 17 vars */]) = 0
brk(NULL) = 0x7fffce061000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f11bfdd0000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/usr/local/gcc-7.1/lib64/tls/x86_64/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/gcc-7.1/lib64/tls/x86_64", 0x7fffd5621ac0) = -1 ENOENT (No such file or directory)
open("/usr/local/gcc-7.1/lib64/tls/libgmodule-2.0.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/gcc-7.1/lib64/tls", 0x7fffd5621ac0) = -1 ENOENT (No such file or directory)
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void *print_message_function( void *ptr );
main()
{
pthread_t thread1, thread2;
const char *message1 = "Thread 1";

How to patch

Open your cstrike/cl_dlls/client.dll with hex editor (for example WinHex) and replace bytes 8B4C240433C02BC87406497403497505B801000000C3 with 837C240401750B8B44240CC7400800000042B001C3C3. In WinHex you can open the replace dialog with Ctrl+Alt+H WinHex example

Info for developers

The original function:

int HUD_GetHullBounds(int hullnum, float* mins, float* maxs)
{
 return (hullnum == 0 || hullnum == 1 || hullnum == 2) ? 1 : 0;
#include <amxmodx>
new const g_fractions[][] = {
"5",
"25",
"125",
"0625",
"03125",
"015625",
"0078125",