DXGL r842 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r841‎ | r842 | r843 >
Date:20:40, 5 August 2018
Author:admin
Status:new
Tags:
Comment:
Add automatic installation of Wine DLL overrides when the installer runs under Wine.
Add descriptions for installer sections.
Modified paths:
  • /Installer/dxgl.nsi (modified) (history)
  • /dxgl-nsis/dxgl-nsis.c (modified) (history)

Diff [purge]

Index: Installer/dxgl.nsi
@@ -215,6 +215,11 @@
216216 ExecWait '"$INSTDIR\dxglcfg.exe" profile_install'
217217 SectionEnd
218218
 219+Section "Set Wine DLL Overrides" SEC_WINEDLLOVERRIDE
 220+ DetailPrint "Setting Wine DLL Overrides"
 221+ WriteRegStr HKCU "Software\Wine\DllOverrides" "ddraw" "native,builtin"
 222+SectionEnd
 223+
219224 Section "Fix DDraw COM registration" SEC_COMFIX
220225 DetailPrint "Setting DDraw Runtime path in registry"
221226 ${If} ${RunningX64}
@@ -338,9 +343,26 @@
339344 BelowEight:
340345 SectionSetFlags ${SEC_COMFIX} 0
341346 VersionFinish:
 347+ dxgl-nsis::IsWine $0
 348+ Pop $0
 349+ ${If} $0 == "0"
 350+ SectionSetFlags ${SEC_WINEDLLOVERRIDE} 0
 351+ SectionSetText ${SEC_WINEDLLOVERRIDE} ""
 352+ ${EndIf}
342353 FunctionEnd
343354
 355+LangString DESC_SEC01 ${LANG_ENGLISH} "Installs the required components for DXGL."
 356+LangString DESC_SEC_VCREDIST ${LANG_ENGLISH} "The Visual C++ Redistributable package required for this version of DXGL was not detected. Selecting this will download a copy of the redistributable hosted on dxgl.info and install it."
 357+LangString DESC_SEC_WINEDLLOVERRIDE ${LANG_ENGLISH} "Sets a DLL override in Wine to allow DXGL to be used."
 358+LangString DESC_SEC_COMFIX ${LANG_ENGLISH} "Adjusts the COM registration of ddraw.dll to allow DXGL to be used from a game's folder. This option only applies to the user profile being used to install DXGL. Use for Windows 8 and above."
344359
 360+!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
 361+!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(DESC_SEC01)
 362+!insertmacro MUI_DESCRIPTION_TEXT ${SEC_VCREDIST} $(DESC_SEC_VCREDIST)
 363+!insertmacro MUI_DESCRIPTION_TEXT ${SEC_WINEDLLOVERRIDE} $(DESC_SEC_WINEDLLOVERRIDE)
 364+!insertmacro MUI_DESCRIPTION_TEXT ${SEC_COMFIX} $(DESC_SEC_COMFIX)
 365+!insertmacro MUI_FUNCTION_DESCRIPTION_END
 366+
345367 Function un.onUninstSuccess
346368 HideWindow
347369 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
Index: dxgl-nsis/dxgl-nsis.c
@@ -79,7 +79,7 @@
8080 {
8181 filename[0] = '1';
8282 }
83 - filename[1] = 0;
 83+ filename[1] = filename[2] = filename[3] = 0;
8484 pushstring(comp);
8585 pushstring(filename);
8686 }
@@ -95,10 +95,33 @@
9696 __cpuid(cpuid, 1);
9797 if ((cpuid[3] >> 26) & 1) out[0] = '1';
9898 else out[0] = '0';
99 - out[1] = 0;
 99+ out[1] = out[2] = out[3] = 0;
100100 pushstring(out);
101101 }
102102
 103+void __declspec(dllexport) IsWine(HWND hwndParent, int string_size,
 104+ TCHAR *variables, stack_t **stacktop, extra_parameters *extra)
 105+{
 106+ HMODULE ntdll;
 107+ char* (__cdecl *wine_get_version)();
 108+ char out[256];
 109+ EXDLL_INIT();
 110+ ntdll = LoadLibraryA("ntdll.dll");
 111+ if (!ntdll)
 112+ {
 113+ out[0] = '0';
 114+ out[1] = out[2] = out[3] = 0;
 115+ pushstring(out);
 116+ return;
 117+ }
 118+ wine_get_version = (char*(__cdecl*)())GetProcAddress(ntdll, "wine_get_version");
 119+ if (wine_get_version) out[0] = '1';
 120+ else out[0] = '0';
 121+ FreeLibrary(ntdll);
 122+ out[1] = out[2] = out[3] = 0;
 123+ pushstring(out);
 124+}
 125+
103126 // Quick and dirty memcpy
104127 void *memcpy(unsigned char *dest, unsigned char *src, size_t size)
105128 {