X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "Rod Pemberton" Newsgroups: comp.os.msdos.djgpp Subject: Re: argv[0] Date: Wed, 7 Dec 2011 06:00:48 -0500 Organization: Aioe.org NNTP Server Lines: 68 Message-ID: References: <16b04d29-8317-4c7f-929c-1a22a328fa32 AT p9g2000vbb DOT googlegroups DOT com> <9bf257a7-a0f8-43ba-a65f-36c6027f68cb AT r28g2000yqj DOT googlegroups DOT com> NNTP-Posting-Host: qBjb0U1QTH77eiTXJSCpEw.user.speranza.aioe.org X-Complaints-To: abuse AT aioe DOT org X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.2001 X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Microsoft Outlook Express 6.00.2800.2001 X-Priority: 3 X-MSMail-Priority: Normal Bytes: 3230 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Georg" wrote in message news:dca6ea34-7cf2-4abe-afc3-8a1122602ed9 AT y12g2000vba DOT googlegroups DOT com... > I finally found a way to retrieve the absolute path to the current > program. It seems that the pointer to the environment in the PSP when > using DJGPP is wrong for whatever reason. There is a KB16 program > which has the correct pointer to the environment I am looking for in > its PSP though. > > So I walked through the MCB chain to find the environment block in > there. There are two entries in there with the same PSP, one is the > environment block, the other is the program code. The latter has the > PSP right after the MCB so if that is not the case you have found the > environment block. The absolute path is then located behind the size > given in the MCB of the environment block. Here is my code: > > #include > #include > #include > #include > > main(int argc,char **argv) > { > [...] FYI, that code returns the correct program names, but doesn't return *any* paths here, not for RM DOS, nor for Windows 98 "dosbox." In RM DOS, it also SIGSEGVs. What does this do on your end? It's what I suggested earlier. It prints the correct ENV here. #include #include #include #define env_size 320 int main() { int i; unsigned int env_address = 0; unsigned int the_psp = 0 , old_psp; static char environment[env_size]; the_psp = _go32_info_block.linear_address_of_original_psp; printf("\nPSP:%04X\n",the_psp); dosmemget(the_psp,sizeof(environment),&environment); do{ old_psp=the_psp; dosmemget(the_psp+0x16, 2, &the_psp); the_psp <<= 4; //make linear address dosmemget(the_psp,sizeof(environment),&environment); }while(old_psp!=the_psp); dosmemget(the_psp + 0x2C, 2, &env_address); env_address <<= 4; //make linear address printf("\nENV:%04X\n",env_address); dosmemget(env_address, sizeof(environment), &environment); for (i=0;i