Programming 版 (精华区)
发信人: zpw (zhao), 信区: Programming
标 题: FAQ for VXD(之六)
发信站: 紫 丁 香 (Tue Jul 28 14:14:23 1998), 转信
How do I access physical memory at (e.g. D000:0000) from a Windows 3.1
application?
This is very easy to do. Here is a sample program that references the VGA
display buffer at A000:0000. You can use the same technique, except use
_D000h instead of _A000h. KERNEL defines a whole set of these selectors
for you covering the A000 through F000 range.
#define STRICT
#include "windows.h"
typedef WORD SELECTOR;
// __A000h is an absolute value; by declaring it as a NEAR variable
// in our data segment we can take its "address" and get the
// 16-bit absolute value.
extern BYTE NEAR CDECL _A000h; // use _A000H for Borland compilers
SELECTOR selVGA = (SELECTOR)&_A000h;
int PASCAL WinMain (HINSTANCE hinst,
HINSTANCE hinstPrev,
LPSTR lpszCmdLine,
int cmdShow
)
{
WORD FAR * lpVGA = MAKELP( selVGA, 0 );
// Should put garbage pixels on top left of screen
lpVGA[0] = 0x1234;
lpVGA[1] = 0x5678;
return 0;
}
--
※ 来源:.紫 丁 香 bbs.hit.edu.cn.[FROM: yaoyu.hit.edu.cn]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.188毫秒