343{
350
351 WORD FinalSS, FinalSP;
352 WORD FinalCS, FinalIP;
353
354
356
357 DPRINT1(
"DosLoadExecutableInternal(%d, 0x%p, '%s', 0x%p, 0x%p, 0x%p)\n",
359
361 {
362
363 if (CommandLine)
364 {
365
367
369 LPSTR CmdLineStart = CmdLineBuffer + 1;
370 LPSTR CmdLinePtr = CmdLineStart;
371
372
374
375
376
377
378
379
381 *CmdLineSize = 0;
382
383
384
385
386
387 if (*CommandLine && *CommandLine != '\r' && *CommandLine != '\n' &&
388 *CommandLine != ' ' && *CommandLine != '\t')
389 {
390 (*CmdLineSize)++;
391 *CmdLinePtr++ = ' ';
392 }
393
394
396
397
398 while (CmdLineLen && (CommandLine[CmdLineLen - 1] == '\r' || CommandLine[CmdLineLen - 1] == '\n'))
399 {
400 CmdLineLen--;
401 }
402
403
404 *CmdLineSize += CmdLineLen;
406 CmdLineStart[*CmdLineSize] = '\r';
407
408
409 CommandLine = CmdLineBuffer;
410 }
411 else
412 {
413
414
415
416
419 }
420
421
423 {
425
428
429 else
431 }
432
433
435 if (EnvBlock == 0)
436 {
439 }
440 }
441
442
443
444
445
446
447
448 ExeSignature = *(
PWORD)ExeBuffer;
449 if (ExeSignature == 'MZ' || ExeSignature == 'ZM')
450 {
451
458
459
461
462
463#if 0
466#else
467
468
469
470
471
472
473
474 BaseSize = ((
Header->e_cp << 5) -
Header->e_cparhdr) & 0xFFFF;
475#endif
476
478 {
481
482
484
485
486 TotalSize = BaseSize + (
sizeof(
DOS_PSP) >> 4);
487
488
489 if (MaxAllocSize < TotalSize + Header->e_minalloc)
490 {
493 }
494
495
497 {
498
500 TotalSize = MaxAllocSize;
501 }
502 else
503 {
504
505 if (
Header->e_maxalloc != 0)
506 TotalSize =
min(TotalSize +
Header->e_maxalloc, MaxAllocSize);
507 else
508 TotalSize = MaxAllocSize;
509 }
510
511
514 {
517 }
518
519
522
523
525
526
529
530
531 if (!LoadHigh)
533 else
534 LoadSegment =
Segment + TotalSize - BaseSize;
535
536 RelocFactor = LoadSegment;
537 }
538 else
539 {
542 RelocFactor =
Parameters->Overlay.RelocationFactor;
543 }
544
545
547 ExeBuffer + (
Header->e_cparhdr << 4),
548 min(ExeBufferSize - (
Header->e_cparhdr << 4), BaseSize << 4));
549
550
551 RelocationTable = (
PDWORD)(ExeBuffer +
Header->e_lfarlc);
552
553
555 {
556
559
560
561 *RelocWord += RelocFactor;
562 }
563
564
565 FinalSS = LoadSegment +
Header->e_ss;
567
568
569 FinalCS = LoadSegment +
Header->e_cs;
571 }
572 else
573 {
574
575
577 {
578
580
581
582 if (((
DWORD)MaxAllocSize << 4) < (ExeBufferSize +
sizeof(
DOS_PSP)))
583 {
586 }
587
588
591 {
594 }
595
596
599
600
602
603
606
607
609 }
610 else
611 {
614 }
615
616
618 ExeBuffer, ExeBufferSize);
619
620
622 FinalSP = 0xFFFE;
623
624
625
626
627
629
630
632 FinalIP = 0x0100;
633 }
634
636 {
637
639 {
640
642
643#ifdef ADVANCED_DEBUGGING
644 DPRINT1(
"Sda->CurrentPsp = 0x%04x; Old LastStack = 0x%08x, New LastStack = 0x%08x\n",
646#endif
647
648
650 }
651
652
655
656
659
660
661
662
663
664
669
673
674
675
676
677
679
680
682
683
686 }
688 {
692 }
693
696 {
697
700 }
701
703}
#define ERROR_NOT_ENOUGH_MEMORY
_ACRTIMP size_t __cdecl strlen(const char *)
#define SEG_OFF_TO_PTR(seg, off)
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define RtlFillMemory(Dest, Length, Fill)
VOID CpuExecute(WORD Segment, WORD Offset)
WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable)
VOID DosChangeMemoryOwner(WORD Segment, WORD NewOwner)
BOOLEAN DosFreeMemory(WORD BlockData)
VOID DosCreatePsp(WORD Segment, WORD ProgramSize)
static VOID DosInitPsp(IN WORD Segment, IN WORD EnvBlock, IN LPCSTR CommandLine, IN LPCSTR ProgramName)
VOID DosSetProcessContext(WORD Segment)
static WORD DosCopyEnvironmentBlock(IN LPCSTR Environment OPTIONAL, IN LPCSTR ProgramName)
static VOID DosSaveState(VOID)
#define DOS_CMDLINE_LENGTH
VOID VDDCreateUserHook(USHORT DosPDB)
VOID WINAPI setBX(USHORT)
VOID WINAPI setCX(USHORT)
VOID WINAPI setDX(USHORT)
VOID WINAPI setSP(USHORT)
VOID WINAPI setDS(USHORT)
VOID WINAPI setEFLAGS(ULONG)
USHORT WINAPI getSP(VOID)
VOID WINAPI setBP(USHORT)
VOID WINAPI setSS(USHORT)
VOID WINAPI setAX(USHORT)
VOID WINAPI setES(USHORT)
ULONG WINAPI getEFLAGS(VOID)
VOID WINAPI setSI(USHORT)
VOID WINAPI setDI(USHORT)
USHORT WINAPI getSS(VOID)