Echelon9 / cxbx-shogun

shogun's mirrored branch of the Cxbx original Xbox emulator
GNU General Public License v2.0
33 stars 7 forks source link

Support SetThreadPriority() via Ntdll call pass-through #9

Closed Echelon9 closed 10 years ago

Echelon9 commented 10 years ago

At present, Cxbx's version of SetThreadPriority() is equivalent to a NOP.

SetThreadPriority() sets the priority value for the specified thread. This value, together with the priority class of the thread's process, determines the thread's base priority level.

Dxbx has implemented a pass through to the Ntdll version of SetThreadPriority() for some time. We should support properly, unless compelling reason not to. Errors should also be passed back to the caller.

Dxbx implementation
function XTL_EmuSetThreadPriority
(
    hThread: HANDLE;
    nPriority: int
): BOOL; stdcall;
// Branch:shogun  Revision:0.8.1-Pre2  Translator:Shadow_Tj  Done:100
var
  bRet: BOOL;
begin
  EmuSwapFS(fsWindows);

  if MayLog(lfUnit) then
    LogBegin('EmuSetThreadPriority').
      _(hThread, 'hThread').
      _(nPriority, 'nPriority').
    LogEnd();

  bRet := BOOL(SetThreadPriority(hThread, nPriority));  // marked by cxbx

  if bRet = BOOL_FALSE then
    EmuWarning('SetThreadPriority Failed!');

  // HACK! Commented by cxbx
  //Sleep(10);

  EmuSwapFS(fsXbox);

  Result := bRet;
end;
Echelon9 commented 10 years ago

No further need for commented out code, and error reporting already setup to warn to KrnlDebug.txt and back to the caller.

Echelon9 commented 10 years ago

Resolved in PR #10