Você pode tentar criar um programa que o chama no DosBox. Em seguida, renomeie o executável de 16 bits para progname.old.exe
e renomeie o novo programa para progname.exe
. Aqui está um programa de exemplo (Nota: isso não foi testado. Pode nem mesmo compilar.):
#include <stdlib.h>
#include <string.h>
#include <windows.h>
int main(int argc, char* argv[]) {
// The string we use to call DOSBOX:
const char *dosboxstrstart = "path\to\dosbox \"path\to\progname.old.exe ";
const char *dosboxstrend = "\" -exit";
// Get the entire command line, with a full path prepended
// to the first argument
char *allcmdline = GetCommandLine();
// Get a pointer to the start of this program's name, then
// skip past this program's name to get the arguments only
char *argstart = strstr(allcmdline, argv[0]) + strlen(argv[0]);
// Get the length of the argument string
// Get the length of the DosBox strings
size_t argstartlen = str_len(argstart);
size_t dosboxstrstartlen = str_len(dosboxstrstart);
size_t dosboxstrendlen = str_len(dosboxstrend);
// Create a buffer for the string to go into (+1 for the #include <stdlib.h>
#include <string.h>
#include <windows.h>
int main(int argc, char* argv[]) {
// The string we use to call DOSBOX:
const char *dosboxstrstart = "path\to\dosbox \"path\to\progname.old.exe ";
const char *dosboxstrend = "\" -exit";
// Get the entire command line, with a full path prepended
// to the first argument
char *allcmdline = GetCommandLine();
// Get a pointer to the start of this program's name, then
// skip past this program's name to get the arguments only
char *argstart = strstr(allcmdline, argv[0]) + strlen(argv[0]);
// Get the length of the argument string
// Get the length of the DosBox strings
size_t argstartlen = str_len(argstart);
size_t dosboxstrstartlen = str_len(dosboxstrstart);
size_t dosboxstrendlen = str_len(dosboxstrend);
// Create a buffer for the string to go into (+1 for the %pre%)
// Assumes that malloc won't go wrong; a lovely segfault
// will occur if it does! :-p
char *finalstring = malloc(argstartlen + dosboxstrstartlen + dosboxstrendlen + 1);
// Put the string into it, piece by piece
memcpy(finalstring, dosboxstrstart, dosboxstrstartlen);
memcpy(finalstring + dosboxstrstartlen, argstart, argstartlen);
memcpy(finalstring + dosboxstrstartlen + argstartlen, dosboxstrend, dosboxendlen + 1);
// Run the command
system(finalstring);
// Perform our duty to the almighty kernel!
free(finalstring);
}
)
// Assumes that malloc won't go wrong; a lovely segfault
// will occur if it does! :-p
char *finalstring = malloc(argstartlen + dosboxstrstartlen + dosboxstrendlen + 1);
// Put the string into it, piece by piece
memcpy(finalstring, dosboxstrstart, dosboxstrstartlen);
memcpy(finalstring + dosboxstrstartlen, argstart, argstartlen);
memcpy(finalstring + dosboxstrstartlen + argstartlen, dosboxstrend, dosboxendlen + 1);
// Run the command
system(finalstring);
// Perform our duty to the almighty kernel!
free(finalstring);
}
Esse código pressupõe que os argumentos que o programa de 32 bits passa não contêm aspas. Se sim, você terá que adicionar algum tipo de função de escape, e eu não sei de nenhum na biblioteca padrão.