Skip to content

Commit

Permalink
Readme + now you can host games.
Browse files Browse the repository at this point in the history
Because the previous version did not wait for the process to finish, it
was not possible to host games.
  • Loading branch information
serpi90 committed Jun 23, 2017
1 parent cf12506 commit acb70c6
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 55 deletions.
45 changes: 45 additions & 0 deletions Frozen Throne.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <windows.h>
#include <stdio.h>

#define MAX_COMMAND_SIZE 1024

int launchGame( char commandLine[] ) {
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInformation;
ZeroMemory( &startupInfo, sizeof( startupInfo ) );
startupInfo.cb = sizeof( startupInfo );
ZeroMemory( &processInformation, sizeof( processInformation ) );

/* Start the child process. */
if( CreateProcess( NULL, commandLine, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation ) ) {
printf( "Waiting for the process to finish ...\r\n" );
/* Wait until child process exits. */
WaitForSingleObject( processInformation.hProcess, INFINITE );
/* Close process and thread handles. */
CloseHandle( processInformation.hProcess );
CloseHandle( processInformation.hThread );
return EXIT_SUCCESS;
} else {
printf( "Failed to start the process (%d).\n", GetLastError() );
return EXIT_FAILURE;
}
}

int main( ) {
const char configFileName[] = "fakew3.txt";
char defaultCommandLine[] = "\"C:\\Program Files (x86)\\Warcraft III\\Frozen Throne.exe\" -window";
char commandLine[MAX_COMMAND_SIZE];
FILE * configFile = fopen( configFileName, "r" );

if( configFile == NULL ) {
return launchGame( defaultCommandLine );
} else if( fgets( commandLine, MAX_COMMAND_SIZE, configFile ) == NULL ) {
printf( "Error reading configuration file %s, using default %s\r\n", configFileName, defaultCommandLine );
fclose( configFile );
return launchGame( defaultCommandLine );
} else {
printf( "Starting %s\r\n", commandLine );
fclose( configFile );
return launchGame( commandLine );
}
}
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# FakeW3

Used to bypass around *GameRanger* limitation of not being able to launch *Warcraft III* in windowed mode.

To run *Warcraft III* in windowed mode you must pass the `-window` argument to the game, but *GameRanger* does not have an option for that. The solution was to take a program that requires no arguments, but launches the game in windowed mode.

This program attempts to read the command line to execute from a configuration file. If file is missing or there is an error reading it, then it will tttempt to use default *Warcraft III* location: `C:\Program Files (x86)\Warcraft III\Frozen Throne.exe`.

## Configuration

The configuration file **fakew3.txt** only has the command line to execute, using the full path to the game (and passing the required `-window` argument). Example:

```
"C:\Program Files (x86)\Warcraft III\Frozen Throne.exe" -window```

Please remember to wrap the path (but not the `-window` argument) with double quotes `"`, as shown in the example.

## Additional Files

Currently *GameRanger* requres an executable file named **Frozen Throne.exe** and a file named **War3x.mpq** to be present in the same folder to allow it to be selected as *Warcraft III: Frozen Throne*. An empty file with that name currently does the trick.

I have not tested it but my guess is that for *Warcraft III: Reign of Chaos* you need an empty file named **War3.mpq**, and rename this program to **Warcraft III.exe**
55 changes: 0 additions & 55 deletions fakew3.c

This file was deleted.

0 comments on commit acb70c6

Please sign in to comment.