Alef/nocdkey – User

From Bohemia Interactive Community
Jump to navigation Jump to search
Line 8: Line 8:


===ws2_32.dll===
===ws2_32.dll===
To connect to the Internet, like all the other programs on Windows, ArmA uses a DLL called <tt>ws2_32.dll</tt>, that is a file installed in <tt>c:\windows\system32</tt>. If you put another file with the same name in the ArmA installation directory, ArmA will use that instead of the Windows one. It is the same like Armalib from Kegetys, which uses <tt>dsound.dll</tt> to inject custom code in the ArmA process address space.
To connect to the Internet, like all the other programs on Windows, ArmA uses a DLL called <tt>ws2_32.dll</tt>, that is a file installed in <tt>c:\windows\system32</tt>. If you put another file with the same name in the ArmA installation directory, ArmA will use that instead of the Windows one. It is the same like Armalib from Kegetys, which uses <tt>dsound.dll</tt> to inject custom code in the ArmA process address space.<br>
I've modified a program found online (see the [[#Links|links]] below), that intercept the functions ArmA does to connect other computers. One of these functions is <tt>[http://msdn.microsoft.com/en-us/library/ms738524(VS.85).aspx gethostbyname]</tt>, which is used to obtain an internet address given a name, like ''www.ofpec.com'' returns ''85.17.58.182''. Now, if ArmA asks for hosts in <tt>gamespy.com</tt> domain, to check for duplicated CD keys, if the address it's found and valid, the check will happens. This function is enables only if you use <tt>-host</tt> and <tt>-nocdkey</tt>. The server will get the message "No challenge value was received from the master server." when attempting to check for duplicated CD keys.
I've modified a program found online (see the [[#Links|links]] below), that intercept the functions ArmA does to connect other computers. One of these functions is <tt>[http://msdn.microsoft.com/en-us/library/ms738524(VS.85).aspx gethostbyname]</tt>, which is used to obtain an IP address given a name.<br>
The DLL will intercept all of the network functions. All of them, apart the one above, add an overhead for this to work. This overhead consists of a single <tt>jmp</tt> instruction without stack management (nacked), which I suppose should at least be long as a single CPU cycle, or less. So if you run a 3GHz CPU, the added delay should be 0,33 ns ([http://en.wikipedia.org/wiki/Nanosecond nanosecond], a billionth of second).
====How it works====
When ArmA asks for host names in the domain <tt>gamespy.com</tt>, in order to check for duplicated CD keys, if the address it's found and valid, the check will happens. If ''not'', the server will get the message <tt>"No challenge value was received from the master server."</tt>. My <tt>ws2_32.dll</tt> let the latter happens, but only if you use <b><tt>-nocdkey</tt></b> together with <b><tt>-host</tt></b> on the command line.
====Drawbacks====
The DLL will intercept all of the network functions made by ArmA. All of them, apart the one above, add an overhead for this to work. This overhead consists of a single <tt>jmp</tt> instruction without stack management (nacked), which I suppose should at least be long as a single CPU cycle, or less. So if you run a 3GHz CPU, the added delay should be <b>0,33 ns</b> ([http://en.wikipedia.org/wiki/Nanosecond nanosecond], a billionth of second).


==Legal==
==Legal==

Revision as of 15:32, 29 January 2009

nocdkey here doesn't mean you can play illegal copies with this plugin!

What is this?

This is a plugin to avoid the problems described here.

Gamespy

The CD key check will be skipped at least if the name for the gamespy servers are not found, or resolved. It doesn't simply mean you can force a different IP, like 127.0.0.1, editing your c:\windows\system32\drivers\etc\hosts.

ws2_32.dll

To connect to the Internet, like all the other programs on Windows, ArmA uses a DLL called ws2_32.dll, that is a file installed in c:\windows\system32. If you put another file with the same name in the ArmA installation directory, ArmA will use that instead of the Windows one. It is the same like Armalib from Kegetys, which uses dsound.dll to inject custom code in the ArmA process address space.
I've modified a program found online (see the links below), that intercept the functions ArmA does to connect other computers. One of these functions is gethostbyname, which is used to obtain an IP address given a name.

How it works

When ArmA asks for host names in the domain gamespy.com, in order to check for duplicated CD keys, if the address it's found and valid, the check will happens. If not, the server will get the message "No challenge value was received from the master server.". My ws2_32.dll let the latter happens, but only if you use -nocdkey together with -host on the command line.

Drawbacks

The DLL will intercept all of the network functions made by ArmA. All of them, apart the one above, add an overhead for this to work. This overhead consists of a single jmp instruction without stack management (nacked), which I suppose should at least be long as a single CPU cycle, or less. So if you run a 3GHz CPU, the added delay should be 0,33 ns (nanosecond, a billionth of second).

Legal

I suppose this is something legally doable, because BI already provided the way to work without checking for duplicated CD keys. If BI doesn't want this, I'll remove any reference to this work and notify the reachable forums and mirrors.

Links

Source

You get the full source in the distributed archive. This is the working code extracted from there:

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;
}

Where p_ is the original DLL function entry point and h_ the overloaded one.