Quelltext /~heha/-geheim/multiser.zip/msc.c

#include <windows.h>	// ExitProcess()

#ifdef _M_X64
void __chkstk(unsigned len) {}
#else
#if _MSC_VER >= 1500
# define _alloca_probe _alloca_probe_16
#endif
void _declspec(naked) _cdecl _alloca_probe() {_asm{
	add	eax,3
	and	al,~3		// Teilbarkeit durch 4 sicherstellen
	push	ecx
	 lea	ecx,[esp]+8	// ecx = Endadresse auf Stack
	 jmp	short testpg
onepg:	 sub	ecx,4096
	 sub	eax,4096
	 test	dword ptr [ecx],eax	// seitenweise Speicherlesezyklus anstoßen
testpg:	 cmp	eax,4096
	 jae	short onepg
	 sub	ecx,eax			// ecx = Startadresse auf Stack
	 mov	eax,esp			// eax = Zeiger auf ursprüngliches ecx
	 test	dword ptr [ecx],eax	// nochmal Speicherlesezyklus
	 mov	esp,ecx			// esp = Startadresse (Rückgabewert)
	mov	ecx,[eax]		// ecx restaurieren
	jmp	dword ptr[eax+4]	// Rücksprung zum Aufrufer
}}

void _declspec(naked) _cdecl _aullshr() {_asm{
	btr	ecx,5
	jc	short l1
	shrd	eax,edx,cl
	shr	edx,cl
	ret
l1:	mov	eax,edx
	xor	edx,edx
	shr	eax,cl
	ret 
}}

void _declspec(naked) _cdecl _allshl() {_asm{
	btr	ecx,5
	jc	short l1
	shld	edx,eax,cl
	shl	eax,cl
	ret
l1:	mov	edx,eax
	xor	eax,eax
	shl	edx,cl
	ret
}}

void _declspec(naked) _cdecl _allmul() {_asm{
	mov	eax,[esp+8]	// hi(f1)
	mov	ecx,[esp+16]	// hi(f2)
	or	ecx,eax
	mov	ecx,[esp+12]	// lo(f2)
	jnz	short l1
	mov	eax,[esp+4]	// lo(f1)
	mul	ecx		// edx:eax = lo(f2)×lo(f1)
	ret	16
l1:	push	ebx
	 mul	ecx		// (edx:)eax = lo(f2)×hi(f1)
	 mov	ebx,eax
	 mov	eax,[esp+8]	// lo(f1)
	 mul	dword ptr[esp+20]// (edx:)eax = lo(f1)×hi(f2)
	 add	ebx,eax
	 mov	eax,[esp+8]
	 mul	ecx		// edx:eax = lo(f2)×lo(f1)
	 add	edx,ebx
	pop	ebx
	ret	16
}}
#endif

#pragma bss_seg(".CRT$XCA")
char ctor_start;
#pragma bss_seg(".CRT$XCZ")
char ctor_end;
#pragma bss_seg()
#pragma comment(linker,"/merge:.rdata=.text")
DECLSPEC_IMPORT void _cdecl _initterm(const char*a,const char*e);
DECLSPEC_IMPORT void _cdecl __getmainargs(int*,char***,char***,int,int*);
extern int _cdecl main(int,char**,char**);

void mainCRTStartup() {
 int argc,newmode;
 char**argv,**envp;
 _initterm(&ctor_start,&ctor_end);
 __getmainargs(&argc,&argv,&envp,0,&newmode);
 ExitProcess(main(argc,argv,envp));
}
Vorgefundene Kodierung: UTF-80