返回信息流
这是一条镜像帖。来源:北邮人论坛 / soft-design / #20735同步于 2007/8/30
该镜像源已超过 30 天没有更新,可能在源站已被删除。
SoftDesign机器人发帖
c上面的文件句柄是怎么回事?
willen
2007/8/30镜像同步4 回复
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
没听说c上面有什么文件句柄
文件句柄是操作系统内核对象层的概念,而这一对象你能在c语言里调用那是因为m$在它自己的函数库中定义了这一东西
在c里面如果直接操作文件的话,返回的是指针,并没有转化为handle
如果是win32平台的话
花5分钟逆了一下msvcrt.dll,即win32的c run-time library
经过一系列的检测及向下调用,最终还是调用了CreateFileA
.text:77BFF436 mov eax, [ebp+arg_0]
.text:77BFF439 push 0 ; hTemplateFile
.text:77BFF43B push esi ; dwFlagsAndAttributes
.text:77BFF43C push [ebp+dwCreationDisposition] ; dwCreationDisposition
.text:77BFF43F mov dword ptr [eax], 1
.text:77BFF445 mov eax, [ebp+arg_4]
.text:77BFF448 mov [eax], edi
.text:77BFF44A lea eax, [ebp+SecurityAttributes]
.text:77BFF44D push eax ; lpSecurityAttributes
.text:77BFF44E push [ebp+dwShareMode] ; dwShareMode
.text:77BFF451 push [ebp+lDistanceToMove] ; dwDesiredAccess
.text:77BFF454 push [ebp+lpFileName] ; lpFileName
.text:77BFF457 call ds:CreateFileA(x,x,x,x,x,x,x)
【 在 willen (willen) 的大作中提到: 】
windows的三种子模式,win32,os/2,posix
看来posix不过是使用win32对posix函数进行的封装,
即
posix win32 os/2
| | |
------------------------------------
kernel32.dll,user32.dll,gdi32.dll
-------------------------------------
|
ntdll.dll
|
内核
【 在 flyingkisser (齐天大猫) 的大作中提到: 】
: 如果是win32平台的话
: 花5分钟逆了一下msvcrt.dll,即win32的c run-time library
: 经过一系列的检测及向下调用,最终还是调用了CreateFileA
: ...................