Solved

self-modifying code API

Posted on 1998-11-30
1
237 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
1 Comment
 
LVL 20

Accepted Solution

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

Regards, Madshi.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 108
Using idhttp to login to instagram 2 89
How to load 2 images in same column in Delphi 2 45
update joined tables 2 45
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…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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 …

805 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