Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

reading out gdt

Posted on 2000-05-08
8
Medium Priority
?
521 Views
Last Modified: 2013-12-03

I want to write a programm which reads out the gdt                         so i wrote (compiled with Vc++ 5.0) a console app.:

#include <conio.h>
typedef struct gdt_info {
              unsigned short length;
              unsigned char *addr;
              }gdt_info;

gdt_info gdt;
unsigned short temp,c;
void main()
{
_asm {
   sgdt gdt
   }
printf("%u %lu",gdt.length,gdt.addr);
getch();
printf("%u",gdt.addr[0]); //at this line of code the program exits                                      //because of an
getch();                         //'ungültige' page with this nice box                                      //    close,debug,detail
}                                   //you know what i mean :-)

so i ask how can i get access to the address i got from sgdt.I also wondered about the termination: it was no GP# Fault but an illegal page in my code (don't know english word for 'ungueltig')
0
Comment
Question by:grimlock
  • 4
  • 3
8 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2789065
Is suppose that the output of

printf("%u %lu",gdt.length,gdt.addr);


is sth. like

<some number> <some small number or even 0>

Windows protects the lower pages in memory in order to detect NULL pointer access, thus 'invalid page fault' (or "Diese Anwendung verursachte einen Fehler durch eine ungültige Seite...")

By accessing 'gdt.addr[0]' you're doing something similar like

char* pc = 0x0000000a;
char c = *p;

which causes this.

0
 
LVL 15

Expert Comment

by:NickRepin
ID: 2790290
jkr is absolutely right.
You have an access to your own address space only, but not to the system-controlled areas.

BTW, Intel says: The SGDT/SIDT instructions are only useful in operating-system software.

Why do you need this?!
0
 

Author Comment

by:grimlock
ID: 2792098
i need it to do my own mem.management
because i don't want windows to swap my accessed memory even if i don't use it for at while.
So i thought building my own descriptors for my own segments.
but say is the ldt accessed in my process address space or is it even possible by building an device driver to acces to gdt/ldt and how???
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:grimlock
ID: 2792110
additional:

your right the length of the ldt was 4095 bytes, that is right because if i do sgdt with a dos app. its the same and the address is 49405 decimal

and there is another curious thing:

in the book advanced windows(jeff richter) is said that windows partitions first 4191305 bytes for MS-DOS and 16bit Windows, but in a program which walkes throught virtual mem. it is wrote that these 4 Megs are free and the author doesn't say anything about this???
0
 
LVL 86

Expert Comment

by:jkr
ID: 2792246
>>because i don't want windows to swap
>>my accessed memory even if i don't
>>use it for at while.
>>So i thought building my own
>>descriptors for my own segments.

What about simply using

VirtualProtect( ..., ..., PAGE_NOCACHE);

BTW: You cannot alter the GDT or build a descriptor from within a user mode program, only a VxD could do this...

0
 

Author Comment

by:grimlock
ID: 2792343
does virtualprotect work under win95/98???

how to build a VxD?
0
 
LVL 86

Expert Comment

by:jkr
ID: 2792395
does virtualprotect work under win95/98???

From the docs:

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winbase.h.
  Import Library: Use kernel32.lib.


>>how to build a VxD?

This can be done using the DDK (Device Driver Kit, available for free (!) at 'http://www.microsoft.com/hwdev/ddk/' - On Win9x, this is still mostly assembler coding). The DDK comes with documentation and a bunch of samples.




0
 
LVL 86

Accepted Solution

by:
jkr earned 600 total points
ID: 2797528
Hmm, as we didn't hear from you that you still need to know something, I'll lock this Q...
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

810 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