|
Answer» Hi,
I'm trying to intercept calls to a .exe to trace them (legit as my company WROTE the .exe) as part of debugging, and I've suceeded in writing a short .bat file which does what I want after renaming the original command with -ORIG.
the-command.bat Code: [Select]@echo off echo .|time >> logfile.txt echo %0 %* >> logfile.txt the-command-ORIG.exe %*
The problem is that the customer's program is expecting to call the-command.exe not the-command.bat.
I tried renaming the .bat file, but then it won't execute. I tried creating a shortcut with .exe extension to the .bat but that didn't work either.
Is there a compiler I could use to convert it from .bat to .exe? or do I need to WRITE a one-line program to call the .bat and compile it? or would it be a whole lot easier to write a C program to do the tracing instead?I've nearly SOLVED it with MinGW and the following code
Code: [Select]#include <unistd.h> #include <stdio.h>
main(INT argc, char *argv[])
{ argv[0] = "C:\\path\\etc\\the-command.bat"; execv("C:\\path\\etc\\the-command.bat", argv); RETURN 0; } I'll follow up on the final problems in the programming forum.
|