RawInput plugin causing crash in Packaged build

I’ve been running into several issues with using the RawInput plugin but have hashed out most of them by editing the source code. I’ve been using the ue5-main branch and just fetched the latest changes so of course this issue could be related to the fact that it’s an experimental branch.

To get more in depth on the crash, I have added some methods in to the RawInputFunctionLibrary.cpp as well as the header file that have worked perfectly fine in the editor. Here’s a slice of the cpp file with the method in question that is causing issues as well as the original GetRegisteredDevices() method:

#include "RawInputFunctionLibrary.h"
#include "RawInputSettings.h"
#if PLATFORM_WINDOWS
	#include "Windows/RawInputWindows.h"
#endif

void URawInputFunctionLibrary::RefreshRawInputDevices()
{
#if PLATFORM_WINDOWS
	FRawInputWindows* RawInput = static_cast<FRawInputWindows*>(static_cast<FRawInputPlugin*>(&FRawInputPlugin::Get())->GetRawInputDevice().Get());

	RawInput->InitializeRawInputDevice();
#endif
}

TArray<FRegisteredDeviceInfo> URawInputFunctionLibrary::GetRegisteredDevices()
{
	TArray<FRegisteredDeviceInfo> RegisteredDevices;

#if PLATFORM_WINDOWS
	FRawInputWindows* RawInput = static_cast<FRawInputWindows*>(static_cast<FRawInputPlugin*>(&FRawInputPlugin::Get())->GetRawInputDevice().Get());

	RegisteredDevices.Reserve(RawInput->RegisteredDeviceList.Num());
	for (const TPair<int32, FRawWindowsDeviceEntry>& RegisteredDevice : RawInput->RegisteredDeviceList)
	{
		const FRawWindowsDeviceEntry& DeviceEntry = RegisteredDevice.Value;
		if (DeviceEntry.bIsConnected)
		{
			RegisteredDevices.Add(RawInput->GetDeviceInfo(RegisteredDevice.Key));
		}
	}

#endif

	return RegisteredDevices;
}

My visual studio builds the source code and project code with no errors so I assume this error might be related to some gen files being created incorrectly during the Packaging process but I’m not sure where or how I would fix it. The error log:

LogWindows: Error: === Critical error: ===
LogWindows: Error:
LogWindows: Error: Fatal error!
LogWindows: Error:
LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000000000000000
LogWindows: Error:
LogWindows: Error: [Callstack] 0x00007ff77c0f5637 BlankProject.exe!URawInputFunctionLibrary::execRefreshRawInputDevices() [C:\Projects\BlankProject\Intermediate\Build\Win64\BlankProject\Inc\RawInput\UHT\RawInputFunctionLibrary.gen.cpp:233]
LogWindows: Error: [Callstack] 0x00007ff7751f3128 BlankProject.exe!UObject::execCallMathFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1075]
LogWindows: Error: [Callstack] 0x00007ff7751cf5b8 BlankProject.exe!ProcessLocalScriptFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1205]
LogWindows: Error: [Callstack] 0x00007ff7751a6a15 BlankProject.exe!ProcessScriptFunction<void (__cdecl*)(UObject *,FFrame &,void )>() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1038]
LogWindows: Error: [Callstack] 0x00007ff7751cef9e BlankProject.exe!ProcessLocalFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1276]
LogWindows: Error: [Callstack] 0x00007ff7751cf5b8 BlankProject.exe!ProcessLocalScriptFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1205]
LogWindows: Error: [Callstack] 0x00007ff7751a6a15 BlankProject.exe!ProcessScriptFunction<void (__cdecl
)(UObject *,FFrame &,void *)>() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1038]
LogWindows: Error: [Callstack] 0x00007ff7751cef9e BlankProject.exe!ProcessLocalFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1276]
LogWindows: Error: [Callstack] 0x00007ff7751cf5b8 BlankProject.exe!ProcessLocalScriptFunction() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1205]
LogWindows: Error: [Callstack] 0x00007ff7751ce67c BlankProject.exe!UObject::ProcessInternal() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:1303]
LogWindows: Error: [Callstack] 0x00007ff774eb7f89 BlankProject.exe!UFunction::Invoke() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:6917]
LogWindows: Error: [Callstack] 0x00007ff7751cd0ca BlankProject.exe!UObject::ProcessEvent() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\CoreUObject\Private\UObject\ScriptCore.cpp:2143]
LogWindows: Error: [Callstack] 0x00007ff779e328c0 BlankProject.exe!AActor::ProcessEvent() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\Actor.cpp:1096]
LogWindows: Error: [Callstack] 0x00007ff779e10a5a BlankProject.exe!AActor::BeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\Actor.cpp:4252]
LogWindows: Error: [Callstack] 0x00007ff77ae3261b BlankProject.exe!APawn::BeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\Pawn.cpp:179]
LogWindows: Error: [Callstack] 0x00007ff779e157df BlankProject.exe!AActor::DispatchBeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\Actor.cpp:4192]
LogWindows: Error: [Callstack] 0x00007ff77b81e0fe BlankProject.exe!AWorldSettings::NotifyBeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\WorldSettings.cpp:306]
LogWindows: Error: [Callstack] 0x00007ff77a768d01 BlankProject.exe!AGameStateBase::HandleBeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\GameStateBase.cpp:228]
LogWindows: Error: [Callstack] 0x00007ff77b735961 BlankProject.exe!UWorld::BeginPlay() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\World.cpp:5329]
LogWindows: Error: [Callstack] 0x00007ff77b5ee9c8 BlankProject.exe!UEngine::LoadMap() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp:15564]
LogWindows: Error: [Callstack] 0x00007ff77b5706aa BlankProject.exe!UEngine::Browse() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp:14702]
LogWindows: Error: [Callstack] 0x00007ff77a78d3e5 BlankProject.exe!UGameInstance::StartGameInstance() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\GameInstance.cpp:658]
LogWindows: Error: [Callstack] 0x00007ff77a78cd01 BlankProject.exe!UGameEngine::Start() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Engine\Private\GameEngine.cpp:1217]
LogWindows: Error: [Callstack] 0x00007ff77be00148 BlankProject.exe!FEngineLoop::Init() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:4921]
LogWindows: Error: [Callstack] 0x00007ff77be1d176 BlankProject.exe!GuardedMain() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Launch\Private\Launch.cpp:164]
LogWindows: Error: [Callstack] 0x00007ff77be1d36a BlankProject.exe!GuardedMainWrapper() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:118]
LogWindows: Error: [Callstack] 0x00007ff77be201d5 BlankProject.exe!LaunchWindowsStartup() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:258]
LogWindows: Error: [Callstack] 0x00007ff77be30aa4 BlankProject.exe!WinMain() [D:\Unreal Engine Source Codes\UnrealEngineGit\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:299]
LogWindows: Error: [Callstack] 0x00007ff780498b6a BlankProject.exe!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
LogWindows: Error: [Callstack] 0x00007fff70e2257d KERNEL32.DLL!UnknownFunction
LogWindows: Error:
LogExit: Executing StaticShutdownAfterError
LogWindows: FPlatformMisc::RequestExit(1, LaunchWindowsStartup.ExceptionHandler)
LogWindows: FPlatformMisc::RequestExitWithStatus(1, 3, LaunchWindowsStartup.ExceptionHandler)
LogCore: Engine exit requested (reason: Win RequestExit)

If anyone has any ideas or needs more information in order to help me out here then I will do whatever I can. Been stuck on packaging issues for the past week and have managed fix them somewhat such as JSBSim plugin issues and other various things so I’m just about at my breaking point.

1 Like