Fixed Module32Next

Marius Grigoriu <[email protected]> Sat, 07 Aug 2004 21:52:16 -0400
Newsgroups gmane.comp.emulators.winex.devel
Message-ID <[email protected]>
This patch corrects a problem with Module32Next by filling out the 
szModule field of the struct assembled. Currently, the string is always 
null, but this patch correctly returns the module name by stripping the 
path off of szExePath. Also, a few other fields are updated with the 
values as documented in the MSDN. This patch enables Anarchy Online to 
load sounds and music, and game objects like doors, shop terminals, and 
player heads. AO deserializes objects from its resource database by 
extracting the name of the function used to instantiate it. Module32Next 
is used along with GetProcAddress until the function is found in one of  
the many dlls. Without this patch, the module name is always null and 
GetProcAddress is never called.
module32next.patch (text/x-patch, 992 B)
? module32next.patch
Index: toolhelp.c
===================================================================
RCS file: /cvsroot/winex/dlls/kernel/toolhelp.c,v
retrieving revision 1.5
diff -r1.5 toolhelp.c
337a338
> 	const char *module_name;
352c353
<             lpme->th32ModuleID   = 0;  /* toolhelp internal id, never used */
---
>             lpme->th32ModuleID   = 1;  /* unused, always 1 */
354,355c355,356
<             lpme->GlblcntUsage   = 0; /* FIXME */
<             lpme->ProccntUsage   = 0; /* FIXME */
---
>             lpme->GlblcntUsage   = 0xFFFF;
>             lpme->ProccntUsage   = 0xFFFF;
359d359
<             lpme->szModule[0]    = 0;  /* FIXME */
360a361,366
> 			/* strip path from szExePath to get the module name */
> 			module_name = strrchr(lpme->szExePath, '\\');
> 			if(!module_name++) module_name = lpme->szExePath;
> 			strncpy(lpme->szModule, module_name, sizeof(lpme->szModule));
> 
> 			TRACE("Module: %s, ExePath: %s\n", lpme->szModule, lpme->szExePath);