MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / VmReadMemN

Function VmReadMemN

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:5335–5369  ·  view source on GitHub ↗

Read a natural value from memory. May or may not be aligned. @param VmPtr current VM context @param Addr the address to read from @return The natural value at address Addr. **/

Source from the content-addressed store, hash-verified

5333
5334**/
5335UINTN
5336VmReadMemN (
5337 IN VM_CONTEXT *VmPtr,
5338 IN UINTN Addr
5339 )
5340{
5341 UINTN Data;
5342 volatile UINT32 Size;
5343 UINT8 *FromPtr;
5344 UINT8 *ToPtr;
5345 //
5346 // Convert the address if it's in the stack gap
5347 //
5348 Addr = ConvertStackAddr (VmPtr, Addr);
5349 //
5350 // Read direct if aligned
5351 //
5352 if (IS_ALIGNED (Addr, sizeof (UINTN))) {
5353 return * (UINTN *) Addr;
5354 }
5355 //
5356 // Return unaligned data
5357 //
5358 Data = 0;
5359 FromPtr = (UINT8 *) Addr;
5360 ToPtr = (UINT8 *) &Data;
5361
5362 for (Size = 0; Size < sizeof (Data); Size++) {
5363 *ToPtr = *FromPtr;
5364 ToPtr++;
5365 FromPtr++;
5366 }
5367
5368 return Data;
5369}
5370
5371/**
5372 Returns the version of the EBC virtual machine.

Callers 8

ExecuteMOVxxFunction · 0.85
ExecuteJMPFunction · 0.85
ExecuteMOVsnwFunction · 0.85
ExecuteMOVsndFunction · 0.85
ExecutePUSHnFunction · 0.85
ExecutePOPnFunction · 0.85
ExecuteCALLFunction · 0.85
ExecuteRETFunction · 0.85

Calls 1

ConvertStackAddrFunction · 0.85

Tested by

no test coverage detected