Raised This Month: $ Target: $400
 0% 

SV_ConnectClient: get joining IP


Post New Thread Reply   
 
Thread Tools Display Modes
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-01-2014 , 00:30   Re: SV_ConnectClient: get joining IP
Reply With Quote #11

I created a memory file called netadr_ip then I tested:
PHP Code:
OrpheuMemoryGetAtAddressptr"netadr_ip"ip); 
I got:
Code:
L 04/01/2014 - 01:23:14: [ORPHEU] Invalid memory structure "netadr_ip"
L 04/01/2014 - 01:23:14: [AMXX] Displaying debug trace (plugin "test.amxx")
L 04/01/2014 - 01:23:14: [AMXX] Run time error 10: native error (native "OrpheuMemoryGetAtAddress")
L 04/01/2014 - 01:23:14: [AMXX]    [0] test.sma::OnNET_IsLocalAddress_Post (line 24)
I also tried:
PHP Code:
OrpheuMemoryGetAtAddressptr+4"int"ip); 
But hlds stopped working...
__________________

Last edited by Neeeeeeeeeel.-; 04-01-2014 at 00:30.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-01-2014 , 07:54   Re: SV_ConnectClient: get joining IP
Reply With Quote #12

Well, actually it won't work, we need value be a pointer. Don't think you can do something whatever Orpheu/Okapi, it would need something so we get some pointer to this structure.

So, we need to find another way.

Maybe trying to get directly net_from address. Though for windows going to be a pain.
It needs some more investigation.
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 04-01-2014 , 11:47   Re: SV_ConnectClient: get joining IP
Reply With Quote #13

Quote:
Originally Posted by Arkshine View Post
Well, actually it won't work, we need value be a pointer. Don't think you can do something whatever Orpheu/Okapi, it would need something so we get some pointer to this structure.

So, we need to find another way.

Maybe trying to get directly net_from address. Though for windows going to be a pain.
It needs some more investigation.
By changing:

PHP Code:
public OnNET_IsLocalAddress(ptr
to

PHP Code:
public OnNET_IsLocalAddress(ptr[16]) 
It gives many numbers, may that be something?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-01-2014 , 17:24   Re: SV_ConnectClient: get joining IP
Reply With Quote #14

Some progress. I've retrieved net_from address and I can retrieve IP. But not port. I'm not sure how to do it, we are supposed to read an short type.
About linux, it's untested, it should find "net_from" symbol. Under windows, I had to get SVC_Ping function address and retrieve net_from address inside function.
It may have a better way to get such address, will check later.

Using Okapi:

Code:
#include <amxmodx> #include <amxmisc> #include <okapi> enum net_adr {     type  = 0,       ip[4] = 4,     port  = 18   }; public client_connect( id ) // Of course use SV_ConnectClient instead. {     new data[ net_adr ];     okapi_get_ptr_array( getNetFromPointer(), data, net_adr);         log_amx( "type = %d", data[type] );     log_amx("value = %d.%d.%d.%d:%d", data[ip][0], data[ip][1], data[ip][2], data[ip][3], data[port]); } getNetFromPointer() {     static pointer;         if( !pointer)     {         // linux/osx         if( ( pointer = okapi_engine_get_symbol_ptr( "net_from" ) ) )         {             return pointer;         }         // Windows         new const SVC_PingSignature[] = { 0x55, 0x8B, 0xDEF, 0x83, 0xDEF, 0xDEF, 0x56, 0x57, 0x0C };         const SVC_PingSize = 0x44;             // Retrieve SVC_Ping start address.         new funcAddress = okapi_engine_find_sig( SVC_PingSignature, sizeof SVC_PingSignature );         if( funcAddress )         {             // Dump all function bytes             new bytes[ SVC_PingSize ];             okapi_get_ptr_array( funcAddress, bytes, sizeof bytes );                 // Try to find opcode: BE XXXX, where XXXX is the net_from offset.             new address = okapi_engine_ptr_find_byte_at( funcAddress, 0xBE );             if( address )             {                 return okapi_get_ptr_int( address + 1 );             }         }                 set_fail_state( "^"net_adr^" address could not found" );     }     return pointer; }
__________________

Last edited by Arkshine; 04-02-2014 at 06:22.
Arkshine is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 04-01-2014 , 20:18   Re: SV_ConnectClient: get joining IP
Reply With Quote #15

Would be the same in SV_ConnectClient instead of client_connect?

Edit: Nvm it worked on SV_ConnectClient, you rock.
__________________

Last edited by Neeeeeeeeeel.-; 04-01-2014 at 22:51.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 04-01-2014 , 22:56   Re: SV_ConnectClient: get joining IP
Reply With Quote #16

Quote:
Originally Posted by Arkshine View Post
Some progress. I've retrieved net_from address and I can retrieve IP. But not port. I'm not sure how to do it, we are supposed to read an short type.
About linux, it's untested, it should find "net_from" symbol. Under windows, I had to get SVC_Ping function address and retrieve net_from address inside function.
It may have a better way to get such address, will check later.

Using Okapi:
So with that skills you told me that you're a newbie? ahaha lool it worked, the port is bugged but we don't need it anyway, you did it again boy
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by Arkshine; 04-02-2014 at 06:05. Reason: Code removed since updated above
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2014 , 03:44   Re: SV_ConnectClient: get joining IP
Reply With Quote #17

Well, it's really not complicated. Just need IDA, you see net_from is used all the time. Under linux, it's easy as it's a symbol. Under windows, you have just to find some short function where it's used, then when you to the disassembled code, you see net_from is called like "BE XXXX". So, once you found that, just a matter to check what can do okapi as native, and that's it.

EDIT: code updated a bit ; I've tested now under linux. Linux doesn't like "assert" in a plugin.
__________________

Last edited by Arkshine; 04-02-2014 at 06:02.
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 04-02-2014 , 12:48   Re: SV_ConnectClient: get joining IP
Reply With Quote #18

Just a question, port may not work because you forgot to define this...

Code:
struct netadr_s {    netadrtype_t type;    unsigned __int8 ip[4];    unsigned __int8 ipx[10];    unsigned __int16 port; };

in sample plugin?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2014 , 12:51   Re: SV_ConnectClient: get joining IP
Reply With Quote #19

Did not forget, I think it's unused, just for padding.

From OSHLDS :

Code:
typedef struct netadr_s { //sizeof 20, 0x14.  This struct cannot be modified (damnation) for IPv6 support--mods use it.

   //The question on my mind is how can we fit an IPv6 address in here without breaking mods.
   netadrtype_t type;
   unsigned char ip[4]; //must be network order
   unsigned char ipx[10]; //HA-HAHAHAHAHAhahahaha still need it for padding
   unsigned short port;
} netadr_t;
__________________
Arkshine is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 04-02-2014 , 13:21   Re: SV_ConnectClient: get joining IP
Reply With Quote #20

Quote:
Originally Posted by Arkshine View Post
Did not forget, I think it's unused, just for padding.

From OSHLDS :

Code:
typedef struct netadr_s { //sizeof 20, 0x14.  This struct cannot be modified (damnation) for IPv6 support--mods use it.

   //The question on my mind is how can we fit an IPv6 address in here without breaking mods.
   netadrtype_t type;
   unsigned char ip[4]; //must be network order
   unsigned char ipx[10]; //HA-HAHAHAHAHAhahahaha still need it for padding
   unsigned short port;
} netadr_t;
So, if it's there just for padding, you'll have more reasons for adding it to the plugin *for padding* I think i didn't get the idea
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode