Unlimited objects in Battlecraft 1942

Ask questions, discuss ideas, get answers
Skull Kid
Posts: 173
Joined: Fri Aug 03, 2012 8:44 pm
Location: Sweden

Unlimited objects in Battlecraft 1942

Post by Skull Kid »

It seems I've been able to patch the Battlecraft 1942 executable (bc42.exe) with OllyDBG (a x86 disassembler) to load an unlimited amount of objects. So far, no error message, including the "more than 1024 objects, rest is truncated." or anything as such.

I don't know if there are any who will benefit from this, but I could post the patched bc42.exe here, if anybody's interested.
Regards,

Skull Kid
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Unlimited objects in Battlecraft 1942

Post by Diamondback »

Please do post it. I am however worried about the performance issues of going over the limit when you test the map.
See my Strasbourg map project here.
Skull Kid
Posts: 173
Joined: Fri Aug 03, 2012 8:44 pm
Location: Sweden

Re: Unlimited objects in Battlecraft 1942

Post by Skull Kid »

I found a problem though... when trying to select an object instead of "(None)", Battlecraft 1942 crashes... still want the executable? You will have to find a way to spawn new objects if you really need to I'm sorry to say. I will look into it. I used the x86 debugger OllyDBG to accomplish this.
Attachments
bc42_unlimited.zip
(760.25 KiB) Downloaded 497 times
Last edited by Skull Kid on Mon Oct 05, 2020 12:52 pm, edited 1 time in total.
Regards,

Skull Kid
duffman
Posts: 55
Joined: Tue Apr 15, 2014 8:02 am

Re: Unlimited objects in Battlecraft 1942

Post by duffman »

very Interesting...

I have had to do some nifty workarounds to be able to add x4 times as much contents on
a map. Mostly by splitting the StaticObjects.con into 4 different areas NE,SE,SW,NW etc (different files for BF1942 to load).

The limitation in BC1942 doesnt exist in BF1942 it will x4 that contents easy..

What did you find when debugging? hard-coded limit (value) set somewhere?

If it is a hard-coded value then there most likely is a second part to it, as in it will go like this:

(programmer sets: max_number_of_objects=1024)

allocate memory for "pointers" to 1024 objects <--- FIND THIS ONE AND INCREASE
if max_number_of_objects IS EQUAL 1024 then dont load more else we might crash <-- YOU FOUND THIS ONE

back in the day of 32bit a "pointer" its x4 bytes address to tell where the object is stored in memory.. a look-up list..
so the allocate memory for this table of "pointers" is actually x4 ... aka something like 4096 (0x1000)
there would be probably be a malloc (memory allocate call with that value somewhere that correspond to 1024
(but would look like x4 aka 4096) you found.. as in the allocated memory size only fits 1024...
but those limitations are not a problem today..)
learnmore info on malloc: https://www.cs.uaf.edu/2010/fall/cs301/ ... alloc.html

Not sure how much knowledge you have in asm and c/c++ and the debugger.. so wrote generically as easy as I could (hopefully it was helpful!).
If I had more time in my day I would loved to get my hands dirty right here..

Since you are debugging hard... the one biggest annoying thing about BC1942 (except the one above) is the damn
"loading/splash dialog" ... the first thing that pops up "battlecraft develop by bla bla" that sits there and waits for you to click it...
then finally loads the rest... find the "call" to that one and replace it with NOP's (No OPeration) or if you can make it go away instantly it would
soo make my day better... anyway I a big wish from me...

Well done on finding and patching that limit in the first place!!


Duffman
Skull Kid
Posts: 173
Joined: Fri Aug 03, 2012 8:44 pm
Location: Sweden

Re: Unlimited objects in Battlecraft 1942

Post by Skull Kid »

Hey, thanks Duffman :) Yes, I have mostly followed guides on YouTube. But I am now using x64DBG as OllyDBG doesn't work with 64-bit applications, and x64DBG is a little more convenient to use in my opinion.

I still cannot get all objects to load in Battlecraft 1942 though... in Forgotten Hope Secret Weapon, I load Alpenfestung-1945 for example, and I still get errors. the limit must be in the .lst file in Battlecraft 1942 as well, somewhere...

EDIT: Done! Here's the Battlecraft 1942 executable, without an object limit, or splash screen. Patched with x64DBG :)

EDIT2: Here's what I found in x64DBG, when I set to find the object limit.

First instruction
Second instruction

EDIT3: I fixed the Battlecraft 1942 executable from secretly crashing when shutdown, this is the final executable.
Attachments
bc42_unlimited_no_splash.zip
(760.26 KiB) Downloaded 439 times
Last edited by Skull Kid on Mon Jan 25, 2021 11:18 pm, edited 2 times in total.
Regards,

Skull Kid
Crash42modder
Posts: 71
Joined: Mon Feb 03, 2020 7:15 am

Re: Unlimited objects in Battlecraft 1942

Post by Crash42modder »

Interesting!
Diamondback
Posts: 589
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Unlimited objects in Battlecraft 1942

Post by Diamondback »

Good work Skull Kid!
See my Strasbourg map project here.
Skull Kid
Posts: 173
Joined: Fri Aug 03, 2012 8:44 pm
Location: Sweden

Re: Unlimited objects in Battlecraft 1942

Post by Skull Kid »

Thanks Diamondback!

I will try to see what causes Battlecraft 1942 not to load all objects from the .lst file. Currently, there must be one more limit...
Regards,

Skull Kid
Grabbi
Posts: 42
Joined: Wed Aug 03, 2011 3:37 pm
Location: Germany
Contact:

Re: Unlimited objects in Battlecraft 1942

Post by Grabbi »

wish we had this already 10 years ago !


Great job!


Best regards


Grabbi
[url=bf1942://85.214.226.169:14567]Image[/url]
Crash42modder
Posts: 71
Joined: Mon Feb 03, 2020 7:15 am

Re: Unlimited objects in Battlecraft 1942

Post by Crash42modder »

Nice. I'll test it later tonight.
Post Reply