62 PspName = ProgramName;
65 switch (*ProgramName++)
68 case ':':
case '\\':
case '/':
69 PspName = ProgramName;
74 for (
i = 0;
i <
sizeof(
Mcb->Name) && PspName[
i] !=
'.' && PspName[
i] !=
'\0'; ++
i)
79 if (
i <
sizeof(
Mcb->Name))
Mcb->Name[
i] =
'\0';
89#ifdef ADVANCED_DEBUGGING
91 "DosSaveState(before) -- SS:SP == %04X:%04X\n"
92 "Original CPU State =\n"
93 "DS = %04X; ES = %04X; AX = %04X; CX = %04X\n"
94 "DX = %04X; BX = %04X; BP = %04X; SI = %04X; DI = %04X"
120#ifdef ADVANCED_DEBUGGING
122 "DosSaveState(after) -- SS:SP == %04X:%04X\n"
124 "DS = %04X; ES = %04X; AX = %04X; CX = %04X\n"
125 "DX = %04X; BX = %04X; BP = %04X; SI = %04X; DI = %04X"
143#ifdef ADVANCED_DEBUGGING
145 "DosRestoreState(before) -- SS:SP == %04X:%04X\n"
147 "DS = %04X; ES = %04X; AX = %04X; CX = %04X\n"
148 "DX = %04X; BX = %04X; BP = %04X; SI = %04X; DI = %04X"
168#ifdef ADVANCED_DEBUGGING
170 "DosRestoreState(after) -- SS:SP == %04X:%04X\n"
171 "Restored CPU State =\n"
172 "DS = %04X; ES = %04X; AX = %04X; CX = %04X\n"
173 "DX = %04X; BX = %04X; BP = %04X; SI = %04X; DI = %04X"
208 TotalSize +=
strlen(ProgramName) + 1;
212 if (!DestSegment)
return 0;
225 *(DestBuffer++) =
'\0';
234 *(DestBuffer++) =
'\0';
237 *(DestBuffer++) =
'\0';
244 strcpy(DestBuffer, ProgramName);
286 PspBlock->
Exit[0] = 0xCD;
287 PspBlock->
Exit[1] = 0x20;
351 WORD FinalSS, FinalSP;
352 WORD FinalCS, FinalIP;
357 DPRINT1(
"DosLoadExecutableInternal(%d, 0x%p, '%s', 0x%p, 0x%p, 0x%p)\n",
369 LPSTR CmdLineStart = CmdLineBuffer + 1;
370 LPSTR CmdLinePtr = CmdLineStart;
387 if (*CommandLine && *CommandLine !=
'\r' && *CommandLine !=
'\n' &&
388 *CommandLine !=
' ' && *CommandLine !=
'\t')
398 while (CmdLineLen && (CommandLine[CmdLineLen - 1] ==
'\r' || CommandLine[CmdLineLen - 1] ==
'\n'))
404 *CmdLineSize += CmdLineLen;
406 CmdLineStart[*CmdLineSize] =
'\r';
409 CommandLine = CmdLineBuffer;
448 ExeSignature = *(
PWORD)ExeBuffer;
449 if (ExeSignature ==
'MZ' || ExeSignature ==
'ZM')
474 BaseSize = ((
Header->e_cp << 5) -
Header->e_cparhdr) & 0xFFFF;
486 TotalSize = BaseSize + (
sizeof(
DOS_PSP) >> 4);
489 if (MaxAllocSize < TotalSize + Header->e_minalloc)
500 TotalSize = MaxAllocSize;
505 if (
Header->e_maxalloc != 0)
506 TotalSize =
min(TotalSize +
Header->e_maxalloc, MaxAllocSize);
508 TotalSize = MaxAllocSize;
534 LoadSegment =
Segment + TotalSize - BaseSize;
536 RelocFactor = LoadSegment;
542 RelocFactor =
Parameters->Overlay.RelocationFactor;
547 ExeBuffer + (
Header->e_cparhdr << 4),
548 min(ExeBufferSize - (
Header->e_cparhdr << 4), BaseSize << 4));
551 RelocationTable = (
PDWORD)(ExeBuffer +
Header->e_lfarlc);
561 *RelocWord += RelocFactor;
565 FinalSS = LoadSegment +
Header->e_ss;
569 FinalCS = LoadSegment +
Header->e_cs;
582 if (((
DWORD)MaxAllocSize << 4) < (ExeBufferSize +
sizeof(
DOS_PSP)))
618 ExeBuffer, ExeBufferSize);
643#ifdef ADVANCED_DEBUGGING
644 DPRINT1(
"Sda->CurrentPsp = 0x%04x; Old LastStack = 0x%08x, New LastStack = 0x%08x\n",
719 DPRINT1(
"DosLoadExecutable(%d, '%s', 0x%p, 0x%p, 0x%p)\n",
729 ExecutablePath = ShortFullPath;
757 if (FileMapping ==
NULL)
809 static const PCSTR AppName =
"\"%ProgramFiles%\\otvdm\\otvdmw.exe\" ";
817 if ((Ret.Size == 0) || (Ret.Size >
_countof(ExpName)))
826 "\"%s\"", ProgramName);
860 L"WOW16 applications are not supported internally by NTVDM at the moment.\n"
861 L"Consider installing WineVDM from the ReactOS Applications Manager in\n'%S'.\n\n"
862 L"Click on OK to continue.",
863 ProgramName, ExpName);
907 CmdLinePtr +=
strlen(CmdLinePtr);
915 CmdLinePtr[CmdLineSize] =
'\0';
918 while (*CmdLinePtr && *CmdLinePtr !=
'\r' && *CmdLinePtr !=
'\n') CmdLinePtr++;
943 BYTE TerminationType;
945 DPRINT(
"DosTerminateProcess: Psp 0x%04X, ReturnCode 0x%02X, KeepResident 0x%04X\n",
946 Psp, ReturnCode, KeepResident);
952 if (PspBlock->
ParentPsp == Psp)
goto Done;
954 if (KeepResident == 0)
979 if ((McbSegment + 1) == Psp && KeepResident < CurrentMcb->
Size)
997 McbSegment += CurrentMcb->
Size + 1;
1019 TerminationType = (KeepResident != 0 ? 0x03 : 0x00);
1022#ifdef ADVANCED_DEBUGGING
1023 DPRINT1(
"PspBlock->ParentPsp = 0x%04x; Sda->CurrentPsp = 0x%04x\n",
1029#ifdef ADVANCED_DEBUGGING
1030 DPRINT1(
"Sda->CurrentPsp = 0x%04x; Old SS:SP = %04X:%04X going to be LastStack = 0x%08x\n",
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
INT __cdecl DisplayMessage(_In_opt_ HWND hWnd, _In_ UINT uType, _In_opt_ PCWSTR pszTitle, _In_opt_ PCWSTR pszFormatMessage,...)
#define ERROR_NOT_ENOUGH_MEMORY
static CHAR AppName[MAX_PATH]
DWORD DosStartProcess32(IN LPCSTR ExecutablePath, IN LPCSTR CommandLine, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL, IN BOOLEAN StartComSpec)
#define NT_SUCCESS(StatCode)
#define INVALID_HANDLE_VALUE
#define CreateFileA(a, b, c, d, e, f, g)
#define FILE_ATTRIBUTE_NORMAL
DWORD WINAPI ExpandEnvironmentStringsA(IN LPCSTR lpSrc, IN LPSTR lpDst, IN DWORD nSize)
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
DWORD WINAPI GetShortPathNameA(IN LPCSTR lpszLongPath, OUT LPSTR lpszShortPath, IN DWORD cchBuffer)
DWORD WINAPI GetFullPathNameA(IN LPCSTR lpFileName, IN DWORD nBufferLength, OUT LPSTR lpBuffer, OUT LPSTR *lpFilePart)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
BOOL WINAPI GetBinaryTypeA(IN LPCSTR lpApplicationName, OUT LPDWORD lpBinaryType)
static const WCHAR CmdLine[]
static const WCHAR Cleanup[]
#define SEG_OFF_TO_PTR(seg, off)
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
struct _IMAGE_DOS_HEADER * PIMAGE_DOS_HEADER
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
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)
PVOID PVOID PWCHAR PVOID Environment
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
CHAR NTAPI RtlUpperChar(_In_ CHAR Source)
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
PULONG MinorVersion OPTIONAL
CHAR CommandLine[DOS_CMDLINE_LENGTH]
VOID CpuExecute(WORD Segment, WORD Offset)
VOID DosCopyHandleTable(LPBYTE DestinationTable)
BOOLEAN DosCloseHandle(WORD DosHandle)
BOOLEAN DosResizeMemory(WORD BlockData, WORD NewSize, WORD *MaxAvailable)
WORD DosAllocateMemory(WORD Size, WORD *MaxAvailable)
VOID DosChangeMemoryOwner(WORD Segment, WORD NewOwner)
BOOLEAN DosFreeMemory(WORD BlockData)
#define SEGMENT_TO_MCB(seg)
VOID DosClonePsp(WORD DestSegment, WORD SourceSegment)
VOID DosCreatePsp(WORD Segment, WORD ProgramSize)
static VOID DosInitPsp(IN WORD Segment, IN WORD EnvBlock, IN LPCSTR CommandLine, IN LPCSTR ProgramName)
static VOID DosRestoreState(VOID)
DWORD DosLoadExecutableInternal(IN DOS_EXEC_TYPE LoadType, IN LPBYTE ExeBuffer, IN DWORD ExeBufferSize, IN LPCSTR ExePath, IN PDOS_EXEC_PARAM_BLOCK Parameters, IN LPCSTR CommandLine OPTIONAL, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL)
DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType, IN LPCSTR ExecutablePath, IN PDOS_EXEC_PARAM_BLOCK Parameters, IN LPCSTR CommandLine OPTIONAL, IN LPCSTR Environment OPTIONAL, IN DWORD ReturnAddress OPTIONAL)
WORD DosCreateProcess(IN LPCSTR ProgramName, IN PDOS_EXEC_PARAM_BLOCK Parameters, IN DWORD ReturnAddress OPTIONAL)
VOID DosSetProcessContext(WORD Segment)
static WORD DosCopyEnvironmentBlock(IN LPCSTR Environment OPTIONAL, IN LPCSTR ProgramName)
VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode, WORD KeepResident)
static VOID DosSaveState(VOID)
#define SEGMENT_TO_PSP(seg)
#define DOS_CMDLINE_LENGTH
#define DOS_PROGRAM_NAME_TAG
struct _DOS_REGISTER_STATE DOS_REGISTER_STATE
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
VOID VDDCreateUserHook(USHORT DosPDB)
VOID VDDTerminateUserHook(USHORT DosPDB)
VOID WINAPI setBX(USHORT)
VOID WINAPI setCX(USHORT)
VOID WINAPI setDX(USHORT)
USHORT WINAPI getBX(VOID)
USHORT WINAPI getDS(VOID)
USHORT WINAPI getCX(VOID)
USHORT WINAPI getSI(VOID)
USHORT WINAPI getDX(VOID)
VOID WINAPI setSP(USHORT)
VOID WINAPI setDS(USHORT)
VOID WINAPI setEFLAGS(ULONG)
USHORT WINAPI getAX(VOID)
USHORT WINAPI getES(VOID)
USHORT WINAPI getBP(VOID)
USHORT WINAPI getDI(VOID)
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)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
DWORD WINAPI GetLastError(void)
#define CreateFileMapping
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO