Jump to content

Trailing Zeros with Integer


Recommended Posts

Hi guys!

I tried lately to write some stuff at the end of a compiled .exe file (which is written in C if someone needs to know)

It's kind of a configuration GUI for the other programm, so I want to write a string and some integers behind the other stuff.

$SomeString=GUICtrlRead($inputfield)
$number1=GUICtrlRead($inputfield2)

$handle=FileOpen("test.exe", 1)
Filewrite($handle, $SomeString)
Filewrite($handle, BinaryString(StringLen($SomeString)))
Filewrite($handle, $number1)
Fileclose($handle)

So far so good. Now If I open the .exe with a HEX-Editor like WinHex or XVI32 it shows me this:

Hex: 6D 79 73 74 72 69 6E 67 08 00 00 00 D2 04 00 00 00 00 00 00

Dec: m y s t r i n g 8 zeros 1234 and again zeros

Well, it writes the string, ok

it writes the length of it, ok

it also writes my testnumber 1234

nut it just ads some stupid zeros behind it...

btw: i tried to write $number 1 with Int() or BinaryString() and even Formatstring() it doesnt' work

Can anyone explain how I can get these numbers without any zeros into the file?

Thank you very much for every answer.

Greetz tannerli

Link to comment
Share on other sites

From back in the day -

Func RawWrite($File,$Hex)
    If IsInt(StringLen($Hex)/2)=0 Then Return (-1)
    Local $a
    For $a=1 To StringLen($Hex) Step 2
        FileWrite($File,Chr(Dec(StringMid($Hex,$a,2))))
    Next
EndFunc

This was the function i used for writing binary, first arg is the filename or handle, second arg is a string of hex numbers ( "ED1AB6" or so). Remeber when you jus tsimply FileWrite() it does text.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...