Page 15 of 30

Posted: Fri Feb 04, 2011 11:39 pm
by Mel
Great that i <3 u...

Posted: Sat Feb 05, 2011 11:27 am
by ent1ty
The funny part was supposed to be the mushrooms.... nevermind.
I guess i should have said that he is 14.

Posted: Tue Feb 08, 2011 3:12 am
by kazymjir
Mushrooms are very good :D
Unfortunately, it's not season for shrooms.


Image

This one is good :D

Posted: Tue Feb 08, 2011 6:56 am
by Brainsaw
Hello World? Need vacation ;)

Posted: Tue Feb 08, 2011 7:13 am
by kazymjir
Brainsaw, are you sure? :D

Posted: Tue Feb 08, 2011 9:26 am
by pippy3

Code: Select all

a: 
   goto a


I think it will get into an infinite loop.

Posted: Tue Feb 08, 2011 11:46 am
by Brainsaw
kazymjir wrote:Brainsaw, are you sure? :D
Just a wild guess ;). It does, however, almost look as good as the "hello world" of Brainfuck ;)

Posted: Tue Feb 08, 2011 11:49 am
by kazymjir
This picture is very trickery.
All people is starting to analysis those hexadecimal ascii values, but...
look at printf function.
Is there something missing? :)

Posted: Tue Feb 08, 2011 12:13 pm
by hybrid
why would you need a separate format string when you already built one? Should work without any problems.

Posted: Tue Feb 08, 2011 12:56 pm
by kazymjir
Ok, I will give you solution.
This code will output... an error.
Why? Because printf() is in stdio.h, which is not included in this code :)

Solutions of most problems are very easy, but human perception always looking for complex solutions, not seeing simple patterns.

Posted: Tue Feb 08, 2011 4:10 pm
by hybrid
No, that's an incomplete answer. The thing is that the output of this function was searched. It's also called _tmain, which will probably also not link without a proper main(). But you could still define the output of this function in case it's called (which would also require that it's properly linked before).

Posted: Tue Feb 08, 2011 7:11 pm
by Bate
Put aside all the sophistry and it actually says "Hello World" ;)

Code: Select all

#include <stdio.h>

int main()
{
  char* p=new char[12];*p=0x48;++p;*p=0x65;++p;*p=0x6c;
  ++p;*p=0x6c;++p;*p=0x6f;++p;*p=0x20;++p;*p=0x57;++p;
  *p=0x6f;++p;*p=0x72;++p;*p=0x6c;++p;*p=0x64;++p;
  *p=0x0;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;

  printf(p);
  delete p;

  return 0;
}

Posted: Wed Feb 09, 2011 2:36 am
by kazymjir
hybrid wrote:It's also called _tmain, which will probably also not link without a proper main().
_tmain is used in VC++. _t* functions is calling ANSI functions if _UNICODE isn't defined. If _UNICODE is defined, it's calling UNICODE version of that function.
So everything is ok, proper main will be called (main if ANSI, wmain if UNICODE).
But, there don't even must be main() function. Why?
Because, compiler is working always first. If compiler found error in code, it will not run linker.

So, output will be an error that printf() function is not found.
Linker will be not called, because of error found by compiler in code :)

Posted: Wed Feb 09, 2011 7:18 am
by Brainsaw
Here is my optimized version:

Code: Select all

  #include <stdio.h>

int main() {
  char *p=new char[13];
  *p++=0x48;*p++=0x65;*p++=0x6c;*p++=0x6c;*p++=0x6f;
	*p++=0x20;*p++=0x57;*p++=0x6f;*p++=0x72;*p++=0x6c;*p++=0x64;*p++=0x0A;*p=0;
  --p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;printf(p);return 0;
}

Posted: Wed Feb 09, 2011 9:10 am
by kazymjir
Let's do more optimization!

Code: Select all

int main() {
	char *p=new char[13];
	*p++=0x48;*p++=0x65;*p++=0x6c;*p++=0x6c;*p++=0x6f;
	*p++=0x20;*p++=0x57;*p++=0x6f;*p++=0x72;*p++=0x6c;*p++=0x64;*p++=0x0A;*p=0;
	--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;--p;
	__asm__("\
		movl $4, %%eax\n\
		movl $0, %%ebx\n\
		push %0\n\
		pop %%ecx\n\
		movl $13,%%edx\n\
		int $0x80" : :"g"(p)); return 0;
}