Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

542 lines
17 KiB

  1. /* SCCSID = %W% %E% */
  2. /*
  3. * Copyright Microsoft Corporation, 1983-1987
  4. *
  5. * This Module contains Proprietary Information of Microsoft
  6. * Corporation and should be treated as Confidential.
  7. */
  8. /****************************************************************
  9. * *
  10. * NEWSTA.C *
  11. * *
  12. * Statically allocated global variable definitions. *
  13. * *
  14. ****************************************************************/
  15. #include <minlit.h>
  16. #include <bndtrn.h>
  17. #include <bndrel.h>
  18. #include <newexe.h>
  19. #if EXE386
  20. #include <exe386.h>
  21. #endif
  22. #if SETVBUF
  23. #include <lnkio.h>
  24. #endif
  25. #if OXOUT OR OIAPX286
  26. #include <xenfmt.h>
  27. #endif
  28. #include <extern.h>
  29. /* Variables shared regardless of executable format */
  30. char FAR *lpszLink;
  31. char FAR *lpszPath;
  32. char FAR *lpszTMP;
  33. char FAR *lpszLIB;
  34. char FAR *lpszQH;
  35. char FAR *lpszHELPFILES;
  36. char FAR *lpszCmdLine;
  37. #if OSEGEXE
  38. RBTYPE procOrder;
  39. #endif
  40. int vmfd;
  41. BSTYPE bsErr /* DLH stderr isn't constant with CRT DLL */ /* = stderr */;
  42. BSTYPE bsInput;
  43. BSTYPE bsLst;
  44. BSTYPE bsRunfile;
  45. WORD cbBakpat;
  46. WORD cbRec;
  47. WORD cErrors;
  48. int (cdecl *cmpf)(const RBTYPE *sb1, const RBTYPE *sb2);
  49. #if OMF386
  50. FTYPE f386;
  51. #endif
  52. #if (OSEGEXE AND defined(LEGO)) OR EXE386
  53. FTYPE fKeepFixups;
  54. #endif
  55. #if EXE386
  56. GRTYPE ggrFlat;
  57. FTYPE fFullMap;
  58. FTYPE fKeepVSize;
  59. #endif
  60. WORD extMac;
  61. WORD extMax;
  62. int ExitCode=0;
  63. FTYPE fFullMap;
  64. FTYPE fCommon;
  65. #if C8_IDE
  66. FTYPE fC8IDE = FALSE;
  67. #endif
  68. FTYPE fDelexe = (FTYPE) FALSE;
  69. FTYPE fDrivePass;
  70. FTYPE fFarCallTrans;
  71. FTYPE fIgnoreCase = (FTYPE) IGNORECASE;
  72. FTYPE fInOverlay;
  73. FTYPE fLibPass;
  74. FTYPE fLibraryFile;
  75. FTYPE fListAddrOnly;
  76. FTYPE fLstFileOpen;
  77. FTYPE fScrClosed = (FTYPE) TRUE;
  78. FTYPE fUndefinedExterns;
  79. FTYPE fExeStrSeen = FALSE;
  80. FTYPE fPackFunctions = (FTYPE) TRUE;
  81. #if TCE
  82. FTYPE fTCE = FALSE;
  83. #endif
  84. FTYPE fTextMoved = (FTYPE) FALSE;
  85. int NullDelta = 16;
  86. #if O68K
  87. FTYPE f68k = (FTYPE) FALSE;
  88. FTYPE fTBigEndian = (FTYPE) FALSE;
  89. BYTE iMacType = MAC_NONE;
  90. #endif /* O68K */
  91. GRTYPE ggrDGroup;
  92. GRTYPE ggrMac = 1;
  93. GRTYPE grMac;
  94. SNTYPE gsnMac = 1;
  95. SNTYPE gsnMax = DFGSNMAX;
  96. SNTYPE gsnStack;
  97. WORD ifhLibCur;
  98. WORD ifhLibMac;
  99. long lfaLast;
  100. WORD lnameMac;
  101. WORD lnameMax = 256;
  102. WORD modkey;
  103. SNTYPE *mpextgsn;
  104. RATYPE *mpextra;
  105. RBTYPE FAR *mpextprop;
  106. SNTYPE mpggrgsn[GGRMAX];
  107. GRTYPE *mpgrggr;
  108. #if FAR_SEG_TABLES
  109. RATYPE FAR *mpgsndra;
  110. FTYPE FAR *mpgsnfCod;
  111. RBTYPE FAR *mpgsnrprop;
  112. SEGTYPE FAR *mpgsnseg;
  113. RATYPE FAR *mpsegraFirst;
  114. SATYPE FAR *mpsegsa;
  115. BYTE FAR * FAR *mpsegMem;
  116. BYTE FAR * FAR *mpsaMem;
  117. #else
  118. RATYPE *mpgsndra;
  119. FTYPE *mpgsnfCod;
  120. RBTYPE *mpgsnrprop;
  121. SEGTYPE *mpgsnseg;
  122. RATYPE *mpsegraFirst;
  123. SATYPE *mpsegsa;
  124. #endif
  125. SNTYPE *mpsngsn;
  126. RBTYPE mpifhrhte[IFHLIBMAX];
  127. long *mpitypelen;
  128. WORD *mpityptyp;
  129. RBTYPE FAR *mplnamerhte;
  130. BYTE *psbRun;
  131. WORD pubMac;
  132. #if TCE
  133. APROPCOMDAT *pActiveComdat;
  134. #endif
  135. int QCExtDefDelta = 0;
  136. int QCLinNumDelta = 0;
  137. WORD symMac; /* Number of symbols defined */
  138. long raStart;
  139. #if NOT NEWSYM OR AUTOVM
  140. #if AUTOVM
  141. WORD rbMacSyms;
  142. #else
  143. RBTYPE rbMacSyms;
  144. #endif
  145. #endif
  146. RECTTYPE rect;
  147. #if RGMI_IN_PLACE
  148. BYTE bufg[DATAMAX + 4];
  149. BYTE *rgmi;
  150. #else
  151. BYTE rgmi[DATAMAX + 4];
  152. #endif
  153. RBTYPE rhteBegdata;
  154. RBTYPE rhteBss;
  155. RBTYPE rhteFirstObject;
  156. RBTYPE rhteRunfile;
  157. RBTYPE rhteStack;
  158. RBTYPE rprop1stFile;
  159. RBTYPE rprop1stOpenFile;
  160. RBTYPE r1stFile;
  161. SBTYPE sbModule;
  162. SEGTYPE segCodeLast;
  163. SEGTYPE segDataLast;
  164. SEGTYPE segLast;
  165. SEGTYPE segStart;
  166. WORD snkey;
  167. SNTYPE snMac;
  168. WORD typMac;
  169. WORD vcbData;
  170. WORD vcln;
  171. FTYPE vfCreated;
  172. FTYPE vfLineNos;
  173. FTYPE vfMap;
  174. FTYPE vfNewOMF;
  175. FTYPE vfNoDefaultLibrarySearch;
  176. FTYPE vfPass1; /* Pass 1 flag */
  177. SNTYPE vgsnCur;
  178. #if EXE386
  179. DWORD vpageCur; /* Current object page number */
  180. #endif
  181. RATYPE vraCur;
  182. SNTYPE vgsnLineNosPrev;
  183. RECTTYPE vrectData;
  184. RBTYPE vrhte;
  185. RBTYPE vrhteCODEClass;
  186. RBTYPE vrhteFile;
  187. RBTYPE vrprop;
  188. RBTYPE vrpropFile;
  189. RBTYPE vrpropTailFile;
  190. SEGTYPE vsegCur;
  191. WORD ExeStrLen = 0;
  192. WORD ExeStrMax = 0;
  193. char FAR *ExeStrBuf = 0;
  194. #if LOCALSYMS
  195. FTYPE fLocals;
  196. WORD locMac;
  197. #endif
  198. #if FDEBUG
  199. FTYPE fDebug;
  200. #endif
  201. #if CMDXENIX
  202. WORD symlen;
  203. #endif
  204. #if OSMSDOS
  205. char bigbuf[LBUFSIZ];
  206. FTYPE fPauseRun;
  207. BYTE chRunFile;
  208. BYTE chListFile;
  209. RBTYPE rhteLstfile;
  210. BYTE DskCur;
  211. #endif
  212. #if LIBMSDOS
  213. FTYPE fNoExtDic;
  214. long libHTAddr;
  215. #endif
  216. #if FIXEDSTACK
  217. int _stack = STKSIZ;
  218. #endif
  219. #if ECS
  220. FTYPE fLeadByte[0x80]; /* f(n) true iff n+0x80 is lead byte */
  221. #endif
  222. #if CRLF
  223. char _eol[] = "\r\n";
  224. #endif
  225. #if SYMDEB
  226. FTYPE fSymdeb;
  227. FTYPE fCVpack = (FTYPE) TRUE;
  228. FTYPE fDebSeg;
  229. FTYPE fSkipPublics;
  230. WORD cSegCode;
  231. WORD ObjDebTotal;
  232. SEGTYPE segDebFirst;
  233. SEGTYPE segDebLast;
  234. //DWORD vaCVMac = (DWORD) AREACV;
  235. //DWORD vaCVBase;
  236. #if OSEGEXE
  237. WORD cbImpSeg;
  238. SNTYPE gsnImports;
  239. #endif
  240. #endif
  241. #if NOT M_WORDSWAP OR M_BYTESWAP
  242. char _cbexehdr[] = "wssssssssssssss2sssssls7sl";
  243. char _cbnewexe[] = "wsccsslssssllsssssssslss12c";
  244. char _cbnewrlc[] = "wccs2cs";
  245. char _cbnewseg[] = "wssss";
  246. char _cblong[] = "wl";
  247. char _cbword[] = "ws";
  248. #endif
  249. #if C8_IDE
  250. char msgBuf[_MAX_PATH];
  251. #endif
  252. #if OUT_EXP
  253. char bufExportsFileName[_MAX_PATH] = {'\0'};
  254. #endif
  255. /* Variables for segmented-executable format */
  256. #if OSEGEXE
  257. SNTYPE gsnAppLoader;
  258. RBTYPE vpropAppLoader;
  259. #if EXE386
  260. DWORD hdrSize = 0x10000L;
  261. DWORD virtBase = 0x10000L;
  262. DWORD cbEntTab;
  263. DWORD cbNamePtr;
  264. DWORD cbOrdinal;
  265. DWORD cbExpName;
  266. DWORD cbImports;
  267. DWORD cbImportsMod;
  268. DWORD *mpsaVMArea;
  269. DWORD *mpsaBase;
  270. DWORD cbStack;
  271. DWORD cbStackCommit;
  272. DWORD cbHeap;
  273. DWORD cbHeapCommit;
  274. #else
  275. WORD cbHeap;
  276. WORD cbStack;
  277. #endif
  278. WORD cFixupBuckets;
  279. #if EXE386
  280. WORD cChainBuckets = BKTMAX;
  281. #endif
  282. long chksum32;
  283. WORD cMovableEntries;
  284. #if EXE386
  285. BYTE TargetOs;
  286. BYTE TargetSubsys = E32_SSWINCHAR;
  287. DWORD dfCode = OBJ_CODE | OBJ_READ | OBJ_EXEC;
  288. DWORD dfData = OBJ_INITDATA | OBJ_READ | OBJ_WRITE;
  289. BYTE ExeMajorVer = 0;
  290. BYTE ExeMinorVer = 0;
  291. BYTE UserMajorVer = 0;
  292. BYTE UserMinorVer = 0;
  293. #else
  294. #if DOSEXTENDER OR DOSX32 OR WIN_NT
  295. BYTE TargetOs = NE_WINDOWS; // For DOS the default is Windows
  296. #else
  297. BYTE TargetOs = NE_OS2;
  298. #endif
  299. WORD dfCode = NSCODE | (3<<SHIFTDPL);
  300. WORD dfData = NSDATA | (3<<SHIFTDPL);
  301. BYTE ExeMajorVer = DEF_EXETYPE_WINDOWS_MAJOR;
  302. BYTE ExeMinorVer = DEF_EXETYPE_WINDOWS_MINOR;
  303. #endif
  304. WORD expMac;
  305. FTYPE fHeapMax;
  306. FTYPE fRealMode;
  307. FTYPE fStub = (FTYPE) TRUE;
  308. FTYPE fWarnFixup;
  309. EPTYPE FAR * FAR *htsaraep;
  310. DWORD FAR *mpsacb;
  311. #if O68K
  312. DWORD *mpsadraDP;
  313. #endif
  314. DWORD FAR *mpsacbinit;
  315. #if EXE386
  316. DWORD *mpsacrlc;
  317. DWORD *mpsaflags;
  318. WORD *mpextflags;
  319. #else
  320. RLCHASH FAR * FAR *mpsaRlc;
  321. BYTE FAR *mpextflags;
  322. WORD FAR *mpsaflags;
  323. #endif
  324. RLCPTR rlcCurLidata;
  325. RLCPTR rlcLidata;
  326. WORD raChksum;
  327. RBTYPE rhteDeffile;
  328. RBTYPE rhteModule;
  329. RBTYPE rhteStub;
  330. WORD fileAlign = DFSAALIGN;
  331. #if EXE386
  332. WORD pageAlign = DFPGALIGN;
  333. WORD objAlign = DFOBJALIGN;
  334. #endif
  335. SATYPE saMac;
  336. WORD vepMac = 1;
  337. #if EXE386
  338. WORD vFlags = 0;
  339. WORD dllFlags = 0;
  340. #else
  341. WORD vFlags = NEINST;
  342. BYTE vFlagsOthers;
  343. #endif
  344. #endif /* OSEGEXE */
  345. FTYPE fExePack;
  346. #if PCODE
  347. FTYPE fMPC;
  348. FTYPE fIgnoreMpcRun = FALSE;
  349. #endif
  350. /* Variables for DOS3 format executables */
  351. #if ODOS3EXE
  352. FTYPE fBinary = FALSE;
  353. WORD cparMaxAlloc = 0xFFFF;
  354. WORD csegsAbs;
  355. WORD dosExtMode;
  356. FTYPE fNoGrpAssoc;
  357. SEGTYPE segResLast;
  358. WORD vchksum;
  359. WORD vdoslev;
  360. FTYPE vfDSAlloc;
  361. #if FEXEPACK
  362. FRAMERLC FAR mpframeRlc[16];
  363. #endif
  364. #if OVERLAYS
  365. FTYPE fOverlays;
  366. FTYPE fOldOverlay = (FTYPE) FALSE;
  367. FTYPE fDynamic;
  368. SNTYPE gsnOvlData;
  369. SNTYPE gsnOverlay;
  370. WORD iovMac = 1;
  371. WORD ovlThunkMax = 256;
  372. WORD ovlThunkMac = 1;
  373. SNTYPE FAR *mposngsn;
  374. SNTYPE FAR *htgsnosn;
  375. IOVTYPE FAR *mpsegiov;
  376. RUNRLC FAR *mpiovRlc;
  377. ALIGNTYPE FAR *mpsegalign;
  378. SNTYPE osnMac = 1;
  379. BYTE vintno = DFINTNO;
  380. #endif /* OVERLAYS */
  381. #endif /* ODOS3EXE */
  382. /* Variables for segmented-x.out format */
  383. #if OIAPX286
  384. long absAddr = -1L;
  385. FTYPE fPack = TRUE;
  386. SATYPE *mpstsa;
  387. SATYPE stBias = DFSTBIAS;
  388. SATYPE stDataBias;
  389. SATYPE stLast;
  390. WORD stMac;
  391. #if EXE386
  392. WORD xevmod;
  393. RATYPE rbaseText;
  394. RATYPE rbaseData = 0x1880000L;
  395. WORD xevmod;
  396. FTYPE fPageswitch;
  397. BYTE cblkPage = 1024 >> 9;
  398. #endif
  399. #endif
  400. /* Variables shared by segmented x.out and DOS3 exes */
  401. #if OIAPX286 OR ODOS3EXE
  402. GRTYPE *mpextggr;
  403. long FAR *mpsegcb;
  404. FTYPE FAR *mpsegFlags;
  405. char *ompimisegDstIdata;
  406. #endif
  407. /* Variables for x.out format */
  408. #if OXOUT OR OIAPX286
  409. FTYPE fIandD;
  410. FTYPE fLarge;
  411. FTYPE fLocals;
  412. FTYPE fMedium;
  413. FTYPE fMixed;
  414. FTYPE fSymbol = TRUE;
  415. WORD xever = DFXEVER;
  416. #endif
  417. #ifdef QCLINK
  418. #if NOT WIN_3
  419. FTYPE fZ1 = FALSE;
  420. #endif
  421. FTYPE fZ2 = FALSE;
  422. #endif
  423. /* Variables for ILINK support */
  424. #if ILINK
  425. FTYPE fZincr = FALSE;
  426. FTYPE fQCIncremental = FALSE;
  427. FTYPE fIncremental = FALSE;
  428. WORD imodFile;
  429. WORD imodCur = 0; /* one-based module number */
  430. #endif
  431. WORD cbPadCode; /* code padding size */
  432. WORD cbPadData = 16; /* data padding size */
  433. /* Variables shared by segmented-exe and DOS3 executables */
  434. #if OEXE
  435. FTYPE fDOSExtended;
  436. FTYPE fNoNulls;
  437. FTYPE fPackData = FALSE;
  438. FTYPE fPackSet;
  439. FTYPE fSegOrder;
  440. DWORD packLim;
  441. DWORD DataPackLim;
  442. #endif
  443. /* Variables for dual-exe format capability */
  444. #if OSEGEXE AND ODOS3EXE
  445. FTYPE fNewExe;
  446. FTYPE fOptimizeFixups;
  447. void (NEAR *pfProcFixup)(FIXINFO *pfi);
  448. #endif
  449. /* Variables shared by segmented-exe and segmented-x.out */
  450. #if OSEGEXE OR OIAPX286
  451. RBTYPE mpggrrhte[GRMAX];
  452. #if FAR_SEG_TABLES
  453. SNTYPE FAR *mpseggsn;
  454. #else
  455. SNTYPE *mpseggsn;
  456. #endif
  457. #endif
  458. FTYPE fNoEchoLrf;
  459. FTYPE fNoBanner;
  460. FTYPE BannerOnScreen;
  461. /* Variables for MS-DOS style command interface */
  462. #if CMDMSDOS
  463. BYTE bSep = ','; /* Separator character */
  464. BYTE chMaskSpace = ' ';
  465. FTYPE fEsc;
  466. #if WIN_3
  467. FTYPE fNoprompt = TRUE;
  468. #else
  469. FTYPE fNoprompt;
  470. #endif
  471. #if USE_REAL
  472. FTYPE fUseReal = FALSE;
  473. FTYPE fSwNoUseReal = FALSE;
  474. #endif
  475. RBTYPE rgLibPath[IFHLIBMAX];
  476. WORD cLibPaths;
  477. # if OSXENIX
  478. char CHSWITCH = '-'; /* Switch character */
  479. # else
  480. char CHSWITCH = '/'; /* Switch character */
  481. # endif
  482. #if OSMSDOS AND NOT WIN_3
  483. int (cdecl *pfPrompt)() = PromptStd;
  484. #endif
  485. #if WIN_3
  486. int (cdecl *pfPrompt)() = NULL;
  487. #endif
  488. #endif /* CMDMSDOS */
  489. /* Miscellaneous combinations */
  490. #if QBLIB
  491. FTYPE fQlib;
  492. #endif
  493. #if OSEGEXE OR QCLINK
  494. typedef void (FAR * FARFPTYPE)(); /* FAR function pointer type */
  495. FARFPTYPE FAR *pfQTab;
  496. #endif
  497. char *lnknam = "LINK";
  498. #if NEWSYM
  499. long cbSymtab;
  500. void (*pfEnSyms)(void (*pproc)(APROPNAMEPTR papropName,
  501. RBTYPE rhte,
  502. RBTYPE rprop,
  503. WORD fNewHte),
  504. ATTRTYPE attr) = BigEnSyms;
  505. #endif /* NEWSYM */
  506. #if NEWLIST
  507. RBTYPE rbLstUndef = RHTENIL;
  508. #endif
  509. #if WIN_3
  510. void (*pfCputc)(int ch) = CputcWin;
  511. void (*pfCputs)(char *str) = CputsWin;
  512. #else
  513. void (*pfCputc)(int ch) = CputcStd;
  514. void (*pfCputs)(char *str) = CputsStd;
  515. #endif
  516. #if NEWIO
  517. RBTYPE rbFilePrev;
  518. char mpifhfh[IFHLIBMAX];
  519. #endif
  520. #if ILINK OR SYMDEB
  521. long lfaBase;
  522. #endif
  523. #if ALIGN_REC
  524. BYTE *pbRec; // data for current record
  525. char recbuf[8192]; // record buffer...
  526. #endif