The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: 2-Bit Chip on September 13, 2009, 04:19:36 PM

Title: The Windows API
Post by: 2-Bit Chip on September 13, 2009, 04:19:36 PM
Are the functions of the Windows API optimized for best performance or for reliability?

Are there alternatives avaliable: Like opening a file without using the winapi?
Title: Re: The Windows API
Post by: Jimg on September 13, 2009, 04:55:36 PM
Obviously the api is not optimized, or it would be written in assembly.

Why would one ever write a program that is not reliable?  It it doesn't work, it's a bug.  So there is no optimizing for reliability, only writing programs that work and those that don't.

There are no VIABLE alternatives for windows programming.
Title: Re: The Windows API
Post by: dedndave on September 13, 2009, 04:57:20 PM
in DOS days, or even win95/98 with FAT drives, it may have been easy
by the time you write the code to find a file on an NTFS drive, you'd be better off using the API
even then, you'd have to get into ring 0 i think
the API calls aren't "optimized" at all, from what i can see - lol
they are biased toward functionality
keep in mind, that files on a drive may be partially in cache or shared
you're better off letting the system determine what is shared - what is cached - what permissions are needed
reading and writing files seems pretty fast to me using the API
Title: Re: The Windows API
Post by: Astro on September 13, 2009, 05:04:04 PM
QuoteAre there alternatives avaliable: Like opening a file without using the winapi?
Why would you want to do that? ::)

Astro.
Title: Re: The Windows API
Post by: 2-Bit Chip on September 13, 2009, 05:06:00 PM
The reason for me asking about alternatives is for speed.
Title: Re: The Windows API
Post by: Astro on September 13, 2009, 05:09:12 PM
Ahh - thought it might be for some other reason.

Astro.
Title: Re: The Windows API
Post by: BlackVortex on September 13, 2009, 09:32:13 PM
Well, winapi+cache management+hard disk's hardware cache and all that shiznit has pretty good performance actually.

If you want to improve upon it, then you can use your own virtual filesystem (kinda) , like steam's gcf files, which are big container files that contain thousands of files. The actual reading is kinda the same, but you can optimize the read/seek times, because you can stack the files exactly the way you want and make your own indexes and whatever.

I've no practical experience and I am simplifying it, but I hope you get the idea.

@ Astro : Your constant I-wannabe-a-cracker yapping has gotten tiring.
Title: Re: The Windows API
Post by: hutch-- on September 13, 2009, 09:37:45 PM
If you are interfacing with the OS, use the OS functions, its the only reliable way to do it. If a normal OS function will do the job and its clean and simple to use, (not all of them are) then use it but if you need speed and can write the code reliably without the system's inbuilt SEH and other considerations that make it slower, write your own andd see the difference.