From 5c0604dbf95bc30a71a1594c5207f82dd7dc965d Mon Sep 17 00:00:00 2001 From: Regina König Date: Wed, 19 Aug 2020 17:30:00 +0200 Subject: able to append one symbol to an existing file --- .../ProtocolInformation/ProtocolInformation.c | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'memtestEDK') diff --git a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c index 547c91e..ddc6e82 100644 --- a/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c +++ b/memtestEDK/Memtest/ProtocolInformation/ProtocolInformation.c @@ -18,6 +18,9 @@ UefiMain ( EFI_BOOT_SERVICES* bs = SystemTable->BootServices; EFI_GUID sfspGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *Console = SystemTable->ConOut; + + EFI_HANDLE* handleBuffer = NULL; EFI_HANDLE* handleBuffer2 = NULL; UINTN handleCount = 0; @@ -179,32 +182,37 @@ UefiMain ( Print(L"File Buffer Pointer: %p\n", fileBuffer); Print(L"File Content: %a\n", fileBuffer); + UINT64 currPos; token->GetPosition(token, &currPos); Print(L"Current File Position: %d\n", currPos); - fileBuffer[0] = (CHAR16) 'X'; - Print(L"New file Buffer: %a\n", fileBuffer); - token->SetPosition(token, 0); - efiStatus = token->Write(token, &fileSize, fileBuffer); + fileBuffer[0] = (CHAR16) 'C'; + fileBuffer[1] = (CHAR16) '\0'; + Console->OutputString(Console, fileBuffer); + UINTN length = 2; + fileSize += 2; + + token->SetPosition(token, 35); + + efiStatus = token->Write(token, &length, fileBuffer); Print(L"Status after file write: %r\n", efiStatus); + token->SetPosition(token, fileSize - 2); + + efiStatus = token->Read(token, &fileSize, fileBuffer); + Print(L"File Content after write: %a\n", fileBuffer); + + + token->SetPosition(token, 0); + + efiStatus = token->Read(token, &fileSize, fileBuffer); + Print(L"File Content after write: %a\n", fileBuffer); -/* - EFI_FILE_OPEN Open; - EFI_FILE_CLOSE Close; - EFI_FILE_DELETE Delete; - EFI_FILE_READ Read; - EFI_FILE_WRITE Write; - EFI_FILE_GET_POSITION GetPosition; - EFI_FILE_SET_POSITION SetPosition; - EFI_FILE_GET_INFO GetInfo; - EFI_FILE_SET_INFO SetInfo; - EFI_FILE_FLUSH Flush;*/ } } } -- cgit v1.2.3-55-g7522