[PATCH] Implement GetCurrentHwProfileA() fully

Ben Collins bcollins at ubuntu.com
Thu Feb 23 20:25:59 CST 2006


I setup Wine mainly to make use of some online poker clients that I use
a lot. I experienced some known bugs related to advapi32.dll,
specifically GetCurrentHwProfileA()'s semi-stub.

The first issue was that the szHwProfileGuid was being set to a string
that was one byte too long. This resulted in it actually being a
concantenation of szHwProfileGuid and szHwProfileName. Fixing that,
programs like FullTiltPoker.exe were able to work. The website suggested
changing the return value to 0 (false), but that was just so things got
ignored.

The second issue with this function was more related to the hard coding
of the GUID. Some sites, such as PacificPoker and ParadisePoker, can and
will kill user access to the site. They do not do this by username, but
but the Profile GUID (I didn't realize this till I started reading bug
reports, and checking things). Presumably, this reduces the chance that
someone simply changes their username. They pretty much block the user's
system, unless they reinstall, or manually change the GUID.

Because of this, all wine installs by default are not allowed to login
to these sites (it only took one person to get kicked before the GUID
was dead).

So, to get things done to my liking, I just bit the bullet and
implemented GetCurrentHwProfileA() correctly.

The patch below has two parts

1. Implement GetCurrentHwProfileA() fully. It will read the current
profile (0x0000 value), and obtain the values from this profile for
docking state, profile name, and profile GUID.

2. Add default registry entries for the HWLK\*\IDConfigDB\* values.

This still results in a default profile GUID. If anyone knows a way to
generate a value for this during wineboot, that's probably the best
solution.

diff -urN wine-0.9.6/dlls/advapi32/advapi.c wine-0.9.6-ben/dlls/advapi32/advapi.c
--- wine-0.9.6/dlls/advapi32/advapi.c	2006-01-19 14:13:51.000000000 +0000
+++ wine-0.9.6-ben/dlls/advapi32/advapi.c	2006-02-24 02:18:26.000000000 +0000
@@ -116,11 +116,57 @@
  */
 BOOL WINAPI GetCurrentHwProfileA(LPHW_PROFILE_INFOA pInfo)
 {
-	FIXME("(%p) semi-stub\n", pInfo);
-	pInfo->dwDockInfo = DOCKINFO_DOCKED;
-	strcpy(pInfo->szHwProfileGuid,"{12340001-1234-1234-1234-1233456789012}");
-	strcpy(pInfo->szHwProfileName,"Wine Profile");
-	return 1;
+	CHAR profile[32];
+	DWORD type;
+	DWORD size;
+	DWORD ret;
+	DWORD val;
+	HKEY hkey;
+	BOOL profile_result = 0;
+
+	ret = RegOpenKeyA(HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Control\\IDConfigDB",
+			  &hkey);
+
+	if (ret != ERROR_SUCCESS)
+		goto profile_error;
+
+	ret = RegGetValueA(hkey, NULL, "CurrentConfig", RRF_RT_DWORD,
+			   &type, &val, &size);
+	if (ret != ERROR_SUCCESS || size != 4 || type != REG_DWORD)
+		goto profile_error;
+
+	/* At least, I think the profile names are hex */
+	sprintf(profile, "Hardware Profiles\\%04x", (WORD)(val & 0xffff));
+
+	/* Set the profile name */
+	size = MAX_PROFILE_LEN;
+	ret = RegGetValueA(hkey, profile, "FriendlyName", RRF_RT_REG_SZ,
+			   &type, pInfo->szHwProfileName, &size);
+
+	if (ret != ERROR_SUCCESS || type != REG_SZ)
+		goto profile_error;
+
+	/* Now get the GUID of this profile */
+	size = HW_PROFILE_GUIDLEN;
+	ret = RegGetValueA(hkey, profile, "HwProfileGuid", RRF_RT_REG_SZ,
+			   &type, pInfo->szHwProfileGuid, &size);
+
+	if (ret != ERROR_SUCCESS || type != REG_SZ)
+		goto profile_error;
+
+	/* And finally the docking state */
+	ret = RegGetValueA(hkey, "CurrentDockInfo", "DockingState", RRF_RT_DWORD,
+			   &type, &pInfo->dwDockInfo, &size);
+
+	if (ret != ERROR_SUCCESS || size != 4 || type != REG_DWORD)
+		goto profile_error;
+
+	/* Success */
+	profile_result = 1;
+
+profile_error:
+	RegCloseKey(hkey);
+	return profile_result;
 }
 
 /******************************************************************************
diff -urN wine-0.9.6/tools/wine.inf wine-0.9.6-ben/tools/wine.inf
--- wine-0.9.6/tools/wine.inf	2006-01-19 14:14:43.000000000 +0000
+++ wine-0.9.6-ben/tools/wine.inf	2006-02-24 02:19:19.000000000 +0000
@@ -211,6 +211,23 @@
 HKLM,System\CurrentControlSet\Control\Session Manager\Environment,"windir",,"%10%"
 HKLM,System\CurrentControlSet\Control\Session Manager\Environment,"winsysdir",,"%11%"
 
+[IDConfigDB]
+HKLM,System\CurrentControlSet\Control\IDConfigDB,"CurrentConfig",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB,"UserWaitInterval",,0x0000001e
+HKLM,System\CurrentControlSet\Control\IDConfigDB,"IsPortable",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Alias\0000,"DockingState",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Alias\0000,"Capabilities",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Alias\0000,"DockID",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Alias\0000,"SerialNumber",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Alias\0000,"ProfileNumber",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles,"Unknown",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0000,"PreferenceOrder",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0000,"FriendlyName",,"Wine Profile"
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0000,"Aliasable",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0000,"Cloned",,0x00000000
+HKLM,System\CurrentControlSet\Control\IDConfigDB\Hardware Profiles\0000,"HwProfileGuid",,"{12340001-1234-1234-1234-123345678901}"
+
+
 [Fonts]
 HKLM,%FontSubStr%,"Arial CE,238",,"Arial,238"
 HKLM,%FontSubStr%,"Arial CYR,204",,"Arial,204"


-- 
Ubuntu     - http://www.ubuntu.com/
Debian     - http://www.debian.org/
Linux 1394 - http://www.linux1394.org/
SwissDisk  - http://www.swissdisk.com/




More information about the wine-devel mailing list