From 5d9a1df970e1d6c4cd1801d050b3a8aac5cb8226 Mon Sep 17 00:00:00 2001 From: shelru Date: Fri, 4 Nov 2016 22:53:29 +0300 Subject: [PATCH] //Garry & Juice --- cmdlist-checker-bypass.txt | 159 +++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 cmdlist-checker-bypass.txt diff --git a/cmdlist-checker-bypass.txt b/cmdlist-checker-bypass.txt new file mode 100644 index 0000000..3b5a160 --- /dev/null +++ b/cmdlist-checker-bypass.txt @@ -0,0 +1,159 @@ + +DWORD dwCmdList; +void hookedCmdList() +{ + int total_cmds = 0; + int odd_cmds = 0; + bool log = false; + bool is_legit_cmd = false; + pcommand_t pCmd = g_Engine.pfnGetCmdList(); + char cmd[1024]; + char gamedir[256]; + + FILE *w; + + gamedir[0] = 0; + cmd[0] = 0; + strncat( cmd, g_Engine.Cmd_Argv(1), sizeof(cmd) ); + + if( cmd[0] == '?' && cmd[1] == 0 ) + { + g_Engine.Con_Printf( "CmdList : List all commands\nCmdList [Partial] : List commands starting with 'Partial'\nCmdList log [Partial] : Logs commands to file \"cmdlist.txt\" in the gamedir.\n"); + return; + } + g_Engine.Con_Printf( "Command List\n--------------\n" ); + if( cmd[0] == '!' && cmd[1] == 0 ) + { + while( pCmd ) + { + if( !is_legit_cmd ) + { + odd_cmds++; + if( pCmd->pfnFunc == last_added_cmd ) + { + is_legit_cmd = true; + } + } + + g_Engine.Con_Printf( "%-16.16s%s\n", pCmd->pszName, is_legit_cmd ? "" : "\t\t\t(odd)" ); + + total_cmds++; + pCmd = pCmd->pNext; + } + g_Engine.Con_Printf( "--------------\n%3i Total Commands (%d odd)\nCmdList ? for syntax\n", total_cmds, odd_cmds ); + + return; + } + strncat(gamedir,g_Engine.pfnGetGameDirectory(),sizeof(gamedir)); + strncat(gamedir,"/cmdlist.txt",sizeof(gamedir)); + if( strncmp( cmd, "log", strlen(cmd) ) == 0 ) + { + w = fopen( gamedir, "w" ); + log = true; + } + + if( log && w == NULL ) + { + log = false; + g_Engine.Con_Printf( "Couldn't open %s for writing!\n", gamedir ); + return; + } +if( g_Engine.Cmd_Argc() == 2 ) + { + if( log ) + { + while( pCmd ) + { + if( pCmd->pfnFunc == last_added_cmd ) + { + is_legit_cmd = true; + } + + if( is_legit_cmd ) + { + g_Engine.Con_Printf( "%-16.16s\n", pCmd->pszName ); + fprintf( w, "%-16.16s\n", pCmd->pszName ); + total_cmds++; + } + pCmd = pCmd->pNext; + } + + g_Engine.Con_Printf( "--------------\n%3i Total Commands\nCmdList ? for syntax\n", total_cmds ); + fclose(w); + return; + } + else + { + while( pCmd ) + { + if( pCmd->pfnFunc == last_added_cmd ) + { + is_legit_cmd = true; + } + if( is_legit_cmd && strncmp( cmd, pCmd->pszName, strlen(cmd) ) == 0 ) + { + g_Engine.Con_Printf( "%-16.16s\n", pCmd->pszName ); + total_cmds++; + } + pCmd = pCmd->pNext; + } + g_Engine.Con_Printf( "--------------\n%3i Commands for [%s]\nCmdList ? for syntax\n", total_cmds, cmd ); + + return; + } + } + if( g_Engine.Cmd_Argc() == 3 && log ) + { + while( pCmd ) + { + if( pCmd->pfnFunc == last_added_cmd ) + { + is_legit_cmd = true; + } + + if( is_legit_cmd && strncmp( g_Engine.Cmd_Argv(2), pCmd->pszName, strlen(g_Engine.Cmd_Argv(2)) ) == 0 ) + { + g_Engine.Con_Printf( "%-16.16s\n", pCmd->pszName ); + fprintf( w, "%-16.16s\n", pCmd->pszName ); + total_cmds++; + } + + pCmd = pCmd->pNext; + } + g_Engine.Con_Printf( "--------------\n%3i Total Commands\nCmdList ? for syntax\n", total_cmds ); + fclose(w); + return; + } + + while( pCmd ) + { + if( pCmd->pfnFunc == last_added_cmd )is_legit_cmd = true; + if( is_legit_cmd ) + { + g_Engine.Con_Printf( "%-16.16s\n", pCmd->pszName ); + if( log ) + fprintf( w, "%-16.16s\n", pCmd->pszName ); + + total_cmds++; + } + pCmd = pCmd->pNext; + } + g_Engine.Con_Printf( "--------------\n%3i Total Commands\nCmdList ? for syntax\n", total_cmds ); + if( log ) + fclose(w); +} + +void hookCommand( char *cmdName, DWORD *dwCmdPointer, void (*func)( void ) ) +{ + pcommand_t pCmd = g_Engine.pfnGetCmdList( ); + while( pCmd ) + { + if( !strcmp( pCmd->pszName, cmdName ) ) + { + *dwCmdPointer = pCmd->pfnFunc; + pCmd->pfnFunc = (DWORD)( (void *)func ); + break; + } + pCmd = pCmd->pNext; + }; +} \ No newline at end of file