thqby / ahk2_lib

MIT License
233 stars 32 forks source link

Native 不适用 AutoHotkey.dll #52

Closed DeepTulip closed 5 months ago

DeepTulip commented 5 months ago

AutoHotkey.exe 正常,dll 报错。

code:="
(
    #UseStdLib
    p := DllCall('GetProcAddress', 'ptr', DllCall('GetModuleHandle', 'str', 'user32', 'ptr'), 'astr', 'SetWindowTextW', 'ptr')
    f := Native.mdfunc(p, ["int32", "uint64", "string"])
    f(A_ScriptHwnd, "测试")
    MsgBox WinGetTitle(A_ScriptHwnd)
)"

DllCall("LoadLibraryW", "str", "D:\AutoHotkey.dll","UPtr")

DllCall('AutoHotkey.dll\NewThread', "Str", code, "Str", '', "Str", '', "UInt")
MsgBox 

报错: Error: Expected a ? but got an Integer.

Specifically: 983082

▶ 004: f(A_ScriptHwnd, "测试")

+++

顺便请教大佬 int* intP 有对应的 mdfunc 类型吗?

thqby commented 5 months ago

当前dll和exe的函数对象有不同的内存结构,size和offset都加8