When a new SetState request is recieved, make sure to either
queue it to the polling thread or return a SUCCESS. Otherwise
the requesting thread will die waiting for something you
didn't take not of.
Once the pFeedback->Header.hEvent event is set, the game is free to free
the buffer that it was pointing to. In HP1 game, the pointer
even lead to the stack. Because that stack was changing a lot,
pFeedback->Header.dwStatus eventually resolved to a non-zero
value and we started to overwrite some random memory.
The main issue was that the corresponding Event to the CriticalSection
wasn't created when the CriticalSection was and the return value of
KeWaitForSingleObject wasn't checked, so the STATUS_INVALID_HANDLE
was quitely ignored.
This actually gets Harry Potter and the Sorcerer's Stone to intro.
* \src\cxbxkrnl\emursa.cpp(1032): warning C4018: '<': signed/unsigned mismatch
* \src\cxbxkrnl\emursa.cpp(1034): warning C4018: '<=': signed/unsigned mismatch
* \src\cxbxkrnl\emuxapi.cpp(256): warning C4018: '<': signed/unsigned mismatch
* \src\cxbxkrnl\emufile.cpp(331): warning C4267: '=': conversion from 'size_t' to 'xboxkrnl::USHORT', possible loss of data
* \src\cxbxkrnl\emuxinput.cpp(63): warning C4789: buffer 'g_Controller' of size 16 bytes will be overrun; 24 bytes will be written starting at offset 0
* \src\cxbxkrnl\emud3d8\convert.cpp(769): warning C4244: '=': conversion from 'uint32' to 'uint8', possible loss of data
* \src\cxbxkrnl\emud3d8\convert.cpp(770): warning C4244: '=': conversion from 'uint32' to 'uint8', possible loss of data
* \src\cxbxkrnl\emud3d8\convert.cpp(771): warning C4244: '=': conversion from 'uint32' to 'uint8', possible loss of data
* \src\cxbxkrnl\gloffscreen\gloffscreen_common.cpp(64): warning C4018: '<': signed/unsigned mismatch
* \src\devices\video\emunv2a_pfifo.cpp(81): warning C4805: '|': unsafe mix of type 'xbaddr' and type 'bool' in operation
* \src\devices\video\emunv2a_pgraph.cpp(3103): warning C4838: conversion from 'int' to 'unsigned int' requires a narrowing conversion
* \src\devices\video\nv2a_vsh.cpp(704): warning C4018: '<': signed/unsigned mismatch
* \src\devices\video\nv2a_shaders.cpp(231): warning C4018: '<': signed/unsigned mismatch
* \src\devices\video\emunv2a_pgraph.cpp(2938): warning C4018: '<': signed/unsigned mismatch
* \src\devices\video\emunv2a_pgraph.cpp(3749): warning C4018: '<': signed/unsigned mismatch
* \src\devices\video\emunv2a_pgraph.cpp(2972): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
* \src\devices\video\emunv2a_pgraph.cpp(2973): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
* Apply only for src and resource directories.
With this setup, it should work as intended only for Cxbx-Reloaded's source code without affecting third-party projects.