-
-
[旧帖] [分享]《win32汇编语言程序设计》中的一个知识点 0.00雪花
-
发表于: 2014-3-17 18:19 1306
-
第一次看罗云彬的《win32汇编语言程序设计》的时候,对于第11章的动态链接库和钩子里面的typedef和ptr的用法一头雾水,现在慢慢终于理解了,记录下,如有不当的地方,还请大神指点,谢谢!
首先看《Microsoft MASM Programmer's Guide Assembly-Languiage Development System v6.1》中对ptr的解释
type PTR expression
Forces the expression to be treated as having the specified type.
[[distance]] PTR type
Specifies a pointer to type.
很明显罗云彬书中是第二种用法,即定义一个指针。
而typedef的用法如下
name TYPEDEF type
Defines a new type called name, which is equivalent to type.
即对于类型type定义一个别名,和C语言中的typedef用法类似。
书中语句如下:
_PROCVAR2 typedef proto :dword,:dword
PROCVAR2 typedef ptr _PROCVAR2
第一句就是用typedef来为函数声明来定义一个别名_PROCVAR2,然后第二句用typedef结合ptr定义一个指向_PROCVAR2的指针的别名。
此后就可以用PROCVAR2来定义指向函数的指针变量了。如书中所写:
.data?
lpIncCount PROCVAR2 ?
lpDecCount PROCVAR2 ?
首先看《Microsoft MASM Programmer's Guide Assembly-Languiage Development System v6.1》中对ptr的解释
type PTR expression
Forces the expression to be treated as having the specified type.
[[distance]] PTR type
Specifies a pointer to type.
很明显罗云彬书中是第二种用法,即定义一个指针。
而typedef的用法如下
name TYPEDEF type
Defines a new type called name, which is equivalent to type.
即对于类型type定义一个别名,和C语言中的typedef用法类似。
书中语句如下:
_PROCVAR2 typedef proto :dword,:dword
PROCVAR2 typedef ptr _PROCVAR2
第一句就是用typedef来为函数声明来定义一个别名_PROCVAR2,然后第二句用typedef结合ptr定义一个指向_PROCVAR2的指针的别名。
此后就可以用PROCVAR2来定义指向函数的指针变量了。如书中所写:
.data?
lpIncCount PROCVAR2 ?
lpDecCount PROCVAR2 ?
赞赏
赞赏
雪币:
留言: