mollismerx / elfspy

C++ Testing using spies and fakes for isolation and simulation
GNU General Public License v2.0
59 stars 10 forks source link

Faking read, write and open #4

Open jmcruz-uma opened 4 years ago

jmcruz-uma commented 4 years ago

Hi, I've made some examples that fake unix functions successfully (i.e. socket, close or pipe). However, when I try to fake the read() and write() functions included in , the fake functions are never executed, but just the original ones.

Regarding open(), the problem arises at compilation-time because of the signature of the function:

int open(const char *, int flags, ...);

It seems that the variable arguments in functions are not allowed in this versión of elfspy. Definitely it would be nice to support this kind of signatures.

Best regards and thanks for this fantastic library, Jesus

ttm56p commented 4 years ago

@jmcruz-uma Hey. You should inspect assembly if read and write function are invoked at all, instead of syscall interrupt. For example https://en.wikibooks.org/wiki/X86_Assembly/Interfacing_with_Linux#int_0x80 Linux version of this assembler contain example that using this interrupt to write to console - https://flatassembler.net/download.php You could use it to test things out.