CVS: winex/dlls/dinput/joystick main.c,1.13,1.14

[email protected] 1 Aug 2007 12:30:24 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/dinput/joystick main.c,1.13,1.14Update of /var/lib/cvsd/cvsroot/winex/dlls/dinput/joystick
In directory agravaine:/tmp/cvs-serv29005/dlls/dinput/joystick

Modified Files:
	main.c 
Log Message:

- fixed GetModuleFileNameA() to properly return a truncated filename error code.  GetModuleFileNameW() just calls GetModuleFileNameA(), so its error codes should be updated as well.
- fixed all the calls to GetModuleFileNameA/W() to check for small buffer and bad module errors.  Currently small buffer errors are just reported and are allowed to proceed with either an empty string or truncated string for the filename.  In the case of an error retrieving the module filename (error == 0), the calling function reports the error and returns immediately.


Index: main.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/dinput/joystick/main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- main.c	30 Mar 2007 22:06:10 -0000	1.13
+++ main.c	1 Aug 2007 12:30:21 -0000	1.14
@@ -144,6 +144,8 @@
 	
   char buffer[MAX_PATH+16];
   HKEY hkey, appkey = 0;
+  DWORD error;
+
   if (joystickoptionsread)
 	return;
   if (RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\dinput", 0, NULL,
@@ -154,7 +156,7 @@
   
   /* open the app-specific key */
   if (GetModuleFileName16( GetCurrentTask(), buffer, MAX_PATH ) ||
-      GetModuleFileNameA( 0, buffer, MAX_PATH )) {
+      ((error = GetModuleFileNameA( 0, buffer, MAX_PATH )) != 0 && error != MAX_PATH)) {
     HKEY tmpkey;
     char *p, *appname = buffer;
     if ((p = strrchr( appname, '/' ))) appname = p + 1;
@@ -167,6 +169,10 @@
     }
   }
 
+  else
+      ERR("could not retrieve the module file name (reason: '%s')\n", error == 0 ? "bad module" : "buffer too small");
+
+
   if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer) ))
   {
     int configDeadZone = atoi( buffer );