Solved

How to poke into code segment?

Posted on 2006-11-15
5
455 Views
Last Modified: 2010-04-04
Hi, using Delphi 2006, I have a need to poke a few bytes into the code so I can set breakpoints, something like:

    var p: ^ byte;

    function Func( x: integer ): integer;
    begin
        Func := x * x ;
       end;


begin
    p := @Func;
    p^ := $CC;
end;


... but of course I'm not allowed to write to the code.  A good thing, except right now.

Any ideas?

0
Comment
Question by:grg99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 4

Expert Comment

by:tobjectpascal
ID: 17953257
i thought you set break points from the IDE not the code?
0
 
LVL 22

Author Comment

by:grg99
ID: 17954932
Hi, I figure out how to do it.  You call VirtualProtect with READ_WRITE.

0
 
LVL 9

Expert Comment

by:alkisg
ID: 17957953
For a complete working example, look at the fastcode.sourceforge.net library.
It uses code patching to substitute delphi functions with faster ones.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21133154
PAQed with points refunded (125)

Computer101
EE Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question