Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

加载最新版sciter.dll崩溃STATUS_ACCESS_VIOLATION错 #47

Closed
idigger opened this issue Jul 2, 2024 · 4 comments · Fixed by #48
Closed

加载最新版sciter.dll崩溃STATUS_ACCESS_VIOLATION错 #47

idigger opened this issue Jul 2, 2024 · 4 comments · Fixed by #48

Comments

@idigger
Copy link

idigger commented Jul 2, 2024

最新版 sciter.dll(v5.0.3.13) 用 mmpp 加载崩溃 STATUS_ACCESS_VIOLATION 错,v5.0.3.13版之前的均可正常加载。

不知这一版开始有了什么变化。

dll下载连接 https://gitlab.com/sciter-engine/sciter-js-sdk/-/blob/main/bin/windows/x32/sciter.dll?ref_type=heads

用最新提交的 mmpp 加载也不行。
__LdrLoadDllMemoryExW 崩溃 STATUS_ACCESS_VIOLATION

int main() {
    size_t len = 0;
    PVOID buffer = ReadDllFile2("MemoryModule.dll", &len);
    printf("1: %p, %u\n", buffer, len);
    HMODULE hm = (HMODULE)LoadLibraryWithReflectiveLoader( buffer, len );
    printf("2: hm: %p\n", hm);

    //MmpGlobalDataPtr = *(PMMP_GLOBAL_DATA*)GetProcAddress(hm, "MmpGlobalDataPtr");
    //printf("3: %p\n", MmpGlobalDataPtr);
    __LdrLoadDllMemoryExW = (LdrLoadDllMemoryExW_t)GetProcAddress(hm, "LdrLoadDllMemoryExW");
    __LdrUnloadDllMemory = (LdrUnloadDllMemory_t)GetProcAddress(hm, "LdrUnloadDllMemory");
    printf("4: %p, %p\n", __LdrLoadDllMemoryExW, __LdrUnloadDllMemory);

    VirtualFree(buffer, len, MEM_RELEASE);
    buffer = ReadDllFile2("sciter50313.dll", &len);
    printf("5: %p, %u\n", buffer, len);

    HMODULE hm1 = NULL;
    NTSTATUS res = __LdrLoadDllMemoryExW(&hm1, NULL, LOAD_FLAGS_NOT_FAIL_IF_HANDLE_TLS, buffer, 0, NULL, NULL);

    printf("6: res: %x, hm1: %p\n", res, hm1);
    
    //DisplayStatus();

    return 0;
}

上面 ReadDllFile2 中内存是用 VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE) 分配的。

错误日志

故障存储段 2115915853192506159,类型 1
事件名称: APPCRASH
响应: 不可用
Cab ID: 0

问题签名:
P1: loader_mmpp_from_mem.exe
P2: 0.0.0.0
P3: 00000000
P4: 3752B4E99BA4A6F1.DLL
P5: 0.0.0.0
P6: 66843965
P7: c0000005
P8: 000059e4
P9: 
P10: 

上面测试程序可以正常加载 5.0.3.13版之前的 sciter.dll

麻烦大侠看看能否解决一下,多谢了。

@bb107
Copy link
Owner

bb107 commented Jul 3, 2024

你好,感谢反馈。问题发生的原因是,在处理重定位时没有正确判断边界条件,导致内存访问冲突。稍后将发布修复。

@idigger
Copy link
Author

idigger commented Jul 3, 2024

问题定位真是快啊,为你点赞,静候佳音。

@bb107
Copy link
Owner

bb107 commented Jul 3, 2024

试试relocation分支

@idigger
Copy link
Author

idigger commented Jul 3, 2024

经测试 relocation 分支加载 sciter.dll v5.0.3.13 及以前的版本均没有问题了,
可以合并到master了吧,
感谢及时修复,祝一切顺利。

@bb107 bb107 linked a pull request Jul 3, 2024 that will close this issue
@bb107 bb107 closed this as completed in #48 Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants