RibShark / SafeDiscShim

SafeDiscShim is a compatibility tool that allows for SafeDisc protected games which utilize the insecure Macrovision Security Driver ("secdrv.sys") to run on modern versions of Windows .
Other
386 stars 12 forks source link

DxWnd integration #9

Closed ghotik closed 3 months ago

ghotik commented 3 months ago

Hello, RibShark I was brought to your SafeDiscShim code by a post on DxWnd forum by MrPepka, the guy that also wrote a post to you about the Polish version of "Tom & Jerry". I couldn't analyze completely the problem yet, but I got the suspicion that your shim and DxWnd could be incompatible when used together because they both rely on code injection hooks that could interfere with each other, but in theory is could be possible to integrate the logic of your shim with the DxWnd hooks. So, I wrote this message to ask you permission to be inspired by your source code and add this SafeDiscShim functionality to my DxWnd tool, of course keeping due reference to you as author of the code. You can visit the DxWnd pages on SourceForge and take a look to the DxWnd help/about section where I added the references to the open-source licence (a GPL v3) and hall of fame with all the contributors. Thank you for your attention, Ghotik

RibShark commented 3 months ago

Hi!

Yes, that's absolutely fine, since DxWnd is also licensed under the GPLv3 it is absolutely fine for you to include any relevant code (probably just the IOCTL handler; everything else is just hook/injection logic which would already be handled on your end).

ghotik commented 3 months ago

Hi, thank you so much for allowing this marriage ;) If I'm not asking too much, I'd like to have some support from you. So far I think I successfully integrated the "father" part of the SafeDisc logic, though with some caveats. I was also trying to identify a suitable testbed and I picked "Age of Empires II" ant that seems to work since the executable reaches the point where it tries to start the .ICD file. I don't know if you could suggest a better one to start with. But to get there I had to hook also the kernel32 DeviceIoControl API in addition to the ntdll NtDeviceIoControlFile counterpart. Now I should hook the CreateProcessA/W API, but it's not clear to me what should exactly happen. Looking at the code, it seems that SafeDiscShim is loading and executing the drvmgt.dll module from the Windows system directory and your readme notes describe what one should do in the case drvmgt.dll would be in the game folder. Well, now this is exactly the case of AoE2, there is a drvmgt.dll in the game folder and no file in my Windows11 system folders, so I wonder if I picked the wrong test case ... Also, in DxWnd logs the .ICD file showed some trace of dxwnd.dll in the arguments, which is probably something that your code should hide by injecting some proper data in the target process memory, but the operation is not too clear. Also in the process.c source there is a Process::Relaunch() method that seems unreferenced in all the project, never used anywhere. Is that so? Finally, I noted your statement about the unmanaged 0xCA002813 IoControlCode: I hope that through the replication of your code in DxWnd logic it will be easier to identify and fix all the cases and that both projects will benefit from our collaboration, I added a dialog box so that any user would be aware of the situation and will tell us where this code is to be found.

mirh commented 3 months ago

If you want another set of uh.. hunches, you can take a look at this other new project https://github.com/alekasm/SafeDiscAnalyzer/tree/master/SafeDiscAnalyzer