DeveloperGuide/GameConnectionDetection
(DeveloperGuide/GameConnectionDetection@groupWiki:goim) 458 Hits - Changes: 3 - Last Change: 2006-07-16 11:27:01 by Herbert Poul (Kahless) - [ History ] [ Latest changes ]To detect game connections there are currently two separate classes making use of the Java Native Interface to make calls to a small library programmed in C/C++.Both of the native code is located in the net.sphene.goim.netstat project. It contains a .dev file for both projects. (a dev-C++ project file - see: http://www.bloodshed.net/devcpp.html)
Netstat
The first native class is a netstat like implementation - java class: net.sphene.goim.netstat.NetStatIt has two native methods:- private native void nativeGetUdpPortsApps();
- protected native String[] getModulesFromProcess(long processId);
- protected void addUdpPortApp(int a,int b, int c, int d, int port, String path);
SniffUdpConns
As said before the responsibility of net.sphene.goim.sniffudpconns.SniffUdpConns is to sniff UDP packets which are sent or received on the local UDP port bound by a game.This class has one native method:- protected native String nativeStartSniffing()
/** * List of all connections, a 2 dimensional array. * the elements for one connection are the 4 bytes of an IP plus the port */ protected int[][] conns = new int[0][0];
- public void gotOutgoing(int id, long ip, int port, int sourceport);
byte ip[] = {
(ip >> 24) & 0xFF,
(ip >> 16) & 0xFF,
(ip >> 8) & 0xFF,
ip & 0xFF
};env->MonitorEnter( obj );
jobjectArray connsarray = (jobjectArray)env->GetObjectField(obj, fid_conns);
/* convert the java connsarray to a C++ int[][] */
env->MonitorExit( obj );| 0 Comments |
|---|
| You need to be logged in to post a Comment ! |