dreamstalker / rehlds

Reverse-engineered HLDS
GNU General Public License v3.0
653 stars 167 forks source link

CRT Issue #1028

Open abramann opened 4 months ago

abramann commented 4 months ago

I'm reversing hw.so starting from this project, sometimes, the execution crashes at ntdll after specific game DLL call or delete / free memory call, sometimes not seems there is an incompatibility between the loaded CRTs, like chromhtml.dll, which is VC 10, and most game DLLs are VC 6.0 while I am compiling VC 14. Sometimes LoadLibrary crashes when load chromhtml.dll but if loaded at DllMain will never crash.

Static linking MT/MTd did not resolve the issue.

Is the only way to fix this by rebuilding with the same toolset?

Is there a rule for CRTs compatibility because game originally loads different CRTs.

deprale commented 3 months ago

Sometimes LoadLibrary crashes when load chromhtml.dll but if loaded at DllMain will never crash.

so just do it at dllmain? why make an issue lol.

anyway this sounds like you're just not cleaning up before calling freelibrary func, you need to load chrom as a separate thread, then when u are unloading it - you need to use WaitForSingleObject, close the handle, and ONLY THEN use freelibrary (I am assuming chromhtml exports a function you can call that will unload itself).

edit: but if u insist doing it the other way, you can always have a separate thread, and when you want to load chromhtml you just pause ALL execution in MainThread, and in the separate thread u can load chromhtml.