Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > General Questions & Help
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

General Questions & Help General & Advanced Orbiter flight questions, Orbiter installation questions, to all other help topics here.

Reply
 
Thread Tools
Old 02-11-2019, 05:33 AM   #1
Fearless
Orbinaut
Default Changing a .dll file

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.
Fearless is offline   Reply With Quote
Old 02-11-2019, 05:52 AM   #2
Donamy
Beta Tester


Default

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.
Donamy is offline   Reply With Quote
Old 02-11-2019, 07:58 AM   #3
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by Fearless View Post
 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.
Face is offline   Reply With Quote
Old 02-11-2019, 08:57 AM   #4
Fearless
Orbinaut
Default

Quote:
Originally Posted by Face View Post
 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.
Fearless is offline   Reply With Quote
Old 02-11-2019, 09:51 AM   #5
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by Fearless View Post
 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.
Face is offline   Reply With Quote
Thanked by:
Old 02-11-2019, 11:05 AM   #6
fred18
Addon Developer

Default

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
fred18 is offline   Reply With Quote
Old 02-11-2019, 11:57 AM   #7
Face
Beta Tester
 
Face's Avatar

Default

Quote:
Originally Posted by fred18 View Post
 
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 .

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

BTW: if
this
is what is meant, the constant occurs only once at position 0x00003860 in the Providence.dll .
Face is offline   Reply With Quote
Thanked by:
Old 02-11-2019, 12:05 PM   #8
fred18
Addon Developer

Default

Quote:
Originally Posted by Face View Post
 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.
fred18 is offline   Reply With Quote
Thanked by:
Old 02-12-2019, 02:23 AM   #9
Fearless
Orbinaut
Default

Thanks all. The hex change procedure as advised by Face worked.
Fearless is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > General Questions & Help


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 06:39 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright ©2007 - 2017, Orbiter-Forum.com. All rights reserved.