Fire30
Seasoned Member
So I need to replace certain parts of a char * buffer in a function that I am hooking so I found the function that works fine on pc, but when I run it on xbox I get an error in watson and the xbox turns off. It is just using standard library functions so idk why the xbox is having so much trouble.
The error I am getting is:
This heap cannot be used from the current thread.
------------------------------------------------------------------------
stop code: 0xf4 (CRITICAL_OBJECT_TERMINATION)
(0x78C50000,0x91844F38,0x000005EA,0x000000E8)
------------------------------------------------------------------------
Here is the function:
Here is how I am calling it:
I think it has to do with the strcpy or strncpy but I am still confused.
The error I am getting is:
This heap cannot be used from the current thread.
------------------------------------------------------------------------
stop code: 0xf4 (CRITICAL_OBJECT_TERMINATION)
(0x78C50000,0x91844F38,0x000005EA,0x000000E8)
------------------------------------------------------------------------
Here is the function:
C:
void replace(char * o_string, char * s_string, char * r_string) {
//a buffer variable to do all replace things
char buffer[8092];
//to store the pointer returned from strstr
char * ch;
//first exit condition
if(!(ch = strstr(o_string, s_string)))
return;
//copy all the content to buffer before the first occurrence of the search string
strncpy(buffer, o_string, ch-o_string);
//prepare the buffer for appending by adding a null to the end of it
buffer[ch-o_string] = 0;
//append using sprintf function
sprintf(buffer+(ch - o_string), "%s%s", r_string, ch + strlen(s_string));
//empty o_string for copying
o_string[0] = 0;
strcpy(o_string, buffer);
//pass recursively to replace other occurrences
return replace(o_string, s_string, r_string);
}
Here is how I am calling it:
C:
int functionHook(char FAR *buf, int len)
{
int ret = function(buf,len);
replace(buf,"THISISREPLACED","THISISSUBSITUTEDIN");
return ret;
}
I think it has to do with the strcpy or strncpy but I am still confused.
Last edited: