Jump to content
  • Advertisement
Sign in to follow this  
nerd_boy

Hand Crafting .Com Dos files

This topic is 5462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have tried to hand craft .com dos files(I am a looney, I know) just to see what I could do. I started out trying to make Interrupt 21h(I think that is the one that makes a message box pop up and say "This won't run in dos blah blah blah."). So I opened up my hex-editor, entered in the two hexadecimals for it: 0xCD 0x21 It doesn't work! So my question is, is there some sort of file format, like for the win32? Because I always thought it was pure binary. Or am I just doing something else wrong? Or,as is far more likely, am I doing both wrong? Thanks for your help.

Share this post


Link to post
Share on other sites
Advertisement
No, there is no special format. It's just that you have no idea what the various interrupts do. While the raw binary for calling Int 0x21 is 0xCD21, Int 0x21 has nothing to do with putting up a message about not running in DOS.

Open up your hex editor and enter this:

B4 09 BA 09 01 CD 21 CD 20 49 20 6E 65 65 64 20 74 6F 20 6C 65 61 72 6E 20 6D 6F 72 65 20 61 62 6F 75 74 20 44 4F 53 20 69 6E 74 65 72 72 75 70 74 73 24

then save as .COM file

Share this post


Link to post
Share on other sites
If it helps, I believe interrupt 21h is the interrupt you would use to run various DOS related functions... I'm betting that it's "this won't run in DOS" output you got (and thus, why it seemed to you that that was its function) is probably based on the way that modern Windows OSes prefer to deal with interrupts, and computer codes in general.

Remember, interrupts are basically ways of telling the computer to do something at its most basic level (BIOS, or in the case of 21h basic DOS functions). If you do a search on interrupt 21h you'll find some of those functions. I'd reccommend using Assembly programming to access those functions however, as hex editing to make a program is pretty much doing the same thing except denying you the naming conventions (which, of course, is why Assembly was created in the first place; to replace hard to remember opcodes with easy to remember commands, among other things of course).

Anyways, give Assembly a shot. You'll essentially be doing the same thing.

Share this post


Link to post
Share on other sites
Okay, thanks. Now, another question. What does the extra stuff do? I kinda like to know what is going on. Are there any tutorials about this kinda thing.

I am pwned by your knowledge.

Share this post


Link to post
Share on other sites
Quote:
Original post by smitty1276

Here


You dare to use Yahoo! instead of Google!!!???

BTW, Michalson, You changed it! It did only have "ned" instead of "need". If only I had tried your program out earlier.

Edit: Michalson, you have "teh" greatest avatars.

Share this post


Link to post
Share on other sites
What exactly those opcodes are and what they stand for are also something you could look up. Perhaps try "Intel Opcodes" or something? Anyways, the opcodes themselves have convoluded meanings because many of them are likely shorthand for registers, memory, or other important internal components. They won't all map directly to functions (that is, to something that is being done), a lot will map to the things being done to, if that makes sense. =)

Anyways, as I was saying before, I would suggest keeping it at Assembly level. you're essentially doing what you wanted to do before, but without having to manage physical memory locations and without errors costing you big... I'll explain.

I'm assuming that Windows probably has protections against these kinds of things, but programming directly with opcodes is very dangerous in general, and even moreso on a Multitasking operating system.

In both cases, you'll have the problem of writing the wrong opcode = deleting parts of hard drive, erasing BIOS, invalidating your FAT table, and causing any sort of a million other permanent and nonpermanent problems.

However, in multitasking, you'll also have the problem that memory is already being used by other threads that are running. If you're writing to Opcodes, I'd assume that you are skipping over the protection that languages from Assembly up give in that they won't assign memory to variables that are already in use by variables. In Opcodes, variables themselves don't exist: you are literally writing to a physical memory (drive, etc) location. If that location has something there, something important, then you'll be screwing up something important. Now, I would imagine that Windows wouldn't allow that to happen, but I've never actually tried it myself... and quite honestly, I'd rather not give it a try. Some things in computing just arent' worth the hassle, especially when there's something else that does the exact same thing but with built-in protections (IE Assembly). You must understand that, in essence, you are doing the same thing as writing opcodes with Assembly; you're just given some conveniences to protect your computer as well as to protect your brain from having to remember a bunch of worthless junk.

So in the end, I'd reccommend that you learn Assembly. That's really the way to go, I promise! Besides, Assembly is cooler than Opcodes in general. ;)

Share this post


Link to post
Share on other sites
I thought the executable part of a com file started at 100h?

Open a command shell and type 'debug'. I forget the DOS code for it now, but you can enter code to save a file and then use debug to hand craft assemlby (it's like narcotic-free dental work).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!