Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// Copyright 2011-2019 Molecular Matters GmbH, all rights reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreTypes.h"
|
|
|
|
|
#include "LC_Thread.h"
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace process
|
|
|
|
|
{
|
|
|
|
|
struct Context
|
|
|
|
|
{
|
|
|
|
|
uint32_t flags;
|
|
|
|
|
HANDLE pipeReadEnd;
|
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
thread::Handle threadId;
|
|
|
|
|
std::wstring stdoutData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Module
|
|
|
|
|
{
|
|
|
|
|
std::wstring fullPath;
|
|
|
|
|
void* baseAddress;
|
|
|
|
|
uint32_t sizeOfImage;
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-16 08:43:32 -04:00
|
|
|
struct Environment
|
|
|
|
|
{
|
|
|
|
|
size_t size;
|
|
|
|
|
char* data;
|
|
|
|
|
};
|
|
|
|
|
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
typedef HANDLE Handle;
|
|
|
|
|
|
|
|
|
|
// returns the process ID for the calling process
|
|
|
|
|
unsigned int GetId(void);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct SpawnFlags
|
|
|
|
|
{
|
|
|
|
|
enum Enum : uint32_t
|
|
|
|
|
{
|
|
|
|
|
NONE = 0u,
|
2019-07-16 08:43:32 -04:00
|
|
|
REDIRECT_STDOUT = 1u << 0u,
|
|
|
|
|
NO_WINDOW = 1u << 1u,
|
|
|
|
|
SUSPENDED = 1u << 2u
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// spawns a new process
|
|
|
|
|
Context* Spawn(const wchar_t* exePath, const wchar_t* workingDirectory, const wchar_t* commandLine, const void* environmentBlock, uint32_t flags);
|
|
|
|
|
|
2019-07-16 08:43:32 -04:00
|
|
|
// resumes a process that was spawned in a suspended state
|
|
|
|
|
void ResumeMainThread(Context* context);
|
|
|
|
|
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// waits until a spawned process has exited
|
|
|
|
|
unsigned int Wait(Context* context);
|
|
|
|
|
|
2019-07-16 08:43:32 -04:00
|
|
|
// waits until a process has exited
|
|
|
|
|
unsigned int Wait(Handle handle);
|
|
|
|
|
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// destroys a spawned process
|
|
|
|
|
void Destroy(Context*& context);
|
|
|
|
|
|
|
|
|
|
// terminates a spawned process
|
|
|
|
|
void Terminate(Handle processHandle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// opens a process
|
|
|
|
|
Handle Open(unsigned int processId);
|
|
|
|
|
|
|
|
|
|
// closes a process
|
|
|
|
|
void Close(Handle& handle);
|
|
|
|
|
|
|
|
|
|
// returns the full path for a process' image
|
|
|
|
|
std::wstring GetImagePath(Handle handle);
|
|
|
|
|
|
|
|
|
|
// returns the base address of the calling process
|
|
|
|
|
void* GetBase(void);
|
|
|
|
|
|
|
|
|
|
// returns the path to the executable of the calling process
|
|
|
|
|
std::wstring GetImagePath(void);
|
|
|
|
|
|
2019-07-16 08:43:32 -04:00
|
|
|
// returns the working directory of the calling process
|
|
|
|
|
std::wstring GetWorkingDirectory(void);
|
|
|
|
|
|
|
|
|
|
// returns the command line of the calling process
|
|
|
|
|
std::wstring GetCommandLine(void);
|
|
|
|
|
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// returns the size of a module loaded into the virtual address space of a given process
|
|
|
|
|
uint32_t GetImageSize(Handle handle, void* moduleBase);
|
|
|
|
|
|
|
|
|
|
// returns whether the process with the given handle is still active
|
|
|
|
|
bool IsActive(Handle handle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reads from process memory
|
|
|
|
|
void ReadProcessMemory(Handle handle, const void* srcAddress, void* destBuffer, size_t size);
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
T ReadProcessMemory(Handle handle, const void* srcAddress)
|
|
|
|
|
{
|
|
|
|
|
T value = {};
|
|
|
|
|
ReadProcessMemory(handle, srcAddress, &value, sizeof(T));
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// writes to process memory
|
|
|
|
|
void WriteProcessMemory(Handle handle, void* destAddress, const void* srcBuffer, size_t size);
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
void WriteProcessMemory(Handle handle, void* destAddress, const T& value)
|
|
|
|
|
{
|
|
|
|
|
WriteProcessMemory(handle, destAddress, &value, sizeof(T));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scans a region of memory in the given process until a free block of a given size is found.
|
|
|
|
|
// will only consider blocks at addresses with a certain alignment.
|
|
|
|
|
void* ScanMemoryRange(Handle handle, const void* lowerBound, const void* upperBound, size_t size, size_t alignment);
|
|
|
|
|
|
|
|
|
|
// makes the memory pages in the given region executable (in case they aren't already) while keeping other protection flags intact
|
|
|
|
|
void MakePagesExecutable(Handle handle, void* address, size_t size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flushes the process' instruction cache
|
|
|
|
|
void FlushInstructionCache(Handle handle, void* address, size_t size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// suspends a process
|
|
|
|
|
void Suspend(Handle handle);
|
|
|
|
|
|
|
|
|
|
// resumes a suspended process
|
|
|
|
|
void Resume(Handle handle);
|
|
|
|
|
|
|
|
|
|
// continues the calling thread of a process with the given thread context
|
|
|
|
|
void Continue(CONTEXT* threadContext);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// enumerates all threads of a process, returning their thread IDs.
|
|
|
|
|
// NOTE: only call on suspended processes!
|
|
|
|
|
std::vector<unsigned int> EnumerateThreads(unsigned int processId);
|
|
|
|
|
|
|
|
|
|
// enumerates all modules of a process, returning their info.
|
|
|
|
|
// NOTE: only call on suspended processes!
|
|
|
|
|
std::vector<Module> EnumerateModules(Handle handle);
|
|
|
|
|
|
|
|
|
|
|
2019-07-16 08:43:32 -04:00
|
|
|
// converts any combination of page protection flags (e.g. PAGE_NOACCESS, PAGE_GUARD, ...) to protection flags
|
|
|
|
|
// that specify an executable page (e.g. PAGE_EXECUTE).
|
|
|
|
|
uint32_t ConvertPageProtectionToExecutableProtection(uint32_t protection);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// returns whether a process runs under Wow64 (32-bit emulation on 64-bit versions of Windows)
|
|
|
|
|
bool IsWoW64(Handle handle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reads the environment of any process
|
|
|
|
|
Environment* CreateEnvironment(Handle handle);
|
|
|
|
|
|
|
|
|
|
// BEGIN EPIC MOD - Allow passing environment block for linker
|
|
|
|
|
Environment* CreateEnvironmentFromMap(const TMap<FString, FString>& Pairs);
|
|
|
|
|
// END EPIC MOD
|
|
|
|
|
|
|
|
|
|
// destroys an environment
|
|
|
|
|
void DestroyEnvironment(Environment*& environment);
|
|
|
|
|
|
|
|
|
|
|
Integrating live coding feature (aka Live++) into UE4.
Allows fast iteration of C++ changes without restarting the application. To use, select the "Live Coding (Experimental)" mode from the drop down menu next to the editor's compile button, or type "LiveCoding" into the console for a monolithic build. Press Ctrl+Alt+F11 to find changes and compile.
Changes vs standalone Live++ version:
* UBT is used to execute builds. This allows standard UE4 adaptive unity mode, allows us to reuse object files when we do regular builds, supports using any build executor allowed by UBT (XGE, SNDBS, etc..).
* Adding new source files is supported.
* Custom visualizer for FNames is supported via a weakly linked symbol in a static library (Engine/Extras/NatvisHelpers).
* Settings are exposed in the editor's project settings dialog.
* Standalone application has been rewritten as a Slate app ("LiveCodingConsole"). There is an additional option to start the program as hidden, where it will not be visible until Ctrl+Alt+F11 is hit. Similarly, closing the window will hide it instead of closing the application.
* Does not require a standalone licensed version of Live++.
Known issues:
* Does not currently support class layout changes / object reinstancing
#rb none
[FYI] Marc.Audy, Stefan.Boberg, Nick.Penwarden
#jira
#ROBOMERGE-SOURCE: CL 5304722 in //UE4/Release-4.22/...
#ROBOMERGE-BOT: RELEASE (Release-4.22 -> Main)
[CL 5309051 by ben marsh in Main branch]
2019-03-05 18:49:25 -05:00
|
|
|
// dumps raw memory for a given process
|
|
|
|
|
void DumpMemory(Handle handle, const void* address, size_t size);
|
|
|
|
|
}
|