Battlefield 3 Alpha


Notes for myself - 07/31/11


I got bored with playing the same level. Started messing around. A lot 
of good info is in "initfs_Win32"...

Created shortcut to bf3.exe with "-server -platform win32" and I now have my own server in 
"Conquest" mode (not "Rush" as all other server):


Here's proof it actually works and shows up on the Multiplayer Servers listing (my hostname is "SEVEN"): Since I can't fire up two instances of bf3.exe I had a friend test. He confirmed he can access my server. Not enough players so he couldnt actually play, but was able to "ghost" and fly around the map. I didn't have to do any port-forwarding or magical network configs. It fires up, authenticates as a server and just works! The "-server" interface shows some basic stats including my GameID but I can't figure out any commands (tried EVERYTHING). Unknown use. Probably missing some trigger to actually start the admin interface.
Created shortcut to bf3.exe with "-thinClient 1" as argument and got this:


Not sure what it does. Added "testingEnabled 1" as argument, same thing. No "commands" in the 
prompt work. The game just errors out after a while. Added requisite arguments to connect to a 
valid game, same issue. Unknown use.


Various random notes:
PID: 4792, Command line: "C:\Program Files (x86)\Origin\Origin.exe" 
"origin://LaunchGame/71170?Title=BF3%u0020Alpha%u0020Trial&ProductId=DR:229644500&CommandParams=-defaultConfig%20Game.cfg%20--debug%20-verbose"
^-- IIRC this is trigger from the Origin client to fire up the game (I modified it with my arguments, to no avail).

PID: 3624, Command line: "C:\Program Files (x86)\BF3 Alpha Trial Web Plugins\esnlauncher.exe" 
NO#!#SW_SHOWNA#!#C:\Program Files (x86)\Origin Games\Battlefield 3 Alpha Trial\bf3.exe#!#bf3.exe  -super layout.toc 
-skipFastLevelLoad 1 -VeniceOnline.EnableSnowroller 1 -Window.Minimized 1 -Blaze.Service battlefield-3-pc-trial 
-sonarInstance battlefield.com -Online.Environment OnlineEnvironment_Production -loginToken  -requestState State_ClaimReservation -requestStateParams "\">" #!#C:\Program Files 
(x86)\Origin Games\Battlefield 3 Alpha Trial\

^-- "esnlauncher.exe" is actually what is called/triggered by the browser plug-in to fire up bf3.exe (with practically 
the same arguments). I've bolded some interesting things. Login token seems to change at least a few times a day, new 
one needs to be caught with either ProcExp or my EXE replacement "BF3-Arg-Catcher.exe"->"bf3.exe" (just reads incoming 
app arguments and spits them back out telling you what args were called while starting said EXE). "personaref" is just 
your account/gamer ID. View the source of the Multiplayer page and you can find yours. 

I created a batch script (this is Windows after all) to 

Here is a better representation of the args sent to ESNLAUNCHER.EXE:

Arg[0] = [NO#!#SW_SHOWNA#!#C:\Program]
Arg[1] = [Files]
Arg[2] = [(x86)\Origin]
Arg[3] = [Games\Battlefield]
Arg[4] = [3]
Arg[5] = [Alpha]
Arg[6] = [Trial\bf3.exe#!#bf3.exe]
Arg[7] = [-super]
Arg[8] = [layout.toc]
Arg[9] = [-skipFastLevelLoad]
Arg[10] = [1]
Arg[11] = [-VeniceOnline.EnableSnowroller]
Arg[12] = [1]
Arg[13] = [-Window.Minimized]
Arg[14] = [1]
Arg[15] = [-Blaze.Service]
Arg[16] = [battlefield-3-pc-trial]
Arg[17] = [-sonarInstance]
Arg[18] = [battlefield.com]
Arg[19] = [-Online.Environment]
Arg[20] = [OnlineEnvironment_Production]
Arg[21] = [-loginToken]
Arg[22] = [HERP DERP] <-- Login Token Hash
Arg[23] = [-requestState]
Arg[24] = [State_ClaimReservation] <<-- Fail here... more later...
Arg[25] = [-requestStateParams]
Arg[26] = [
]
Arg[27] = [#!#C:\Program]
Arg[28] = [Files]
Arg[29] = [(x86)\Origin]
Arg[30] = [Games\Battlefield]
Arg[31] = [3]
Arg[32] = [Alpha]
Arg[33] = [Trial\]

Above is the exact format of the arguments sent to "esnlauncher.exe", they must be reproduced exactly for the game to 
launch (more later). 

Next up, bf3.exe is called by esnlauncher.exe with pretty much the exact same arguments other than the junk in Arg[0]:

PID: 6000, Command line: "C:\Program Files (x86)\Origin Games\Battlefield 3 Alpha Trial\bf3.exe" bf3.exe  -super 
layout.toc -skipFastLevelLoad 1 -VeniceOnline.EnableSnowroller 1 -Window.Minimized 1 -Blaze.Service 
battlefield-3-pc-trial -sonarInstance battlefield.com -Online.Environment OnlineEnvironment_Production -loginToken 
 -requestState State_ClaimReservation -requestStateParams "\">" 

NOTES ON PROCESS:

1) Browser plugin cals ESNLAUNCHER.EXE with args
2) This calls BF3.exe with similar args
3) This starts EACoreServer.exe with:
Arg[0] = [-CoreServerId=::Access3Test]
4) Game starts.

So the obvious step is to skip the browser multiplayer game finder thingy and do it from my local machine. Created a 
batch script to start ESNLAUNCHER.EXE (because skipping this and starting bf3.exe with proper args FAILS).
It took me a few tries to get the batch script right because Windows sucks so much ass and I didn't feel like going 
with PowerShell at this point as I was on a roll...

Created "esnlauncher.bat" with this exact format:

esnlauncher.exe NO#!#SW_SHOWNA#!#C:\Program Files (x86)\Origin Games\Battlefield 3 Alpha Trial\bf3.exe#!#bf3.exe 
-super layout.toc -skipFastLevelLoad 1 -VeniceOnline.EnableSnowroller 1 -Window.Minimized 1 -Blaze.Service 
battlefield-3-pc-trial -sonarInstance battlefield.com -Online.Environment OnlineEnvironment_Production -loginToken 
 -requestState State_ClaimReservation -requestStateParams """>" #!#C:\Program Files (x86)\Origin Games\Battlefield 3 Alpha Trial\

So... this .bat (run as Administrator) calls "esnlauncher.exe" with the args I found in the proper format with the 
proper token and gameid 
(found in HTML source of Multiplayer page on Battlelog).

The first few tries failed with "Server disconnected unexpectedly" (shown in the browser's GAME MANAGER), I wasn't 
sure why but I decided to dig around bf3.exe.

I changed the "-requestedState State_ClaimReservation" to "-requestedState ConnectToGameId" and it WORKS! This changes 
the connection process from "Log in, Join server, Check for # of players, Reserve slot, connect, load 
level" to just 
"Login, Check # 
of players, connect, load level., join game" I don't know why, but this was a necessary change.

So, now I can connect directly to a game assuming:
1) The LoginToken is correct
2) The GameID is correct
3) The server is not full (happens often...)

Even with all these proper settings I'd constantly get "Server disconnected unexpectedly. Do you have the latest 
version of the game?" from the "GAME MANAGER" plug-in, just keep trying and it works. Or pick a different game id.

Whats the point of this? To learn how this stuff works I guess... and see what we can do after the trial is over ;) 
Also now that we can MANUALLY start the game, we can pass MORE command line arguments to it! 

But thats where the problems start. No command line arg's that I passed seemed to work other than "-debug -verbose" 
which, when I attached to bf3.exe process with WinDbg, seems to spit out a bit more "debug" info into the command 
watch window. Standard Break/Attach/Reg/Mem watch stuff... I'm not looking to cheat at this game, thats boring. But 
its nice to know I can attach to the process and not have it crap itself, even though it DOES seem to have code to 
check "IsDebuggerRunning" ;)



08/01/11 - Got my own server and client running on one PHYSICAL machine...

Created Win7 x64 VM in VirtualBox. Installed Origin. It downloaded and installed BF3, new version (old=749691, new=760867). New version has no "-server" option as expected. Copied OLD exe over to the VM, replaced bf3.exe. Server now running in VM. I even get a GameID. Fired up my bf3-ESNLAUNCHER.bat on local machine with correct GameID.. AND IM IN! Flying around... as a ghost... with no HUD. Just like what my friend saw when I had him connect... 5 minutes later... the Frostbite client dies. The server loses GameID... I restart the server... no GameID... I dont know what happened... but I cant get a GameID anymore. Sadness. -roto