Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 12:32

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: CoD4 Con print test run, and...
PostPosted: 01 Jun 2010 19:07 

Joined: 08 May 2010 17:58
Posts: 55
Location: In vast nothingness of space...
so i was trying to make some kind of brute forcer for q3dirtrav (to automatically go through download main/something.cfg if i cant find the fila manually) and i compiled everything okay, ran cod4, succesfully injected the .dll i compiled, pressed shourtcut key num1, and cod4 crashed
now, i was wondering, coudl this be a game flaw, or im simply sending too mucha commands for it to handle in same time?

Here is my code (cpp, compile as normal .dll)
Code:
#include <windows.h>

bool Print = false;

typedef void (*g_ConPrint)(int Index, const char *fmt);
g_ConPrint trap_ConPrint = (g_ConPrint)0x004FCAB0; // CoD4 1.7 Offset For Con Acces
void ConPrint(int Index, const char *fmt)
{
   (trap_ConPrint)(Index, fmt);
}

DWORD WINAPI HotKeysThread(LPVOID)
{
    for(;; Sleep(500))
    {
        if(GetAsyncKeyState(VK_NUMPAD1))
       {
           Print=!Print;
      }


      if(Print == true)
      {
         
         ConPrint(0, "download main/server.cfg");
         ConPrint(0, "download main/config.cfg");
         ConPrint(0, "download main/configuration.cfg");
         ConPrint(0, "download main/name.cfg");
         ConPrint(0, "download main/server.cfg");
         ConPrint(0, "download main/something.cfg");
         ConPrint(0, "download main/mod.cfg");
         ConPrint(0, "download main/main.cfg");
         ConPrint(0, "download main/killer.cfg");
         ConPrint(0, "download main/rcon.cfg");
         ConPrint(0, "download main/password.cfg");
         ConPrint(0, "download main/cfg.cfg");
         ConPrint(0, "download main/konfig.cfg");
         ConPrint(0, "download main/settings.cfg");
         ConPrint(0, "download main/setting.cfg");
       
      }
    }
    return 0;
}

BOOL APIENTRY DllMain(HMODULE hModule,DWORD AreWeInside,LPVOID lpReserved)
{
    if (AreWeInside == DLL_PROCESS_ATTACH)
    {
         
          CreateThread(NULL, NULL, HotKeysThread, NULL, NULL, NULL);
          Beep(150,150);
    }

    return TRUE;
Code:


Top
 Profile  
 
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 01 Jun 2010 19:35 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
I don't remember if ConPrint is the correct function for what you want to do, anyway try to force the calling convention placing it before the various declarations of the function.
it should be __cdecl or __stdcall depening by the compiler used in cod4


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 01 Jun 2010 20:20 

Joined: 08 May 2010 17:58
Posts: 55
Location: In vast nothingness of space...
no, the function is just right, i rewrote it from some old poker message print, so basically i replaced the function from that hack with one that i found in q3sdk, found the offset in odbg by searching for "record" or demoname (dont remember now...) and at first try (just to test if it works) i succesfully printed Hello World in console of cod4, so yeah 0x004FCAB0 is the right offset, and function works fine, with one command/word to print
also, i know this wouldtn work as it should (it would loop same commands as long as num1 toggles it) but that can be fixed easily

so i was just asking, if game crash was as an reaction to printing, or something doesnt work in my code (probably i could just put sleep between ever call to print to fix this)


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 01 Jun 2010 20:38 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
in doubt try to place a Sleep(500) after each command so that it will not flood the console.
anyway remember that if the calling convention is wrong the game could not crash immediately so be sure at 100% that it's correct (the same source code can be compiled as stdcall on vc and cdecl on mingw, so there is a big difference)


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 01 Jun 2010 21:22 

Joined: 08 May 2010 17:58
Posts: 55
Location: In vast nothingness of space...
Quote:
(probably i could just put sleep between ever call to print to fix this)


hehe, im pretty sure that code is just fine, but it just floods console, and game crashes
i will try as soon as i get some motivation for making it work (now im motivated to... umm, i really dont know , haha)


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 02 Jun 2010 10:45 

Joined: 08 May 2010 17:58
Posts: 55
Location: In vast nothingness of space...
got sick of mechanics this morning, adn decided to fix this

Code:
#include <windows.h>

bool Print = false;

typedef void (*g_ConPrint)(int Index, const char *fmt);
g_ConPrint trap_ConPrint = (g_ConPrint)0x004FCAB0; // CoD4 1.7 Offset For Con Acces
void ConPrint(int Index, const char *fmt)
{
   (trap_ConPrint)(Index, fmt);
}

DWORD WINAPI HotKeysThread(LPVOID)
{
    for(;; Sleep(500))
    {
        if(GetAsyncKeyState(VK_NUMPAD1))
       {
           Print=!Print;
      }


      if(Print == true)
      {
         
         ConPrint(0, "download main/server.cfg");
Sleep(500);
         ConPrint(0, "download main/config.cfg");
Sleep(500);
         ConPrint(0, "download main/configuration.cfg");
Sleep(500);
         ConPrint(0, "download main/name.cfg");
Sleep(500);
         ConPrint(0, "download main/server.cfg");
Sleep(500);
         ConPrint(0, "download main/something.cfg");
Sleep(500);
         ConPrint(0, "download main/mod.cfg");
Sleep(500);
         ConPrint(0, "download main/main.cfg");
Sleep(500);
         ConPrint(0, "download main/killer.cfg");
Sleep(500);
         ConPrint(0, "download main/rcon.cfg");
Sleep(500);
         ConPrint(0, "download main/password.cfg");
Sleep(500);
         ConPrint(0, "download main/cfg.cfg");
Sleep(500);
         ConPrint(0, "download main/konfig.cfg");
Sleep(500);
         ConPrint(0, "download main/settings.cfg");
Sleep(500);
         ConPrint(0, "download main/setting.cfg");

         Print=!Print;
       
      }
    }
    return 0;
}

BOOL APIENTRY DllMain(HMODULE hModule,DWORD AreWeInside,LPVOID lpReserved)
{
    if (AreWeInside == DLL_PROCESS_ATTACH)
    {
         
          CreateThread(NULL, NULL, HotKeysThread, NULL, NULL, NULL);
          Beep(150,150);
    }

    return TRUE;



same thing as last time, even if i put sleep between every call to conprint function, and i fixed the looping
i just inject it, open full console, press my hotkey, cod4 freezes for sec or two, and crashes
tho, with printing a single word to console works with same code
il work something out, and post the working source here


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 02 Jun 2010 18:50 

Joined: 08 May 2010 17:58
Posts: 55
Location: In vast nothingness of space...
after half an hour of trying to figure out what is crashing the game, i decided to check the offset again, and there was my problem
real offset for 1.7 is 0x004FCBC0
so i got all working, but this wont actually send commands to the game, it will just PRINT any text to console, not execute the command i print there
so for this il have to find something else to send commands to game, althought il just drop the project because i really dont have any idea how would i do that...


Top
 Profile  
 
 Post subject: Re: CoD4 Con print test run, and...
PostPosted: 06 Jun 2010 15:18 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
is CL_AddReliableCommand the function you want to hook?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron