Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
RatinCN committed Nov 30, 2024
1 parent 81f3128 commit 572aea0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 63 deletions.
45 changes: 0 additions & 45 deletions Source/KNSoft.MakeLifeEasier/IO/File.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
#include "../MakeLifeEasier.inl"

#pragma region Directory

NTSTATUS
NTAPI
IO_OpenDirectory(
_Out_ PHANDLE DirectoryHandle,
_In_ PUNICODE_STRING DirectoryPath,
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG ShareAccess)
{
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(DirectoryPath, OBJ_CASE_INSENSITIVE);

return NtOpenFile(DirectoryHandle,
DesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
ShareAccess,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT);
}

#pragma endregion

#pragma region Find File

#define FILE_FIND_BUFFER_SIZE PAGE_SIZE
Expand Down Expand Up @@ -109,27 +86,5 @@ IO_BeginFindFile(
return Status;
}

NTSTATUS
NTAPI
IO_ContinueFindFileFind(
_Inout_ PFILE_FIND FindData)
{
return IO_FindFile(FindData->DirectoryHandle,
FindData->Buffer,
FindData->Length,
FindData->FileInformationClass,
FindData->SearchFilter,
FALSE,
&FindData->HasData);
}

LOGICAL
NTAPI
IO_EndFindFile(
_In_ PFILE_FIND FindData)
{
return Mem_Free(FindData->Buffer);
}

#pragma endregion

38 changes: 29 additions & 9 deletions Source/KNSoft.MakeLifeEasier/IO/File.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ EXTERN_C_START

#pragma region Directory

MLE_API
FORCEINLINE
NTSTATUS
NTAPI
IO_OpenDirectory(
_Out_ PHANDLE DirectoryHandle,
_In_ PUNICODE_STRING DirectoryPath,
_In_ ACCESS_MASK DesiredAccess,
_In_ ULONG ShareAccess);
_In_ ULONG ShareAccess)
{
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(DirectoryPath, OBJ_CASE_INSENSITIVE);

return NtOpenFile(DirectoryHandle,
DesiredAccess,
&ObjectAttributes,
&IoStatusBlock,
ShareAccess,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT);
}

#pragma endregion

Expand Down Expand Up @@ -55,17 +65,27 @@ IO_BeginFindFile(
_In_opt_ PCUNICODE_STRING SearchFilter,
_In_ FILE_INFORMATION_CLASS FileInformationClass);

MLE_API
FORCEINLINE
NTSTATUS
NTAPI
IO_ContinueFindFileFind(
_Inout_ PFILE_FIND FindData);
_Inout_ PFILE_FIND FindData)
{
return IO_FindFile(FindData->DirectoryHandle,
FindData->Buffer,
FindData->Length,
FindData->FileInformationClass,
FindData->SearchFilter,
FALSE,
&FindData->HasData);
}

MLE_API
FORCEINLINE
LOGICAL
NTAPI
IO_EndFindFile(
_In_ PFILE_FIND FindData);
_In_ PFILE_FIND FindData)
{
return Mem_Free(FindData->Buffer);
}

#pragma endregion

Expand Down
2 changes: 1 addition & 1 deletion Source/KNSoft.MakeLifeEasier/String/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ Str_FromIntEx_Impl(
} else if (Base == 8)
{
uPowerFlag = 3;
} else if (Base == 10 || Base == 0)
} else if (Base == 10)
{
uPowerFlag = 0;
} else if (Base == 16)
Expand Down
18 changes: 10 additions & 8 deletions Source/KNSoft.MakeLifeEasier/String/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ Str_ToIntExA(
_Out_writes_bytes_(ValueSize) PVOID Value,
_In_ ULONG ValueSize);

#define Str_ToIntW(StrValue, Value) Str_ToIntExW(StrValue, FALSE, 0, Value, sizeof(*(Value)))
#define Str_ToIntA(StrValue, Value) Str_ToIntExA(StrValue, FALSE, 0, Value, sizeof(*(Value)))
#define Str_ToUIntW(StrValue, Value) Str_ToIntExW(StrValue, TRUE, 0, Value, sizeof(*(Value)))
#define Str_ToUIntA(StrValue, Value) Str_ToIntExA(StrValue, TRUE, 0, Value, sizeof(*(Value)))
#define Str_HexToIntW(StrValue, Value) Str_ToIntExW(StrValue, FALSE, 16, Value, sizeof(*(Value)))
#define Str_HexToIntA(StrValue, Value) Str_ToIntExA(StrValue, FALSE, 16, Value, sizeof(*(Value)))
#define Str_HexToUIntW(StrValue, Value) Str_ToIntExW(StrValue, TRUE, 16, Value, sizeof(*(Value)))
Expand All @@ -49,6 +45,11 @@ Str_ToIntExA(
#define Str_BinToUIntW(StrValue, Value) Str_ToIntExW(StrValue, TRUE, 2, Value, sizeof(*(Value)))
#define Str_BinToUIntA(StrValue, Value) Str_ToIntExA(StrValue, TRUE, 2, Value, sizeof(*(Value)))

#define Str_ToIntW Str_DecToIntW
#define Str_ToIntA Str_DecToIntA
#define Str_ToUIntW Str_DecToUIntW
#define Str_ToUIntA Str_DecToUIntA

#pragma endregion

#pragma region String From Integer
Expand All @@ -75,10 +76,6 @@ Str_FromIntExA(
_Out_writes_(DestCchSize) PSTR StrValue,
_In_ ULONG DestCchSize);

#define Str_FromIntW(Value, StrValue) Str_FromIntExW(Value, FALSE, 0, StrValue, ARRAYSIZE(StrValue))
#define Str_FromIntA(Value, StrValue) Str_FromIntExA(Value, FALSE, 0, StrValue, ARRAYSIZE(StrValue))
#define Str_FromUIntW(Value, StrValue) Str_FromIntExW(Value, TRUE, 0, StrValue, ARRAYSIZE(StrValue))
#define Str_FromUIntA(Value, StrValue) Str_FromIntExA(Value, TRUE, 0, StrValue, ARRAYSIZE(StrValue))
#define Str_HexFromIntW(Value, StrValue) Str_FromIntExW(Value, FALSE, 16, StrValue, ARRAYSIZE(StrValue))
#define Str_HexFromIntA(Value, StrValue) Str_FromIntExA(Value, FALSE, 16, StrValue, ARRAYSIZE(StrValue))
#define Str_HexFromUIntW(Value, StrValue) Str_FromIntExW(Value, TRUE, 16, StrValue, ARRAYSIZE(StrValue))
Expand All @@ -96,6 +93,11 @@ Str_FromIntExA(
#define Str_BinFromUIntW(Value, StrValue) Str_FromIntExW(Value, TRUE, 2, StrValue, ARRAYSIZE(StrValue))
#define Str_BinFromUIntA(Value, StrValue) Str_FromIntExA(Value, TRUE, 2, StrValue, ARRAYSIZE(StrValue))

#define Str_FromIntW Str_DecFromIntW
#define Str_FromIntA Str_DecFromIntA
#define Str_FromUIntW Str_DecFromUIntW
#define Str_FromUIntA Str_DecFromUIntA

#pragma endregion

EXTERN_C_END

0 comments on commit 572aea0

Please sign in to comment.