Solved

How to poke into code segment?

Posted on 2006-11-15
5
453 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
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi - replicating a form 8 74
Convert MS Word document to a PDF file 9 78
CheckListBox usage 3 58
Delphi and Access based Enumeration 9 63
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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