actboy168 / YDWE

A Tool to Help the Creation of Warcraft III Map
GNU General Public License v3.0
467 stars 137 forks source link

测试地图无法拉起War3 #114

Closed Whimsyduke closed 6 years ago

Whimsyduke commented 6 years ago

WE的测试地图按钮无法拉起War3,YD自身正常最小化, 分析了下代码,下面调用过程中的函数调用及返回结果都是正确的

int create(lua_State* L),

bool process::create(const std::optional& application, const std::wstring& command_line, const std::optional& current_directory),

bool create_process( const wchar_t application, wchar_t command_line, bool inherit_handle, uint32_t creation_flags, const wchar_t* current_directory, LPSTARTUPINFOW startup_info, LPPROCESS_INFORMATION process_information, const fs::path& inject_dll, const std::map<std::string, fs::path>& replace_dll)

最终Detours的函数 BOOL WINAPI DetourCreateProcessWithDllW(_Inopt LPCWSTR lpApplicationName, _Inoutopt LPWSTR lpCommandLine, _Inopt LPSECURITY_ATTRIBUTES lpProcessAttributes, _Inopt LPSECURITY_ATTRIBUTES lpThreadAttributes, In BOOL bInheritHandles, In DWORD dwCreationFlags, _Inopt LPVOID lpEnvironment, _Inopt LPCWSTR lpCurrentDirectory, In LPSTARTUPINFOW lpStartupInfo, Out LPPROCESS_INFORMATION lpProcessInformation, In LPCSTR lpDllName, _Inopt PDETOUR_CREATE_PROCESS_ROUTINEW pfCreateProcessW); 也被调了,并且返回值是正确的,所以日志也是对的。但是War3就是没能启动

正常YD目录的启动War3是正常的。

luciouskami commented 6 years ago

并不是没有弹错,事实上有报错。 bug

actboy168 commented 6 years ago

如果@luciouskami和@Whimsyduke是在说同一个问题的话,错误信息上已经说得很清楚了,你的yd_loader.dll缺少序号为1的导出函数。

Whimsyduke commented 6 years ago

日志上并没有错误。也没有任何弹窗,目前在测试是哪个提交导致的问题。 如果是 @luciouskami 提到的问题,日志上应该是有记录的吧。 目前测试结果,问题出在“移除SetWindow”和“Fixed #112”之间

actboy168 commented 6 years ago

这是windows告诉你的错误,并不会在写在ydwe的日志里

Whimsyduke commented 6 years ago

SHA-1: 7844a12b51128b270c44de3629fd073c2a258e65

这个提交及之后就无法启动了

我这里并没有war3.exe的进程,所以也不存在那个报错窗口

actboy168 commented 6 years ago

yd_loader在这之前已经修改了加载方式。如果你因为这个提交出错,说明你编译的ydwe有错误/不完整

luciouskami commented 6 years ago

是这样的,我下的是AppVeyor编译好的版本。 bp 了 we的CreateProcessW 这个崩溃是在ResumeThread的时候发生的。跟进去发现是在call NtFlushInstructionCache的时候崩溃 image 这个jmp好像不太正常,看起来是被破坏了。

YDWE启动魔兽没有走到ResumeThread,所以并没有报错。

luciouskami commented 6 years ago

上面那个函数并没有问题,因为在别的进程中代码也是相同的,还需要继续测试

actboy168 commented 6 years ago

我统一两种启动方式,应该已经好了

luciouskami commented 6 years ago

这次还是报错,不过log有记录了 2017-11-14 00:04:48.321 [lua]-[error] Executed E:\YDWE\ydwe.exe failed

Whimsyduke commented 6 years ago

我对比单步调试 7844a12b51128b270c44de3629fd073c2a258e65 和 c9f0e0b72d2b4d6de56a076d9f023679ad65531d 两个提交的lua回到c++后面的代码 lua部分函数为function sys.spawn (command_line, current_dir, wait) 通过p:create(nil, command_line, current_dir)一句回到c++ 对应的c++函数是Development\Plugin\Lua\sys\luaopen_sys.cpp的int create(lua_State* L),(在227行) 二者完全相同,但是执行完Development\Core\ydbase\base\win\process.cpp的bool create_process()函数(在58行)之后只有一个war3被启动。并且内存中的返回值也一样

出现问题的点是DetourCreateProcessWithDllW这个函数,虽然成功执行了,但是后面一个提交编译的YD并没有成功启动进程

Whimsyduke commented 6 years ago

qq 20171114163112 war3进程实际上是拉起来了,问题是不知道为何在ResumeThread(pi.hThread);之后会挂掉 那么就是yd_loader.dll的问题了 无法启动的提交中,yd_loader.dll的DllMain都没能被调用……

luciouskami commented 6 years ago

看起来问题好像解决了,但是关于为什么ResumeThread在调用 NtFlushInstructionCache 的时候会崩溃这件事还是没有找到原因。

Whimsyduke commented 6 years ago

是yd_loader 的PluginName不能删,会导致war3.exe挂掉,ResumeThread挂掉的原因是这个

luciouskami commented 6 years ago

@Whimsyduke 这是一个问题。

Whimsyduke commented 6 years ago

@luciouskami 是一个问题,ResumeThread会挂掉是因为yd_loader 缺了PluginName,也就是出问题的提交干掉的

luciouskami commented 6 years ago

不知道原因,这个错很奇怪。

Whimsyduke commented 6 years ago

@luciouskami @actboy168 目前能拉起war3,但是没能加载相应的yd dll, 比如yd_jass_api之类的

luciouskami commented 6 years ago

@Whimsyduke 修复过的提交也不行吗?

luciouskami commented 6 years ago

应该没问题了,这个可以close了

Whimsyduke commented 6 years ago

@luciouskami @actboy168 似乎依旧不能拉起,

Whimsyduke commented 6 years ago

image yd路径下的就这么多 yd_japi之类的插件没有加载

luciouskami commented 6 years ago

2018-02-01 05:18:28.440 [root]-[info ] ------------------------------------------------------ 2018-02-01 05:18:28.441 [root]-[info ] LuaEngine 1, 31, 6, 2042 started. 2018-02-01 05:18:28.441 [root]-[info ] Compiled at 00:12:11, Jan 31 2018 2018-02-01 05:18:28.441 [root]-[info ] Windows version: 10.0.16299 2018-02-01 05:18:28.441 [root]-[debug] Initialize LuaEngine successfully. 2018-02-01 05:18:28.443 [lua]-[debug] ydwe path E:\YDWE 2018-02-01 05:18:28.444 [lua]-[error] [i18n]current language zh-CN 2018-02-01 05:18:28.446 [lua]-[debug] war3 path F:\war3_1.27a 2018-02-01 05:18:28.458 [lua]-[info ] LoadLibraryA kernel32.dll 2018-02-01 05:18:28.462 [lua]-[info ] LoadLibraryA blizzard.ax 2018-02-01 05:18:28.470 [lua]-[info ] LoadLibraryA Game.dll 以上是log 版本 fetch-master 魔兽又拉不起来了

luciouskami commented 6 years ago

这个问题已经解决了。@actboy168