ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Tiny 'Touch' 32 bits program in C (3 kb)

<< < (5/6) > >>

hwtan:
If you want it smaller, here's the program in assembly. Executable file has size of 1536 bytes.


--- Code: ASM ---.486                                ; create 32 bit code    .model flat, stdcall                ; 32 bit memory model    option casemap :none                ; case sensitive      include \masm32\include\windows.inc    include \masm32\include\kernel32.inc    include \masm32\include\user32.inc    include \masm32\include\shell32.inc      includelib \masm32\lib\kernel32.lib    includelib \masm32\lib\shell32.lib     .codestart: main proc        local   commandLine:LPSTR        local   numOfArgs:DWORD        local   argsP:DWORD        local   fileH:HANDLE        local   currentSysTime:SYSTEMTIME        local   newFileTime:FILETIME            invoke  GetCommandLineW        mov     commandLine, eax        invoke  CommandLineToArgvW, commandLine, addr numOfArgs        mov     argsP, eax        cmp     numOfArgs, 2        jl      failure        mov     eax, argsP        mov     ebx, [eax + 4]        invoke  CreateFileW, ebx, FILE_READ_ATTRIBUTES+FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ+FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL        mov     fileH, eax        cmp     eax, INVALID_HANDLE_VALUE        je      failure        invoke  GetSystemTime, addr currentSysTime        invoke  SystemTimeToFileTime, addr currentSysTime, addr newFileTime        invoke  SetFileTime, fileH, NULL, NULL, addr newFileTime        invoke  ExitProcess, 0        failure:                 invoke  ExitProcess, -1 main    endp    end     start

Gerome:
Hello,

Nicer :)
BTW, you can also compile it up to 1024 bytes using PellesC, and still in plain C :)

hwtan:
Interesting... AFAIK, win32 PE header is already 1KB in side...

Gerome:
Hi,
Interesting... AFAIK, win32 PE header is already 1KB in side...


-ethan (October 01, 2006, 02:17 PM)
--- End quote ---

Yes, but there are also PE compilation options using MSVC++6.0 that allows you to make 512 bytes length 32 bits executables :)
Below it's impossible, but 512 bytes for MSVC++ 6 is amazing :)

f0dder:
Just for fun, here's a 1kb C (well, C++) version, that has proper system return code :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version