Go to the source code of this file.
◆ DOS_ALLOC_HIGH
◆ DOS_ALLOC_HIGH_LOW
#define DOS_ALLOC_HIGH_LOW 0x80 |
◆ SEGMENT_TO_MCB
◆ DOS_MCB
◆ PDOS_MCB
◆ DOS_ALLOC_STRATEGY
Enumerator |
---|
DOS_ALLOC_FIRST_FIT | |
DOS_ALLOC_BEST_FIT | |
DOS_ALLOC_LAST_FIT | |
Definition at line 20 of file memory.h.
◆ C_ASSERT()
◆ DosAllocateMemory()
Definition at line 136 of file memory.c.
142 DPRINT(
"DosAllocateMemory: Size 0x%04X\n",
Size);
162 DPRINT1(
"The DOS memory arena is corrupted!\n");
168 if (CurrentMcb->
OwnerPsp != 0)
goto Next;
174 if (CurrentMcb->
Size > MaxSize) MaxSize = CurrentMcb->
Size;
177 if (CurrentMcb->
Size <
Size)
goto Next;
233 DPRINT(
"DosAllocateMemory FAILED. Maximum available: 0x%04X\n", MaxSize);
235 if (MaxAvailable) *MaxAvailable = MaxSize;
static VOID DosCombineFreeBlocks(WORD StartBlock)
#define ERROR_NOT_ENOUGH_MEMORY
IN PVOID IN PVOID IN USHORT IN USHORT Size
_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
static BOOLEAN ValidateMcb(PDOS_MCB Mcb)
#define DOS_ALLOC_HIGH_LOW
#define ERROR_ARENA_TRASHED
#define RtlCopyMemory(Destination, Source, Length)
#define SEGMENT_TO_MCB(seg)
Referenced by DosCopyEnvironmentBlock(), DosCountryInitialize(), DosCreateDeviceEx(), DosInt21h(), DosLoadDriver(), DosLoadExecutableInternal(), DosMouseInitialize(), and DosResizeHandleTable().
◆ DosChangeMemoryOwner()
◆ DosFreeMemory()
◆ DosInitializeMemory()
Definition at line 665 of file memory.c.
680 Mcb->BlockType =
'Z';
#define FIRST_MCB_SEGMENT
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
#define SEGMENT_TO_MCB(seg)
Referenced by DosKRNLInitialize().
◆ DosInitializeUmb()
Definition at line 582 of file memory.c.
585 USHORT UmbSegment = 0x0000, PrevSegment;
619 Mcb->BlockType =
'Z';
624 #if 0 // Keep here for reference; this will be deleted as soon as it becomes unneeded. 646 Mcb->Size = PrevMcb->
Size - (UmbSegment +
Size - PrevSegment) + 1;
652 PrevMcb->
Size = UmbSegment - PrevSegment - 1;
656 Mcb->BlockType =
'M';
BOOLEAN UmaDescReserve(IN OUT PUSHORT Segment, IN OUT PUSHORT Size)
IN PVOID IN PVOID IN USHORT IN USHORT Size
_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
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
WORD DosGetPreviousUmb(WORD UmbSegment)
#define RtlCopyMemory(Destination, Source, Length)
#define SEGMENT_TO_MCB(seg)
Referenced by DosKRNLInitialize().
◆ DosLinkUmb()
Definition at line 446 of file memory.c.
460 while (Segment < SysVars->UmbChainStart)
468 DPRINT1(
"The DOS memory arena is corrupted!\n");
474 if (
Mcb->BlockType ==
'Z')
break;
481 if (
Mcb->BlockType !=
'Z')
return FALSE;
484 Mcb->BlockType =
'M';
static BOOLEAN ValidateMcb(PDOS_MCB Mcb)
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
#define ERROR_ARENA_TRASHED
#define SEGMENT_TO_MCB(seg)
Referenced by DosInt21h().
◆ DosResizeMemory()
Definition at line 289 of file memory.c.
292 WORD Segment = BlockData - 1, ReturnSize = 0, NextSegment;
295 DPRINT(
"DosResizeMemory: BlockData 0x%04X, NewSize 0x%04X\n",
308 ReturnSize =
Mcb->Size;
314 if (
Mcb->BlockType ==
'Z')
316 DPRINT(
"Cannot expand memory block 0x%04X: this is the last block (size 0x%04X)!\n",
Segment,
Mcb->Size);
329 DPRINT1(
"The DOS memory arena is corrupted!\n");
335 if (NextMcb->OwnerPsp != 0)
337 DPRINT(
"Cannot expand memory block 0x%04X: next segment is not free!\n",
Segment);
347 ReturnSize += NextMcb->Size + 1;
351 DPRINT(
"Cannot expand memory block 0x%04X: insufficient free segments available!\n",
Segment);
358 Mcb->Size = ReturnSize;
359 Mcb->BlockType = NextMcb->BlockType;
362 NextMcb->BlockType =
'I';
367 DPRINT(
"Block too large, reducing size from 0x%04X to 0x%04X\n",
374 NextMcb->BlockType =
Mcb->BlockType;
376 NextMcb->OwnerPsp = 0;
379 Mcb->BlockType =
'M';
383 else if (NewSize < Mcb->
Size)
385 DPRINT(
"Shrinking block from 0x%04X to 0x%04X\n",
391 NextMcb->BlockType =
Mcb->BlockType;
393 NextMcb->OwnerPsp = 0;
396 Mcb->BlockType =
'M';
407 DPRINT(
"DosResizeMemory FAILED. Maximum available: 0x%04X\n", ReturnSize);
410 if (MaxAvailable) *MaxAvailable = ReturnSize;
static VOID DosCombineFreeBlocks(WORD StartBlock)
#define ERROR_NOT_ENOUGH_MEMORY
IN PVOID IN PVOID IN USHORT IN USHORT Size
#define ERROR_INVALID_BLOCK
static BOOLEAN ValidateMcb(PDOS_MCB Mcb)
_Must_inspect_result_ _In_ USHORT NewSize
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
#define ERROR_ARENA_TRASHED
#define SEGMENT_TO_MCB(seg)
Referenced by DosInt21h(), DosResizeHandleTable(), and DosTerminateProcess().
◆ DosUnlinkUmb()
Definition at line 492 of file memory.c.
497 DPRINT(
"Unlinking UMB\n");
506 while (Segment < SysVars->UmbChainStart)
514 DPRINT1(
"The DOS memory arena is corrupted!\n");
524 Mcb->BlockType =
'Z';
static BOOLEAN ValidateMcb(PDOS_MCB Mcb)
IN PVCB IN ULONG IN OUT PULONG IN BOOLEAN OUT PLARGE_MCB Mcb
#define ERROR_ARENA_TRASHED
#define SEGMENT_TO_MCB(seg)
Referenced by DosInt21h().