Alef/nocdkey – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 19: Line 19:


Will post on OFPEC for beta, if someone interested, and on BI forum.
Will post on OFPEC for beta, if someone interested, and on BI forum.
<pre>
struct hostent* FAR(__stdcall h_gethostbyname)(__in const char *name) {
    using namespace std;
    static const string master("armedass.master.gamespy.com"), available("armedass.available.gamespy.com");
    static const wstring mhost(L"-host"), mnocdkey(L"-nocdkey");
    static bool host=false, nocdkey=false, argschecked=false;
    struct hostent* FAR rc = 0;
    if (!argschecked) {
argschecked=true;
LPWSTR *szArglist;
int nArgs;
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if( NULL != szArglist ) for(int i=0; i<nArgs ; ++i) {
if (!host)    host=(mhost.compare(szArglist[i]) == 0);
if (!nocdkey) nocdkey=(mnocdkey.compare(szArglist[i]) == 0);
}
LocalFree(szArglist);
    }
    if (host && nocdkey && name && (master.compare(name) == 0 || available.compare(name) == 0) ) {
p_WSASetLastError(WSAHOST_NOT_FOUND);
    } else {
rc=p_gethostbyname(name);
    }
    return rc;
}
</pre>

Revision as of 05:05, 6 December 2008

nocdkey here doesn't mean you can play illegal copies with this plugin!
This plugin simulate what you usually can do just dropping your connection to the internet using -host mode. You can't use kickduplicate=0 because the -config=server.cfg doesn't get read in -host mode.

This is a file called ws2_32.dll to put in the same arma.exe directory, and get enabled using -nocdkey and -host arguments on the command line. It will intercept the host name resolution for gamespy service, returning a "not found" answer. This is the same effect you can obtain disconnecting the network cable.

How to run 2 ArmAs on the same PC

Need a crafted ws2_32.dll, which returns WSAHOST_NOT_FOUND in gethostbyname() for armedass.master.gamespy.com or armedass.available.gamespy.com if -nokey is given on the server (-host) command line.

Editor/Server:
\ArmA\arma.exe -window -nosplash -world=empty -nopause -host -nokey

Client:
\ArmA\arma.exe -window -nosplash -world=empty -nopause -connect=localhost

The server will get the message "No challenge value was received from the master server."

Will post on OFPEC for beta, if someone interested, and on BI forum.

struct hostent* FAR(__stdcall h_gethostbyname)(__in const char *name) {
    using namespace std;
    static const string master("armedass.master.gamespy.com"), available("armedass.available.gamespy.com");
    static const wstring mhost(L"-host"), mnocdkey(L"-nocdkey");
    static bool host=false, nocdkey=false, argschecked=false;
    struct hostent* FAR rc = 0;
    if (!argschecked) {
	argschecked=true;
	LPWSTR *szArglist;
	int nArgs;
	szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
	if( NULL != szArglist ) for(int i=0; i<nArgs ; ++i) {
		if (!host)    host=(mhost.compare(szArglist[i]) == 0); 
		if (!nocdkey) nocdkey=(mnocdkey.compare(szArglist[i]) == 0);
	}
	LocalFree(szArglist);
    }
    if (host && nocdkey && name && (master.compare(name) == 0 || available.compare(name) == 0) ) {
	p_WSASetLastError(WSAHOST_NOT_FOUND);
    } else {
	rc=p_gethostbyname(name);
    }
    return rc;
}