summaryrefslogtreecommitdiffstats
path: root/private/mvdm/vdmexts/i386
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/mvdm/vdmexts/i386
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/mvdm/vdmexts/i386')
-rw-r--r--private/mvdm/vdmexts/i386/profile.c307
-rw-r--r--private/mvdm/vdmexts/i386/regs.c252
-rw-r--r--private/mvdm/vdmexts/i386/vdmtib.c308
3 files changed, 867 insertions, 0 deletions
diff --git a/private/mvdm/vdmexts/i386/profile.c b/private/mvdm/vdmexts/i386/profile.c
new file mode 100644
index 000000000..73fc19d4a
--- /dev/null
+++ b/private/mvdm/vdmexts/i386/profile.c
@@ -0,0 +1,307 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ Profile.c
+
+Abstract:
+
+ This module contains routines for controling the rudimentary sampling
+ profiler built into the profiling version of Ntvdm.
+
+Author:
+
+ Dave Hastings (daveh) 31-Jul-1992
+
+Notes:
+
+ The routines in this module assume that the pointers to the ntsd
+ routines have already been set up.
+
+Revision History:
+
+--*/
+
+#include <precomp.h>
+#pragma hdrstop
+#include <stdio.h>
+
+VOID
+ProfDumpp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine causes the profile information to be dumped the next
+ time ntvdm switches from 32 to 16 bit mode.
+
+
+Arguments:
+
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address, Flags;
+
+ Address = FIXED_NTVDMSTATE_LINEAR;
+
+ //
+ // Get Flags
+ //
+
+ Status = READMEM((PVOID)Address, &Flags, sizeof(ULONG));
+
+ if (!Status) {
+
+ (ULONG)Address = (*GetExpression)("ntvdm!InitialVdmTibFlags");
+
+ Status = READMEM((PVOID)Address, &Flags, sizeof(ULONG));
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get InitialVdmTibFlags\n");
+ return;
+ }
+ }
+
+ //
+ // Enable profile dump
+ //
+
+ Flags |= VDM_ANALYZE_PROFILE;
+
+ Status = WRITEMEM(
+ (PVOID)Address,
+ &Flags,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not set Flags\n");
+ return;
+ }
+}
+
+VOID
+ProfIntp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine changes the profile interval the next time profiling is
+ started.
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address, ProfInt;
+
+ //
+ // Get profile interval
+ //
+
+ if (sscanf(lpArgumentString, "%ld", &ProfInt) < 1) {
+ (*Print)("Profile Interval must be specified\n");
+ return;
+ }
+
+ //
+ // Get the address of the profile interval
+ //
+
+ Address = (*GetExpression)(
+ "ProfInt"
+ );
+
+ if (Address) {
+ Status = WRITEMEM(
+ (PVOID)Address,
+ &ProfInt,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not set profile interval");
+ }
+ }
+ return;
+}
+
+VOID
+ProfStartp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine causes profiling to start the next
+ time ntvdm switches from 32 to 16 bit mode.
+
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address, Flags;
+
+ Address = FIXED_NTVDMSTATE_LINEAR;
+
+ //
+ // Get Flags
+ //
+
+ Status = READMEM(
+ (PVOID)Address,
+ &Flags,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+
+ (ULONG)Address = (*GetExpression)("ntvdm!InitialVdmTibFlags");
+
+ Status = READMEM(
+ (PVOID)Address,
+ &Flags,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get InitialTibflags\n");
+ return;
+ }
+ }
+
+ //
+ // Enable profiling
+ //
+
+ Flags |= VDM_PROFILE;
+
+ Status = WRITEMEM(
+ (PVOID)Address,
+ &Flags,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get set Flags\n");
+ return;
+ }
+}
+
+VOID
+ProfStopp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine causes profiling to stop the next
+ time ntvdm switches from 32 to 16 bit mode.
+
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address, Flags;
+
+ Address = FIXED_NTVDMSTATE_LINEAR;
+
+
+ //
+ // Get Flags
+ //
+
+ Status = READMEM((PVOID)Address, &Flags, sizeof(ULONG));
+
+ if (!Status) {
+
+ (ULONG)Address = (*GetExpression)("ntvdm!InitialVdmTibFlags");
+ Status = READMEM((PVOID)Address, &Flags, sizeof(ULONG));
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get InitialTibflags\n");
+ return;
+ }
+ }
+
+ //
+ // Disable profiling
+ //
+
+ Flags &= ~VDM_PROFILE;
+
+ Status = WRITEMEM(
+ (PVOID)Address,
+ &Flags,
+ sizeof(ULONG)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get set VDM Flags in DOS arena\n");
+ return;
+ }
+}
diff --git a/private/mvdm/vdmexts/i386/regs.c b/private/mvdm/vdmexts/i386/regs.c
new file mode 100644
index 000000000..f700b02e6
--- /dev/null
+++ b/private/mvdm/vdmexts/i386/regs.c
@@ -0,0 +1,252 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ Registers.c
+
+Abstract:
+
+ This module contains routines for manipulating registers.
+
+Author:
+
+ Dave Hastings (daveh) 1-Apr-1992
+
+Notes:
+
+ The routines in this module assume that the pointers to the ntsd
+ routines have already been set up.
+
+Revision History:
+
+--*/
+
+#include <precomp.h>
+#pragma hdrstop
+#include <stdio.h>
+
+const char *FpuTagNames[] = {
+ "Valid",
+ "Zero",
+ "Special",
+ "Empty"
+};
+
+VOID
+PrintContext(
+ IN PCONTEXT Context
+ );
+
+VOID
+IntelRegistersp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine dumps out the 16 bit register set from the vdmtib
+
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address;
+ CONTEXT IntelRegisters;
+
+ //
+ // Get the address of the VdmTib
+ //
+
+ if (sscanf(lpArgumentString, "%lx", &Address) < 0) {
+ Address = (*GetExpression)(
+ "ntvdm!VdmTib"
+ );
+ }
+
+ if (!Address) {
+ (*Print)("Error geting VdmTib address\n");
+ return;
+ }
+
+ //
+ // Read the 16 bit context
+ //
+
+ Status = READMEM(
+ &(((PVDM_TIB)Address)->VdmContext),
+ &IntelRegisters,
+ sizeof(CONTEXT)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get VdmContext\n");
+ } else {
+ PrintContext(&IntelRegisters);
+ }
+}
+
+VOID
+PrintContext(
+ IN PCONTEXT Context
+ )
+/*++
+
+Routine Description:
+
+ This routine dumps out a context.
+
+Arguments:
+
+ Context -- Supplies a pointer to the context to dump
+
+Return Value:
+
+ None.
+
+--*/
+{
+ (*Print)(
+ "eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
+ Context->Eax,
+ Context->Ebx,
+ Context->Ecx,
+ Context->Edx,
+ Context->Esi,
+ Context->Edi
+ );
+
+ (*Print)(
+ "eip=%08lx esp=%08lx ebp=%08lx\n",
+ Context->Eip,
+ Context->Esp,
+ Context->Ebp
+ );
+
+ (*Print)(
+ "cs=%04x ss=%04x ds=%04x es=%04x fs=%04x gs=%04x eflags=%08x\n",
+ Context->SegCs,
+ Context->SegSs,
+ Context->SegDs,
+ Context->SegEs,
+ Context->SegFs,
+ Context->SegGs,
+ Context->EFlags
+ );
+}
+
+VOID
+Fpup(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine dumps out the x86 floating-point state.
+
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ CONTEXT IntelRegisters;
+ USHORT Temp;
+ int RegNum;
+
+ //
+ // Read the thread's context
+ //
+ IntelRegisters.ContextFlags = CONTEXT_FLOATING_POINT;
+ if (GetThreadContext(hCurrentThread, &IntelRegisters) == FALSE) {
+ GetLastError();
+ (*Print)("Could not get 32-bit thread context\n");
+ return;
+ };
+
+ Temp = (USHORT)IntelRegisters.FloatSave.ControlWord;
+ (*Print)(" Control word = %X\n", Temp);
+
+ (*Print)(
+ " Infinity = %d Rounding = %d Precision = %d PM=%d UM=%d OM=%d ZM=%d DM=%d IM=%d\n",
+ (Temp >> 11) & 1, // Infinity
+ (Temp >> 9) & 3, // Rounding (2 bits)
+ (Temp >> 7) & 3, // Precision (2 bits)
+ (Temp >> 5) & 1, // Precision Exception Mask
+ (Temp >> 4) & 1, // Underflow Exception Mask
+ (Temp >> 3) & 1, // Overflow Exception Mask
+ (Temp >> 2) & 1, // Zero Divide Exception Mask
+ (Temp >> 1) & 1, // Denormalized Operand Exception Mask
+ Temp & 1 // Invalid Operation Exception Mask
+ );
+
+ Temp = (USHORT)IntelRegisters.FloatSave.StatusWord;
+ (*Print)(" Status word = %X\n", Temp);
+
+ (*Print)(
+ " Top=%d C3=%d C2=%d C1=%d C0=%d ES=%d SF=%d PE=%d UE=%d OE=%d ZE=%d DE=%d IE=%d\n",
+ (Temp >> 11) & 7, // Top (3 bits)
+ (Temp >> 7) & 1, // Error Summary
+ (Temp >> 14) & 1, // C3
+ (Temp >> 10) & 1, // C2
+ (Temp >> 9) & 1, // C1
+ (Temp >> 8) & 1, // C0
+ (Temp >> 7) & 1, // Error Summary
+ (Temp >> 6) & 1, // Stack Fault
+ (Temp >> 5) & 1, // Precision Exception
+ (Temp >> 4) & 1, // Underflow Exception
+ (Temp >> 3) & 1, // Overflow Exception
+ (Temp >> 2) & 1, // Zero Divide Exception
+ (Temp >> 1) & 1, // Denormalized Operand Exception
+ Temp & 1 // Invalid Operation Exception
+ );
+
+ (*Print)(" Last Instruction: CS:EIP=%X:%X EA=%X:%X\n",
+ (USHORT)IntelRegisters.FloatSave.ErrorSelector,
+ IntelRegisters.FloatSave.ErrorOffset,
+ (USHORT)IntelRegisters.FloatSave.DataSelector,
+ IntelRegisters.FloatSave.DataOffset
+ );
+
+ (*Print)(" Floating-point registers:\n");
+ for (RegNum=0; RegNum<8; ++RegNum) {
+
+ PBYTE r80 = (PBYTE)&IntelRegisters.FloatSave.RegisterArea[RegNum*10];
+
+ Temp = (((USHORT)IntelRegisters.FloatSave.TagWord) >> (RegNum*2)) & 3;
+
+ (*Print)(
+ " %d. %s %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X\n",
+ RegNum,
+ FpuTagNames[Temp],
+ r80[0], r80[1], r80[2], r80[3], r80[4], r80[5], r80[6], r80[7], r80[8], r80[9]
+ );
+ }
+}
diff --git a/private/mvdm/vdmexts/i386/vdmtib.c b/private/mvdm/vdmexts/i386/vdmtib.c
new file mode 100644
index 000000000..675a987be
--- /dev/null
+++ b/private/mvdm/vdmexts/i386/vdmtib.c
@@ -0,0 +1,308 @@
+/*++
+
+Copyright (c) 1991 Microsoft Corporation
+
+Module Name:
+
+ Vdmtib.c
+
+Abstract:
+
+ This module contains routines for manipulating the vdmtib.
+
+Author:
+
+ Dave Hastings (daveh) 1-Apr-1992
+
+Notes:
+
+ The routines in this module assume that the pointers to the ntsd
+ routines have already been set up.
+
+Revision History:
+
+--*/
+
+#include <precomp.h>
+#pragma hdrstop
+#include <stdio.h>
+
+VOID
+PrintEventInfo(
+ IN PVDMEVENTINFO EventInfo
+ );
+
+VOID
+VdmTibp(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine dumps out the contents of the register block, and
+ event info from the vdmtib. If no address is specified (normal case),
+ then the vdmtib is looked up (symbol VdmTib).
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address;
+ CONTEXT Context;
+ VDMEVENTINFO EventInfo;
+
+ //
+ // Get the address of the vdmtib
+ //
+ if (sscanf(lpArgumentString,"%lx",&Address) < 0) {
+ Address = (*GetExpression)(
+ "ntvdm!VdmTib"
+ );
+ }
+
+ if (!Address) {
+ (*Print)("Error geting VdmTib address\n");
+ return;
+ }
+
+ //
+ // Get the 32 bit context and print it out
+ //
+
+ Status = READMEM(
+ &(((PVDM_TIB)Address)->MonitorContext),
+ &Context,
+ sizeof(CONTEXT)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get MonitorContext\n");
+ } else {
+ (*Print)("\n32 bit context\n");
+ PrintContext(&Context);
+ }
+
+ //
+ // Get the 16 bit context and print it out
+ //
+
+ Status = READMEM(
+ &(((PVDM_TIB)Address)->VdmContext),
+ &Context,
+ sizeof(CONTEXT)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get VdmContext\n");
+ } else {
+ (*Print)("\n16 bit context\n");
+ PrintContext(&Context);
+ }
+
+ //
+ // Get the event info and print it out
+ //
+
+ Status = READMEM(
+ &(((PVDM_TIB)Address)->EventInfo),
+ &EventInfo,
+ sizeof(VDMEVENTINFO)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get EventInfo\n");
+ } else {
+ (*Print)("\nEvent Info\n");
+ PrintEventInfo(&EventInfo);
+ }
+}
+
+VOID
+EventInfop(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine dumps the contents of an event info structure. If no
+ address is specifed (normal case), the event info from the Vdmtib is
+ dumped.
+
+Arguments:
+
+ None.
+
+Return Value:
+
+ None.
+
+Notes:
+
+ This routine assumes that the pointers to the ntsd routines have already
+ been set up.
+
+--*/
+{
+ BOOL Status;
+ ULONG Address;
+ VDMEVENTINFO EventInfo;
+
+ //
+ // Get the address of the eventinfo
+ //
+ if (sscanf(lpArgumentString,"%lx",&Address) < 0) {
+ Address = (*GetExpression)(
+ "ntvdm!VdmTib"
+ );
+ Address = (ULONG)(&(((PVDM_TIB)Address)->EventInfo));
+ }
+
+ if (!Address) {
+ (*Print)("Error geting VdmTib address\n");
+ return;
+ }
+
+ //
+ // Get the event info and print it out
+ //
+
+ Status = READMEM(
+ (PVOID)Address,
+ &EventInfo,
+ sizeof(VDMEVENTINFO)
+ );
+
+ if (!Status) {
+ GetLastError();
+ (*Print)("Could not get EventInfo\n");
+ } else {
+ (*Print)("\nEvent Info\n");
+ PrintEventInfo(&EventInfo);
+ }
+}
+
+VOID
+PrintEventInfo(
+ IN PVDMEVENTINFO EventInfo
+ )
+/*++
+
+Routine Description:
+
+ This routine prints out the contents of an event info structure
+
+Arguments:
+
+ EventInfo -- Supplies a pointer to the eventinfo
+
+Return Value:
+
+ None.
+
+--*/
+{
+ switch (EventInfo->Event) {
+ case VdmIO :
+
+ (*Print)("IO Instruction Event\n");
+
+ if (EventInfo->IoInfo.Read) {
+ (*Print)("Read from ");
+ } else {
+ (*Print)("Write to ");
+ }
+
+ switch (EventInfo->IoInfo.Size) {
+ case 1 :
+ (*Print)("Byte port ");
+ break;
+ case 2 :
+ (*Print)("Word port ");
+ break;
+ case 4 :
+ (*Print)("Dword port ");
+ break;
+ default:
+ (*Print)("Unknown size port ");
+ }
+
+ (*Print)(" number %x\n", EventInfo->IoInfo.PortNumber);
+ break;
+
+ case VdmStringIO :
+
+ (*Print)("String IO Instruction Event\n");
+
+ if (EventInfo->StringIoInfo.Read) {
+ (*Print)("Read from ");
+ } else {
+ (*Print)("Write to ");
+ }
+
+ switch (EventInfo->StringIoInfo.Size) {
+ case 1 :
+ (*Print)("Byte port ");
+ break;
+ case 2 :
+ (*Print)("Word port ");
+ break;
+ case 4 :
+ (*Print)("Dword port ");
+ break;
+ default:
+ (*Print)("Unknown size port ");
+ }
+
+ (*Print)(" number %x, ", EventInfo->StringIoInfo.PortNumber);
+ (*Print)(
+ " Count = %lx, Address = %lx\n",
+ EventInfo->StringIoInfo.Count,
+ EventInfo->StringIoInfo.Address
+ );
+ break;
+
+ case VdmIntAck :
+
+ (*Print)("Interrupt Acknowlege Event\n");
+ break;
+
+ case VdmBop:
+
+ (*Print)("Bop Event\n");
+ (*Print)("Bop number %x\n",EventInfo->BopNumber);
+ break;
+
+ case VdmError :
+
+ (*Print)("Error Event\n");
+ (*Print)("Error Status %lx\n",EventInfo->ErrorStatus);
+
+ case VdmIrq13 :
+
+ (*Print)("IRQ 13 Event\n");
+ break;
+
+ default:
+
+ (*Print)("Unknown Event %x\n",EventInfo->Event);
+
+ }
+
+}