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

SafeDisc 1 games crash #17

Open NicknineTheEagle opened 2 months ago

NicknineTheEagle commented 2 months ago

It appears that none of SafeDisc 1 games work for me, ICD always crashes in dplayerx.dll. Tried the following games:

Running Windows 10. Using Alcohol 120% to mount Redump disc images. Not an issue with the game code since cracked exe produced by UnSafeDisc works fine. The games do work if Alcohol virtual drive is passed through to Windows XP VM.

Logs: LEGORacers.exe_SafeDiscShim.log LEGORacers.ICD_SafeDiscShim.log

Windows event log entries:

Faulting application name: LEGORacers.ICD, version: 0.0.0.0, time stamp: 0x37979360
Faulting module name: dplayerx.DLL, version: 0.0.0.0, time stamp: 0x3729dba5
Exception code: 0xc0000005
Fault offset: 0x00013044
Faulting process id: 0x138c
Faulting application start time: 0x01da9f18bcf2fb97
Faulting application path: C:\Games\LEGORacers\LEGORacers.ICD
Faulting module path: D:\dplayerx.DLL
Report Id: 0882d3a8-0083-41f4-baed-b1dc4d246f80
Faulting package full name: 
Faulting package-relative application ID: 
Faulting application name: LEGORacers.ICD, version: 0.0.0.0, time stamp: 0x37979360
Faulting module name: LEGORacers.ICD, version: 0.0.0.0, time stamp: 0x37979360
Exception code: 0xc0000005
Fault offset: 0x000a867c
Faulting process id: 0x138c
Faulting application start time: 0x01da9f18bcf2fb97
Faulting application path: C:\Games\LEGORacers\LEGORacers.ICD
Faulting module path: C:\Games\LEGORacers\LEGORacers.ICD
Report Id: 89584dd5-b462-46cc-ad53-0f5b8c27a40f
Faulting package full name: 
Faulting package-relative application ID: 
NicknineTheEagle commented 2 months ago

Figured out the root cause, it looks like the new injection mechanism involving overwriting the entry point from https://github.com/RibShark/SafeDiscShim/commit/8fedebb00cf7f73a8514f0bff292dd3a6f7a2d1e does not work for SafeDisc 1 ICDs. Simply calling Initialize from DllMain for ICD like in older revisions makes the game work.

NicknineTheEagle commented 2 months ago

While initializing from DllMain is unsafe due to loader lock, as far as I can tell, there's literally no other way to do this for ICD specifically. dplayerx.dll seems to be loaded before ICD entry point (from import table?) and it needs Secdrv driver in its own DllMain meaning that the shim must be initialized by this point or dplayerx.dll will crash.

mirh commented 2 months ago

My memory aches trying to remember what rule of thumb I must have read in the past, but you might want to take a notice at: https://www.vogons.org/viewtopic.php?t=51818 https://github.com/ElliotKillick/LdrLockLiberator

RibShark commented 2 months ago

I have a solution in mind for this; I will work on it once I have completed some other obligations.