Source file: /~heha/hsn/switch_mode.zip/switch_mode.cpp

#include <stdlib.h>
#include <cstdio>

extern "C" bool switch_cs(int cs, bool (*f)());
extern "C" bool check_mode();
extern "C" __int64*_sgdt();

void mainCRTStartup() {
 int hi = (__int64)check_mode >> 32;
 if (hi) {
  printf("Pech, Adresse > 2 GB, High-Teil = 0x%X\n",hi);
  return;
 }
 int cs = 0x23;
 printf("switch to CS=%02x\n", cs);
// if (argc > 1) cs = strtoul(argv[1], 0, 16);
 __int64*gdt=_sgdt();	// Ob sgdt oder sldt hängt vom Bit 2 von cs ab!
 printf("gdt:%llX\n",gdt);
 if (__int64(gdt)>=0) {		// Oh, das darf nicht gelesen werden!
  __int64 ent=gdt[cs>>3];
  printf("ent:%llX\n",ent);
 }
 bool r = switch_cs(cs, check_mode);
 if (r) printf("cs=%02x: 64-bit mode\n", cs);
 else   printf("cs=%02x: 32-bit mode\n", cs);
}
Detected encoding: ANSI (CP1252)4
Wrong umlauts? - Assume file is ANSI (CP1252) encoded