Is it possible to program win32 pe files without using api's?
Obviusely... yes....BUT WHY? you run under windows...then use it... apis are there to help...well most of them...:) I you want no APIS at ALL...write your own OS... i am doing that...but dont know when i will..if ever...end :)
What I would like to know is once you're done writing this program that runs w/o using any API, will anyone be able to detect it's existence? W/o API, how can you even open a window? OK, perhaps you can bit bang the IO port and make a printer respond, but so what? Been decades since anyone made a computer do anything as useless as TYPE every last bit of output it makes. Code is a tool to accomplish a task. Writing code is not a religion, you don't get closer to the godhead when you code in some 'pure' form. If you want an example of PURE assembly, try this: Pick a nice single chip processor, like the Z-80. Get a piece of paper and write a program for it to perform. Don't forget to sketch out some peripherals too, like buttons and display lights. Then wire wrap them together. So take this paper with your program on it, and write down the opcodes for each instruction, then leave dashes for any offsets or addresses. Once you have this, you can add in everything's absolute address, and finish the compilation. Now, take these opcodes and set the address and data switches on your manual EPROM burner and save the program to EPROM. Turn it on, and with an oscilloscope see if everything is running fine. If you can do this, then you have earned the right to talk to me about 'pure' assembler. Otherwise, 'pure' assembler is a myth, it just depends on how you define the term.
If your Win32 app jumps into ring-0, then you could theoretically get by without Win32 API. Even then, I'm sure you're going to have problems doing direct mem/io port access activities while running under an OS that's doing all kinds of things.
What happened to all those int 21h calls that you needed to do in in a dos application when you're making a windows application? Should console applications be able to call those since it's kind of like in a dos box except 32bit? If that is the case then you would be able to create a win32 application without using any apis at all.
No, a console based program has nothing to do with DOS. In fact, if I remember correctly, the console based program idea was originally instated in Windows NT, and was later added to Windows 95 for platform cros compatibility. A console based program is actually a Windows program that just starts with a text interface, rather than nothing. Windows still has to load the PE file, switch to protected mode, disable the interrupts, and begin execution, just like a normal GUI program.
I have tried to sell the view in the MASM32 introduction that assembler can do most things if you know how to write it. If you are trying to write win32 code, it cannot be done without API calls somewhere. Console output, screen display, disk IO etc.. For it to be win32 code, it MUST interact with the operating system somewhere. If you write 16 bit DOS code, it runs under a subsystem of windows if you are not using real mode DOS and you are calling interrupts that are in memory in IO.SYS so you are still calling operating system code, its just that 32 bit API calls are a hell of a lot more powerful than DOS interrupts in most things. Try and call DOS interrupts from 32 bit and in most instances you will get some interesting crashes in win9x, NT4/2K will be more gracious in the way it terminates you attempt to illegally access this code. C and Pascal can call API's, so can assembler, it can also create and use libraries as high level languages do but it can also write non standard code that uses common collectors, jumps across procedures, procedures with parameters passed in registers, macros that automate repetitious code and more or less anything you like. Its the flexibility and power that makes assembler a useful language to write in at low level if you are not MAN enough to write you code directly in HEX opcodes. :) These things make it a good choice in writing low level code, not some crippled notion of purity that will not work, that mentality died with people who had a copy of TASM and notepad and wondered why they could not write working applications. Regards, firstname.lastname@example.org PS: Happy New Year !
Strictly speaking, unless you want to program every piece of hardware you use, you must use some kind of API. For instance, when Windows programming became popular, INT 21H began to be called the DOS API. Win32 w/o explicit calls to Win32 API -- NO. You might be able to walk the export tables of the preloaded DLLs to find API entries, but I would expect their locations to be version specific. Win9x w/o Win32 API -- VxD (INT 20H) or Ring 0 back door WinNT w/o Win32 API -- NT kernel (I think it's INT 31H)