Skip to content

Commit d7e95e2

Browse files
committed
Minor code improvements
1 parent 2e57eb3 commit d7e95e2

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Source/Include/KNSoft/NDK/Package/RandGen.inl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
#include "../NDK.h"
1616

17-
/*
18-
* Generate software random numbers by calling RtlRandomEx [0..MAXLONG-1], use the low 31 bits only
19-
*/
17+
/* Generate software random numbers by calling RtlRandomEx [0..MAXLONG-1], use the low 31 bits only */
2018

2119
static ULONG g_ulRandSeed = 0;
2220

@@ -52,6 +50,7 @@ Rand_SW16(void)
5250
#if (defined(_M_X64) && !defined(_M_ARM64EC)) || defined(_M_IX86)
5351

5452
__forceinline
53+
_Success_(return != FALSE)
5554
LOGICAL
5655
Rand_HW32(
5756
_Out_ unsigned int* Random)
@@ -71,6 +70,7 @@ Rand_HW32(
7170
}
7271

7372
__forceinline
73+
_Success_(return != FALSE)
7474
LOGICAL
7575
Rand_HW64(
7676
_Out_ unsigned __int64* Random)
@@ -97,6 +97,7 @@ Rand_HW64(
9797
}
9898

9999
__forceinline
100+
_Success_(return != FALSE)
100101
LOGICAL
101102
Rand_HW16(
102103
_Out_ unsigned short* Random)
@@ -119,6 +120,7 @@ Rand_HW16(
119120
#else
120121

121122
__forceinline
123+
_Success_(return != FALSE)
122124
LOGICAL
123125
Rand_HW32(
124126
_Out_ unsigned int* Random)
@@ -128,6 +130,7 @@ Rand_HW32(
128130
}
129131

130132
__forceinline
133+
_Success_(return != FALSE)
131134
LOGICAL
132135
Rand_HW64(
133136
_Out_ unsigned __int64* Random)
@@ -137,6 +140,7 @@ Rand_HW64(
137140
}
138141

139142
__forceinline
143+
_Success_(return != FALSE)
140144
LOGICAL
141145
Rand_HW16(
142146
_Out_ unsigned short* Random)
@@ -160,6 +164,7 @@ Rand_SWSizeT(VOID)
160164
}
161165

162166
__forceinline
167+
_Success_(return != FALSE)
163168
LOGICAL
164169
Rand_HWSizeT(
165170
_Out_ SIZE_T* Random)
@@ -232,6 +237,7 @@ Rand_SWBuffer(
232237
}
233238

234239
__inline
240+
_Success_(return != FALSE)
235241
LOGICAL
236242
Rand_HWBuffer(
237243
_Out_writes_bytes_(RandomBufferLength) void* RandomBuffer,

Source/Include/KNSoft/NDK/Win32/API/Kernel32.inl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ _Inline_GetModuleHandleW(
204204
return (HMODULE)NtCurrentPeb()->ImageBaseAddress;
205205
}
206206

207-
RtlInitUnicodeString(&DllName, lpModuleName);
207+
_Inline_RtlInitUnicodeString(&DllName, lpModuleName);
208208
Status = LdrGetDllHandle(NULL, NULL, &DllName, &DllHandle);
209209
if (NT_SUCCESS(Status))
210210
{
@@ -247,7 +247,7 @@ _Inline_GetModuleHandleExW(
247247

248248
if (lpModuleName == NULL)
249249
{
250-
*phModule = NtCurrentPeb()->ImageBaseAddress;
250+
*phModule = (HMODULE)NtCurrentPeb()->ImageBaseAddress;
251251
return TRUE;
252252
}
253253
if (dwFlags & GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS)
@@ -259,7 +259,7 @@ _Inline_GetModuleHandleExW(
259259
}
260260
} else
261261
{
262-
RtlInitUnicodeString(&DllName, lpModuleName);
262+
_Inline_RtlInitUnicodeString(&DllName, lpModuleName);
263263
Status = LdrGetDllHandle(NULL, NULL, &DllName, &DllHandle);
264264
if (!NT_SUCCESS(Status))
265265
{
@@ -275,7 +275,7 @@ _Inline_GetModuleHandleExW(
275275
}
276276
}
277277

278-
*phModule = DllHandle;
278+
*phModule = (HMODULE)DllHandle;
279279
return TRUE;
280280

281281
_Fail:
@@ -310,7 +310,7 @@ _Inline_GetModuleFileNameW(
310310
}
311311
} else
312312
{
313-
PRTL_PERTHREAD_CURDIR PerThreadCurdir = NtReadTeb(NtTib.SubSystemTib);
313+
PRTL_PERTHREAD_CURDIR PerThreadCurdir = (PRTL_PERTHREAD_CURDIR)NtReadTeb(NtTib.SubSystemTib);
314314
if (PerThreadCurdir != NULL && PerThreadCurdir->ImageName != NULL)
315315
{
316316
ImageName = PerThreadCurdir->ImageName;
@@ -320,7 +320,9 @@ _Inline_GetModuleFileNameW(
320320
}
321321

322322
PLDR_DATA_TABLE_ENTRY HeadEntry, Entry;
323-
HeadEntry = CONTAINING_RECORD(NtCurrentPeb()->Ldr->InLoadOrderModuleList.Flink, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
323+
HeadEntry = CONTAINING_RECORD(NtCurrentPeb()->Ldr->InLoadOrderModuleList.Flink,
324+
LDR_DATA_TABLE_ENTRY,
325+
InLoadOrderLinks);
324326
Entry = HeadEntry;
325327
LdrLockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS, NULL, &Cookie);
326328
LoaderLocked = TRUE;
@@ -1300,7 +1302,6 @@ _Inline_InterlockedPushListSListEx(
13001302
RtlInterlockedPushListSList
13011303
#endif
13021304
(ListHead, List, ListEnd, Count);
1303-
13041305
}
13051306

13061307
__inline

0 commit comments

Comments
 (0)