Initial qiwei secondary development handoff

This commit is contained in:
2026-06-23 21:11:20 +08:00
commit 858cb68f4f
207 changed files with 52782 additions and 0 deletions

105
helper/dll.go Normal file
View File

@@ -0,0 +1,105 @@
package main
import (
"fmt"
"os"
"syscall"
)
func loadDLL(dllPath string) (syscall.Handle, error) {
if _, err := os.Stat(dllPath); os.IsNotExist(err) {
return 0, fmt.Errorf("DLL file does not exist: %s", dllPath)
}
dll, err := syscall.LoadLibrary(dllPath)
if err != nil {
return 0, fmt.Errorf("load DLL failed: %v", err)
}
globalLogger.Info("[辅助程序] 成功加载DLL: %s", dllPath)
return dll, nil
}
func getLoaderProcAddress(dll syscall.Handle, name string, legacyOffset uintptr) (uintptr, error) {
addr, err := syscall.GetProcAddress(dll, name)
if err == nil && addr != 0 {
return addr, nil
}
bundle := resolveDLLBundle()
if supportsLegacyLoaderOffsets(bundle.LoaderVersion) {
globalLogger.Warn("[辅助程序] Loader %s 未导出 %s回退使用旧版偏移 0x%x", bundle.LoaderVersion, name, legacyOffset)
return uintptr(dll) + legacyOffset, nil
}
return 0, fmt.Errorf("Loader %s does not export %s; legacy offsets are only allowed for %s", bundle.LoaderVersion, name, fallbackDLLVersion)
}
func supportsLegacyLoaderOffsets(version string) bool {
switch version {
case fallbackDLLVersion, "5.0.8.6009":
return true
default:
return false
}
}
func getLoaderFunctions(dll syscall.Handle) (*LoaderFunctions, error) {
const (
GetUserWxWorkVersion = 0x4B70
UseUtf8 = 0x4A60
UseRecvJsUnicode = 0x4AC0
InitWxWorkSocket = 0x4B10
SetDataLocationPath = 0x5460
InjectWxWork = 0x4BF0
InjectWxWorkMultiOpen = 0x4E80
InjectWxWorkPid = 0x50D0
DestroyWxWork = 0x5310
SendWxWorkData = 0x5800
)
var err error
funcs := &LoaderFunctions{}
funcs.GetUserWxWorkVersion, err = getLoaderProcAddress(dll, "GetUserWxWorkVersion", GetUserWxWorkVersion)
if err != nil {
return nil, err
}
funcs.UseUtf8, err = getLoaderProcAddress(dll, "UseUtf8", UseUtf8)
if err != nil {
return nil, err
}
funcs.UseRecvJsUnicode, err = getLoaderProcAddress(dll, "UseRecvJsUnicode", UseRecvJsUnicode)
if err != nil {
return nil, err
}
funcs.InitWxWorkSocket, err = getLoaderProcAddress(dll, "InitWxWorkSocket", InitWxWorkSocket)
if err != nil {
return nil, err
}
funcs.SetDataLocationPath, err = getLoaderProcAddress(dll, "SetDataLocationPath", SetDataLocationPath)
if err != nil {
return nil, err
}
funcs.InjectWxWorkPid, err = getLoaderProcAddress(dll, "InjectWxWorkPid", InjectWxWorkPid)
if err != nil {
return nil, err
}
funcs.DestroyWxWork, err = getLoaderProcAddress(dll, "DestroyWxWork", DestroyWxWork)
if err != nil {
return nil, err
}
funcs.InjectWxWork, err = getLoaderProcAddress(dll, "InjectWxWork", InjectWxWork)
if err != nil {
return nil, err
}
funcs.InjectWxWorkMultiOpen, err = getLoaderProcAddress(dll, "InjectWxWorkMultiOpen", InjectWxWorkMultiOpen)
if err != nil {
return nil, err
}
funcs.SendWxWorkData, err = getLoaderProcAddress(dll, "SendWxWorkData", SendWxWorkData)
if err != nil {
return nil, err
}
globalLogger.Info("[辅助程序] 成功获取Loader DLL函数指针")
return funcs, nil
}