Solved

Accessing memory explicitly

Posted on 1998-09-20
1
150 Views
Last Modified: 2010-04-06
[Note: I am using Delphi 2.0]

If XPtr and YPtr are pointer variables and Offset is an integer/word/longint/etc., is it legal to do the following?

XPtr := YPtr + Offset;

(in case you're curious, in my application XPtr is a pointer to a bitmap and I want to get the memory location Offset bytes from the beginning)

In Delphi 2, I noticed that the seg and ofs functions are obsolete.

I have not tried compiling the unit that uses the XPtr := YPtr + Offset yet, but I assume it is legal.  If it is, would someone confirm this, and if it is not, please tell me how to do it.  Thanks.




0
Comment
Question by:scrapdog
1 Comment
 
LVL 20

Accepted Solution

by:
Madshi earned 0 total points
ID: 1340339
scrapdog,

it is legal. But be careful with the types!!!

var XPtr,YPtr : ^integer;
    Offset    : integer;

inc(XPtr,integer(YPtr)+Offset);  
// don't do it this way, because Delphi then thinks that you mean:
// inc(XPtr^,integer(YPtr)+Offset);

// do it this way...
XPtr:=pointer(integer(YPtr)+Offset);

Regards, Madshi.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now