In Assembly (using FASM assembler), I would like to create a .bat file and then run it.
I can create the file normally using the functions contained in msvcrt.dll. I close the file and try to run using system, but nothing happens (not even an error message)
The file is created correctly. Program code section:
main:
push mode ; w
push fileN ; run.bat
call [fopen]
pop [fileP] ; pego o endereço do stream do arquivo e jogo em fileP
push [fileP] ; coloco novamente o valor na pilha, para o fwrite
push eax
mov eax, 85 ; número de valores para escrever
push eax
mov eax, 1 ; tamanho em bytes de cada valor
push eax
push dataB ; conteúdo do arquivo batch
call [fwrite] ; -> até aqui tudo ok
push [fileP] ; endereço stream do arquivo
call [fclose] ; Creio que funcione corretamente
push pExec ; string contento os comandos pada executar
call [system] ; executado corretamente, mas não executa o .bat
call [exit]
I assumed that it might not be closing the file correctly, or that at runtime the file would still not be closed (by system delay)
I tried to use system to use the timeout, anyway nothing happened. (except timeout execution)
I thought about using sleep, but I do not know how to use it in ASM. (I've also tried to do delay with a loop, same result.)
Would anyone know the error?
More details: I am mounting to 32bits, the S.O. is Windows 7 64bit.