remove RtlGenRandom and use the newer BCryptGenRandom

This commit is contained in:
a 2023-12-14 04:29:42 +02:00
parent a841f43f4b
commit 3afde6e996
5 changed files with 4 additions and 13 deletions

1
.gitignore vendored
View File

@ -11,7 +11,6 @@ release/*
/dll/net.pb.h /dll/net.pb.h
base.exp base.exp
base.lib base.lib
rtlgenrandom*
steamclient.exp steamclient.exp
steamclient.lib steamclient.lib
out/* out/*

View File

@ -22,8 +22,9 @@
static void static void
randombytes(char * const buf, const size_t size) randombytes(char * const buf, const size_t size)
{ {
while (!RtlGenRandom((PVOID) buf, (ULONG) size)) { // NT_SUCCESS is: return value >= 0, including Ntdef.h causes so many errors
PRINT_DEBUG("RtlGenRandom ERROR\n"); while (BCryptGenRandom(NULL, (PUCHAR) buf, (ULONG) size, BCRYPT_USE_SYSTEM_PREFERRED_RNG) < 0) {
PRINT_DEBUG("BCryptGenRandom ERROR\n");
Sleep(100); Sleep(100);
} }

View File

@ -61,9 +61,7 @@
#define MSG_NOSIGNAL 0 #define MSG_NOSIGNAL 0
#define SystemFunction036 NTAPI SystemFunction036 #include <bcrypt.h>
#include <ntsecapi.h>
#undef SystemFunction036
#ifndef EMU_RELEASE_BUILD #ifndef EMU_RELEASE_BUILD
#define PRINT_DEBUG(a, ...) do {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t); WSASetLastError(0);} while (0) #define PRINT_DEBUG(a, ...) do {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t); WSASetLastError(0);} while (0)

View File

@ -1,4 +0,0 @@
#include <windows.h>
#define RtlGenRandom SystemFunction036
#define DLLEXPORT __declspec(dllexport)
DLLEXPORT BOOLEAN WINAPI RtlGenRandom(PVOID in, ULONG len) {}

View File

@ -1,3 +0,0 @@
LIBRARY advapi32.dll
EXPORTS
SystemFunction036