General Question Changing a .dll file

Fearless

Member
Joined
Oct 16, 2007
Messages
56
Reaction score
2
Points
6
Hi all, I’m currently flying the Providence however as this ship doesn’t have a .ini file, I was wondering how I could increase the main’s fuel quantity.
It holds 150k.
It has a providence.dll file in the modules folder.

Can anyone advise how I can change the quantity from 150k to 350m?

Your assistance will be greatly appreciated.
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
204
Points
138
Location
Cape
One way (not easy) is to dock a tank to the vessel. Then you can use the fuel transferMFD, to transfer fuel if you need to.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Hi all, I’m currently flying the Providence however as this ship doesn’t have a .ini file, I was wondering how I could increase the main’s fuel quantity.
It holds 150k.
It has a providence.dll file in the modules folder.

Can anyone advise how I can change the quantity from 150k to 350m?

Your assistance will be greatly appreciated.

You can try to reverse-engineer it and find the machine code position where the 150k are set, then change it to whatever you want.

You could also write a module that uses the Orbiter API to change the fuel setting of the vessel.

In addition, there is the possibility to use the scenario editor with the IIRC generic "propellant" section that allows you to refuel the tank.
 

Fearless

Member
Joined
Oct 16, 2007
Messages
56
Reaction score
2
Points
6
You can try to reverse-engineer it and find the machine code position where the 150k are set, then change it to whatever you want.

You could also write a module that uses the Orbiter API to change the fuel setting of the vessel.

In addition, there is the possibility to use the scenario editor with the IIRC generic "propellant" section that allows you to refuel the tank.

Thanks for that. Yes I could use the scenario editor but as far as writing a module or reverse engineering is beyond me.
I opened up the .dll with hex editor but info made absolutely no sense to me.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Thanks for that. Yes I could use the scenario editor but as far as writing a module or reverse engineering is beyond me.
I opened up the .dll with hex editor but info made absolutely no sense to me.

Well, I didn't know about your level of expertise. Without the source code of the module you can't change it without reverse-engineering, and I assume that you don't have it.

In this case however, the thing is not that hard to do, especially if you already know what a hex-editor is and how you can change bytes with it. In principle you are searching for a single 8-byte combination and have to exchange it to another one. Chances are that you will find it only once, but it is possible that there are multiple occurrences. You can simply use trial-and-error to find the right one, always only changing one occurrence.

First, go here to convert the number into hexadecimal representation: http://www.binaryconvert.com/result_double.html

There you enter the number 150000, which will give you the hex-number 0x41024F8000000000. Now you have to reverse the byte order, because such constants are saved in little-endian in the code. It will give the byte sequence 00 00 00 00 80 4F 02 41 . Search for that in the hex editor. Once found, overwrite it with the byte sequence for your number (350000000=0x41B4DC9380000000= 00 00 00 80 93 dc b4 41). Save it (remember to make a copy of the original DLL) and try.

Now this will of course only work in standard coded vessel modules. If there is anything fancy going on in there, chances are you won't get far with this method. But most fuel mass settings are just using one constant, and that's where this should work.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
I think there is a much easier way to do it: LUA.

1) Be sure that in the launchpad - modules section the "LuaConsole" is ticked
2) open the sim and focus on your vessel
3) got to orbiter menu select function
4) in the window that opens select lua console window and press open.
5) in the window that opens write the following line by line and press enter each line:
Code:
v=vessel.get_focusinterface()
h=v:get_propellanthandle(0)
v:set_propellantmaxmass(h,350000000)
v:set_propellantmass(h,350000000)

that's it! close the lua console and enjoy

for a single scenario it should work. if you want it to be like this every time you open the scenario there are the mission scripts for lua that can be added, but I would do one step at the time and I would check if this is working before proceeding to the next step
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Code:
v=vessel.get_focusinterface()
h=v:get_propellanthandle(0)
v:set_propellantmaxmass(h,350000000)
v:set_propellantmass(h,350000000)

This is assuming that the first propellant resource is the one holding the discussed fuel mass. In most of the cases this would suffice, but it could be that the RCS fuel or some other thruster system is first created. Perhaps it would be good to first iterate over all handles and display the max mass of each one, so the index is known.

But there we are already into coding a module that uses the Orbiter API and I thought this to be a bit more complex to explain to a complete newbie than exchanging some bytes. As funny as it sounds, but for the given problem the hacking was easier :rofl: .

---------- Post added at 12:57 ---------- Previous post was at 12:45 ----------

BTW: if [ame="https://www.orbithangar.com/searchid.php?ID=3944"]this[/ame] is what is meant, the constant occurs only once at position 0x00003860 in the Providence.dll .
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,667
Reaction score
104
Points
78
This is assuming that the first propellant resource is the one holding the discussed fuel mass. In most of the cases this would suffice, but it could be that the RCS fuel or some other thruster system is first created. Perhaps it would be good to first iterate over all handles and display the max mass of each one, so the index is known.

yep, but for making a first test I thought that would be enough. if it doesn't work he could make a step into iterations. Personally I have very little confidence with bytes and this kind of stuff, so for me is much easier to write some lines in lua.

Also I have to say that I think that lua commands are a very good entry point for newbies to start to understand the orbiter APIs. I personally started there.
 

Fearless

Member
Joined
Oct 16, 2007
Messages
56
Reaction score
2
Points
6
Thanks all. The hex change procedure as advised by Face worked.
 
Top