Skip to content

Posts from Programming

5.0 (1 rating)
User Avatar
10 years ago
Auto-translated
I can't verify the correctness of the test.com program. I don't know assembly language well. Write a program in C/Pascal/Delphi that opens a file as text and copies the data where it needs to go. In the case of Pascal/Delphi, these are standard tools like readln, etc. I've already done this, and it's not difficult.
User Avatar
10 years ago
Auto-translated
By the way, you don't have to write anything. I just checked that Hex Editor in Insert Mode works perfectly well for deleting/inserting bytes. All .exe files in Windows start approximately the same way:
Attachments 1
1 file attached • Total size: 20.1 KB
User Avatar
10 years ago
Auto-translated
The program, which is supposed to copy all bytes starting from the 33rd, should be very small, which is why assembly language is used. And it copies everything correctly! The problem isn't that it copies incorrectly, but that even after it correctly copies the files Folder1\test.exe and Folder2\test.exe, they will be different, even though they have the same content and the same name.
User Avatar
10 years ago
Auto-translated
I don't believe it. Let me compare myself;)
Unless it's these points:
After that, it was opened in a text editor, and a 32-character text string was added to the beginning (including the newline character before the exe file content, making it 33 characters).
A text editor is a poorly controlled tool. It can add even more characters at its discretion. For example, an end-of-file character at the very end of the file. Also, you say that you added 33 characters (because a newline is also a character). But you only remove 32 (leaving the 33rd). So, the error might be in that.
But I don't believe that after all the operations, you got exactly the same test.exe that you had before. No way.
In reply to Ment
User Avatar
10 years ago
Auto-translated
Ment
I don't believe it. Let me compare them myself ;)

I wouldn't have believed it before either :D
http://www.hermit.besaba.com/forment.zip

Added 19 minutes later
Also, try opening any .exe file, even my test.exe from Folder1 (it's small), in Notepad and then saving it to another directory from Notepad with the exact same name and extension. You'll see that it won't run afterwards, even though the size, content, attributes, and even the names of both files will be absolutely identical.
User Avatar
10 years ago
Auto-translated
Well, I know that it won't run after being opened in Notepad. But, if everything is done correctly (using a program/Hex Editor), it will run. In this case, the Hex Editor clearly showed that the files are different. Notepad converted the zero characters (code 00) into spaces (code 20). That's why it doesn't work. That's the whole mystery. I can attach screenshots.
User Avatar
10 years ago
Auto-translated
Okay, I understand about the notepad, but what about the test.com program? Are you referring to different test.exe files in the Folder1 and Folder2 folders?
User Avatar
10 years ago
Auto-translated
Aren't the different test.exe files in the Folder1 and Folder2 folders different?
Yes. I didn't look at the rest, to be honest. I think test.com works correctly, but test.txt contains nonsense.
User Avatar
10 years ago
Auto-translated
Here, I'm attaching screenshots. They show the executable files from different folders; the first one is correct, and the second one is the result of editing it with Notepad and test.com.
Attachments 2
2 files attached • Total size: 179.1 KB
User Avatar
10 years ago
Auto-translated
Yes, Ment! You are absolutely right! Thank you!

Added 2 hours 30 minutes ago
Yes, test.com works correctly, but Notepad @ replaced 00h with 20h!!! and the incorrect content of the exe file was already being sent to test.com!
User Avatar
9 years ago
Auto-translated
Here's the question.
A .bat file is launched, and its output is redirected to a text file. For example, task.bat > result.txt. This file uses the start command to launch a program. I even tried redirecting all its output streams to nowhere: 1>nul 2>nul. The .bat file finishes, but the program continues to run. And until it's closed, it's impossible to delete the result.txt file, which is very necessary. What could be the problem?
User Avatar
9 years ago
Auto-translated
I don't understand. Why can't the program explicitly specify a condition for its termination, so that it ends before the batch file closes?
User Avatar
9 years ago
Auto-translated
Because it needs to work, and the result.txt file should be deleted.
User Avatar
9 years ago
Auto-translated
Why can’t I close the file in the program?
In reply to Ment
User Avatar
9 years ago
Auto-translated
Ment
Why can't I close the file in the program?
It doesn't even open it. But it won't let me delete it.

Statistics

Welcome our newest member: recijeb