Subversion Repositories WoWGM

Rev

Rev 34 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34 Rev 36
Line 3... Line 3...
3
 
3
 
4
#include "ConsoleClient.h"
4
#include "ConsoleClient.h"
5
#include <Os/W32/OsFile.h>
5
#include <Os/W32/OsFile.h>
6
 
6
 
7
 
7
 
8
/****************************************************************************
8
/******************************************************************************
9
*
9
*
10
*   Client memory addresses
10
*   Client memory addresses
11
*
11
*
12
***/
12
***/
13
 
13
 
14
#define  CONSOLECOMMANDDESTROY  0x007685C0
14
#define  CONSOLECOMMANDDESTROY  0x007685C0
15
 
15
 
16
 
16
 
17
/****************************************************************************
17
/******************************************************************************
18
*
18
*
19
*   Client symbol pointers
19
*   Client symbol pointers
20
*
20
*
21
***/
21
***/
22
 
22
 
23
void (*ConsoleCommandDestroyPtr)() = *(void(*)())CONSOLECOMMANDDESTROY;
23
void (*ConsoleCommandDestroyPtr)() = *(void(*)())CONSOLECOMMANDDESTROY;
24
 
24
 
25
 
25
 
26
/****************************************************************************
26
/******************************************************************************
27
*
27
*
28
*   Private
28
*   Private
29
*
29
*
30
***/
30
***/
31
 
31
 
32
static char s_fileName[260] = {};
32
static char s_fileName[260] = {};
33
 
33
 
34
//===========================================================================
34
//=============================================================================
35
void ConsoleCommandDestroy () {
35
void ConsoleCommandDestroy () {
36
	// Remove the function trampoline
36
	// Remove the function trampoline
37
	DETOUR_INIT;
37
	DETOUR_INIT;
38
	DETOUR_DETACH(ConsoleCommandDestroyPtr,ConsoleCommandDestroy);
38
	DETOUR_DETACH(ConsoleCommandDestroyPtr,ConsoleCommandDestroy);
39
	DETOUR_COMMIT;
39
	DETOUR_COMMIT;
Line 46... Line 46...
46
 
46
 
47
	// Call the original function to handle clean-up
47
	// Call the original function to handle clean-up
48
	ConsoleCommandDestroyPtr();
48
	ConsoleCommandDestroyPtr();
49
}
49
}
50
 
50
 
51
//===========================================================================
51
//=============================================================================
52
BOOL ValidateFileName (char const* fileName) {
52
BOOL ValidateFileName (char const* fileName) {
53
  if (fileName && *fileName) {
53
  if (fileName && *fileName) {
54
    if (strstr(fileName,"..") || strstr(fileName,"\\")) {
54
    if (strstr(fileName,"..") || strstr(fileName,"\\")) {
55
      ConsoleWrite("File Name cannot contain '\\' or '..'",ERROR_COLOR);
55
      ConsoleWrite("File Name cannot contain '\\' or '..'",ERROR_COLOR);
56
      return FALSE;
56
      return FALSE;
Line 67... Line 67...
67
  }
67
  }
68
 
68
 
69
  return FALSE;
69
  return FALSE;
70
}
70
}
71
 
71
 
72
//===========================================================================
72
//=============================================================================
73
BOOL CreateWTFFilePath (char* filePath, unsigned int size) {
73
BOOL CreateWTFFilePath (char* filePath, unsigned int size) {
74
	char buffer[FILENAME_MAX] = {};
74
	char buffer[FILENAME_MAX] = {};
75
 
75
 
76
	if (filePath && *filePath && size != 0) {
76
	if (filePath && *filePath && size != 0) {
77
		SStrCopy(buffer,"WTF\\",FILENAME_MAX);
77
		SStrCopy(buffer,"WTF\\",FILENAME_MAX);
Line 93... Line 93...
93
 
93
 
94
	return FALSE;
94
	return FALSE;
95
}
95
}
96
 
96
 
97
 
97
 
98
/****************************************************************************
98
/******************************************************************************
99
*
99
*
100
*   Command definitions
100
*   Command definitions
101
*
101
*
102
***/
102
***/
103
 
103
 
104
//===========================================================================
104
//=============================================================================
105
BOOL ConsoleCommand_CreateExec (char const* cmd, char const* arguments) {
105
BOOL ConsoleCommand_CreateExec (char const* cmd, char const* arguments) {
106
	if (ValidateFileName(arguments)) {
106
	if (ValidateFileName(arguments)) {
107
		char folder[FILENAME_MAX] = {};
107
		char folder[FILENAME_MAX] = {};
108
		char filePath[FILENAME_MAX] = {};
108
		char filePath[FILENAME_MAX] = {};
109
 
109
 
Line 135... Line 135...
135
	}
135
	}
136
 
136
 
137
	return FALSE;
137
	return FALSE;
138
}
138
}
139
 
139
 
140
//===========================================================================
140
//=============================================================================
141
BOOL ConsoleCommand_CloseExec (char const* cmd, char const* arguments) {
141
BOOL ConsoleCommand_CloseExec (char const* cmd, char const* arguments) {
142
	BOOL result = FALSE;
142
	BOOL result = FALSE;
143
 
143
 
144
	if (g_ExecCreateMode < EM_APPEND || g_ExecCreateMode > EM_WRITEFILE)
144
	if (g_ExecCreateMode < EM_APPEND || g_ExecCreateMode > EM_WRITEFILE)
145
	{
145
	{
Line 186... Line 186...
186
	}
186
	}
187
 
187
 
188
	return result;
188
	return result;
189
}
189
}
190
 
190
 
191
//===========================================================================
191
//=============================================================================
192
BOOL ConsoleCommand_RunExec (char const* command, char const* arguments) {
192
BOOL ConsoleCommand_RunExec (char const* command, char const* arguments) {
193
	BOOL result = FALSE;
193
	BOOL result = FALSE;
194
	char filename[FILENAME_MAX] = { '\0' };
194
	char filename[FILENAME_MAX] = { '\0' };
195
	char tmp[FILENAME_MAX] = { '\0' };
195
	char tmp[FILENAME_MAX] = { '\0' };
196
	char lineBuffer[128] = { '\0' };
196
	char lineBuffer[128] = { '\0' };
Line 271... Line 271...
271
	}
271
	}
272
 
272
 
273
	return result;
273
	return result;
274
}
274
}
275
 
275
 
276
//===========================================================================
276
//=============================================================================
277
BOOL ConsoleCommand_Ver (LPCSTR command, LPCSTR args) {
277
BOOL ConsoleCommand_Ver (LPCSTR command, LPCSTR args) {
278
#ifdef NDEBUG
278
#ifdef NDEBUG
279
	ConsoleWriteA("WoW [Release] Build 12340 (%s)", DEFAULT_COLOR, __DATE__);
279
	ConsoleWriteA("WoW [Release] Build 12340 (%s)", DEFAULT_COLOR, __DATE__);
280
#else
280
#else
281
	ConsoleWriteA("WoW [Debug] Build 12340 (%s)", DEFAULT_COLOR, __DATE__);
281
	ConsoleWriteA("WoW [Debug] Build 12340 (%s)", DEFAULT_COLOR, __DATE__);
282
#endif
282
#endif
283
	return TRUE;
283
	return TRUE;
284
}
284
}
285
 
285
 
286
 
286
 
287
/****************************************************************************
287
/******************************************************************************
288
*
288
*
289
*   External
289
*   External
290
*
290
*
291
***/
291
***/
292
 
292
 
293
//===========================================================================
293
//=============================================================================
294
void ConsoleCommandInitialize () {
294
void ConsoleCommandInitialize () {
295
	DETOUR_INIT;
295
	DETOUR_INIT;
296
	DETOUR_ATTACH(ConsoleCommandDestroyPtr,ConsoleCommandDestroy);
296
	DETOUR_ATTACH(ConsoleCommandDestroyPtr,ConsoleCommandDestroy);
297
	DETOUR_COMMIT;
297
	DETOUR_COMMIT;
298
 
298