Verifying match between Source.bas and Run.exe

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
MrBill
Newbie
Posts: 3
Joined: Thu Jan 29, 2009 4:09 pm
Location: NJ

Verifying match between Source.bas and Run.exe

Post by MrBill » Thu Jan 29, 2009 4:24 pm

I have been asked to modify a QB45 program. The author is deceased. The .exe program is used to generate some complicated manufacturing process parameters. I have a .bas module with the same name and a time stamp within seconds of the .exe, but when I compile it and compare the .exe to the original that is is production, they are not the same. I have tried the compile under XP, 95, and 98 which is where I think it was originally compiled, but I can not get a identical .exe to prove I have the correct source.bas. Any information about how the compile environment might affect the .exe that results from the compile would be appreciated.

User avatar
burger2227
Veteran
Posts: 2344
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Thu Jan 29, 2009 5:31 pm

Does the BAS run the same as the EXE? That's all that matters! QB's compiler naturally changes the code to machine code. Why would you try to read the EXE? Notepad or another editor will not display EXE code correctly anyhow.

With the time stamp, I would assume it is the correct BAS file.

Ted :roll:
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Thu Jan 29, 2009 8:19 pm

Some time ago, I tried what you are trying to do. The .EXE files were not the same.

Then I took a program of mine, compiled it, and saved the .EXE. Then I re-compiled the program again and compared the new .EXE to the one saved. The were not equal. Apparently, the compiler gives different results, I don't know exactly why. Maybe the compiler grabs different values for certain blocks of memory, which will be different on each compilation. However, the .EXE files run exactly the same, and as Ted says, that's what is important.

Regards..... Moneo

MrBill
Newbie
Posts: 3
Joined: Thu Jan 29, 2009 4:09 pm
Location: NJ

Post by MrBill » Fri Jan 30, 2009 9:28 am

As I mentioned this is a rather complex and complicated manufacturing process, and the cost of doing it wrong are high. Trying to test every path through the code would be a daunting task, so it is difficult to say if they run the same. The time stamps would suggest that I probably have the right source code... but you know the old saying about assuming.

markm
Coder
Posts: 14
Joined: Thu May 01, 2008 11:08 am

It's not just QBasic

Post by markm » Fri Jan 30, 2009 10:07 am

A few weeks ago, I had a similar question about a C program for a PIC microcontroller. Wrapped together in one folder were two .HEX files for programming the chips, two main programs, and numerous sub-modules of various dates. There wasn't even any information indicating what compiler had been used. (The free development system supplied by the PIC manufacturer only supported assembly language for the particular model, so that wasn't it.)

Hey, now I know why they fired that programmer!

User avatar
burger2227
Veteran
Posts: 2344
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Fri Jan 30, 2009 2:25 pm

Well.........If you cannot test the program with fake readings then I suggest you don't mess with it! All you can do is mess it up.

The BAS file should be capable of doing the SAME things that the EXE does. It should be tested in REAL conditions before any alterations are made to it. What exactly is wrong with the old EXE?

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Fri Jan 30, 2009 9:17 pm

MrBill, it is possible that the original EXE may have different libraries linked in. Also, one might be compiled for use with BRUN45, and the other standalone. These two details can produce EXEs of different sizes. How large of a discrepancy are you talking about though?

MrBill
Newbie
Posts: 3
Joined: Thu Jan 29, 2009 4:09 pm
Location: NJ

Post by MrBill » Mon Feb 02, 2009 9:46 am

It was definitely compiled to run stand alone without debug? that is the only way the size will come out right. As a matter of fact when I do the compile stand alone I get the exact same size? there are just a few dozen bytes toward the end, scattered among the literals (readable print characters) that are different. I would love not to mess with it, but there are things that need to be done. I am ok with the changes that I will make, but I am concerned that some other unintended change may be introduced if I don?t have the correct source. In an attempt to reproduce the environment in which the original .exe was compiled I went back to the PC on which the source .bas was found and compiled it there, but still the differences. I have no idea what may have changed on the PC since the production .exe was created in 2004, or if it is the same PC. There is also a .obj that is created during the compile? what is its role in this process?

User avatar
burger2227
Veteran
Posts: 2344
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Mon Feb 02, 2009 1:22 pm

OBJ files are created after every compile. OBJ files can be used to create QB libraries. I usually just delete them.

Ted
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt » Mon Feb 02, 2009 6:35 pm

The OBJ files are the object code that the compiler generates. They're used at the link phase to produce the final executable. Once the EXE is built, you no longer have a need for them, and can delete them.

moneo
Veteran
Posts: 451
Joined: Tue Jun 28, 2005 7:00 pm
Location: Mexico City, Mexico

Post by moneo » Mon Feb 02, 2009 8:38 pm

I wouldn't waste any more time trying to figure out the differences with the .EXEs. The minute you start making any needed modifications to the source code, the program will be your total responsibility from then on.

I would start out by doing some good testing with the original .EXE to learn how the program operates. Hopefully you have some specifications on the program. Then start making some changes, compiling, and testing again, to make sure that your changes didn't screw something up. Good luck.

Regards..... Moneo

iamdenteddisk
Veteran
Posts: 185
Joined: Mon Jun 30, 2008 4:10 pm

suggestion

Post by iamdenteddisk » Fri Feb 06, 2009 5:54 pm

I found this works like the checksum on an eprom, this size difference is caused by fragmentation in the pagefile meaning you have to view a bigger chunk than is nessicery to contain the file durring compile so you need to fix it so that the compile happens in a relitivly free memory perhaps freeing up some resources by closing progs on the bottom right of the screen or by using start run config or msconfig.exe.

two options
1 compile on a relitivly empty machine after defragmenting religiously for a few days till it says theres nothing to defrag. this might work streight up.

2 if the file is smaller than is required you can allocate more memory from the program untill you hit the perfect mark..

if neither of these works out you may need to write a program to allocate memory for the compile and convert it to qlb and include it after.
there is a basic source file that exist out there somewhere I used once prewritten for this unfortunatly I don't remember its name.

Im guessing you are attempting a TSR?

Good luck!

User avatar
burger2227
Veteran
Posts: 2344
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Wed Mar 11, 2009 8:09 pm

Hogwash! GO AWAY.........
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Post Reply