mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
process code stubs
This commit is contained in:
parent
7168fe8ba3
commit
bfc36cb872
@ -22,6 +22,7 @@ set(TOOLBOX_SRC
|
||||
sane.cpp
|
||||
saneparser.cpp
|
||||
pathnames.cpp
|
||||
process.cpp
|
||||
utility.cpp
|
||||
fs_spec.cpp
|
||||
realpath.c
|
||||
|
107
toolbox/process.cpp
Normal file
107
toolbox/process.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Kelvin W Sherlock
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cerrno>
|
||||
#include <cctype>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cpu/defs.h>
|
||||
#include <cpu/CpuModule.h>
|
||||
#include <cpu/fmem.h>
|
||||
|
||||
#include <macos/sysequ.h>
|
||||
#include <macos/errors.h>
|
||||
|
||||
#include "toolbox.h"
|
||||
#include "stackframe.h"
|
||||
#include "process.h"
|
||||
|
||||
using ToolBox::Log;
|
||||
|
||||
namespace Process {
|
||||
|
||||
const unsigned kProcessID = 1986;
|
||||
|
||||
uint16_t GetCurrentProcess()
|
||||
{
|
||||
// FUNCTION GetCurrentProcess (VAR PSN: ProcessSerialNumber): OSErr;
|
||||
|
||||
uint32_t psn;
|
||||
uint32_t sp;
|
||||
sp = StackFrame<4>(psn);
|
||||
Log(" GetCurrentProcess(%08x)\n", psn);
|
||||
if (psn) memoryWriteLongLong(1, psn);
|
||||
ToolReturn<2>(sp, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t GetProcessInformation()
|
||||
{
|
||||
// FUNCTION GetProcessInformation (PSN: ProcessSerialNumber;
|
||||
// VAR info: ProcessInfoRec): OSErr;
|
||||
|
||||
enum {
|
||||
/* ProcessInfoRec */
|
||||
_processInfoLength = 0,
|
||||
_processName = 4,
|
||||
_processNumber = 8,
|
||||
_processType = 16,
|
||||
_processSignature = 20,
|
||||
_processMode = 24,
|
||||
_processLocation = 28,
|
||||
_processSize = 32,
|
||||
_processFreeMem = 36,
|
||||
_processLauncher = 40,
|
||||
_processLaunchDate = 48,
|
||||
_processActiveTime = 52,
|
||||
_processAppSpec = 56,
|
||||
};
|
||||
|
||||
uint32_t psn;
|
||||
uint32_t info;
|
||||
uint32_t sp;
|
||||
sp = StackFrame<8>(psn, info);
|
||||
Log(" GetProcessInformation(%08x, %08x)\n", psn, info);
|
||||
|
||||
if (!psn || memoryReadLongLong(psn) != kProcessID)
|
||||
{
|
||||
ToolReturn<2>(sp, MacOS::paramErr);
|
||||
return MacOS::paramErr;
|
||||
}
|
||||
|
||||
ToolReturn<2>(sp, MacOS::paramErr);
|
||||
return MacOS::paramErr;
|
||||
}
|
||||
|
||||
|
||||
}
|
13
toolbox/process.h
Normal file
13
toolbox/process.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __mpw_process_h__
|
||||
#define __mpw_process_h__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Process {
|
||||
|
||||
uint16_t GetCurrentProcess();
|
||||
uint16_t GetProcessInformation();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -33,16 +33,24 @@
|
||||
#include <cpu/CpuModule.h>
|
||||
#include <cpu/fmem.h>
|
||||
|
||||
#include <macos/traps.h>
|
||||
#include <macos/errors.h>
|
||||
|
||||
#include "toolbox.h"
|
||||
#include "rm.h"
|
||||
|
||||
#include "loader.h"
|
||||
#include "mm.h"
|
||||
#include "os.h"
|
||||
#include "packages.h"
|
||||
#include "process.h"
|
||||
#include "qd.h"
|
||||
#include "rm.h"
|
||||
#include "sane.h"
|
||||
#include "utility.h"
|
||||
#include "loader.h"
|
||||
#include "macos/traps.h"
|
||||
#include "stackframe.h"
|
||||
#include "utility.h"
|
||||
|
||||
|
||||
|
||||
|
||||
// yuck. TST.W d0
|
||||
extern "C" void cpuSetFlagsNZ00NewW(UWO res);
|
||||
@ -80,6 +88,11 @@ namespace ToolBox {
|
||||
case 0x0020:
|
||||
return MM::TempDisposeHandle();
|
||||
|
||||
case 0x0037:
|
||||
return Process::GetCurrentProcess();
|
||||
|
||||
case 0x003a:
|
||||
return Process::GetProcessInformation();
|
||||
|
||||
default:
|
||||
fprintf(stderr, "OSDispatch: selector %04x not implemented\n",
|
||||
|
Loading…
Reference in New Issue
Block a user