TC官方合作论坛

 找回密码
 立即注册
查看: 64|回复: 0

[问题] 请教如何使用WINAPI FILEREAD读取二进制地图档“文档”

[复制链接]
发表于 2021-2-19 03:01:54 | 显示全部楼层 |阅读模式

马上加入TC

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
本帖最后由 bestkakkoii 于 2021-2-19 03:24 编辑

需要读取二进制.dat地图档只知WINAPI CreateFileA,ReadFile可以读但不知道在TC中指出参数怎么填才正确
用TC自带的文件读取只能读到标头的前几个字

原码如下:

  1. function WH()
  2.     var path = "D:/BlueCrossgate/map/1/3/2160.dat"
  3.     var hFile = fileopen(path)
  4.     traceprint(hFile)
  5.     var content = ReadFile(hFile)
  6.     traceprint(content)
  7.     var FF = fileclose(hFile)
  8.     traceprint(FF)
  9. end
  10. function CreateFileA(lpFileName, dwDesiredAccess = #80000000, dwShareMode = #1, lpSecurityAttributes = null, dwCreationDisposition = 0, dwFlagsAndAttributes = #80, hTemplateFile = null)
  11.     //dwDesiredAccess
  12.     var GENERIC_READ = #80000000
  13.     //dwShareMode
  14.     var off = #0
  15.     var FILE_SHARE_DELETE = #00000004
  16.     var FILE_SHARE_READ = #00000001
  17.     var FILE_SHARE_WRITE = #00000002
  18.     //dwCreationDisposition
  19.     var OPEN_EXISTING = 3
  20.     return dllcall("kernel32.dll", "int", "CreateFileA", "char *", lpFileName, "int", dwDesiredAccess, "int", dwShareMode, "int", lpSecurityAttributes, "int", dwCreationDisposition, "int", dwFlagsAndAttributes, "int", hTemplateFile)
  21. end
  22. var tempcontent = 0
  23. function ReadFile(hFile, lpOverlapped = null)
  24.     var nNumberOfBytesToRead = dllcall("kernel32.dll", "long", "GetFileSize", "long", hFile, "long", null)
  25.     tempcontent = 0
  26.     var lpBufferPointer = getvarpointer(tempcontent)
  27.     traceprint(lpBufferPointer)
  28.     var lpNumberOfBytesRead = 0
  29.     var lpNumberOfBytesReadaddr = getvarpointer(lpNumberOfBytesRead)
  30.     traceprint(lpNumberOfBytesReadaddr)
  31.     var CC = dllcall("kernel32.dll", "int", "ReadFile", "int", hFile, "int", lpBufferPointer, "int", nNumberOfBytesToRead, "int", lpNumberOfBytesReadaddr, "int", lpOverlapped)
  32.     traceprint(CC)
  33.     return tempcontent
  34. end
  35. function Closehandle(hObject)
  36.     return dllcall("kernel32.dll", "long", "CloseHandle", "long", hObject)
  37. end
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条

关闭

小黑屋|TC官方合作论坛 (苏ICP备18045623号)

GMT+8, 2021-2-28 15:14 , Processed in 0.034309 second(s), 23 queries .

Powered by 海安简单软件服务部

© 2008-2019 版权所有 保留所有权利

快速回复 返回顶部 返回列表