mirror of
https://github.com/decompals/wibo.git
synced 2025-12-13 23:26:17 +00:00
Initial guest-to-host trampoline generation
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
#include "bcrypt.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "context.h"
|
||||
#include "errors.h"
|
||||
#include "modules.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sys/random.h>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
typedef PVOID BCRYPT_ALG_HANDLE;
|
||||
|
||||
constexpr ULONG BCRYPT_RNG_USE_ENTROPY_IN_BUFFER = 0x00000001;
|
||||
constexpr ULONG BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
|
||||
|
||||
@@ -33,7 +34,7 @@ bool fillWithSystemRandom(PUCHAR buffer, size_t length) {
|
||||
|
||||
namespace bcrypt {
|
||||
|
||||
NTSTATUS WIN_FUNC BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags) {
|
||||
NTSTATUS WINAPI BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer, ULONG cbBuffer, ULONG dwFlags) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
DEBUG_LOG("BCryptGenRandom(%p, %p, %lu, %lu)\n", hAlgorithm, pbBuffer, cbBuffer, dwFlags);
|
||||
if (pbBuffer == nullptr && cbBuffer != 0)
|
||||
@@ -66,7 +67,7 @@ NTSTATUS WIN_FUNC BCryptGenRandom(BCRYPT_ALG_HANDLE hAlgorithm, PUCHAR pbBuffer,
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL WIN_FUNC ProcessPrng(PBYTE pbData, SIZE_T cbData) {
|
||||
BOOL WINAPI ProcessPrng(PBYTE pbData, SIZE_T cbData) {
|
||||
HOST_CONTEXT_GUARD();
|
||||
DEBUG_LOG("ProcessPrng(%p, %lu)\n", pbData, cbData);
|
||||
if (pbData == nullptr && cbData != 0)
|
||||
@@ -76,13 +77,7 @@ BOOL WIN_FUNC ProcessPrng(PBYTE pbData, SIZE_T cbData) {
|
||||
|
||||
} // namespace bcrypt
|
||||
|
||||
static void *resolveByName(const char *name) {
|
||||
if (strcmp(name, "BCryptGenRandom") == 0)
|
||||
return (void *)bcrypt::BCryptGenRandom;
|
||||
if (strcmp(name, "ProcessPrng") == 0)
|
||||
return (void *)bcrypt::ProcessPrng;
|
||||
return nullptr;
|
||||
}
|
||||
#include "bcrypt_trampolines.h"
|
||||
|
||||
extern const wibo::ModuleStub lib_bcrypt = {
|
||||
(const char *[]){
|
||||
@@ -90,6 +85,6 @@ extern const wibo::ModuleStub lib_bcrypt = {
|
||||
"bcryptprimitives",
|
||||
nullptr,
|
||||
},
|
||||
resolveByName,
|
||||
bcrypt_trampoline_by_name,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user