|
-
Aug 23rd, 2005, 10:26 PM
#1
Thread Starter
Addicted Member
Delete a file in ASM?
How is this done? I saw very little documentation on it and I think it went something like,
Code:
lea dx, ptrtofilename;
mov ah, 41h;
but I wasn't entirely sure.. can anyone clarify?
-
Aug 24th, 2005, 02:14 AM
#2
Re: Delete a file in ASM?
It depends. What instruction set are you using? Is it going to be 32-bit or 16-bit? If its 32-bit (well, MASM), it wouldn't be too hard.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 26th, 2005, 07:52 AM
#3
Addicted Member
Re: Delete a file in ASM?
INT 21H Function 41H : Delete File
This function deletes a file (but not read-only) from within a program. Load the address in the DX of an ASCII string containing the device path and filename, with no wild-card references:
Code:
ASCstrng DB 'd:\pathname', 00H ; ASCII string
...
MOV AH,41H
LEA DX, ASCstrng
INT 21H
A valid operation clears the carry flag, marks the filename in the directory as deleted, and releases the file's allocated disk space in the FAT. An error sets the carry flag and returns code 02, 03, or 05 in the AX.
you should get yourself Ralf-Brown's Interrupt List
http://www.cs.cmu.edu/afs/cs/user/ra...WWW/files.html
if u felt my post make u happy ,
then u could make me happy too by rating my post
-
Aug 26th, 2005, 08:00 AM
#4
Re: Delete a file in ASM?
Thats compiler specific isn't it? I mean, the interrupts wouldn't work in 32-bit assembly?
Which is why I asked what he was using..
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 26th, 2005, 08:28 AM
#5
Addicted Member
Re: Delete a file in ASM?
compiler specific?
that is MS DOS (operating system) interrupt to delete a file, of course, you must using FAT filesystem.
whether the interrupt would works in 32-bit windows... em.. could create a com file to try. i am not so sure, but i guess it should work.
if u felt my post make u happy ,
then u could make me happy too by rating my post
-
Aug 26th, 2005, 08:39 AM
#6
Re: Delete a file in ASM?
I'll give it a test when I get my new PC.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 26th, 2005, 08:52 AM
#7
Addicted Member
Re: Delete a file in ASM?
k, just confirm, you can use the DOS interrupt to delete file, create directory and much more.
Code:
ORG 100h
jmp start
aa db 'c:\apple.txt',00h
start:
mov ah,41h
mov dx,aa
int 21h
mov ax,4ch
int 21h
create a file in c:\apple.txt or wat sover place u want to put and (if change then modify the aa variable)
i use fasm assembler (free and open source) http://flatassembler.net
Code:
fasm myfile.txt myfile.com
Last edited by asmdev; Aug 26th, 2005 at 08:56 AM.
if u felt my post make u happy ,
then u could make me happy too by rating my post
-
Aug 26th, 2005, 09:23 AM
#8
Re: Delete a file in ASM?
Nice. That will become very useful. I've always had to resort to calling API's. No doubt this would be alot faster aswell (without having to go through all the windows crap beforehand).
Ta.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 26th, 2005, 01:30 PM
#9
Re: Delete a file in ASM?
Uh, in Windows, you should be calling the APIs, not using DOS interrupts. It's always better to do it the supported way.
-
Aug 26th, 2005, 05:12 PM
#10
Addicted Member
Re: Delete a file in ASM?
ya, so that the code works in FAT, NTFS or watever new FS microsoft introduce ;-p
if u felt my post make u happy ,
then u could make me happy too by rating my post
-
Aug 27th, 2005, 12:38 AM
#11
Re: Delete a file in ASM?
 Originally Posted by penagate
Uh, in Windows, you should be calling the APIs, not using DOS interrupts. It's always better to do it the supported way.
True, but it's always good to experiment (if you've got the money, and decide to ruin your PC ).
PS: How often do you change your avatar penagate? My god, its like you change it after every meal 
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 28th, 2005, 01:56 AM
#12
Re: Delete a file in ASM?
Change is healthy (or whatever). I refocused it again after twice being accused by RobDog of not seeing things properly 
Congrats on 2K posts BTW.
-
Aug 28th, 2005, 08:46 AM
#13
Re: Delete a file in ASM?
lol. RobDog is wise.
Ta 
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|