Very dangerous code...

This is a discussion on Very dangerous code... within the C++ Programming forums, part of the General Programming Boards category; DON'T SCREW WITH ASM unless you are brave or brilliant. I was brave until last week. thank god i was ...

  1. #16
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    DON'T SCREW WITH ASM unless you are brave or brilliant. I was brave until last week. thank god i was playing on kiddos box.
    M.R.

  2. #17
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    True; all my commands only delete data. No real damage. Its still a pain in the butt though when you hard drive is formated

  3. #18
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    DON'T SCREW WITH ASM unless you are brave or brilliant. I was brave until last week. thank god i was playing on kiddos box.
    M.R.
    Assembly language is not dangerous, nor is there some well kept secret on how to use it. You don't have to be brilliant to understand it either. All you need is a good understanding of machine architecture and your CPU. The safest form of assembler is inline assembler since your compiler will catch most of your errors. You can crash the system with assembler, but you can also crash it with C/C++ too. Besides, what did you do that messed up the system so bad? Every problem can be fixed

    C can be dangerous if you do not know how to use it, and if you are careless. For that matter, I guess DOS interrupts could be dangerous. FDISK can be dangerous. Anything can be dangerous if you are trying to accomplish creating dangerous code. Personally, I feel that more could beneift from good, solid, stable code than viruses, destructive code, and just plain foolish code - all of which fit into the stupid category.

    mov ax,013h
    int 10
    Sets video mode to 13h - Not dangerous


    mov ax,04f05h
    mov bx,0
    mov dx,01h
    int 10h
    Switches video card to memory bank 1 - Not dangerous

    Code:
    typedef unsigned int WORD;
    
    WORD BI(WORD v1,WORD v2,WORD v3,WORD v4,double f1,double f1)
    {
    WORD val1=0;
    WORD val2=0;
    WORD fval=0;
    asm
    {
      START:
        finit                     //init FPU
      FIRSTLI:
        fild v2                 //int load st(0) with v2
        fisub v1              //int sub v1 from st(0)
        fmul f1               //real mult st(0) by f1
        fiadd v1             //int add v1 to st(0)
        fistp val1           //store st(0) in val1, pop st(0)
      SECONDLI:  
        fild v4                //int load st(0) with v4
        fisub v3             //int sub v3 from st(0)
        fmul f1              //real mult st(0) by f1
        fiadd v3            //int add v3 to st(0)
        fistp val2          //store st(0) in val2, pop st(0)
      FINALLI:  
        fild val2            //int load st(0) with val2
        fisub val1         //int sub val1 from st(0)
        fmul f2             //real mult st(0) by f2
        fiadd val1        //int add val1 to st(0)
        fistp fval         //store st(0) in fval, pop st(0)
     }
     return fval;
    }
    Bilinear interpolation between 4 values. Not dangerous.

    All of these could just as easily be done in TASM and MASM and put in a separate object module. But they are not dangerous, nor are they going to destroy your machine.

    There is more chance for error in assembly and that your model of CPU may or may not support certain instruction opcodes, but it is not dangerous nor do you have to be some crazy genius to use it.

    (Steps off of soapbox............)

  4. #19
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    howdy bubba,
    i imagine you are probably right. my terrible experience was the result of blind ignorance and the debug "g" command.
    writing directly from a register to a disk location (any how i think thats what happened) did however create an unrecoverable disk error at the expense of tonka joes construction equipment, ask a 5 year old how important his tonka tractor is. devastating!!

    M.R.

  5. #20
    Registered User alex6852's Avatar
    Join Date
    Sep 2001
    Posts
    43
    Hey people, I got an idea! Remember WinChi virus? If, no I can tell you that it's real name is Chernobil and it makes PHYSICAL demage to your computer. How? Simple, by reprogramming(well I lied - "erasing") Flash BIOS. Very deadly trust me. In fy father's institute 60 computers went down permanently!!!
    Think about it.
    C++ rulez!!!

  6. #21
    Unregistered
    Guest
    "On windows 95/98 machines edit msdos.sys and change BootGUI=1 to BootGUI=0 and watch people's reaction."

    I am too afraid to try that. Can you get you computer back after editing msdos.sys like that ?!

  7. #22
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Yea. Just change the file back. GUI means Graphical User Interface. All you are doing is telling windows to boot into dos mode. From there type WIN and your back into windows. Its just funny because not too many people remember how to manipulate dos.

  8. #23
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    and what ever you do Don't take the floppy out of the a A drive it contains your OS - OOPS i guess i'm dating myself.

    i still have my 5.25 inch floppy if anyone needs it - i just dont have a 5.25 floppy drive

    M.R.

  9. #24
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Wha?

    Wha? No floppy drive? WTF! They are rarely used nowadays, but you still got to have one, right?
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  10. #25
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Yes there are viruses that can erase FLASH, mess hard drives up, etc. But they do not deserve the attention that everyone gives them. It is code designed to destroy. It is foolish, against the law, and counter-productive.

  11. #26
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Also, the "g" command in DEBUG does not write anything. It tells debug to move to the start of your program and execute it from there. In fact, if you DEBUG one of your C executables and then type in g, it will execute the code just as if you pressed ALT F9 from within the IDE.

    For instance: DEBUG myprog.exe

    DEBUG will place your code at an available memory location. To dump the memory from the top you would dimply type in "d." To unassemble you would type "u." This will display the actual instructions, whereas "d" only displays the opcodes and at the right of the screen if the character is printable, it will display the character, if not, it displays "."

    To write code, you use the "w" command. This command can wipe out your OS if you are dumb enough to write to absolute disk sectors. However, it is extremely useful if you patch a section of code.

    The original Starflight game uses a mode that most newer cards do not support. To patch the game you need to use DEBUG. After you patch the correct section with the correct opcodes using the "e" command, then you write the corrections to disk using "w" by itself. This will write the corrections to disk, in the correct location. It is best not to specify anything else with the "w" command unless you know what you are doing, which most of you do not, so don't try it.

    DEBUG has a use (or did) and it works great if you use it for what it was designed for. But in modern day there are many more user-friendly - Windows based debuggers to be used.

    Before all of you post about assembly, you really should check out some docs so that you know what you are talking about. Look up Randall Hydes Art of Assembly Language Programming on www.excite.com. It will be the 3rd or 4th listing.

    If you want to learn assembly then fine, if you want to misuse it, you get what you deserve.

  12. #27
    In The Light
    Join Date
    Oct 2001
    Posts
    598
    hey bubba, take a red man,
    i may not not everything about everthing but some of us do use these boxes as tools and not just toy's. i still have the note pasted on my monitor that says "make sure disk is inserted and the latch is closed".
    my ASM experience was not created by stupidity it was a function of trying to be as cool as you folks.
    i'll learn ASM but at this point i guess i'd better go to the link you suggested.
    enjoy the experience, unravel your mind, be cool.

    M.R.

  13. #28
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Did not say that your problem was the result of stupidity. I said that people who write viruses and pay homage to them like they are some kind of all powerful being are wasting their time. But, if you try to destroy your own drive too see if you can - yes, that is stupidity.

    If you were just tinkering around, cool. That is how I learned and also through that link. I'm not cool and I'm not all knowing when it comes to assembly, C++, C or anything else in life. Try those commands in DEBUG, and use a debugger to debug your code. You will get a good idea of what really takes place when the computer runs your program.

    If I implied you were stupid, I am sorry and that was uncalled for.
    If you have any questions about asm, feel free to PM me or ask on this board. That Randall Hyde book (he uses it for his classes) is one of, if not, the best concerning asm. Don't look at the HLA link or protected mode asm until you fully understand 16-bit asm. Download the 16-bit asm pdf files only. HLA will only serve to confuse you starting out. Welcome to the world of assembly.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. why is duplicate code dangerous?
    By agentsmith in forum C Programming
    Replies: 14
    Last Post: 01-08-2008, 01:10 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 11:20 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21