Code injection does not work along with FILE* for logging

61 Views Asked by At

In our project, we are injecting the code at various places by rewriting the IL using .Net CorProfiler APIs. Everything works fine. Now, for logging purpose, we have started opening a file using FILE* as shown below -

FILE* ptLogFile = _fsopen(file_name, "a+t, ccs=UTF-8", _SH_DENYWR);
fwrite(message, sizeof(wchar_t), wcslen(message), ptLogFile);
fflush(ptLogFile);

By introducing the above code, I don't get any error, but at the same time, code injection also does not work for some cases. However, it continues working for some other cases. By removing the above code, again everything start working as expected.

Any idea what is the relationship between FILE with IL rewriting? How do I make both of them work together?

UPDATE: Any suggestion, how do I debug this?

0

There are 0 best solutions below