2020-12-15 09:27:44 -04:00
// Copyright 2011-2020 Molecular Matters GmbH, all rights reserved.
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
2020-12-15 09:27:44 -04:00
// BEGIN EPIC MOD
//#include PCH_INCLUDE
// END EPIC MOD
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
# include "LC_Process.h"
# include "LC_Memory.h"
# include "LC_PointerUtil.h"
# include "LC_VirtualMemory.h"
2019-07-16 08:43:32 -04:00
# include "LC_WindowsInternalFunctions.h"
2020-12-15 09:27:44 -04:00
# include "LC_Thread.h"
// BEGIN EPIC MOD
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
# include "LC_Logging.h"
# include <Psapi.h>
2019-07-16 08:47:25 -04:00
# include "Containers/Map.h"
# include "Containers/UnrealString.h"
2020-12-15 09:27:44 -04:00
// END EPIC MOD
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
2019-03-06 12:44:16 -05:00
// BEGIN EPIC MODS
# pragma warning(push)
# pragma warning(disable:6011) // warning C6011: Dereferencing NULL pointer 'processInfo'.
# pragma warning(disable:6335) // warning C6335: Leaking process information handle 'context->pi.hProcess'.
// END EPIC MODS
2020-12-15 09:27:44 -04:00
namespace Process
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
{
2020-12-15 09:27:44 -04:00
struct 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
{
2020-12-15 09:27:44 -04:00
uint32_t flags ;
HANDLE pipeReadEnd ;
PROCESS_INFORMATION processInformation ;
Thread : : Handle drainStdoutThread ;
std : : wstring stdoutData ;
} ;
}
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
2020-12-15 09:27:44 -04:00
void * Process : : Current : : GetBase ( void )
{
return : : GetModuleHandle ( NULL ) ;
}
Process : : Handle Process : : Current : : GetHandle ( void )
{
return Process : : Handle ( : : GetCurrentProcess ( ) ) ;
}
Process : : Id Process : : Current : : GetId ( void )
{
return Process : : Id ( : : GetCurrentProcessId ( ) ) ;
}
Filesystem : : Path Process : : Current : : GetImagePath ( void )
{
wchar_t filename [ Filesystem : : Path : : CAPACITY ] = { ' \0 ' } ;
: : GetModuleFileNameW ( NULL , filename , Filesystem : : Path : : CAPACITY ) ;
return Filesystem : : Path ( filename ) ;
}
Filesystem : : Path Process : : Current : : GetWorkingDirectory ( void )
{
wchar_t workingDirectory [ Filesystem : : Path : : CAPACITY ] = { ' \0 ' } ;
: : GetCurrentDirectoryW ( Filesystem : : Path : : CAPACITY , workingDirectory ) ;
return Filesystem : : Path ( workingDirectory ) ;
}
std : : wstring Process : : Current : : GetCommandLine ( void )
{
return std : : wstring ( : : GetCommandLineW ( ) ) ;
}
Process : : Id Process : : GetId ( const Context * context )
{
return Process : : Id ( context - > processInformation . dwProcessId ) ;
}
Process : : Handle Process : : GetHandle ( const Context * context )
{
return Process : : Handle ( context - > processInformation . hProcess ) ;
}
std : : wstring Process : : GetStdOutData ( const Context * context )
{
return context - > stdoutData ;
}
namespace
{
static Thread : : ReturnValue DrainPipe ( Process : : 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
std : : vector < char > stdoutData ;
2020-12-15 09:27:44 -04:00
stdoutData . reserve ( 1024u ) ;
char buffer [ 1024u ] ;
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
for ( ; ; )
{
DWORD bytesRead = 0u ;
if ( ! : : ReadFile ( context - > pipeReadEnd , buffer , sizeof ( buffer ) - 1u , & bytesRead , NULL ) )
{
// error while trying to read from the pipe, process has probably ended and closed its end of the pipe
const DWORD error = : : GetLastError ( ) ;
if ( error = = ERROR_BROKEN_PIPE )
{
// this is expected
break ;
}
LC_ERROR_USER ( " Error 0x%X while reading from pipe " , error ) ;
break ;
}
stdoutData . insert ( stdoutData . end ( ) , buffer , buffer + bytesRead ) ;
}
// convert stdout data to UTF16
if ( stdoutData . size ( ) > 0u )
{
// cl.exe and link.exe write to stdout using the OEM codepage
const int sizeNeeded = : : MultiByteToWideChar ( CP_OEMCP , 0 , stdoutData . data ( ) , static_cast < int > ( stdoutData . size ( ) ) , NULL , 0 ) ;
wchar_t * strTo = new wchar_t [ static_cast < size_t > ( sizeNeeded ) ] ;
: : MultiByteToWideChar ( CP_OEMCP , 0 , stdoutData . data ( ) , static_cast < int > ( stdoutData . size ( ) ) , strTo , sizeNeeded ) ;
context - > stdoutData . assign ( strTo , static_cast < size_t > ( sizeNeeded ) ) ;
delete [ ] strTo ;
}
2020-12-15 09:27:44 -04:00
return Thread : : ReturnValue ( 0u ) ;
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
}
2020-12-15 09:27:44 -04:00
}
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
2020-12-15 09:27:44 -04:00
Process : : Context * Process : : Spawn ( const wchar_t * exePath , const wchar_t * workingDirectory , const wchar_t * commandLine , const void * environmentBlock , uint32_t flags )
{
Context * context = new Context { flags , nullptr , : : PROCESS_INFORMATION { } , Thread : : Handle ( nullptr ) , { } } ;
: : SECURITY_ATTRIBUTES saAttr ;
saAttr . nLength = sizeof ( SECURITY_ATTRIBUTES ) ;
// BEGIN EPIC MOD
saAttr . bInheritHandle = Windows : : TRUE ;
// END EPIC MOD
saAttr . lpSecurityDescriptor = NULL ;
: : STARTUPINFOW startupInfo = { } ;
startupInfo . cb = sizeof ( startupInfo ) ;
// BEGIN EPIC MOD
Windows : : HANDLE hProcessStdOutRead = NULL ;
Windows : : HANDLE hProcessStdOutWrite = NULL ;
Windows : : HANDLE hProcessStdErrWrite = NULL ;
// END EPIC MOD
if ( flags & SpawnFlags : : REDIRECT_STDOUT )
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
{
2020-12-15 09:27:44 -04:00
// create a STD_OUT pipe for the child process
if ( ! : : CreatePipe ( & hProcessStdOutRead , & hProcessStdOutWrite , & saAttr , 0 ) )
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
{
2020-12-15 09:27:44 -04:00
LC_ERROR_USER ( " Cannot create stdout pipe. Error: 0x%X " , : : GetLastError ( ) ) ;
delete context ;
return nullptr ;
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
}
2020-12-15 09:27:44 -04:00
// create a duplicate of the STD_OUT write handle for the STD_ERR write handle. this is necessary in case the child
// application closes one of its STD output handles.
// BEGIN EPIC MOD
if ( ! : : DuplicateHandle ( : : GetCurrentProcess ( ) , hProcessStdOutWrite , : : GetCurrentProcess ( ) ,
& hProcessStdErrWrite , 0 , Windows : : TRUE , DUPLICATE_SAME_ACCESS ) )
// END EPIC MOD
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
{
2020-12-15 09:27:44 -04:00
LC_ERROR_USER ( " Cannot duplicate stdout pipe. Error: 0x%X " , : : GetLastError ( ) ) ;
: : CloseHandle ( hProcessStdOutRead ) ;
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
: : CloseHandle ( hProcessStdOutWrite ) ;
2020-12-15 09:27:44 -04:00
delete context ;
return nullptr ;
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
}
2020-12-15 09:27:44 -04:00
// the spawned process will output data into the write-end of the pipe, and our process will read from the
// read-end. because pipes can only do some buffering, we need to ensure that pipes never get clogged, otherwise
// the spawned process could block due to the pipe being full.
// therefore, we also create a new thread that continuously reads data from the pipe on our end.
context - > pipeReadEnd = hProcessStdOutRead ;
context - > drainStdoutThread = Thread : : CreateFromFunction ( " DrainStdoutPipe " , 16u * 1024u , & DrainPipe , context ) ;
startupInfo . hStdOutput = hProcessStdOutWrite ;
startupInfo . hStdError = hProcessStdErrWrite ;
startupInfo . dwFlags = STARTF_USESTDHANDLES ;
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
}
2020-12-15 09:27:44 -04:00
wchar_t * commandLineBuffer = nullptr ;
if ( commandLine )
2019-07-16 08:43:32 -04:00
{
2020-12-15 09:27:44 -04:00
commandLineBuffer = new wchar_t [ 32768 ] ;
: : wcscpy_s ( commandLineBuffer , 32768u , commandLine ) ;
2019-07-16 08:43:32 -04:00
}
2022-10-21 19:50:32 -04:00
LC_LOG_DEV ( " %s " , " Spawning process: " ) ;
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
{
2020-12-15 09:27:44 -04:00
LC_LOG_INDENT_DEV ;
LC_LOG_DEV ( " Executable: %S " , exePath ) ;
LC_LOG_DEV ( " Command line: %S " , commandLineBuffer ? commandLineBuffer : L " none " ) ;
LC_LOG_DEV ( " Working directory: %S " , workingDirectory ? workingDirectory : L " none " ) ;
LC_LOG_DEV ( " Custom environment block: %S " , environmentBlock ? L " yes " : L " no " ) ;
LC_LOG_DEV ( " Flags: %u " , flags ) ;
}
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
2020-12-15 09:27:44 -04:00
DWORD creationFlags = CREATE_UNICODE_ENVIRONMENT ;
if ( flags & SpawnFlags : : NO_WINDOW )
{
creationFlags | = CREATE_NO_WINDOW ;
}
if ( flags & SpawnFlags : : SUSPENDED )
{
creationFlags | = CREATE_SUSPENDED ;
}
// the environment block is not written to by CreateProcess, so it is safe to const_cast (it's a Win32 API mistake)
// BEGIN EPIC MOD
const BOOL success = : : CreateProcessW ( exePath , commandLineBuffer , NULL , NULL , Windows : : TRUE , creationFlags , const_cast < void * > ( environmentBlock ) , workingDirectory , & startupInfo , & context - > processInformation ) ;
// END EPIC MOD
if ( success = = 0 )
{
LC_ERROR_USER ( " Could not spawn process %S. Error: %d " , exePath , : : GetLastError ( ) ) ;
}
delete [ ] commandLineBuffer ;
if ( flags & SpawnFlags : : REDIRECT_STDOUT )
{
// we don't need those ends of the pipe
: : CloseHandle ( hProcessStdOutWrite ) ;
: : CloseHandle ( hProcessStdErrWrite ) ;
}
return context ;
}
void Process : : Destroy ( Context * & context )
{
: : CloseHandle ( context - > processInformation . hProcess ) ;
: : CloseHandle ( context - > processInformation . hThread ) ;
memory : : DeleteAndNull ( context ) ;
}
void Process : : ResumeMainThread ( Context * context )
{
: : ResumeThread ( context - > processInformation . hThread ) ;
}
unsigned int Process : : Wait ( Context * context )
{
// wait until process terminates
: : WaitForSingleObject ( context - > processInformation . hProcess , INFINITE ) ;
if ( context - > flags & SpawnFlags : : REDIRECT_STDOUT )
{
// wait until all data is drained from the pipe
Thread : : Join ( context - > drainStdoutThread ) ;
Thread : : Close ( context - > drainStdoutThread ) ;
// close remaining pipe handles
: : CloseHandle ( context - > pipeReadEnd ) ;
}
DWORD exitCode = 0xFFFFFFFFu ;
: : GetExitCodeProcess ( context - > processInformation . hProcess , & exitCode ) ;
return exitCode ;
}
unsigned int Process : : Wait ( Handle handle )
{
// wait until process terminates
: : WaitForSingleObject ( + handle , INFINITE ) ;
DWORD exitCode = 0xFFFFFFFFu ;
: : GetExitCodeProcess ( + handle , & exitCode ) ;
return exitCode ;
}
void Process : : Terminate ( Context * context )
{
Terminate ( Process : : Handle ( context - > processInformation . hProcess ) ) ;
}
void Process : : Terminate ( Handle handle )
{
: : TerminateProcess ( + handle , 0u ) ;
// termination is asynchronous, wait until the process is really gone
: : WaitForSingleObject ( + handle , INFINITE ) ;
}
Process : : Handle Process : : Open ( Id processId )
{
// BEGIN EPIC MOD
return Process : : Handle ( : : OpenProcess ( PROCESS_ALL_ACCESS , Windows : : FALSE , + processId ) ) ;
// END EPIC MOD
}
void Process : : Close ( Handle & handle )
{
: : CloseHandle ( + handle ) ;
handle = INVALID_HANDLE ;
}
void Process : : Suspend ( Context * context )
{
WindowsInternals : : NtSuspendProcess ( context - > processInformation . hProcess ) ;
}
void Process : : Suspend ( Handle handle )
{
WindowsInternals : : NtSuspendProcess ( + handle ) ;
}
void Process : : Resume ( Context * context )
{
WindowsInternals : : NtResumeProcess ( context - > processInformation . hProcess ) ;
}
void Process : : Resume ( Handle handle )
{
WindowsInternals : : NtResumeProcess ( + handle ) ;
}
bool Process : : IsActive ( Handle handle )
{
DWORD exitCode = 0u ;
const BOOL success = : : GetExitCodeProcess ( + handle , & exitCode ) ;
if ( ( success ! = 0 ) & & ( exitCode = = STILL_ACTIVE ) )
{
return true ;
}
// either the function has failed (because the process terminated unexpectedly) or the exit code
// signals that the process exited already.
return false ;
}
bool Process : : IsWoW64 ( Handle handle )
{
// a WoW64 process has a PEB32 instead of a real PEB.
// if we get a meaningful pointer to this PEB32, the process is running under WoW64.
ULONG_PTR peb32 = 0u ;
WindowsInternals : : NtQueryInformationProcess ( + handle , WindowsInternals : : ProcessWow64Information , & peb32 , sizeof ( ULONG_PTR ) , NULL ) ;
return ( peb32 ! = 0u ) ;
}
void Process : : ReadProcessMemory ( Handle handle , const void * srcAddress , void * destBuffer , size_t size )
{
WindowsInternals : : NtReadVirtualMemory ( + handle , const_cast < PVOID > ( srcAddress ) , destBuffer , static_cast < ULONG > ( size ) , NULL ) ;
}
void Process : : WriteProcessMemory ( Handle handle , void * destAddress , const void * srcBuffer , size_t size )
{
DWORD oldProtect = 0u ;
: : VirtualProtectEx ( + handle , destAddress , size , PAGE_READWRITE , & oldProtect ) ;
{
// instead of the regular WriteProcessMemory function, we use an undocumented function directly.
// this is because Windows 10 introduced a performance regression that causes WriteProcessMemory to be 100 times slower (!)
// than in previous versions of Windows.
// this bug was reported here:
// https://developercommunity.visualstudio.com/content/problem/228061/writeprocessmemory-slowdown-on-windows-10.html
WindowsInternals : : NtWriteVirtualMemory ( + handle , destAddress , const_cast < PVOID > ( srcBuffer ) , static_cast < ULONG > ( size ) , NULL ) ;
}
: : VirtualProtectEx ( + handle , destAddress , size , oldProtect , & oldProtect ) ;
}
void * Process : : ScanMemoryRange ( Handle handle , const void * lowerBound , const void * upperBound , size_t size , size_t alignment )
{
for ( const void * scan = lowerBound ; /* nothing */ ; /* nothing */ )
{
// align address to be scanned
scan = pointer : : AlignTop < const void * > ( scan , alignment ) ;
if ( pointer : : Offset < const void * > ( scan , size ) > = upperBound )
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
{
2020-12-15 09:27:44 -04:00
// outside of range to scan
LC_ERROR_DEV ( " Could not find memory range that fits 0x%X bytes with alignment 0x%X in range from 0x%p to 0x%p (scan: 0x%p) " , size , alignment , lowerBound , upperBound , scan ) ;
return nullptr ;
}
else if ( scan < lowerBound )
{
// outside of range (possible wrap-around)
LC_ERROR_DEV ( " Could not find memory range that fits 0x%X bytes with alignment 0x%X in range from 0x%p to 0x%p (scan: 0x%p) " , size , alignment , lowerBound , upperBound , scan ) ;
return nullptr ;
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
}
2020-12-15 09:27:44 -04:00
: : MEMORY_BASIC_INFORMATION memoryInfo = { } ;
: : VirtualQueryEx ( + handle , scan , & memoryInfo , sizeof ( : : MEMORY_BASIC_INFORMATION ) ) ;
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
2020-12-15 09:27:44 -04:00
if ( ( memoryInfo . RegionSize > = size ) & & ( memoryInfo . State = = MEM_FREE ) )
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
{
2020-12-15 09:27:44 -04:00
return memoryInfo . BaseAddress ;
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
}
2020-12-15 09:27:44 -04:00
// keep on searching
scan = pointer : : Offset < const void * > ( memoryInfo . BaseAddress , memoryInfo . RegionSize ) ;
}
}
uint32_t Process : : ConvertPageProtectionToExecutableProtection ( uint32_t protection )
{
// cut off PAGE_GUARD, PAGE_NOCACHE, PAGE_WRITECOMBINE, and PAGE_REVERT_TO_FILE_MAP
const uint32_t extraBits = protection & 0xFFFFFF00u ;
const uint32_t pageProtection = protection & 0x000000FFu ;
switch ( pageProtection )
{
case PAGE_NOACCESS :
case PAGE_READONLY :
case PAGE_READWRITE :
case PAGE_WRITECOPY :
return ( pageProtection < < 4u ) | extraBits ;
case PAGE_EXECUTE :
case PAGE_EXECUTE_READ :
case PAGE_EXECUTE_READWRITE :
case PAGE_EXECUTE_WRITECOPY :
default :
return protection ;
}
}
void Process : : MakePagesExecutable ( Handle handle , void * address , size_t size )
{
const uint32_t pageSize = VirtualMemory : : GetPageSize ( ) ;
const void * endOfRegion = pointer : : Offset < const void * > ( address , size ) ;
for ( const void * scan = address ; /* nothing */ ; /* nothing */ )
{
: : MEMORY_BASIC_INFORMATION memoryInfo = { } ;
const SIZE_T bytesInBuffer = : : VirtualQueryEx ( + handle , scan , & memoryInfo , sizeof ( : : MEMORY_BASIC_INFORMATION ) ) ;
if ( bytesInBuffer = = 0u )
{
// could not query the protection, bail out
break ;
}
const uint32_t executableProtection = ConvertPageProtectionToExecutableProtection ( memoryInfo . Protect ) ;
if ( executableProtection ! = memoryInfo . Protect )
{
// change this page into an executable one
DWORD oldProtection = 0u ;
: : VirtualProtectEx ( + handle , memoryInfo . BaseAddress , pageSize , executableProtection , & oldProtection ) ;
}
const void * endOfThisRegion = pointer : : Offset < const void * > ( memoryInfo . BaseAddress , pageSize ) ;
if ( endOfThisRegion > = endOfRegion )
{
// we are done
break ;
}
// keep on walking pages
scan = endOfThisRegion ;
}
}
void Process : : FlushInstructionCache ( Handle handle , void * address , size_t size )
{
: : FlushInstructionCache ( + handle , address , size ) ;
}
Process : : Environment Process : : CreateEnvironment ( Handle handle )
{
const void * processEnvironment = nullptr ;
2022-06-01 10:02:51 -04:00
// EPIC BEGIN MOD
SIZE_T processEnvironmentSize = 0 ;
// EPIC END MOD
2020-12-15 09:27:44 -04:00
const bool isWow64 = IsWoW64 ( handle ) ;
if ( ! isWow64 )
{
// this is either a 32-bit process running on 32-bit Windows, or a 64-bit process running on 64-bit Windows.
// the environment can be retrieved directly from the process' PEB and process parameters.
WindowsInternals : : NT_PROCESS_BASIC_INFORMATION pbi = { } ;
WindowsInternals : : NtQueryInformationProcess ( + handle , WindowsInternals : : ProcessBasicInformation , & pbi , sizeof ( pbi ) , NULL ) ;
const WindowsInternals : : NT_PEB peb = ReadProcessMemory < WindowsInternals : : NT_PEB > ( handle , pbi . PebBaseAddress ) ;
const WindowsInternals : : RTL_USER_PROCESS_PARAMETERS parameters = ReadProcessMemory < WindowsInternals : : RTL_USER_PROCESS_PARAMETERS > ( handle , peb . ProcessParameters ) ;
processEnvironment = parameters . Environment ;
2022-06-01 10:02:51 -04:00
// EPIC BEGIN MOD
processEnvironmentSize = parameters . EnvironmentSize ;
// EPIC END MOD
2020-12-15 09:27:44 -04:00
}
else
{
// this is a process running under WoW64.
// we must get the environment from the PEB32 of the process, rather than the "real" PEB.
ULONG_PTR peb32Wow64 = 0u ;
WindowsInternals : : NtQueryInformationProcess ( + handle , WindowsInternals : : ProcessWow64Information , & peb32Wow64 , sizeof ( ULONG_PTR ) , NULL ) ;
const WindowsInternals : : NT_PEB32 peb32 = ReadProcessMemory < WindowsInternals : : NT_PEB32 > ( handle , pointer : : FromInteger < const void * > ( peb32Wow64 ) ) ;
const WindowsInternals : : RTL_USER_PROCESS_PARAMETERS32 parameters32 = ReadProcessMemory < WindowsInternals : : RTL_USER_PROCESS_PARAMETERS32 > ( handle , pointer : : FromInteger < const void * > ( peb32 . ProcessParameters32 ) ) ;
processEnvironment = pointer : : FromInteger < const void * > ( parameters32 . Environment ) ;
2022-06-01 10:02:51 -04:00
// EPIC BEGIN MOD
processEnvironmentSize = parameters32 . EnvironmentSize ;
// EPIC END MOD
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
}
2020-12-15 09:27:44 -04:00
if ( ! processEnvironment )
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
{
2020-12-15 09:27:44 -04:00
return Environment { 0u , nullptr } ;
}
2022-06-01 10:02:51 -04:00
// EPIC BEGIN MOD
Environment environment = { processEnvironmentSize , : : malloc ( processEnvironmentSize ) } ;
// EPIC END MOD
2020-12-15 09:27:44 -04:00
ReadProcessMemory ( handle , processEnvironment , environment . data , environment . size ) ;
return environment ;
}
Process : : Environment Process : : CreateEnvironment ( Context * context )
{
return CreateEnvironment ( Process : : Handle ( context - > processInformation . hProcess ) ) ;
}
void Process : : DestroyEnvironment ( Environment & environment )
{
: : free ( environment . data ) ;
environment . data = nullptr ;
environment . size = 0u ;
}
// BEGIN EPIC MOD
std : : vector < Thread : : Id > Process : : EnumerateThreads ( Id processId )
// END EPIC MOD
{
// BEGIN EPIC MOD
std : : vector < Thread : : Id > threadIds ;
// END EPIC MOD
threadIds . reserve ( 256u ) ;
// 2MB should be enough for getting the process information, even on systems with high load
ULONG bufferSize = 2048u * 1024u ;
void * processSnapshot = nullptr ;
WindowsInternals : : NTSTATUS status = 0 ;
do
{
processSnapshot = : : malloc ( bufferSize ) ;
// try getting a process snapshot into the provided buffer
2021-10-12 10:50:53 -04:00
// BEGIN EPIC MOD
status = WindowsInternals : : NtQuerySystemInformation . ExecNoResultCheck ( WindowsInternals : : SystemProcessInformation , processSnapshot , bufferSize , NULL ) ;
// END EPIC MOD
2020-12-15 09:27:44 -04:00
if ( status = = STATUS_INFO_LENGTH_MISMATCH )
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
{
2020-12-15 09:27:44 -04:00
// buffer is too small, try again
: : free ( processSnapshot ) ;
processSnapshot = nullptr ;
bufferSize * = 2u ;
}
else if ( status < 0 )
{
// something went wrong
2021-01-19 11:40:24 -04:00
// BEGIN EPIC MOD - PVS is having problems dealing with + here.
2021-10-12 10:50:53 -04:00
WindowsInternals : : NtQuerySystemInformation . CheckResult ( status ) ; // write the error
2021-01-19 11:40:24 -04:00
LC_ERROR_USER ( " Cannot enumerate threads in process (PID: %d) " , static_cast < DWORD > ( processId ) ) ;
// END EPIC MOD
2020-12-15 09:27:44 -04:00
: : free ( processSnapshot ) ;
return threadIds ;
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
}
}
2020-12-15 09:27:44 -04:00
while ( status = = STATUS_INFO_LENGTH_MISMATCH ) ;
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
2020-12-15 09:27:44 -04:00
// find the process information for the given process ID
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
{
2020-12-15 09:27:44 -04:00
WindowsInternals : : NT_SYSTEM_PROCESS_INFORMATION * processInfo = static_cast < WindowsInternals : : NT_SYSTEM_PROCESS_INFORMATION * > ( processSnapshot ) ;
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
2020-12-15 09:27:44 -04:00
while ( processInfo ! = nullptr )
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
{
2020-12-15 09:27:44 -04:00
if ( processInfo - > UniqueProcessId = = reinterpret_cast < HANDLE > ( static_cast < DWORD_PTR > ( + processId ) ) )
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
{
2020-12-15 09:27:44 -04:00
// we found the process we're looking for
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
break ;
}
2020-12-15 09:27:44 -04:00
if ( processInfo - > NextEntryOffset = = 0u )
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
{
2020-12-15 09:27:44 -04:00
// we couldn't find our process
2020-12-17 10:05:33 -04:00
// BEGIN EPIC MOD - PVS is having problems dealing with + here.
LC_ERROR_USER ( " Cannot enumerate threads, process not found (PID: %d) " , static_cast < DWORD > ( processId ) ) ;
// END EPIC MOD
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
: : free ( processSnapshot ) ;
2019-04-18 17:51:25 -04:00
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
return threadIds ;
}
2020-12-15 09:27:44 -04:00
else
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
{
2020-12-15 09:27:44 -04:00
// walk to the next process info
processInfo = pointer : : Offset < WindowsInternals : : NT_SYSTEM_PROCESS_INFORMATION * > ( processInfo , processInfo - > NextEntryOffset ) ;
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
}
}
2020-12-15 09:27:44 -04:00
// record all threads belonging to the given process
if ( processInfo )
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
{
2020-12-15 09:27:44 -04:00
for ( ULONG i = 0u ; i < processInfo - > NumberOfThreads ; + + i )
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
{
2020-12-15 09:27:44 -04:00
const DWORD threadId = static_cast < DWORD > ( reinterpret_cast < DWORD_PTR > ( processInfo - > Threads [ i ] . ClientId . UniqueThread ) ) ;
threadIds . push_back ( Thread : : Id ( threadId ) ) ;
2019-07-16 08:43:32 -04:00
}
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
}
}
2020-12-15 09:27:44 -04:00
: : free ( processSnapshot ) ;
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
2020-12-15 09:27:44 -04:00
return threadIds ;
}
2019-07-16 08:43:32 -04:00
2020-12-15 09:27:44 -04:00
// BEGIN EPIC MOD
std : : vector < Process : : Module > Process : : EnumerateModules ( Handle handle )
// END EPIC MOD
{
// 1024 modules should be enough for most processes
// BEGIN EPIC MOD
std : : vector < Module > modules ;
2019-07-16 08:43:32 -04:00
// END EPIC MOD
2020-12-15 09:27:44 -04:00
modules . reserve ( 1024u ) ;
2019-07-16 08:43:32 -04:00
2020-12-15 09:27:44 -04:00
WindowsInternals : : NT_PROCESS_BASIC_INFORMATION pbi = { } ;
WindowsInternals : : NtQueryInformationProcess ( + handle , WindowsInternals : : ProcessBasicInformation , & pbi , sizeof ( pbi ) , NULL ) ;
2019-07-16 08:43:32 -04:00
2020-12-15 09:27:44 -04:00
const WindowsInternals : : NT_PEB processPEB = ReadProcessMemory < WindowsInternals : : NT_PEB > ( handle , pbi . PebBaseAddress ) ;
const WindowsInternals : : NT_PEB_LDR_DATA loaderData = ReadProcessMemory < WindowsInternals : : NT_PEB_LDR_DATA > ( handle , processPEB . Ldr ) ;
: : LIST_ENTRY * listHeader = loaderData . InLoadOrderModuleList . Flink ;
: : LIST_ENTRY * currentNode = listHeader ;
do
2019-07-16 08:43:32 -04:00
{
2020-12-15 09:27:44 -04:00
const WindowsInternals : : NT_LDR_DATA_TABLE_ENTRY entry = ReadProcessMemory < WindowsInternals : : NT_LDR_DATA_TABLE_ENTRY > ( handle , currentNode ) ;
wchar_t fullDllName [ Filesystem : : Path : : CAPACITY ] = { ' \0 ' } ;
// certain modules don't have a name and DLL base, skip those
if ( ( entry . DllBase ! = nullptr ) & & ( entry . FullDllName . Length > 0 ) & & ( entry . FullDllName . Buffer ! = nullptr ) )
2019-07-16 08:43:32 -04:00
{
2020-12-15 09:27:44 -04:00
ReadProcessMemory ( handle , entry . FullDllName . Buffer , fullDllName , entry . FullDllName . Length ) ;
modules . emplace_back ( Module { Filesystem : : Path ( fullDllName ) , entry . DllBase , entry . SizeOfImage } ) ;
2019-07-16 08:43:32 -04:00
}
2020-12-15 09:27:44 -04:00
currentNode = entry . InLoadOrderLinks . Flink ;
if ( currentNode = = nullptr )
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
{
2020-12-15 09:27:44 -04:00
break ;
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
}
}
2020-12-15 09:27:44 -04:00
while ( listHeader ! = currentNode ) ;
return modules ;
}
Filesystem : : Path Process : : GetImagePath ( Handle handle )
{
DWORD charCount = Filesystem : : Path : : CAPACITY ;
wchar_t processName [ Filesystem : : Path : : CAPACITY ] = { ' \0 ' } ;
: : QueryFullProcessImageName ( + handle , 0u , processName , & charCount ) ;
return Filesystem : : Path ( processName ) ;
}
uint32_t Process : : GetModuleSize ( Handle handle , void * moduleBase )
{
: : MODULEINFO info = { } ;
: : GetModuleInformation ( + handle , static_cast < HMODULE > ( moduleBase ) , & info , sizeof ( : : MODULEINFO ) ) ;
return info . SizeOfImage ;
}
// BEGIN EPIC MOD - Allow passing environment block for linker
Process : : Environment * Process : : CreateEnvironmentFromMap ( const TMap < FString , FString > & Pairs )
{
std : : vector < wchar_t > environmentData ;
for ( const TPair < FString , FString > & Pair : Pairs )
{
FString Variable = FString : : Printf ( TEXT ( " %s=%s " ) , * Pair . Key , * Pair . Value ) ;
environmentData . insert ( environmentData . end ( ) , * Variable , * Variable + ( Variable . Len ( ) + 1 ) ) ;
}
environmentData . push_back ( ' \0 ' ) ;
Environment * environment = new Environment ;
environment - > size = environmentData . size ( ) ;
environment - > data = : : malloc ( environmentData . size ( ) * sizeof ( wchar_t ) ) ;
if ( environment - > data ! = nullptr )
{
memcpy ( environment - > data , environmentData . data ( ) , environmentData . size ( ) * sizeof ( wchar_t ) ) ;
}
return environment ;
}
// END EPIC MOD
void Process : : DumpMemory ( Handle handle , const void * address , size_t size )
{
uint8_t * memory = new uint8_t [ size ] ;
ReadProcessMemory ( handle , address , memory , size ) ;
2022-10-21 19:50:32 -04:00
LC_LOG_DEV ( " %s " , " Raw data: " ) ;
2020-12-15 09:27:44 -04:00
LC_LOG_INDENT_DEV ;
for ( size_t i = 0u ; i < size ; + + i )
{
LC_LOG_DEV ( " 0x%02X " , memory [ i ] ) ;
}
delete [ ] memory ;
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
}
2019-03-06 12:44:16 -05:00
// BEGIN EPIC MODS
# pragma warning(pop)
// END EPIC MODS