Solved

Data displayed as stored in memory

Posted on 1999-01-28
6
151 Views
Last Modified: 2010-04-16
I need to know how to display the data of stack stored in memory. that means, display how the memory keeps the information.
0
Comment
Question by:smondrag
6 Comments
 

Author Comment

by:smondrag
ID: 1217522
Adjusted points to 150
0
 
LVL 1

Expert Comment

by:quanghoc
ID: 1217523
 Do you mean you want to get values from memory or you want to list all program in memory ?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1217524
smnondrag, I don't exactly udnerstand what your question is.. WOuld you pleas elaborate a bit more what it is that you need? Thank you!

-Viktor
--Ivanov
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 5

Expert Comment

by:scrapdog
ID: 1217525
"Stack" as in an "abstract data type", or literally the program stack?
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1217526
you can view variables as stored in memory by doing this

var
 i:integer;
begin
  i:=3;
  Writeln(Mem[Seg(i):Ofs(i)],' ',Mem[Seg(i):ofs(i)+1);
  readln;
end.
Motaz
0
 
LVL 12

Accepted Solution

by:
Hypo earned 150 total points
ID: 1217527
I THINK that this i what you´re looking for...

 The program dumps a memory block to the screen.
( The memoryblock location is determined by the _seg,_ofs
  variables, and the size of it, by the count variable.)

 If you want to look at the stack after you´ve entered a
 procedure... all that you need to do is to insert the
 first five lines in the testit proc at the point where
 you want to look at the stack.

 In my example you can see that byte number five or six, is the
 same as the last parameter ($15).

(If you need to look at the stack at a certain point were the
 program can't be looping in a wait state, (or maybe you don´t
 use textmode), all you need to do is to dump the stack into an
 array, and then point _seg, _ofs to it and call the writemem
 proc when it´s suitable.)

 Hypo


(--- Cut here
Program MemoryDump{writtin in BP 7.0! }
uses crt;

const hexchar : string[16] = '0123456789ABCDEF';

var _ofs,_seg : word;
    count     : word;

{ The _seg and _ofs variables are the "pointer" to the memory
  position that should be viewed!
  Count is the number of bytes that should be displayed.
 
 To view the stack for instance... you could load the _seg
 variable with the SS register (mov _seg,ss), and the _ofs
 with the SP register (mov _ofs,SP).
 (SS and (E)SP always points at the stack)

}

function wordhex(value: word): string;
begin
 wordhex := hexchar[hi(value) shr 4 +1]+
            hexchar[hi(value) and 15+1]+
            hexchar[lo(value) shr 4 +1]+
            hexchar[lo(value) and 15+1];
end;

function bytehex(value: byte): string;
begin
 bytehex := hexchar[value shr 4 +1]+ hexchar[value and 15+1];
end;

procedure writemem;
var vwd : byte;
begin
 writeln;
 vwd := 0;
 if count > 0 then repeat
 if vwd = 0 then write(wordhex(_seg),':',wordhex(_ofs),'  ');
 write(bytehex(mem[_seg:_ofs]));
 if vwd = 7 then write('-') else write(' ');
 mem[segb800:(wherey-1)*160+122+(vwd+vwd)] := mem[_seg:_ofs];
 inc(vwd);
 inc(_ofs);
 dec(count);
 if vwd = 16 then begin
 writeln;
 vwd := 0;
 end;
 until count = 0;
end;

procedure testit(a, b: byte);
begin
 asm  { always setup the _ofs and _seg variables correctly! }
   mov _ofs,sp; { _ofs := regs.sp; }
   mov _seg,ss; { _seg := regs.ss; }
 end;
 writemem; { dumps the stack to the screen }
 { procedure code below }
end;

begin
 count := 15; { setting up the memory dump size }

 testit($F3,$15);
 writeln;
end.

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Extract text from webbrowser 5 1,374
Convert date 6 399
Copy file in dll not working but working on exe ! 18 83
find a node in VST 2 47
Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

13 Experts available now in Live!

Get 1:1 Help Now