I had problems with the software that I worked on a while ago. I found out that the problems are caused by strcpy (), strcat (), etc. And all sorts of string functions that have no protection and can overwrite target buffers if the source has a problem for any reason.
What I was doing at that time was writing a C-parser (I used C later ...) and found all the function calls (which is easy in the C syntax: '(' is a function call if inside the block In C ++ you classes and structures will also have to be detected, but this is not so much.) Now you can generate an error for any function that your software should not use and that breaks your assembly.
C ++ free parsers exist "everywhere", so you can use one of them and reuse this code.
Now there is another way that the preprocessor uses: for any function that you do not want to use your software, you create #define, which when used generates an error:
#define isspace function-error "please use iswspace() instead of isspace()"
Of course, this means that you need to know the list of such functions in the first place, which, as mentioned above, can be found by looking at the tables of the dynamic library. But as a result, you will not be able to compile your software without first fixing a few things. One of the problems you have to do is in the header file that is included last, or you may get some problems with the library header files:
#include <boost/shared_ptr.hpp> #include <non_unicode_function.h> ... your functions ...
This is probably simpler than the C ++ parser, but probably it is still not so much fun ... But if from time to time you need to call a forbidden function, you can make #undef, which you clearly document, etc. d. and then restore the value.
source share