Funny you should say that hutch. :lol
Source (.cpp):
#pragma comment(linker, "/ENTRY:main")
#undef UNICODE
#include <Windows.h>
void main()
{
MessageBox(NULL, "PowerBASIC shall bow down to VC++!", "VC++", MB_OK);
exit(0);
}
I guess you could say I cheated because I created my own entry point instead of VC++'s t_main(int, char**) ::)
Here is a 1k version of MessageBox but its written in C without the ++.
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
#include <windows.h>
void main()
{
MessageBox(0,"Yo Ho Ho Horton","Small C",MB_OK);
}
/* ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤ */
I'm coming back hard now hutch.
768 bytes in VC++. :8)
Update: Took out the exit() call to size it down to 688 bytes.
nice name, Horton
Alex will probably make one at 512 bytes :P
I think I have came up with a way to size it down past 512 bytes. :P
:bg
Yo ho ho, the minimum legal size for a PE file in 1024 bytes, 1st section has the MZ and PE headers and the section table, the second is .CODE. The tweaked versions don't run on all windows versions. :P
Dang! It's tough squeezing out a few extra bytes!
Final size comes out to be 640 bytes.
#pragma comment(linker, "/ENTRY:main")
#undef UNICODE
#define WIN32_EXTRA_LEAN
#include <Windows.h>
#pragma section(".text", read, execute, shared)
#pragma comment(linker, "/MERGE:.rdata=.text")
void __stdcall main()
{
MessageBox(NULL, "PowerBASIC shall bow down to VC++!", "VC++", MB_OK);
}
Quote from: hutch-- on February 01, 2011, 01:56:54 AM
:bg
Yo ho ho, the minimum legal size for a PE file in 1024 bytes, 1st section has the MZ and PE headers and the section table, the second is .CODE. The tweaked versions don't run on all windows versions. :P
Please have a look into MemInfoMicro thread (http://www.masm32.com/board/index.php?topic=15159.0)
It is 976 bytes. Without an icon it will be less than 800 bytes long.
It is not ordinary "Hello world!" stuff. See details in thread.
It works on *all* Windows versions.
Hold up.
751 bytes C++ proggie. Without "dirty" tricks!!!
MSVC10 compiler. Should work on ALL Windows versions - msvcrt independed.
Quote from: Antariy on February 01, 2011, 03:21:39 AM
751 bytes
Some final automatical postprocessing of EXE. Still it is not "dirty" trick.
735 bytes.
Quote from: hutch-- on February 01, 2011, 06:58:43 AM
Alex,
All I need to do is look at the Microsoft PE specifications and the minimum size for a valid PE file is 2 x 512 byte sections, 1024 bytes. I have seen hand coded hex PE files under 200 bytes but they are not valid 32 bit PE files, they are just non-functional oddities that may not crash all Windows versions.
Reference Microsoft PECOFF.DOCX
Still, MemInfoMicro smaller that 1024 bytes. And it still work under *all* versions of Windows. Just have a look :bg
At least, executable provided are existed, they are not fantasy :bg
Minimum size of executables which may do something useful (i.e. - has import(s)) is less than 600 bytes (~548 bytes is limit by my tests) and this executable will be compatible with all Windows versions.
P.S. I'm fan of PB, too, you know this :bg
:bg
Alex,
Manufacturers specifications are no fantasy, they are designed by the vendor to suit their OS loader. Some versions are more tolerant than others but the bottom line is 2 x 512 byte sections = 1024 bytes. i have seen "PE" files under 500 bytes but they are just curios, not valid applications.
Quote from: Antariy on February 01, 2011, 07:50:48 AM
MemInfoMicro smaller that 1024 bytes ...
Another contest of "Who has the smallest ....?" :bg
I can't compete, so I won't participate :snooty:
It's also the wrong focus, because who cares nowadays about super-small sizes. All you are likely to get with such binaries are problems with various anti-virus software.
The true issues with PB are:
- no support for an object format. You're stuck in the little PB world.
- you have to buy 2 compilers to get the full functionality.
Quote
P.S. I'm fan of PB, too, you know this :bg
I like toys, that's why I'm also a fan.
Quote from: hutch-- on February 01, 2011, 07:59:22 AM
:bg
Alex,
Manufacturers specifications are no fantasy, they are designed by the vendor to suit their OS loader. Some versions are more tolerant than others but the bottom line is 2 x 512 byte sections = 1024 bytes. i have seen "PE" files under 500 bytes but they are just curios, not valid applications.
But I told about real applications. I'm even not deciding things which only do "proper return to OS and exiting" as applications.
1024 bytes is big size to put many things to it, you know :bg
Actually, it is even too big - much more complex app than just "Hello World!" maybe placed into smaller size than bloated 1KB (I'm again about MemInfoMicro :bg :bg :bg)
Quote from: japheth on February 01, 2011, 08:02:04 AM
Quote from: Antariy on February 01, 2011, 07:50:48 AM
MemInfoMicro smaller that 1024 bytes ...
1. Another contest of "Who has the smallest ....?" :bg
2. I can't compete, so I won't participate :snooty:
3. It's also the wrong focus, because who cares nowadays about super-small sizes. All you are likely to get with such binaries are problems with various anti-virus software.
4. The true issues with PB are:
- no support for an object format. You're stuck in the little PB world.
- you have to buy 2 compilers to get the full functionality.
Quote
P.S. I'm fan of PB, too, you know this :bg
5. I like toys, that's why I'm also a fan.
1. That's not contest for me :bg - I just made it as powerful remake of thing included into examples of MASM32 package :bg
That's reason for "The Return" :bg
2. It is interesting anyway to know what peoples are think about it. Still, I've not see anything interest to it. Or too small interest.
3. I've uploaded it to virustotal, and only 7 antiviruses from ~40 (do not remember exact count) get it "suspect" - that was a crappy ones who think that anything advanced file format is a virus. All the commercial powerful AVs do not said anything. Norton said "strage stuff" - or similar, but not a virus. All others (KAV, MS's AV etc etc etc) said it is OK :bg
As about small size... Well, I'm care about it :bg
4. Also it generated some garbage, too. For example ~99 bytes of unusable code at start of file (401000h) - that code required for debugging build only, but included into anything build with no reason.
Also relocations for standard base adrress is strage stuff to do.
5. Yes, it is very convenient for fast writing of useful tools :U
Quote from: Antariy on February 01, 2011, 03:21:39 AM
751 bytes C++ proggie. Without "dirty" tricks!!!
MSVC10 compiler. Should work on ALL Windows versions - msvcrt independed.
How do you build it?
Care to share the batch script?
Quote from: TmX on February 01, 2011, 11:17:32 AM
Quote from: Antariy on February 01, 2011, 03:21:39 AM
751 bytes C++ proggie. Without "dirty" tricks!!!
MSVC10 compiler. Should work on ALL Windows versions - msvcrt independed.
How do you build it?
Care to share the batch script?
Have a look into Horton's posts, things like:
#pragma comment(linker, "/MERGE:.rdata=.text")
are switches used to linker. I'm prefer to not specify them in the source file itself, because MSVC10 linker have some problems with long strings from this pragma.
But you still may specify these switches on the linker's command line:
LINK.EXE /MERGE:.rdata=.text /MERGE:.data=.text ...
to get small output file size (to 1 KB).
Quote from: Antariy on February 02, 2011, 02:05:00 AM
Have a look into Horton's posts, things like:
#pragma comment(linker, "/MERGE:.rdata=.text")
are switches used to linker. I'm prefer to not specify them in the source file itself, because MSVC10 linker have some problems with long strings from this pragma.
But you still may specify these switches on the linker's command line:
LINK.EXE /MERGE:.rdata=.text /MERGE:.data=.text ...
to get small output file size (to 1 KB).
like this?
Quote
cl /c cpptest.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cpptest.cpp
C:\Users\Andre\Desktop>link /MERGE:.rdata=.text /MERGE:.data=.text user32.lib cpptest.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000020) with differen
t attributes
Quote from: TmX on February 02, 2011, 03:16:26 AM
like this?
Quote
cl /c cpptest.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cpptest.cpp
C:\Users\Andre\Desktop>link /MERGE:.rdata=.text /MERGE:.data=.text user32.lib cpptest.obj
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000020) with differen
t attributes
Yes :bg
Also, specify /FIXED switch to a linker for EXEs, since you have using MSVC10, too.
modern computers use cluster sizes of at least 8 Kb
anything less than that, and it's all the same - one cluster :P
Quote from: dedndave on February 04, 2011, 03:31:32 AM
modern computers use cluster sizes of at least 8 Kb
anything less than that, and it's all the same - one cluster :P
Network bandwidth, network bandwidth :P