关于kernel object的问题!!帮忙

dch4890164 2006-05-18 09:43:29
最近正在看programming applications with microsoft windows这本书,以前对于这些知识所知太少!!
呵呵,汗!
问题如下:
主要是我对下面这一段话,不是很理解,原文贴上
Because the kernel object data structures are accessible only by the kernel, it is impossible for an application to locate these data structures in memory and directly alter their contents. Microsoft enforces this restriction deliberately to ensure that the kernel object structures maintain a consistent state. This restriction also allows Microsoft to add, remove, or change the members in these structures without breaking any applications.

If we cannot alter these structures directly, how do our applications manipulate these kernel objects? The answer is that Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object. Think of this handle as an opaque value that can be used by any thread in your process. You pass this handle to the various Windows functions so that the system knows which kernel object you want to manipulate. We'll talk a lot more about these handles later in this chapter.

To make the operating system robust, these handle values are process-relative. So if you were to pass this handle value to a thread in another process (using some form of interprocess communication), the calls that this other process would make using your process's handle value would fail.
-----------------------------------------------------------------------------------
1.既然核心对象只能由核心层进行管理,那么为什么句柄又和进程相关呢(To make the operating system robust, these handle values are process-relative.)为什么这样就具有鲁棒性啦?
2.还有核心对象和核心(kernel)究竟应当怎么理解呢?这本书还提到file也是核心对象,怎么我感觉我可以操作它啊,以该文的意思,我必须得通过句柄访问,不可以直接进行操作吗?
呵呵,谢谢。


...全文
515 52 打赏 收藏 转发到动态 举报
写回复
用AI写文章
52 条回复
切换为时间正序
请发表友善的回复…
发表回复
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
呵呵忽然想起来今天看到的电脑报上说intel最新的处理器架构core的15个新特性,其中一个居然是:如果一条写指令后面跟着一条读指令,core处理器可以自动判断写指令和读指令是否引用同一个地址,如果不是的话就并行执行,而之前架构的处理器(可能指P4),是不判断的,一律等待……

我晕,这个情况在体系结构里叫做数据相关,几十年前就已经有人解决了这个问题,而且好几个CPU都已经有这个特性了,Intel还好意思在这里吹什么新技术……

扯远了,不能只盯着Intel和Windows不放阿……x86经典是因为商业的原因,Windows也不见得就是well design的东西。学cs的眼光应该再放远一点!
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
回寝室睡觉了.
明天揭贴.
以后再有相类似的问题给你发消息.
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
是啊是不能满脑子386,486,我现在做课题用的是奔三2XX,98,内存64M,硬盘512M,郁闷啊!!
呵呵
这方面的只是想好好学习学习.
因为太重要了,身边只有这一种操作系统.
再者也没有时间去研究别的什么东西.
dch4890164 2006-05-21
  • 打赏
  • 举报
回复

大概有点懂了.
这方面的知识还真复杂!!
谢谢您,我简直快崇拜您了.
呵呵
再次感谢.
该揭贴了,
呵呵
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
再罗嗦几句,有的CPU是没有MMU的,根本不存在什么user mode/kernel mode,可不能满脑子x86+windows阿!中国的现在计算机教育真是害死人……
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
sorry,是翻译得很“烂”!顺便bs一下那个什么英×工作室……
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
第一,这个句柄表没有documented!你根本不知道它在内存中哪个地方,所以对你来说仍然是不可见的,依然可以起到保护作用。不管什么东西,不是躲到kernel mode就万事大吉塞进保险箱了;
第二,之所以要让这个表格在user mode可以访问是有原因的,gdi32.dll中导出的函数并非都是依靠win32k.sys的系统服务来完成其功能的(win32k.sys中的函数当然是可以访问GDI对象表的),但是问题是有不少函数的具体实现就在gdi32.dll内部,它们也要访问这张表,而gdi32.dll是位于user mode的,这就迫使MS把这张表映射到user mode可以访问的地址空间内(MS应该不会愚蠢到把这个表拷贝一份到user mode去)。
PS:袁峰的那本书叫做《Windows图形编程》,80块,不过翻译的很难,需要你有透彻的“理解能力”和“反编译能力”,否则你不能把汉语正确反编译成英语……
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
您的意思就是USER可以访问这个objects or Graphics Device Interface (GDI) objects的句柄索引表,可以获得表的内容,那么要句柄还有什么用?呵呵
-----------------------------------------------------------
上面的句柄是指非核心对象的
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
您所说的两个问题正是我要思考的和要问的,还是搞不透
---------------------------------------------------
谢谢您的忠告,今天晚上我会再好好看看书.
非常感谢
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
您的意思就是USER可以访问这个objects or Graphics Device Interface (GDI) objects的句柄索引表,可以获得表的内容,那么要句柄还有什么用?呵呵
-----------------------------------------------------------
谢谢您的不厌其烦
对于您所说的书,我会去找电子版
我是一个穷学生,大部分纸版的书我都消费不起.
呵呵
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
有些问题不要老是站在用户的角度(相对于OS的设计者而言,我们这些程序员就算是用户)去思考问题,问这问那,换个角度,把自己当成OS的设计者(这并不夸张,一个小型的嵌入式OS非常simple),往往有茅塞顿开醍醐灌顶的顿悟。
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
在和你探讨Kernel的定义以及Micro kernel之前,我想先请你思考两个问题:
1. 为什么要有Kernel;
2. 如果让你来写一个小型的os,你觉得哪些东西是必须放到kernel里去的;
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
GDI对象的管理方式和普通的Kernel对象的管理方式很是不同,GDI的系统服务有自己专用的win32k.sys提供。袁峰大虾的书上对GDI的底层讲的很详细,你可以去看看。GDI的对象有一个表格,并且这个表格在user mode是可以访问的。
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
HICON CreateIcon(
HINSTANCE hinst,
int nWidth,
int nHeight,
BYTE cPlanes,
BYTE cBitsPixel,
CONST BYTE *pbANDbits,
CONST BYTE *pbXORbits);

我想问这些句柄是否会放到句柄索引表当中去,由谁来维护?
----------------------------------------------------
关于KERNEL的定义,我查了操作系统的书,姓屠的那一本
感觉说的不清楚.
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
In addition to kernel objects, your application might use other types of objects, such as menus, windows, mouse cursors, brushes, and fonts. These objects are User objects or Graphics Device Interface (GDI) objects, not kernel objects. When you first start programming for Windows, you might be confused when you try to differentiate a User object or a GDI object from a kernel object. For example, is an icon a User object or a kernel object? The easiest way to determine whether an object is a kernel object is to examine the function that creates the object. Almost all functions that create kernel objects have a parameter that allows you to specify security attribute information, as did the CreateFileMapping function shown earlier.
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
句柄并不是核心对象所独有的,有些非核心对象也只有通过操作句柄才能操作它
-----
什么叫做“非核心对象”?举个例子?

KERNEL的功能仅限于此吗?
-----
绕了半天又回到Kernel的定义上去了。
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
为了感谢大家的回答
我又给帖子增加了50分
非常感谢!!
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
再次谢谢大家的回答
但是我感觉有以下几点,还是存在疑问
----------------------------------
第一点:句柄并不是核心对象所独有的,有些非核心对象也只有通过操作句柄才能操作它(我是指在SDK情况下),那么这些非核心对象的句柄是否会加入到进程的句柄索引表当中?
第二点: 进程只具有承认和否定别人具有访问它所创建核心对象的权利,但是它不具有管理权,管理权还是在KERNEL上,那么KERNEL的主要作用应当是维护句柄索引表,这样可以控制有些进程在操作系统上不能够任意访问别人,既我所问的和进程相关的主要原因,这点我清楚了.


我现在所要问的就是: KERNEL的功能仅限于此吗?
dch4890164 2006-05-21
  • 打赏
  • 举报
回复
so only through duplication or inheritance can more than one file handle refer to the same file object.

明白了
谢谢.
会思考的草 2006-05-21
  • 打赏
  • 举报
回复
Whenever an application creates a new file handle, the system creates a new file object. Therefore, more than one file object can refer to a single file on disk, so only through duplication or inheritance can more than one file handle refer to the same file object.
加载更多回复(32)

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧