Skip to content

Commit

Permalink
Fixed crash during API Logging (debug build), bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca1991 committed Mar 7, 2024
1 parent 46491be commit d5d7705
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 28 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# DiscCheckEmu Changelog



## [0.1.1] - 2024-03-07

### Fixed
- Crash in Debug build (API Logging)


## [0.1.0] - 2024-03-07

### Added
Expand All @@ -16,6 +22,7 @@
### Fixed
- Bug in GetVolumeInformationA hook


## [0.0.1] - 2024-02-19

### Added
Expand Down
16 changes: 8 additions & 8 deletions DiscCheckEmuAPIHook/Hook/CreateFileA.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ HANDLE WINAPI HookedCreateFileA(
HANDLE hTemplateFile)
{
#ifndef NDEBUG
std::cout << "---> CreateFileA(" << lpFileName << ", " << dwDesiredAccess <<
", " << dwShareMode << ", " << lpSecurityAttributes << ", " <<
dwCreationDisposition << ", " << dwFlagsAndAttributes << ", " <<
hTemplateFile << ")" << std::endl;
std::cout << "---> CreateFileA(" << (lpFileName != nullptr? lpFileName : "NULL") << ", " <<
dwDesiredAccess << ", " << dwShareMode << ", " <<
lpSecurityAttributes << ", " << dwCreationDisposition << ", " << dwFlagsAndAttributes <<
", " << (hTemplateFile != nullptr ? hTemplateFile : "NULL") << ")" << std::endl;
#endif

auto it = apiConfig.fileRedirections.find(string_utils::toLowercase(lpFileName));
if (it != apiConfig.fileRedirections.end())
lpFileName = LPCSTR(it->second.c_str());

#ifndef NDEBUG
std::cout << "<--- CreateFileA(" << lpFileName << ", " << dwDesiredAccess <<
", " << dwShareMode << ", " << lpSecurityAttributes << ", " <<
dwCreationDisposition << ", " << dwFlagsAndAttributes << ", " <<
hTemplateFile << ")" << std::endl;
std::cout << "<--- CreateFileA(" << (lpFileName != nullptr ? lpFileName : "NULL") << ", " <<
dwDesiredAccess << ", " << dwShareMode << ", " <<
lpSecurityAttributes << ", " << dwCreationDisposition << ", " << dwFlagsAndAttributes <<
", " << (hTemplateFile != nullptr ? hTemplateFile : "NULL") << ")" << std::endl;
#endif

return OGCreateFileA(lpFileName, dwDesiredAccess, dwShareMode,
Expand Down
14 changes: 6 additions & 8 deletions DiscCheckEmuAPIHook/Hook/GetDiskFreeSpaceA.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ BOOL WINAPI HookedGetDiskFreeSpaceA(
LPDWORD lpTotalNumberOfClusters)
{
#ifndef NDEBUG
std::cout << "---> GetDiskFreeSpaceA(" << lpRootPathName << ", " <<
lpSectorsPerCluster << ", " << lpBytesPerSector << ", " <<
lpNumberOfFreeClusters << ", " << lpTotalNumberOfClusters <<
")" << std::endl;
std::cout << "---> GetDiskFreeSpaceA(" << (lpRootPathName != nullptr ? lpRootPathName : "NULL") << ", " <<
lpSectorsPerCluster << ", " << lpBytesPerSector << ", " << lpNumberOfFreeClusters << ", " <<
lpTotalNumberOfClusters << ")" << std::endl;
#endif

for (dce::GetDiskFreeSpaceAConfig& conf : apiConfig.getDiskFreeSpaceAConfigs)
Expand All @@ -59,10 +58,9 @@ BOOL WINAPI HookedGetDiskFreeSpaceA(
}

#ifndef NDEBUG
std::cout << "<--- GetDiskFreeSpaceA(" << lpRootPathName << ", " <<
lpSectorsPerCluster << ", " << lpBytesPerSector << ", " <<
lpNumberOfFreeClusters << ", " << lpTotalNumberOfClusters <<
")" << std::endl;
std::cout << "<--- GetDiskFreeSpaceA(" << (lpRootPathName != nullptr ? lpRootPathName : "NULL") << ", " <<
lpSectorsPerCluster << ", " << lpBytesPerSector << ", " << lpNumberOfFreeClusters << ", " <<
lpTotalNumberOfClusters << ")" << std::endl;
#endif

return OGGetDiskFreeSpaceA(lpRootPathName,
Expand Down
4 changes: 2 additions & 2 deletions DiscCheckEmuAPIHook/Hook/GetDriveTypeA.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static UINT(WINAPI* OGGetDriveTypeA)(LPCSTR lpRootPathName) = GetDriveTypeA;
UINT WINAPI HookedGetDriveTypeA(LPCSTR lpRootPathName)
{
#ifndef NDEBUG
std::cout << "---> GetDriveTypeA(" << lpRootPathName << ")" << std::endl;
std::cout << "---> GetDriveTypeA(" << (lpRootPathName != nullptr? lpRootPathName: "NULL") << ")" << std::endl;
#endif

for (const dce::GetDriveAConfig& conf : apiConfig.getDriveAConfigs)
Expand All @@ -37,7 +37,7 @@ UINT WINAPI HookedGetDriveTypeA(LPCSTR lpRootPathName)
}

#ifndef NDEBUG
std::cout << "<--- GetDriveTypeA(" << lpRootPathName << ")" << std::endl;
std::cout << "<--- GetDriveTypeA(" << (lpRootPathName != nullptr ? lpRootPathName : "NULL") << ")" << std::endl;
#endif

return OGGetDriveTypeA(lpRootPathName);
Expand Down
4 changes: 2 additions & 2 deletions DiscCheckEmuAPIHook/Hook/GetFileAttributesA.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ static DWORD(WINAPI* OGGetFileAttributesA)(
DWORD WINAPI HookedGetFileAttributesA(LPCSTR lpFileName)
{
#ifndef NDEBUG
std::cout << "---> GetFileAttributesA(" << lpFileName << ")" << std::endl;
std::cout << "---> GetFileAttributesA(" << (lpFileName != nullptr ? lpFileName : "NULL") << ")" << std::endl;
#endif

for (dce::GetFileAttributesAConfig& conf : apiConfig.getFileAttributesAConfigs)
{
if (string_utils::areEqualIgnoreCase(lpFileName, conf.lpFileName))
{
#ifndef NDEBUG
std::cout << "<--- GetFileAttributesA | Returning: " << conf.returnValue << std::endl;
std::cout << "<--- GetFileAttributesA(" << (lpFileName != nullptr ? lpFileName : "NULL") << ")" << std::endl;
#endif
return conf.returnValue;
}
Expand Down
14 changes: 8 additions & 6 deletions DiscCheckEmuAPIHook/Hook/GetVolumeInformationA.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ BOOL WINAPI HookedGetVolumeInformationA(LPCSTR lpRootPathName,
DWORD nFileSystemNameSize)
{
#ifndef NDEBUG
std::cout << "---> GetVolumeInformationA(" << lpRootPathName << ", " <<
lpVolumeNameBuffer << ", " << nVolumeNameSize << ", " << lpVolumeSerialNumber <<
lpMaximumComponentLength << ", " << lpFileSystemFlags << ", " << lpFileSystemNameBuffer <<
std::cout << "---> GetVolumeInformationA(" << (lpRootPathName != nullptr? lpRootPathName : "NULL") << ", " <<
(lpVolumeNameBuffer != nullptr ? lpVolumeNameBuffer : "NULL") << ", " << nVolumeNameSize << ", " <<
lpVolumeSerialNumber << lpMaximumComponentLength << ", " << lpFileSystemFlags << ", " <<
(lpFileSystemNameBuffer != nullptr ? lpFileSystemNameBuffer : "NULL") << ", " <<
nFileSystemNameSize << ")" << std::endl;
#endif
for (dce::GetVolumeInformationAConfig& conf : apiConfig.getVolumeInformationAConfigs)
Expand Down Expand Up @@ -69,9 +70,10 @@ BOOL WINAPI HookedGetVolumeInformationA(LPCSTR lpRootPathName,
);
}
#ifndef NDEBUG
std::cout << "<--- GetVolumeInformationA(" << lpRootPathName << ", " <<
lpVolumeNameBuffer << ", " << nVolumeNameSize << ", " << lpVolumeSerialNumber <<
lpMaximumComponentLength << ", " << lpFileSystemFlags << ", " << lpFileSystemNameBuffer <<
std::cout << "<---GetVolumeInformationA(" << (lpRootPathName != nullptr ? lpRootPathName : "NULL") << ", " <<
(lpVolumeNameBuffer != nullptr ? lpVolumeNameBuffer : "NULL") << ", " << nVolumeNameSize << ", " <<
lpVolumeSerialNumber << lpMaximumComponentLength << ", " << lpFileSystemFlags << ", " <<
(lpFileSystemNameBuffer != nullptr ? lpFileSystemNameBuffer : "NULL") << ", " <<
nFileSystemNameSize << ") | Returning: " << conf.returnValue << std::endl;
#endif
return conf.returnValue;
Expand Down
2 changes: 1 addition & 1 deletion DiscCheckEmuAPIHook/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_BUILD 0
#define VERSION_BUILD 1
#define VERSION_PRIVATE 0

#define VER_ORIGINAL_FILENAME "DCEAPIHook.dll"
Expand Down

0 comments on commit d5d7705

Please sign in to comment.