Solved

self-modifying code API

Posted on 1998-11-30
1
241 Views
Last Modified: 2010-04-04
I am trying to make "self-modifying" code, like the following example:

procedure TForm1.Button1Click(Sender: TObject);
var
P: ^Byte;
begin
     P := Addr(TForm1.Button1Click);
     ShowMessage('The address is: ' + IntToHex(Integer(P), 8));
     P^ := 0;    //   <---- Access Violation occurs here
     ShowMessage('Done!');
end;


but the system reports:

Access violation at address 0042BBCA in module 'Project1.exe'
Write of address 0042BB6c

which is understandable, since this is not .DATA segment, but .CODE

What is API(s)  for "unlocking" the CODE segment?
0
Comment
Question by:yuhoo
[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
1 Comment
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 1348706
Look at VirtualProtect(Ex)...

Regards, Madshi.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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