Skip to content

Commit

Permalink
feat: displayed more info about the loaded modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementDreptin committed Sep 4, 2023
1 parent 5c1265c commit b432b7d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 0 additions & 2 deletions ModuleLoader.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
Expand All @@ -59,7 +58,6 @@
<AdditionalIncludeDirectories>$(XEDK)\include\win32</AdditionalIncludeDirectories>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<Optimization>Full</Optimization>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<IntrinsicFunctions>true</IntrinsicFunctions>
Expand Down
15 changes: 14 additions & 1 deletion src/Modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,20 @@ HRESULT ShowLoadedModuleNames(void)

// Go through the loaded modules and print their names
while ((hr = DmWalkLoadedModules(&pModuleWalker, &loadedModule)) == XBDM_NOERR)
puts(loadedModule.Name);
{
// Create a date string from the timestamp
char date[50] = { 0 };
TimestampToDateString(loadedModule.TimeStamp, date, sizeof(date));

printf("%s\n", loadedModule.Name);
printf(" BaseAddress: 0x%X\n", loadedModule.BaseAddress);
printf(" Size: 0x%X\n", loadedModule.Size);
printf(" Timestamp: %s\n", date);
printf(" Checksum: 0x%X\n", loadedModule.CheckSum);
printf(" DataAddress: 0x%X\n", loadedModule.PDataAddress);
printf(" DataSize: 0x%X\n", loadedModule.PDataSize);
printf("\n");
}

// Error handling
if (hr != XBDM_ENDOFLIST)
Expand Down
8 changes: 8 additions & 0 deletions src/Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// XBDM uses bit field types other than int which triggers a warning at warning level 4
// so we just disable it for XBDM
Expand Down Expand Up @@ -88,3 +89,10 @@ void LogXbdmError(HRESULT hr)

LogError(errorMsg);
}

void TimestampToDateString(time_t timestamp, char *date, size_t dateSize)
{
struct tm dateTime;
localtime_s(&dateTime, &timestamp);
strftime(date, dateSize, "%B %d, %Y (%H:%M:%S)", &dateTime);
}
3 changes: 3 additions & 0 deletions src/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ HRESULT AddXdkBinDirToPath(void);

// Translate the HRESULT hr into an error message and write it to stderr.
void LogXbdmError(HRESULT hr);

// Convert a time_t to a formatted date string.
void TimestampToDateString(time_t timestamp, char *date, size_t dateSize);

0 comments on commit b432b7d

Please sign in to comment.