X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Received: by 10.224.64.202 with SMTP id f10mr53805856qai.2.1374991899259; Sat, 27 Jul 2013 23:11:39 -0700 (PDT) X-Received: by 10.49.35.68 with SMTP id f4mr2007170qej.0.1374991899244; Sat, 27 Jul 2013 23:11:39 -0700 (PDT) Newsgroups: comp.os.msdos.djgpp Date: Sat, 27 Jul 2013 23:11:39 -0700 (PDT) Complaints-To: groups-abuse AT google DOT com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=95.28.200.38; posting-account=nu_e-AoAAACYQOcAKQ31NWF_OGDHFEO_ NNTP-Posting-Host: 95.28.200.38 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <698956ae-cfda-4233-bca0-34b7a44a1e21@googlegroups.com> Subject: receiving of environment variables From: Vasya Pupkin Injection-Date: Sun, 28 Jul 2013 06:11:39 +0000 Content-Type: text/plain; charset=ISO-8859-1 Bytes: 1937 Lines: 24 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I try to receive the block of environment variables for executing program. There is the simple code for this target: void getenviron(char *envarea) { unsigned long pspoffs, envoffs; char psparea[256 + 1]; char *chpnt; __dpmi_regs myregs; myregs.x.ax = 0x6200; __dpmi_int(0x21, &myregs); /* Get PSP address */ /* Get segment address of environment variables block */ pspoffs = ((unsigned long)myregs.x.bx << 4) + 0x2C; envoffs = 0; dosmemget(pspoffs, 2, (void *)&envoffs); /* For debugging read whole PSP */ dosmemget(pspoffs - 0x2C, 256, (void *)psparea); envoffs <<= 4; /* Physical offset of environment block */ dosmemget(envoffs, 512, (void *)envarea); } After that "psparea" contains valid PSP (at first glance), but "envarea" contains only random data, which have absolutely no similarity with environment block. Why is this happening? Where is the error?