You are not logged in.

#1 21 Feb 2008 6:53 am

winsr
Extreme Member
Registered: Mar 2007
Posts: 90

GSLIST how does it works?

Hi guys, i was wondering, how does GSLIST does to retreive the list of available gamespy servers? or is there a way to do a wrapper of this program that works with php????

Offline

 

#2 21 Feb 2008 8:33 am

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: GSLIST how does it works?

I haven't really looked at it.  there's already a port of it out there for php: http://sanity-free.org/binary/gslist_php.zip.  the gslist app comes w/ its source code, though its pretty cryptic IMO, you can get that here: http://sanity-free.org/binary/gslist.zip.  I believe I did a wrapper of it at some point in .NET (I'll have to search around though)

Offline

 

#3 21 Feb 2008 8:42 am

winsr
Extreme Member
Registered: Mar 2007
Posts: 90

Re: GSLIST how does it works?

yeah, got that .net wrapper you did... since... well, you did it for me... jejeje... long time ago, and has been the base of my server querys all along. (by the way, did you know you are on the credits of my app...wink)

ill check that php port you did... migth come out handy.

Offline

 

#4 21 Feb 2008 9:53 am

winsr
Extreme Member
Registered: Mar 2007
Posts: 90

Re: GSLIST how does it works?

wow... that port, its one heck of a complicated code... wow....hmm (but if i managed to convert the php code from the bf2142 encription, then i guess ill be able to do it with this one too).  cool

i have also found this code thats done on vb.net (code at the end), im lacking a couple of dlls this guy is using, but im going to fill that hole with the php code you just left me, and heck im going to do one hell of a mess here. tongue

and please all note that i dont know php... at all.... man...i just love challenges... so, hand on the crap and let the stink fest begin... wink

Offline

 

#5 21 Feb 2008 12:28 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: GSLIST how does it works?

well yea.  thats what you get when you can translate code from one language to another.  not knowing exactly what they're doing but trying to replicate that in PHP makes for some ugly translations.  It gets even worse as those translations get translated to other languages without being refactored.

I don't know how well you know C++ but you may be better off, creating a new dll as a C++ assembly then using C++/CLI to wrap the C code into something you can load into visual studio (add a reference to) and use it like a normal dll.  it may take some editing (like changing printf's to return strings or something) of the original C code, but it may be easier than porting that php code to vb.

Offline

 

#6 21 Feb 2008 12:50 pm

winsr
Extreme Member
Registered: Mar 2007
Posts: 90

Re: GSLIST how does it works?

actually i like porting things to its native form.... normally works good, and i learn a LOT!!!,

ok, thats what im doing right now, and im porting php to vb, and here are some questions ive got so far... im going to put the actual code lines:

on this line:

Code:

$num = ($num + $enctmp[$i] + ord($key[$i % $keysz])) & 0xff;

what does the ord function does?,
when you do "$i % $keysz" what are you doing here?

on this line

Code:

$size /= 3;

what are you doing here? initializing the value with the same divided by 3.. so it will be something equal to size = size /3?

i also have this block of code:

   

Code:

$dst='';
    $size /= 3;
    $i=0;
    while($size--) {
        $x = $zob[$i++];
        $y = $zob[$i++];
        $dst .= gsvalfunc($x >> 2);
        $dst .= gsvalfunc((($x & 3) << 4) | ($y >> 4));
        $x = $zob[$i++];
        $dst .= gsvalfunc((($y & 15) << 2) | ($x >> 6));
        $dst .= gsvalfunc($x & 63);
    }
    return $dst;

what are you doing when you do while($size--) ;? my guess is that you are decrementing size by 1 on the first one, and looping until it reaches 0, so it something like

Code:

do while size <> 0 :  step -= 1

And where you do $x = $zob[$i++], you are using the incremented value of "i", or the normal one and then incrementing? does this increment stays in the variable, as if i do something like

Code:

$i++
$x = $zob[$i]

i know this might sound as totally... NOOB questions, but hey... im learning on the go jejeje.

Offline

 

#7 21 Feb 2008 1:38 pm

MadHatter
Administrator
From: Dallas TX
Registered: Jun 2006
Posts: 529
Website

Re: GSLIST how does it works?

you'll grow to love http://php.net.  its has great documentation. 

  • ord returns the ascii value of a character.
  • % is a modulus operator (returns the remainder of the division operation)
  • yes the op= is the same as saying $size = $size / 3;  this works for all your binary operators (+= -= *= /= ^= &= and so on)
  • values greater than 0 are implied true, so yes, while($size--) runs the loop, and on each iteration, decrements size.  ++ increments -- decrements.
  • the ++ and -- operators increment / decrement in the order they are placed $val = $array[$i++]; will return the element @ the index of $i, then increments the value.  conversely $val = $array[++$i]; will increment the value and then return the element at the new index value.  the difference is called pre vs post increment / decrement. pre-increment increments then takes the value, post increment takes the value then increments the value. it saves you 1 line of code somewhere.  its an old C habbit that folks tend to love to hang on to.  actually $i++ is more efficient than $i = $i + 1 because the cpu has a built in inc / dec instruction so the operation is done in 1 tick where as the $i = $i + 1 is an addition instruction then the value has to be pushed into the computer register and pushed onto $i.  thats only the case in increment / decrement operations.
  • Offline

     

    #8 21 Feb 2008 1:39 pm

    winsr
    Extreme Member
    Registered: Mar 2007
    Posts: 90

    Re: GSLIST how does it works?

    holy lots of information.... jejeje. working in changing code... buajaja.... thanks for the info... will come back when more comes out

    Last edited by winsr (21 Feb 2008 1:42 pm)

    Offline

     

    #9 21 Feb 2008 2:08 pm

    winsr
    Extreme Member
    Registered: Mar 2007
    Posts: 90

    Re: GSLIST how does it works?

    here goes another one, looking at this code

    Code:

    function enctype2_decoder(&$key,&$data,$size)
    {
    
    $s="\0";
    for($i=0; $i<326*4; $i++) $s.="\0";
    $dest= new IntPtr(new UberString($s));
    
        $data[0] = $data[0] ^ 0xec;
    
        $datap = new BytePtr($data->uber,$data->shift + 1);
    
        for($i = 0; $key[$i]; $i++) $datap[$i] = $datap[$i] ^ $key[$i];
    
        encshare4($datap, $data[0], $dest);
    
        $datap->shift += $data[0];
        $size -= ($data[0] + 1);
        if($size < 6 )    return;
    
        encshare1($dest, $datap, $size);
    
        $size -= 6;
        return array($datap,$size);
    }

    what does IntPtr and BytePtr stands for?

    Actually... to be honest... what the hell is this line doing, i have been going around it for hours now, and i have totally no idea.

    Code:

    $datap = new BytePtr($data->uber,$data->shift + 1);

    create variable datap, as new BytePtr, and looks line an array of data moved to uber? and data moved to shift +1??? weird code.

    i know you are  laughing after that kind of parsing i tried to do up there, but really, what the heck does it means?

    Last edited by winsr (21 Feb 2008 2:10 pm)

    Offline

     

    #10 21 Feb 2008 4:12 pm

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    I cant say for sure, but most likely IntPtr and BytePtr are objects (pointers 32 and 8 bits wide) that store some information.  since the data is being passed around like it is, I would guess its so that they can deal with one piece of information instead of passing everything by value (guess).

    find the class file for BytePtr and look at its constructor signature.  that should shed some light on what the parameters are for. I'm guessing its assigning some part of uberstring to the byte pointer (typically variables that end in p signify that they are pointers to some object in memory), most likely to keep from having to shift bits around.

    if I get a chance (slim as it may be) I'll see if I cant take a look at the PHP code to get a better idea.

    Offline

     

    #11 22 Feb 2008 12:51 pm

    winsr
    Extreme Member
    Registered: Mar 2007
    Posts: 90

    Re: GSLIST how does it works?

    i found those missing function, i just need to figure out what the do tongue

    Code:

    class IntPtr extends ArrayObject
    {
        public $uber;
        //le shift est en octets
        public $shift;
        
        public function __construct($uber,$shift=0){
            $this->uber = $uber;
            $this->shift=$shift;
        }
    
        public function getIterator(){return new ArrayObjectIterator($this);}
        public function count(){return $this->uber->countInt();}
        public function offsetExists($i){return $this->uber->intOffsetExists($this->shift+$i*4);}
        public function offsetGet($i){return $this->uber->getInt($this->shift+$i*4);}
        public function offsetSet($i,$a){return $this->uber->setInt($this->shift+$i*4,$a);}
    }
    class BytePtr extends ArrayObject
    {
        public $uber;
        //le shift est en octets
        public $shift;
        
        public function __construct(&$uber,$shift=0){
            $this->uber = $uber;
            $this->shift=$shift;
        }
        public function getIterator(){return new ArrayObjectIterator($this);}
    
        public function count(){return $this->uber->countByte();}
    
        public function offsetExists($i){return $this->uber->byteOffsetExists($i);}
        
        public function offsetGet($i){return $this->uber->getByte($i+$this->shift);}
        public function offsetSet($i,$a){return $this->uber->setByte($i+$this->shift,$a);}
    }

    Offline

     

    #12 24 Feb 2008 6:15 pm

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    UberString is his own string class implementation.  IntPtr is an array object that works on 4 bytes at a time, BytePtr is an array object as well that works on a byte for byte level.

    it looks like he uses it to simplify some of the original C code that works with 4 bytes at a time, and 2 bytes at a time.

    Offline

     

    #13 12 May 2008 2:41 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Hey!

    Can you help me maybe with that script?
    It is not working on 64bit systems sad
    I cannot get help anywhere... nobody knows how to upgrade the bit-operation functions so that they are working
    with 32bit and 64bit aswell.
    I mean this script:

    "Gsmsalg PHP Port by jan0" ( http://pr0g.free.fr/gamespy/gslist.zip )

    Can anyone help me?
    Thanks!
    Greets

    Offline

     

    #14 12 May 2008 1:55 pm

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    I would assume that the 32 bit version would work the same on a 64 bit version, but I'll have a look when I can.

    encshared.php contains the shifting logic.  the sizes of the integers they are working with are hard coded for 32 bits (both signed and unsigned) so it should work fine but I've only looked at it for a second and could have missed something.

    Offline

     

    #15 13 May 2008 3:20 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Hey!

    Would be very great if you could have a look at it. I have arranged the code more clear:

    http://rhonkar.kilu.de/gsquery.rar

    wink

    Here, it is not working (Webhoster):
    PHP_VERSION=5.1.6
    PHP_OS=Linux
    PHP_INT_MAX=9223372036854775807
    PHP_INT_SIZE=8
    +1 -> -9223372036854775808
    - -> -9223372036854775807
    -1 -> -9223372036854775808
    L -> dcba
    N -> abcd
    V -> dcba


    And here, it works (XAMPP Local):
    PHP_VERSION=5.2.5
    PHP_OS=WINNT
    PHP_INT_MAX=2147483647
    PHP_INT_SIZE=4
    +1 -> -2147483648
    - -> -2147483647
    -1 -> -2147483648
    L -> dcba
    N -> abcd
    V -> dcba

    //EDIT:
    Not working - Means all the IP's and ports are wrong. See here:
    http://rhonkar.kilu.de/test/index2.php

    Ports should all be 15425 (some 15426, 15427, ..).

    Thanks a lot!
    Greets

    Last edited by Atako (13 May 2008 7:54 am)

    Offline

     

    #16 13 May 2008 9:40 am

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    ah, now that makes sense.  the uberconteneur.php is based on the premise that its working with 32 bit values.

    inverse_byte_order assumes 32 bit values (and only inverses 32 bits)
    UberString does as well for set/getInt
    IntPtr uses a hardcoded PHP_INT_SIZE (he uses the literal value 4 instead of the macro) in offsetExists / offsetGet & offsetSet

    I don't have time at the moment to change / test it, but will try to later.

    Offline

     

    #17 13 May 2008 9:59 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    You are my only hope roll
    I would even pay you if you could get that working on 64bit as it is very important for my clan site.
    Is there a way to make it compatible to 32 and 64 bit?

    Thanks in advance.
    Greets

    Offline

     

    #18 13 May 2008 12:03 pm

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    lol, I'll try.  there is a way to do it for 32 and 64 bit both, but we'll see.

    Offline

     

    #19 01 Jul 2008 10:16 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Hey, it's me again!

    Some progress maybe? neutral

    Thanks!
    Greets

    Offline

     

    #20 01 Jul 2008 12:14 pm

    MadHatter
    Administrator
    From: Dallas TX
    Registered: Jun 2006
    Posts: 529
    Website

    Re: GSLIST how does it works?

    I've worked on it a little bit, but I've been extremely busy at work.  Friday we finished a demo for our investors, but a week ago we had a baby boy.  I've gone over the shifting functions and they seem to be working fine, but I haven't started looking over the encshare functions yet.

    sorry its taking so long.

    Offline

     

    #21 06 Nov 2008 8:07 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Hey!

    I just want to tell you that I still need the script.
    No matter how long it will take.

    Thanks a lot anyway!

    Offline

     

    #22 08 Nov 2008 3:08 pm

    Butcher
    Moderator
    From: Norway
    Registered: Jul 2006
    Posts: 308

    Re: GSLIST how does it works?

    Congratulations on the son and the demo MadHatter! How does it feel?

    On the script being discussed here, are you trying to get something up on a website Atako?


    http://bamboocommandos.com/butcher_img/butchersig7.jpg

    Offline

     

    #23 24 Nov 2008 8:31 am

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Hello!

    Yes, I would like to use this script for my website: http://rhonkar.kilu.de/gsquery.rar
    But it only works on 32bit, not on 64bit.

    Thanks in advance.

    Offline

     

    #24 24 Nov 2008 10:53 am

    Butcher
    Moderator
    From: Norway
    Registered: Jul 2006
    Posts: 308

    Re: GSLIST how does it works?

    Just to get the obvious stuff out of the way:
    What sort of website do you have? Linux? Windows?

    The script you link to, how is it set up? When using it I just get a long list of IPs and Ports, which I assume are from gamespy. Do you have a live example of what stats you want to show, and from what game?


    http://bamboocommandos.com/butcher_img/butchersig7.jpg

    Offline

     

    #25 24 Nov 2008 12:55 pm

    Atako
    Member
    Registered: Apr 2008
    Posts: 10

    Re: GSLIST how does it works?

    Please have a look at post #15.
    I have explained there.

    The ip's and ports are all wrong on 64bit. The ports should all be 1542x.

    Thanks.

    Offline

     



    © 2003 - 2017 NullFX
    Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License