I have a Windows program (exe) that was written in Delphi (Delphi 7 I think) several years ago and that program is still used occasionally. It contains a Single type variable that is multiplied by 0.9 at some point in the code.
I would like to change 0.9 to 0.8 right in the exe file using a hex editor and I need help to find the relevant part of the code to change.
The variable is declared as
private myValue: Single;
and when a button is clicked a component's edit value gets set to Round(myValue * 0.9)
procedure MyForm.buttonClick(Sender: TObject);
begin
if button.Down then
myEditComponent.EditValue := Round(myValue * 0.9);
end;
The value 0.9 is only used once in the whole code so I thought it should be easy to find it. I learnt that the hex representation of 0.9 as a DWORD should be 0x3f666666 but I could not find that value in the exe.
So it's either that I am wrong and 0.9 is represented with a different hex string or the compiler formulated this calculation in a different way (like myValue * 9 / 10 or some other way) or ..
Before you suggest that I recompile the project: I have the source code but it is a large project with several dependencies. The code relies on multiple component pack libraries and dozens of third party components. It could take a couple of days just to get and install an old version of Delhi and register all the components in order to recompile the code. Not something I would like to do for such a small change of an infrequently used program.
If I had Delphi installed I would just write these few lines of code and disassemble / debug it in order to see the assembly code. Having the assembly I could figure out what needs to be changed in the exe. I hope someone could point me in the right direction so I do not have to install an old version of Delphi.
Floating point literal constants are stored as 80-bit extended in the 32 bit versions of Delphi.
A value 0.9 is stored as 66 66 66 66 66 66 66 E6 FE 3F
For 0.8 replace it with CD CC CC CC CC CC CC CC FE 3F
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With