-- Produce exw31.exe, a version of eui.exe that uses 
-- Windows GUI version 3.1 instead of 4.0

include file.e
include get.e

constant new_version = {3,0,10}   -- {4, 0, 0} for 4.0

integer fn

procedure quit()
    if getc(0) then
    end if
    abort(0)
end procedure

system("del exw31.exe > nul", 2)
system("copy eui.exe exw31.exe > nul", 2)

fn = open("exw31.exe", "ub")
if fn = -1 then
    puts(1, "You need to run this from euphoria\\bin\n")
    quit()
end if

if seek(fn, #C8) != 0 then
    puts(2, "1st seek failed\n")
    quit()
end if

puts(2, "Patching:\n")
? get_bytes(fn, 3)

if seek(fn, #C8) != 0 then
    puts(2, "2nd seek failed\n")
    quit()
end if

puts(fn, new_version) 

puts(1, "To:\n")
? new_version
close(fn)

puts(1, "exw31.exe uses Windows GUI version 3.1\n")
puts(1, "Press Enter...\n")
quit()

