Difference between revisions of "User:Mrmagu"

From AlliedModders Wiki
Jump to: navigation, search
(highlight test)
Line 3: Line 3:
 
C++ Highlighted test..<br />
 
C++ Highlighted test..<br />
  
 +
<cpp>
 +
#ifndef SIGSCAN_H
 +
#define SIGSCAN_H
  
<font color="#a020f0">#ifndef SIGSCAN_H</font>
+
// test
<font color="#a020f0">#define SIGSCAN_H</font><br />
+
class CSigScan {
<font color="#2e8b57"><b>class</b></font> CSigScan {
+
private:
<font color="#804040"><b>private</b></font>:
+
/* Private Variables */
    <font color="#0000ff">/*</font><font color="#0000ff"> Private Variables </font><font color="#0000ff">*/</font>
+
/* Base Address of the server module in memory */
    <font color="#0000ff">/*</font><font color="#0000ff"> Base Address of the server module in memory </font><font color="#0000ff">*/</font>
+
static unsigned char *base_addr;
    <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>char</b></font> *base_addr;
+
/* The length to the module's ending address */
    <font color="#0000ff">/*</font><font color="#0000ff"> The length to the module's ending address </font><font color="#0000ff">*/</font>
+
static size_t base_len;
    <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>size_t</b></font> base_len;<br />
+
 
    <font color="#0000ff">/*</font><font color="#0000ff"> The signature to scan for </font><font color="#0000ff">*/</font>
+
/* The signature to scan for */
    <font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>char</b></font> *sig_str;
+
unsigned char *sig_str;
    <font color="#0000ff">/*</font><font color="#0000ff"> A mask to ignore certain bytes in the signature such as addresses</font>
+
/* A mask to ignore certain bytes in the signature such as addresses
<font color="#0000ff">      The mask should be as long as all the bytes in the signature string</font>
+
  The mask should be as long as all the bytes in the signature string
<font color="#0000ff">      Use '?' to ignore a byte and 'x' to check it</font>
+
  Use '?' to ignore a byte and 'x' to check it
<font color="#0000ff">      Example&quot;xxx????xx&quot; - The first 3 bytes are checked, then the next 4 are</font>
+
  Example"xxx????xx" - The first 3 bytes are checked, then the next 4 are
<font color="#0000ff">      ignored, then the last 2 are checked </font><font color="#0000ff">*/</font>
+
  ignored, then the last 2 are checked */
    <font color="#2e8b57"><b>char</b></font> *sig_mask;
+
char *sig_mask;
    <font color="#0000ff">/*</font><font color="#0000ff"> The length of sig_str and sig_mask (not including a terminating null for sig_mask) </font><font color="#0000ff">*/</font>
+
/* The length of sig_str and sig_mask (not including a terminating null for sig_mask) */
    <font color="#2e8b57"><b>size_t</b></font> sig_len;<br/>
+
size_t sig_len;
    <font color="#0000ff">/*</font><font color="#0000ff"> Private Functions </font><font color="#0000ff">*/</font>
+
 
    <font color="#2e8b57"><b>void</b></font>* FindSignature(<font color="#2e8b57"><b>void</b></font>);<br/>
+
/* Private Functions */
<font color="#804040"><b>public</b></font>:
+
void* FindSignature(void);
    <font color="#0000ff">/*</font><font color="#0000ff"> Public Variables </font><font color="#0000ff">*/</font><br />
+
 
    <font color="#0000ff">/*</font><font color="#0000ff"> sigscan_dllfunc is a pointer of something that resides inside the gamedll so we can get</font>
+
public:
<font color="#0000ff">      the base address of it. From a SourceMM plugin, just set this to ismm-&gt;serverFactory(0)</font>
+
/* Public Variables */
<font color="#0000ff">      in Load(). From a Valve Server Plugin, you must set this to an actual factory returned</font>
+
 
<font color="#0000ff">      from gameServerFactory and hope that a SourceMM plugin did not override it. </font><font color="#0000ff">*/</font>
+
/* sigscan_dllfunc is a pointer of something that resides inside the gamedll so we can get
    <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>void</b></font> *(*sigscan_dllfunc)(<font color="#2e8b57"><b>const</b></font> <font color="#2e8b57"><b>char</b></font> *pName, <font color="#2e8b57"><b>int</b></font> *pReturnCode);<br />
+
  the base address of it. From a SourceMM plugin, just set this to ismm->serverFactory(0)
    <font color="#0000ff">/*</font><font color="#0000ff"> If the scan was successful or not </font><font color="#0000ff">*/</font>
+
  in Load(). From a Valve Server Plugin, you must set this to an actual factory returned
    <font color="#2e8b57"><b>char</b></font> is_set;
+
  from gameServerFactory and hope that a SourceMM plugin did not override it. */
    <font color="#0000ff">/*</font><font color="#0000ff"> Starting address of the found function </font><font color="#0000ff">*/</font>
+
static void *(*sigscan_dllfunc)(const char *pName, int *pReturnCode);
    <font color="#2e8b57"><b>void</b></font> *sig_addr;<br />
+
 
    <font color="#0000ff">/*</font><font color="#0000ff"> Public Functions </font><font color="#0000ff">*/</font>
+
/* If the scan was successful or not */
    CSigScan(<font color="#2e8b57"><b>void</b></font>)sig_str(<font color="#ff00ff">NULL</font>), sig_mask(<font color="#ff00ff">NULL</font>), sig_len(<font color="#ff00ff">0</font>), sig_addr(<font color="#ff00ff">NULL</font>) {}
+
char is_set;
    ~CSigScan(<font color="#2e8b57"><b>void</b></font>);<br />
+
/* Starting address of the found function */
    <font color="#2e8b57"><b>static</b></font> <font color="#2e8b57"><b>bool</b></font> GetDllMemInfo(<font color="#2e8b57"><b>void</b></font>);
+
void *sig_addr;
    <font color="#2e8b57"><b>void</b></font> Init(<font color="#2e8b57"><b>unsigned</b></font> <font color="#2e8b57"><b>char</b></font> *sig, <font color="#2e8b57"><b>char</b></font> *mask, <font color="#2e8b57"><b>size_t</b></font> len);
+
 
};<br />
+
/* Public Functions */
<font color="#2e8b57"><b>void</b></font> InitSigs(<font color="#2e8b57"><b>void</b></font>);<br />
+
CSigScan(void)sig_str(NULL), sig_mask(NULL), sig_len(0), sig_addr(NULL) {}
<font color="#0000ff">/*</font><font color="#0000ff"> Sig Functions </font><font color="#0000ff">*/</font>
+
~CSigScan(void);
<font color="#2e8b57"><b>class</b></font> CBaseAnimating;
+
 
<font color="#2e8b57"><b>void</b></font> CBaseAnimating_Ignite(CBaseAnimating *cba, <font color="#2e8b57"><b>float</b></font> flFlameLifetime);<br />
+
static bool GetDllMemInfo(void);
<font color="#a020f0">#endif</font>
+
void Init(unsigned char *sig, char *mask, size_t len);
 +
};
 +
 
 +
void InitSigs(void);
 +
 
 +
/* Sig Functions */
 +
class CBaseAnimating;
 +
void CBaseAnimating_Ignite(CBaseAnimating *cba, float flFlameLifetime);
 +
 
 +
#endif
 +
</cpp>

Revision as of 15:10, 19 January 2006

is a nub :] and wants someone to add the damn syntax highlighter extention already :)

C++ Highlighted test..

#ifndef SIGSCAN_H
#define SIGSCAN_H
 
// test
class CSigScan {
private:
	/* Private Variables */
	/* Base Address of the server module in memory */
	static unsigned char *base_addr;
	/* The length to the module's ending address */
	static size_t base_len;
 
	/* The signature to scan for */
	unsigned char *sig_str;
	/* A mask to ignore certain bytes in the signature such as addresses
	   The mask should be as long as all the bytes in the signature string
	   Use '?' to ignore a byte and 'x' to check it
	   Example"xxx????xx" - The first 3 bytes are checked, then the next 4 are
	   ignored, then the last 2 are checked */
	char *sig_mask;
	/* The length of sig_str and sig_mask (not including a terminating null for sig_mask) */
	size_t sig_len;
 
	/* Private Functions */
	void* FindSignature(void);
 
public:
	/* Public Variables */
 
	/* sigscan_dllfunc is a pointer of something that resides inside the gamedll so we can get
	   the base address of it. From a SourceMM plugin, just set this to ismm->serverFactory(0)
	   in Load(). From a Valve Server Plugin, you must set this to an actual factory returned
	   from gameServerFactory and hope that a SourceMM plugin did not override it. */
	static void *(*sigscan_dllfunc)(const char *pName, int *pReturnCode);
 
	/* If the scan was successful or not */
	char is_set;
	/* Starting address of the found function */
	void *sig_addr;
 
	/* Public Functions */
	CSigScan(void)sig_str(NULL), sig_mask(NULL), sig_len(0), sig_addr(NULL) {}
	~CSigScan(void);
 
	static bool GetDllMemInfo(void);
	void Init(unsigned char *sig, char *mask, size_t len);
};
 
void InitSigs(void);
 
/* Sig Functions */
class CBaseAnimating;
void CBaseAnimating_Ignite(CBaseAnimating *cba, float flFlameLifetime);
 
#endif