Created
July 19, 2015 11:11
-
-
Save dkrutsko/41eabc685bec9c397614 to your computer and use it in GitHub Desktop.
Another way to hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Windows.h> | |
typedef int (__cdecl *PRINTF) | |
(const char* _Format, ...); | |
typedef void (*Mystery) (PRINTF p); | |
void main (void) | |
{ | |
const char mystery[] = | |
{ | |
0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x10, | |
0xC6, 0x45, 0xF0, 0x48, 0xC6, 0x45, | |
0xF1, 0x65, 0xC6, 0x45, 0xF2, 0x6C, | |
0xC6, 0x45, 0xF3, 0x6C, 0xC6, 0x45, | |
0xF4, 0x6F, 0xC6, 0x45, 0xF5, 0x20, | |
0xC6, 0x45, 0xF6, 0x57, 0xC6, 0x45, | |
0xF7, 0x6F, 0xC6, 0x45, 0xF8, 0x72, | |
0xC6, 0x45, 0xF9, 0x6C, 0xC6, 0x45, | |
0xFA, 0x64, 0xC6, 0x45, 0xFB, 0x21, | |
0xC6, 0x45, 0xFC, 0x0A, 0xC6, 0x45, | |
0xFD, 0x00, 0x8D, 0x45, 0xF0, 0x50, | |
0xFF, 0x55, 0x08, 0x83, 0xC4, 0x04, | |
0x8B, 0xE5, 0x5D, 0xC3, 0x00, 0x00, | |
}; | |
DWORD old; | |
VirtualProtect ((LPVOID) mystery, | |
sizeof (mystery), | |
PAGE_EXECUTE_READWRITE, &old); | |
((Mystery) mystery) (printf); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Mystery (PRINTF p) | |
{ | |
const char text[] = | |
{ | |
'H', 'e', 'l', 'l', 'o', ' ', | |
'W', 'o', 'r', 'l', 'd', '!', | |
'\n', '\0', | |
}; | |
p (text); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment