Created
April 24, 2021 10:39
-
-
Save thefakewater/c80fcdc81bfaaadd84d5d5507502f9ac to your computer and use it in GitHub Desktop.
Extract a embed file from the current exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This only cover the extraction of a resource from the current exe | |
// Checkout https://stackoverflow.com/a/62391707/11723029 | |
#include <Windows.h> | |
void extract() { | |
HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(IDB_EMBEDEXE), TEXT("BINARY")); | |
HGLOBAL hGlobal = LoadResource(NULL, hResource); | |
size_t exeSiz = SizeofResource(NULL, hResource); // Size of the embedded data | |
void* exeBuf = LockResource(hGlobal); | |
DWORD at; | |
HANDLE hFile = CreateFile(L"<Filename here>", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // Check MSDN for more info | |
BOOL success = WriteFile(hFile, exeBuf, exeSiz, &at, NULL); // If it fails -> success = 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment