.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   General Programming (http://forums.bots-united.com/forumdisplay.php?f=25)
-   -   very simple debugging question (MSVC) (http://forums.bots-united.com/showthread.php?t=506)

koraX 26-01-2004 20:29

Re: very simple debugging question (MSVC)
 
is it possible to debug bot on non-dedicated server ?

Lazy 26-01-2004 20:51

Re: very simple debugging question (MSVC)
 
Yes, it works the same way except you can step through your code without timing out.
With steam its a little different though and I can't remember how exactly to do it.

Pierre-Marie Baty 26-01-2004 21:06

Re: very simple debugging question (MSVC)
 
There is, however, an internal check inside the Counter-Strike client.dll that will make the game simply exit if a debugger is detected in the system. Using the normal Counter-Strike client.dll it is NOT possible to debug your bot inside a listenserver.

What you can do however, is debug a DEDICATED server, then connect to it using the loopback connection :

hl.exe -dev -console +connect 127.0.0.1:27015

this command line will make HL connect to the HLDS server that is running on your OWN machine (this way you will be able to debug your bot while you are playing the game).

koraX 04-09-2004 09:25

Re: very simple debugging question (MSVC)
 
Sorry to revive old thread, but I've found way how to debug without hlds

Quote:

Originally Posted by Pierre-Marie Baty
There is, however, an internal check inside the Counter-Strike client.dll that will make the game simply exit if a debugger is detected in the system. Using the normal Counter-Strike client.dll it is NOT possible to debug your bot inside a listenserver.

So client.dll is causing trouble ? Well ... I deleted it :D . And guess what. Counter-strike ran in debugger, only difference was that I could not join as player, I could only spectate (this is obvious, there is no client dll hehehe). I have CS 1.5. (I set debugger to call c:\sierra\half-life\hl.exe -dev -debug -console -game cstrike +deathmatch 1 +map de_aztec +maxplayers 15 -sw +sv_lan 1)

*edit* well I haven't spawned a bot yet, I wonder if they could spawn if ther is no client.dll, damn.

*edit2* Oh well, they spawn but they don't join :) Damn this client.dll. At least I can debug something.

BTW is cs client 1.6 with steam terminating if it detect debugger too ? Do you have to debug hlds.exe or you can debug hl.exe ?

Whistler 04-09-2004 11:00

Re: very simple debugging question (MSVC)
 
I think Count Floyd has a patched version of CS 1.3 which has that debugger check removed. You can find a version of CS 1.3 and take a look at the RACC install program source code for the patch. PMB has included it.

Also Cs 1.6 doesn't have debugger check code.

koraX 04-09-2004 13:06

Re: very simple debugging question (MSVC)
 
I've found it
Code:

        FILE *fp,*fp2;

      fp = fopen ("client.dll", "rb+"); // opens CLIENT.DLL file readonly
      if (fp != NULL)
      {
        fp2 = fopen ("client.bak", "wb"); // opens backup file for writing
        if (fp2 != NULL)
        {
            int c, count = 0;

            // get the size of the CLIENT.DLL file
            while ((c = fgetc (fp)) != EOF)
              count++;

            //  if it differs from the CS 1.3 original DLL size
/*            if (count != 655360)
            {
              printf ("CLIENT.DLL is not the genuine Counter-Strike 1.3 DLL. Patch cancelled.\n");
              return -1; // don't allow it to be patched
            }
*/
            rewind (fp); // return back to beginning of file
            while ((c = fgetc (fp)) != EOF)
              fputc (c, fp2); // duplicate client.dll to client.bak

            fclose (fp2); // close backup file

            fseek (fp, 191620L, SEEK_SET); // seek at the start of patch offset
            fputc (0x2B, fp); // actually patch client.dll (at offset 191620)
            fclose (fp); // close patched file

            printf ("Counter-Strike's CLIENT.DLL has been successfully patched.\n");
        }
      }
      else
        printf ("CLIENT.DLL not found in ../cstrike/cl_dlls. Patch cancelled.\n");

      return 0; // end of processing

but it does not work in CS 1.5. It crashes. Of course size of client.dll is different than 1.3. If only somebody would know the position of 'patch offset' in cs 1.5 ...

botman 04-09-2004 14:14

Re: very simple debugging question (MSVC)
 
Well, that's an easy problem to solve.

Download CS 1.3, rename it from .dll to .xxx and open it in the MS-DOS debugger. Look at the instruction at address 191620 (0x2EC84 in hex). You can just write down the 5 or 6 bytes at and after that location.

Then copy the CS 1.5 client.dll to "client.xxx" and load it in the MS-DOS debugger. Do a search for those same 5 (or 6) bytes. Do a disassembly at the address(es) displayed and see if they match up with the ones from CS 1.3.

When you find a match, modify the above source code to use the proper offset instead of 191620L.

P.S. If you don't know how to use the MS-DOS debugger, try searching on google.com for "ms-dos debug" or something similar.

botman

Whistler 05-09-2004 06:34

Re: very simple debugging question (MSVC)
 
Quote:

Originally Posted by botman
Well, that's an easy problem to solve.

Download CS 1.3, rename it from .dll to .xxx and open it in the MS-DOS debugger. Look at the instruction at address 191620 (0x2EC84 in hex). You can just write down the 5 or 6 bytes at and after that location.

Then copy the CS 1.5 client.dll to "client.xxx" and load it in the MS-DOS debugger. Do a search for those same 5 (or 6) bytes. Do a disassembly at the address(es) displayed and see if they match up with the ones from CS 1.3.

When you find a match, modify the above source code to use the proper offset instead of 191620L.

P.S. If you don't know how to use the MS-DOS debugger, try searching on google.com for "ms-dos debug" or something similar.

botman

That won't work. If you open the CS 1.5 or 1.6 client.dll you'll find it isn't DLL at all. Valve just encrypted it.

However CS 1.3 client dll does work with CS 1.5 mp.dll (although there are some weird problems with spectating).


All times are GMT +2. The time now is 00:20.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.