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