当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 用汇编访问COM对象 Erne
 

 

 ·保护模式知识(三)    »显示摘要«
    摘要:描述符 前面已经提到,描述符是描述一个段的大小,地址及各种状态的8个字节的结构,在编程时它可以定义它. 如图2所示,根据描述符所描述对象的不同,描述符可分为存储段描述符、系统段描述符、门描述符三种,而门描述符又可分为调用门、任务门、中断门和陷阱门四类。下面将分别介绍各描述符作用及其各位的意义: 一、存储段描述符 存储段描述符是描述程序中的代码段和数据段的,这其中也包括堆栈段,在保护模式下,应该把堆......
 ·保护模式知识(一)    »显示摘要«
    摘要:序! 对于学习任何编程语言的朋友来说掌握cpu的操作模式都是一件非常重要的事,其中就数保护模式这部分最重要了,现在关于保护模式的中文资料就只有杨季文先生那一家还算全面,但有些人还是觉得看不太懂,为此我就写了这篇文章,看看是否对您的胃口! 一、保护模式概述 顾名思义,就是对程序的运行加以保护。我们知道在实模式下通常只能寻址1m的内存空间,且只能是单任务,就是说同一时间不能有两个任务被激活。......


用汇编访问COM对象

用汇编访问com对象

revised july 10 2000 for the new form of coinvoke. 【程序编程相关:二点tips

ernest murphy ernie@surfree.com

revised dec 26 2000 for inclusion as part of masm32 【推荐阅读:malloc,free和new dele

abstract: 【扩展信息:制作可执行的JAR文件包

sample code for this article is available at ...\com\examples\shortcut

原理:

the com (component object model) is used by the windows operation system in increasing ways. for example, the shell.dll uses com to access some of its api methods. the ishelllink and ipersistfile interfaces of the shell32.dll will be demonstrated to create a shortcut shell link. a basic understanding of com is assumed. the code sample included is masm specific.

com(组件对象模型)越来越多地被windows操作系统使用.例如,shell.dll使用com来访问一些它自己的api函数.shell32.dll的ishelllink与ipersistfile接口将被用来演示如何创建一个快捷方式.com的基本理解是需要的.包含的示例代码是masm专用的.

introduction:

导言:

com may seem complicated with its numerous details, but in use these complications disappear into simple function calls. the hardest part is understanding the data structures involved so you can define the interfaces. i apologize for all the c++ terminology used in here. while com is implementation neutral, it borrows much terminology from c++ to define itself.

com由于其众多的细节可能看上去复杂,但在实际使用中这些复杂因素消失于简单的函数调用之中.最困难的部分是理解其中用到的数据结构,知道了它你旧可以定义接口(interfaces).我对在此处使用的c++术语表示抱歉.虽然com被实现为中立的,但它从c++借用了许多术语来定义自身.

in order to use the com methods of some object, you must first instance or create that object from its coclass, then ask it to return you a pointer to its interface. this process is performed by the api function cocreateinstance. when you are done with the interface you call its release method, and com and the coclass will take care of deleting the object and unloading the coclass.

为了使用一些对象的com函数(method),你必须首先根据它的coclass具像化(示例化)或者说是创建这个对象.当你用完了这个接口,你调用它的release函数,com与coclass将会处理删除对象与卸载coclass的任务.

a com object is referred to as the server. the program that calls up a com object so it may use it is referred to as the client.

com对象被称为server(服务器).调用com对象的程序被称为client(客户)

assessing com methods

访问com函数

to use com methods you need to know before hand what the interface looks like. even if you "late bind" through an idispatch interface, you still need to know what idispatch looks like. a com interface is just table of pointers to functions. lets start with the iunknown interface. if you were to create a component that simply exports the iunknown interface, you have a fully functional com object (albeit on the level of "hello world"). iunknown has the 3 basic methods of every interface, since all interfaces inherit from iunknown. keep in mind all an interface consists of is a structure of function pointers. for iunknown, it looks like this:

为了使用com函数你需要事先知道接口(interface)的模样.即使你通过一个idispatch接口“动态绑定”,你仍然需要知道idispatch的模样.一个com接口就是一个函数指针的表格.让我们从iunknown接口开始.如果你要创建一个仅仅导出(export)iunknown接口的组件,你将得到的是一个完善的com对象(虽然仅是在“hello world”的层次上).每个接口有iunknown的3个基本的函数,因为所有的接口都从iunknown继承而来.始终记得所有的接口是包含函数指针的结构体(structure).对于iunknown来说,它就这模样:

iunknown struct dword ; iunknown methods iunknown_queryinterface queryinterface_pointer ? iunknown_addref addref_pointer ? iunknown_release release_pointer ? iunknown ends

thats it, just 12 bytes long. it holds 3 dword pointers to the procedures that actually implement the methods. it is the infamous "vtable" you may have heard of. the pointers are defined as such so we can have masm do some type checking for us when compiling our calls. since the vtable holds the addresses of functions, or pointers, these pointers are typedefed in our interface definition as such:

这就是它,仅仅12字节长.
...   下一页

 ·硬盘加密----解析三    »显示摘要«
    摘要:硬盘加密--解析三上一篇文章解析了硬盘上有两个分区的加密过程,下面的程序将允许有n个分区的加密过程:source codes: data segment fqb db 512 dup(0);a buffer that will be used to store partition-table firstp db 40 dup(0);storing the first partition info......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE