sstring; crash?
This commit is contained in:
parent
3679e00188
commit
a30438b0c5
@ -22,6 +22,7 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "cvwrapper.h"
|
#include "cvwrapper.h"
|
||||||
#include "netvars.h"
|
#include "netvars.h"
|
||||||
|
#include "sstring.h"
|
||||||
#include "prediction.h"
|
#include "prediction.h"
|
||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ FILE* hConVarsFile = 0;
|
|||||||
void BeginConVars() {
|
void BeginConVars() {
|
||||||
passwd* pwd = getpwuid(getuid());
|
passwd* pwd = getpwuid(getuid());
|
||||||
char* user = pwd->pw_name;
|
char* user = pwd->pw_name;
|
||||||
hConVarsFile = fopen(strfmt("/home/%s/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg/cat_defaults.cfg", user), "w");
|
hConVarsFile = fopen((const char*)strfmt("/home/%s/.local/share/Steam/steamapps/common/Team Fortress 2/tf/cfg/cat_defaults.cfg", user), "w");
|
||||||
SetCVarInterface(interfaces::cvar);
|
SetCVarInterface(interfaces::cvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,13 +741,13 @@ void EndPrediction() {
|
|||||||
interfaces::gvars->frametime = oldFrametime;
|
interfaces::gvars->frametime = oldFrametime;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
char* strfmt(const char* fmt, ...) {
|
sstring strfmt(const char* fmt, ...) {
|
||||||
char buf[1024];
|
sstring result(1024);
|
||||||
va_list list;
|
va_list list;
|
||||||
va_start(list, fmt);
|
va_start(list, fmt);
|
||||||
vsprintf(buf, fmt, list);
|
vsprintf(result, fmt, list);
|
||||||
va_end(list);
|
va_end(list);
|
||||||
return buf;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* powerups[] = {
|
const char* powerups[] = {
|
||||||
|
@ -16,6 +16,7 @@ class CUserCmd;
|
|||||||
class CCommand;
|
class CCommand;
|
||||||
struct player_info_s;
|
struct player_info_s;
|
||||||
class Vector;
|
class Vector;
|
||||||
|
class sstring;
|
||||||
|
|
||||||
#define PI 3.14159265358979323846f
|
#define PI 3.14159265358979323846f
|
||||||
#define RADPI 57.295779513082f
|
#define RADPI 57.295779513082f
|
||||||
@ -69,7 +70,7 @@ bool GetProjectileData(CachedEntity* weapon, float& speed, float& gravity);
|
|||||||
bool IsVectorVisible(Vector a, Vector b);
|
bool IsVectorVisible(Vector a, Vector b);
|
||||||
relation GetRelation(CachedEntity* ent); // TODO new relations
|
relation GetRelation(CachedEntity* ent); // TODO new relations
|
||||||
bool IsSentryBuster(CachedEntity* ent);
|
bool IsSentryBuster(CachedEntity* ent);
|
||||||
char* strfmt(const char* fmt, ...);
|
sstring strfmt(const char* fmt, ...);
|
||||||
// TODO move that to weaponid.h
|
// TODO move that to weaponid.h
|
||||||
bool IsAmbassador(CachedEntity* ent);
|
bool IsAmbassador(CachedEntity* ent);
|
||||||
|
|
||||||
|
@ -14,13 +14,14 @@
|
|||||||
|
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
#include "sdk.h"
|
#include "sdk.h"
|
||||||
|
#include "sstring.h"
|
||||||
|
|
||||||
FILE* logging::handle = 0;
|
FILE* logging::handle = 0;
|
||||||
|
|
||||||
void logging::Initialize() {
|
void logging::Initialize() {
|
||||||
passwd* pwd = getpwuid(getuid());
|
passwd* pwd = getpwuid(getuid());
|
||||||
char* user = pwd->pw_name;
|
char* user = pwd->pw_name;
|
||||||
logging::handle = fopen(strfmt("/tmp/cathook-%s.log", user), "w");
|
logging::handle = fopen((const char*)strfmt("/tmp/cathook-%s.log", user), "w");
|
||||||
}
|
}
|
||||||
|
|
||||||
void logging::Info(const char* fmt, ...) {
|
void logging::Info(const char* fmt, ...) {
|
||||||
|
@ -8,13 +8,14 @@
|
|||||||
#include "sharedobj.h"
|
#include "sharedobj.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "sstring.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
const char* path_from_proc_maps(const char* name) {
|
const char* path_from_proc_maps(const char* name) {
|
||||||
FILE* proc_maps = fopen(strfmt("/proc/%i/maps", getpid()), "r");
|
FILE* proc_maps = fopen((const char*)strfmt("/proc/%i/maps", getpid()), "r");
|
||||||
if (!proc_maps) return (const char*)0;
|
if (!proc_maps) return (const char*)0;
|
||||||
char* buffer = new char[512];
|
char* buffer = new char[512];
|
||||||
while (fgets(buffer, 512, proc_maps)) {
|
while (fgets(buffer, 512, proc_maps)) {
|
||||||
|
22
cathook/src/sstring.h
Normal file
22
cathook/src/sstring.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* sstring.h
|
||||||
|
*
|
||||||
|
* Created on: Dec 23, 2016
|
||||||
|
* Author: nullifiedcat
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SSTRING_H_
|
||||||
|
#define SSTRING_H_
|
||||||
|
|
||||||
|
class sstring {
|
||||||
|
public:
|
||||||
|
inline sstring() { length = 0; p_String = 0; };
|
||||||
|
inline sstring(int length) { this->length = length; p_String = new char[length]; }
|
||||||
|
inline ~sstring() { delete [] p_String; }
|
||||||
|
inline operator const char*() const { return p_String; };
|
||||||
|
inline operator char*() const { return (char*)p_String; }
|
||||||
|
const char* p_String;
|
||||||
|
int length;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SSTRING_H_ */
|
Reference in New Issue
Block a user