Results 1 to 14 of 14

Thread: An odd question

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004

    An odd question

    Can you directly write machine code into the code segment of a running application?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  2. #2
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    Not under Windows

    not under windows, i don't know if it works under linux
    Code Ronin

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Why?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You can in windows. I think the 2.6 Linux kernel has an option to disallow it, but in windows you can. It's done when hooking API calls - you actually replace a piece of code from the windows DLLs.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Now the application change its own code...
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  6. #6
    Addicted Member CodeRonin's Avatar
    Join Date
    Jul 2002
    Location
    Vienna, Austria
    Posts
    233

    nah...

    When I last tried it under W2K, he didn't allow it... how do you do it?
    Code Ronin

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Oops. I just checked my previous post. It really should be:

    Now can the application change its own code...
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If not, you can always allocate some memory with execute rights using VirtualAlloc and write your code there.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    I am using NASM, and I do not have VirtualAlloc. Where can I get that macro (or call or whatever) from?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's a WinAPI call in kernel32.dll.

    If you're programming for DOS, you'll have to look up the various INT21h functions to find out how to allocate memory. DOS gives no restrictions at all on what code is accessible how.

    In UNIX, you'll have to look it up too.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Excuse my ignorance, but is that the same dll that is included in MSVC++?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    It's one of the core dlls of windows, so it doesn't need to come with MSVC++.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    Where could I find information on kernel32.dll?
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  14. #14
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In the SDK docs and with Dependency Viewer (a tool that comes with the SDK and is AFAIK also on the WinXP CD).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width