flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
edfed
[erf mode]
to modify the name, right clic on icon, then, rename. or F2 or ren file.axt file.ext [/erf mode] i insert a general question in this thread. how to modify, access, create, delete, read, write etc files in a "FILE SYSTEM independant" way? is it possible? |
|||
![]() |
|
wisepenguin
hello,
this works successfully for me using latest fasm 1.67.26 Code: start: cinvoke printf, strMain cinvoke rename, strOld, strNew cinvoke exit, 0 section '.data' data readable writeable strMain db 'Renaming cool.txt to mool.txt ',0 strOld db 'cool.txt',0 strNew db 'mool.txt',0 you need to null terminate strings manually in FASM have a good day |
|||
![]() |
|
optiplex
Thank you wisepenguin.
But it didnt work for me ![]() Im also using the latest fasm 1.67.26, but the code doesnt work. Code: ; rename example ; by optiplex format PE CONSOLE 4.0 include 'INCLUDE\win32a.inc' start: cinvoke printf, strMain cinvoke rename, strOld, strNew cinvoke getchar, 0 cinvoke exit, 0 section '.data' data readable writeable strMain db 'Renaming cool.txt to mool.txt ',0 strOld db 'cool.txt',0 strNew db 'mool.txt',0 section '.idata' import data readable writeable library msvcrt, 'msvcrt.dll' import msvcrt,\ printf, 'printf',\ getchar, 'getchar',\ rename, 'rename',\ exit, 'exit' Any idea? Thanks again. |
|||
![]() |
|
wisepenguin
i ran mine on windows xp, with the following set up
my documents\test.exe (your code) my documents\cool.txt so the file to rename is in the same directory as the program. but your first code hard coded it to "C:\cool.txt". if you like change it back to C:\cool.txt and make sure C:\cool.txt exists initially. but i can still confirm, it works successfully here by null terminating the strings. i hope this helps, or you find the fault if it doesn't. |
|||
![]() |
|
dap
optiplex wrote: Thank you wisepenguin. 1 - getchar() doesn't require any parameter 2 - you don't need to call exit() here, you can use the instruction "ret" instead but remember that EAX must contain the return value of main() |
|||
![]() |
|
optiplex
Okay, I got it working now
Thank wisepenguin, and thank you too dap for the tips ![]() |
|||
![]() |
|
wisepenguin
anytime.
what was the problem in the end ? |
|||
![]() |
|
optiplex
I think it was because of the pathes, i used C:\cool.txt > C:\mool.txt, but when I had them in the same directory as the program, like you did, it worked for me.
|
|||
![]() |
|
Goplat
Why is this in the DOS forum?
|
|||
![]() |
|
dap
This works on my computer :
Code: format PE console 4.0 entry start include 'win32a.inc' section '.text' code readable executable start: push ebp mov ebp, esp push new push old call [rename] pop ecx ecx ; rename() returns zero if the operation succeeds test eax, eax jnz .failure push success call [puts] pop ecx .failure: pop ebp xor eax, eax ret section '.rdata' data readable old db 'C:\Documents and Settings\Bastien\Bureau\cool.txt', 0 new db 'C:\Documents and Settings\Bastien\Bureau\mool.txt', 0 success db 'Success', 0 section '.idata' data readable import library msvcrt, 'msvcrt.dll' import msvcrt, \ rename, 'rename', \ puts, 'puts' |
|||
![]() |
|
revolution
You can also use the API MoveFile or MoveFileEx, no need to use msvcrt.
|
|||
![]() |
|
DOS386
..
Last edited by DOS386 on 12 Mar 2008, 01:02; edited 1 time in total |
|||
![]() |
|
revolution
Okay, no problem, if ever I manage to catch a mod roaming around doing nothing I will be sure to grab him by the collar point him here.
|
|||
![]() |
|
asmrox
when you use pe format, why dont u call from kernel32? MoveFile.
and you dont have to 'exit'. Pogram is loading by call from CsrCreateThread, and must return to CsrExitThread. Code: format PE CONSOLE 4.0
entry start also entrypoint is not needed. format pe console is enought. |
|||
![]() |
|
revolution
asmrox wrote: also entrypoint is not needed. format pe console is enought. |
|||
![]() |
|
asmrox
in exe no. Program will start executing from executable section, or smth like tat
|
|||
![]() |
|
revolution
asmrox wrote: in exe no. Program will start executing from executable section, or smth like tat |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.