mirror of
https://github.com/decompals/wibo.git
synced 2025-12-12 14:46:09 +00:00
Disable exceptions and RTTI
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
set(CMAKE_C_FLAGS_INIT "-m32")
|
||||
set(CMAKE_CXX_FLAGS_INIT "-m32")
|
||||
set(CMAKE_CXX_FLAGS_INIT "-m32 -fno-exceptions -fno-rtti")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-m32")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-m32")
|
||||
|
||||
|
||||
@@ -25,8 +25,6 @@ struct FsObject : ObjectBase {
|
||||
};
|
||||
|
||||
struct FileObject : FsObject {
|
||||
static constexpr ObjectType kType = ObjectType::File;
|
||||
|
||||
off_t filePos = 0;
|
||||
bool overlapped = false;
|
||||
bool appendOnly = false;
|
||||
@@ -34,7 +32,9 @@ struct FileObject : FsObject {
|
||||
// Used to notify overlapped operations without an event handle
|
||||
std::condition_variable overlappedCv;
|
||||
|
||||
explicit FileObject(int fd) : FsObject(kType, fd) {
|
||||
explicit FileObject(int fd) : FileObject(ObjectType::File, fd) {}
|
||||
FileObject(ObjectType type, int fd) : FsObject(type, fd) {
|
||||
flags |= Of_File;
|
||||
if (fd >= 0) {
|
||||
off_t pos = lseek(fd, 0, SEEK_CUR);
|
||||
if (pos == -1 && errno == ESPIPE) {
|
||||
@@ -177,3 +177,11 @@ void setLastErrorFromErrno();
|
||||
[[noreturn]] void exitInternal(DWORD exitCode);
|
||||
|
||||
} // namespace kernel32
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <> constexpr bool typeMatches<kernel32::FileObject>(const ObjectBase *o) noexcept {
|
||||
return o && (o->flags & Of_File);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -103,7 +103,7 @@ DWORD normalizeMaxInstances(DWORD value) {
|
||||
}
|
||||
|
||||
struct NamedPipeState : ObjectBase {
|
||||
static constexpr ObjectType kType = ObjectType::NamedPipe;
|
||||
static constexpr ObjectType kType = ObjectType::NamedPipeState;
|
||||
|
||||
std::mutex mutex;
|
||||
std::string key;
|
||||
@@ -171,6 +171,8 @@ struct NamedPipeState : ObjectBase {
|
||||
};
|
||||
|
||||
struct NamedPipeInstance final : FileObject {
|
||||
static constexpr ObjectType kType = ObjectType::NamedPipe;
|
||||
|
||||
Pin<NamedPipeState> state;
|
||||
int companionFd = -1;
|
||||
DWORD accessMode;
|
||||
@@ -182,7 +184,7 @@ struct NamedPipeInstance final : FileObject {
|
||||
std::condition_variable connectCv;
|
||||
|
||||
NamedPipeInstance(int fd, Pin<NamedPipeState> st, int companion, DWORD open, DWORD mode)
|
||||
: FileObject(fd), state(std::move(st)), companionFd(companion), accessMode(open), pipeMode(mode) {
|
||||
: FileObject(kType, fd), state(std::move(st)), companionFd(companion), accessMode(open), pipeMode(mode) {
|
||||
if (state) {
|
||||
state->registerInstance(this);
|
||||
}
|
||||
@@ -494,7 +496,7 @@ HANDLE WIN_FUNC CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMo
|
||||
configureInheritability(companionFd, inheritHandles);
|
||||
}
|
||||
|
||||
auto pipeObj = make_pin<NamedPipeInstance>(serverFd, state.clone(), companionFd, accessMode, dwPipeMode);
|
||||
auto pipeObj = make_pin<NamedPipeInstance>(serverFd, std::move(state), companionFd, accessMode, dwPipeMode);
|
||||
if (!pipeObj) {
|
||||
return fail(ERROR_NOT_ENOUGH_MEMORY);
|
||||
}
|
||||
@@ -528,8 +530,7 @@ BOOL WIN_FUNC ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
DEBUG_LOG("ConnectNamedPipe(%p, %p)\n", hNamedPipe, lpOverlapped);
|
||||
|
||||
auto pin = wibo::handles().get(hNamedPipe);
|
||||
auto *pipe = pin ? dynamic_cast<NamedPipeInstance *>(pin.get()) : nullptr;
|
||||
auto pipe = wibo::handles().getAs<NamedPipeInstance>(hNamedPipe);
|
||||
if (!pipe) {
|
||||
wibo::lastError = ERROR_INVALID_HANDLE;
|
||||
return FALSE;
|
||||
|
||||
@@ -107,16 +107,16 @@ std::filesystem::path pathFromWindows(const char *inStr) {
|
||||
if (followingExisting && !std::filesystem::exists(newPath2) &&
|
||||
(component != ".." && component != "." && component != "")) {
|
||||
followingExisting = false;
|
||||
try {
|
||||
for (std::filesystem::path entry : std::filesystem::directory_iterator{newPath}) {
|
||||
std::error_code ec;
|
||||
std::filesystem::directory_iterator iter{newPath, ec};
|
||||
if (!ec) {
|
||||
for (std::filesystem::path entry : iter) {
|
||||
if (strcasecmp(entry.filename().c_str(), component.c_str()) == 0) {
|
||||
followingExisting = true;
|
||||
newPath2 = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (const std::filesystem::filesystem_error &) {
|
||||
// not a directory
|
||||
}
|
||||
}
|
||||
newPath = newPath2;
|
||||
|
||||
@@ -26,11 +26,13 @@ enum class ObjectType : uint16_t {
|
||||
Heap,
|
||||
RegistryKey,
|
||||
NamedPipe,
|
||||
NamedPipeState,
|
||||
};
|
||||
|
||||
enum ObjectFlags : uint16_t {
|
||||
Of_None = 0x0,
|
||||
Of_Waitable = 0x1,
|
||||
Of_File = 0x2,
|
||||
};
|
||||
|
||||
struct ObjectBase {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "modules.h"
|
||||
#include "processes.h"
|
||||
#include "strutil.h"
|
||||
#include "version_info.h"
|
||||
#include "tls.h"
|
||||
#include "version_info.h"
|
||||
|
||||
#include <asm/ldt.h>
|
||||
#include <charconv>
|
||||
|
||||
Reference in New Issue
Block a user