Game Development Community

Runtime error - all help appreciated

by Arron Bailiss · in Technical Issues · 09/02/2006 (6:45 pm) · 0 replies

Hey all.

I'm using Visual C++ 2005 Express to compile the TGE. I've followed a couple of guides around here and everything is fine apart from one function in "engine/platformWin32/winStrings.cc". The function
char* dStrrchr(char *str, S32 c)
is giving me an access violation.

In one of the guides that I read regarding using VC2005 Express with TGE, they told me to change the dStrrchr function to do the following:

return strstr((char*)str1,(char*)str2);
When I do this I get 2 compile errors saying that "str1" and "str2" are undeclared identifies. As the function declaration says "str" and "c" not "str1" and "str2" I changed this to:

return strstr((char*)str,(char*)c);

This is where the access violation comes into play. When running the application in debugging mode the debugger catches the following in this function:

"Unhandled exception at 0x00c564d7 in torqueDemo_DEBUG.exe: 0xC0000005: Access violation reading location 0x0000002e."

The disassembly is as follows:

char* dStrrchr(char *str, S32 c)
{
00A88240  push        ebp  
00A88241  mov         ebp,esp 
00A88243  sub         esp,0C0h 
00A88249  push        ebx  
00A8824A  push        esi  
00A8824B  push        edi  
00A8824C  lea         edi,[ebp-0C0h] 
00A88252  mov         ecx,30h 
00A88257  mov         eax,0CCCCCCCCh 
00A8825C  rep stos    dword ptr es:[edi] 
   return strstr((char*)str,(char*)c);
00A8825E  mov         eax,dword ptr [c] 
00A88261  push        eax  
00A88262  mov         ecx,dword ptr [str] 
00A88265  push        ecx  
00A88266  call        strstr (703E8Bh) 
00A8826B  add         esp,8 <------------------------ error here!
}

What should I define this function as to get it working? Any and all help would be greatly appreciated.

Thanks in advance.

About the author

Recent Threads