changeset 2481:4f4eb812af28

KEY_ALL_ACCESS
author Ritor1
date Fri, 22 Aug 2014 17:41:25 +0600
parents 24fd08aef81e
children d58599b6306b
files AudioPlayer.cpp Game.cpp Registry.cpp
diffstat 3 files changed, 43 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Fri Aug 22 11:07:07 2014 +0600
+++ b/AudioPlayer.cpp	Fri Aug 22 17:41:25 2014 +0600
@@ -2125,7 +2125,7 @@
 {
   DWORD NumberOfBytesRead; // [sp+Ch] [bp-4h]@3
 
-  hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0x8000080u, 0);
+  hAudioSnd = CreateFileA("Sounds\\Audio.snd", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN, 0);
   if (hAudioSnd == INVALID_HANDLE_VALUE)
   {
     Log::Warning(L"Can't open file: %s", L"Sounds\\Audio.snd");
@@ -2178,7 +2178,7 @@
     v14 = 0;
     bEAXSupported = 0;
     b3DSoundInitialized = 0;
-    ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE");
+    ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128, "NONE");
     CheckA3DSupport(true);
     HPROVIDER prov;
     while ( AIL_enumerate_3D_providers(&v14, &prov, &Str1) )
@@ -2225,8 +2225,13 @@
   }
   pAudioPlayer->sRedbookVolume = AIL_redbook_volume(hAILRedbook);
   pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
+  //unsigned __int64 t = (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 128.0f);
   if ( bPlayerReady && hAILRedbook )
-    AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f) >> 32);
+    //AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 128.0f));
+	AIL_redbook_set_volume(hAILRedbook, (unsigned __int64)(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f) >> 32);
+  //int v = AIL_redbook_volume(pAudioPlayer->hAILRedbook);
+  //if (v)
+    //__debugbreak();
   LoadAudioSnd();
 }
 
@@ -2234,10 +2239,9 @@
 _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void)
 {
   int v0; // ecx@1
-  unsigned int v1; // ebp@2
   size_t v2; // eax@4
   signed int v3; // kr14_4@9
-  char *v5; // [sp+10h] [bp-Ch]@2
+  int v5; // [sp+10h] [bp-Ch]@2
   unsigned int pNum_devices; // [sp+14h] [bp-8h]@1
   _DIG_DRIVER *hDrv; // [sp+18h] [bp-4h]@3
   
@@ -2254,8 +2258,7 @@
 
   if ( sample_Rate < 11025 )
     return 0;
-  v1 = 0;
-  v5 = (char *)pAudioPlayer->array_000BF0;
+  v5 = 0;
   while ( 1 )
   {
     while ( 1 )
@@ -2268,16 +2271,15 @@
       pcmWaveFormat.wf.nAvgBytesPerSec = pcmWaveFormat.wf.nSamplesPerSec * pcmWaveFormat.wf.nBlockAlign;
       if ( !AIL_waveOutOpen(&hDrv, 0, -1, &pcmWaveFormat.wf) )
       {
-        strcpy(pAudioPlayer->pDeviceNames[v1 / 8], "Device: ");
-        v2 = strlen(pAudioPlayer->pDeviceNames[v1 / 8]);
-        AIL_digital_configuration(hDrv, (int *)v5, (int *)(v5 + 64), (char *)pAudioPlayer->pDeviceNames + v2 + v1 * 16);
+        strcpy(pAudioPlayer->pDeviceNames[v5], "Device: ");
+        v2 = strlen(pAudioPlayer->pDeviceNames[v5]);
+        AIL_digital_configuration(hDrv, (int *)pAudioPlayer->array_000BF0 + v5, (int *)pAudioPlayer->array_000C30 + v5, (char *)pAudioPlayer->pDeviceNames + v2 + v5 * 32);
         ++pNum_devices;
-        v1 += 8;
-        v5 += 4;
+        v5++;
         pAudioPlayer->uNumDevices = pNum_devices;
         if ( AIL_get_preference(15) )
           return hDrv;
-        if ( !strstr(pAudioPlayer->pDeviceNames[v1 / 8 - 1], "Emulated") )
+        if ( !strstr(pAudioPlayer->pDeviceNames[v5 - 1], "Emulated") )
           return hDrv;
         AIL_waveOutClose(hDrv);
         AIL_set_preference(15, 1);
@@ -2316,7 +2318,7 @@
   HKEY hKey; // [sp+10h] [bp-4h]@1
   hKey = 0;
   cbData = 4;
-  if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, 0x2001F, &hKey))
+  if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Aureal\\A3D", 0, KEY_READ|KEY_WOW64_32KEY, &hKey))
   {
     int Aureal3D_SplashAudio = 0;
     if (query)
@@ -2552,8 +2554,6 @@
   void *v9; // eax@8
   int v12; // [sp+1Ch] [bp-8h]@1
 
-  //__debugbreak();//Ritor1
-
   if ( this->b3DSoundInitialized )
   {
     //v5 = &this->uNum3DSamples;
@@ -2612,7 +2612,7 @@
     if ( pSounds[i].pSoundData == _this )
     {
       free(_this);
-      memset(&pSounds[i], 0, 0x80u);
+      memset(&pSounds[i], 0, sizeof(pSounds[i]));
     }
   }
 
--- a/Game.cpp	Fri Aug 22 11:07:07 2014 +0600
+++ b/Game.cpp	Fri Aug 22 17:41:25 2014 +0600
@@ -70,7 +70,6 @@
 
 
 
-
 Game *pGame;
 
 
@@ -1746,6 +1745,9 @@
             GUIWindow::Create(243, 162, 0, 0, WINDOW_PressedButton2, (int)pBtn_SliderLeft, (char *)1);
             pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f);
             pAudioPlayer->PlaySound((SoundID)218, -1, 0, -1, 0, 0, 0, 0);
+			//int v = AIL_redbook_volume(pAudioPlayer->hAILRedbook);
+			//if (v)
+				//__debugbreak();
             continue;
           }
           if ( uMessageParam == 5 )//Increase sound level button right
@@ -4884,13 +4886,13 @@
 		hNWC = nullptr,
 		hMM7 = nullptr,
 		hVersion = nullptr;
-	if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hSoftware))
+	if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hSoftware))
 	{
-		if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, 0x2001Fu, &hNWC))
+		if (!RegOpenKeyExA(hSoftware, "New World Computing", 0, KEY_READ|KEY_WOW64_32KEY, &hNWC))
 		{
-			if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, 0x2001Fu, &hMM7))
+			if (!RegOpenKeyExA(hNWC, "Might and Magic VII", 0, KEY_READ|KEY_WOW64_32KEY, &hMM7))
 			{
-				if (!RegOpenKeyExA(hMM7, "1.0", 0, 0x2001Fu, &hVersion))
+				if (!RegOpenKeyExA(hMM7, "1.0", 0, KEY_READ|KEY_WOW64_32KEY, &hVersion))
 				{
 					DWORD cbData = 3;
 					if (!RegQueryValueExA(hVersion, "CDDrive", 0, 0, (BYTE *)drive, &cbData))
@@ -5269,17 +5271,17 @@
 		uTurnSpeed = (unsigned int)uCPUSpeed < 199 ? 128 : 64; // adjust turn speed to estimated fps
 		break;
 
-	case 1u:             // 16x
+	case 1:             // 16x
 		Log::Warning(L"x16 Turn Speed"); // really shouldn't use this mode
 		uTurnSpeed = 128;
 		break;
 
-	case 2u:             // 32x
+	case 2:             // 32x
 		Log::Warning(L"x32 Turn Speed"); // really shouldn't use this mode
 		uTurnSpeed = 64;
 		break;
 
-	case 3u:             // smooth
+	case 3:             // smooth
 		uTurnSpeed = 0;
 		break;
 	}
--- a/Registry.cpp	Fri Aug 22 11:07:07 2014 +0600
+++ b/Registry.cpp	Fri Aug 22 17:41:25 2014 +0600
@@ -30,11 +30,11 @@
   cbData = 4;
   if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )// for 64 bit
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) )
     {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v10, &dwDisposition) )
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v10, &dwDisposition) )
       {
-        if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, 0xF003Fu, 0, &v11, &dwDisposition) )
+        if ( !RegCreateKeyExA(v10, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v11, &dwDisposition) )
         {
 			LSTATUS status;
           if ( status = RegQueryValueExA(v11, lpValueName, 0, 0, Data, &cbData) )
@@ -74,16 +74,16 @@
   v8 = 0;
   hKey = 0;
   phkResult = 0;
-  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
+  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) )
     {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) )
       {
-        if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, 0xF003Fu, 0, &v9, &dwDisposition) )
+        if ( !RegCreateKeyExA(v8, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v9, &dwDisposition) )
         {
           v2 = strlen(Str);
-          RegSetValueExA(v9, lpValueName, 0, 1u, (const BYTE *)Str, v2 + 1);
+          RegSetValueExA(v9, lpValueName, 0, 1, (const BYTE *)Str, v2 + 1);
           RegCloseKey(v9);
         }
         RegCloseKey(v8);
@@ -117,10 +117,10 @@
   hKey = 0;
   phkResult = 0;
   v4 = RegCloseKey;
-  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey)
-    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition)
-    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition)
-    || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) )
+  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey)
+    || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition)
+    || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v13, &dwDisposition)
+    || RegCreateKeyExA(v13, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v14, &dwDisposition) )
   {
     result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen);
   }
@@ -169,13 +169,13 @@
   v7 = 0;
   hKey = 0;
   phkResult = 0;
-  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, 0x2001Fu, &hKey) )
+  if ( !RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ|KEY_WOW64_32KEY, &hKey) )
   {
-    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) )
+    if ( !RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, KEY_ALL_ACCESS, 0, &phkResult, &dwDisposition) )
     {
-      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v7, &dwDisposition) )
+      if ( !RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, KEY_ALL_ACCESS, 0, &v7, &dwDisposition) )
       {
-        if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, 0xF003Fu, 0, &v8, &dwDisposition) )
+        if ( !RegCreateKeyExA(v7, "1.0", 0, "", 0, KEY_ALL_ACCESS, 0, &v8, &dwDisposition) )
         {
           RegSetValueExA(v8, lpValueName, 0, 4, Data, 4);
           RegCloseKey(v8);