@msteed
btw,
Quote:
It would be nice to be able to see the return value from the patched calls, though that will be a bit more complex as you need to report twice, once before the call and once after.
There are some functions that return 64-bit values too, if you get to the point of reporting on return codes.
But i can just call original function before the log, so to have result as well at the same time, i mean something like:
// Wrapper function for patching Open
static BPTR Patched_Open(struct DOSIFace *Self, CONST_STRPTR name, LONG accessMode) {
BPTR result = 0;
// Call the original function
if (Original_Open) {
result = Original_Open(Self, name, accessMode);
}
// Log arguments and return value
LogPatchedFunction(RETURN_BPTR, result, "IDOS->Open(name='%s', accessMode=%ld)", name ? name : "NULL", accessMode, result);
return result;
}
or for int64 return:
// Wrapper function for patching GetFilePosition
static int64 Patched_GetFilePosition(struct DOSIFace *Self, BPTR fh) {
int64 result = 0;
// Call the original function
if (Original_GetFilePosition) {
result = Original_GetFilePosition(Self, fh);
}
// Log arguments and return value
LogPatchedFunction(RETURN_INT64, result, "IDOS->GetFilePosition(Self=0x%lx, fh=0x%lx)", (uint32)Self, fh);
return result;
}
And log it like:
uint32 VARARGS68K LogPatchedFunction(uint32 returnType, int64 returnValue, const char *format, ...) {
char buffer[512];
va_list args;
va_startlinear(args, format);
APTR data = va_getlinearva(args, APTR);
IExec->RawDoFmt(format, data, NULL, buffer);
if (returnType != RETURN_NONE) {
char returnBuffer[64];
switch (returnType) {
case RETURN_BPTR: {
// Use lower 32 bits for BPTR
int32 value = (int32)(returnValue & 0xFFFFFFFF);
IExec->RawDoFmt(" return=0x%lx\n", &value, NULL, returnBuffer);
break;
}
case RETURN_INT32: {
// Use lower 32 bits for int32
int32 value = (int32)(returnValue & 0xFFFFFFFF);
IExec->RawDoFmt(" return=%ld\n", &value, NULL, returnBuffer);
break;
}
case RETURN_LONG: {
// Use lower 32 bits for LONG
int32 value = (int32)(returnValue & 0xFFFFFFFF);
IExec->RawDoFmt(" return=%ld\n", &value, NULL, returnBuffer);
break;
}
case RETURN_INT64: {
// Use full int64
IExec->RawDoFmt(" return=%lld\n", &returnValue, NULL, returnBuffer);
break;
}
case RETURN_BOOL: {
// Use lower 32 bits for BOOL (normalized to 0 or 1)
int32 value = (int32)(returnValue & 0xFFFFFFFF);
IExec->RawDoFmt(" return=%ld\n", &value, NULL, returnBuffer);
break;
}
default:
returnBuffer[0] = '\0'; // No return value if type is unknown
break;
}
// Append return value to the log
IExec->DebugPrintF("%s%s", buffer, returnBuffer);
} else {
IExec->DebugPrintF("%s", buffer);
}
va_end(args);
return 0;
}
Something of that sort..
So it will be:
IIntuition->SetWindowTitles(Self=0x6FFFFC00, window=0x600A52E0, windowTitle=AmigaShell, screenTitle=0xFFFFFFFF)
IDOS->Open(name='NIL:', accessMode=1005) return=0x183F26EC
IDOS->Open(name='console:', accessMode=1006) return=0x183F2722
IDOS->Open(name='Env:Sys/console.prefs', accessMode=1005) return=0x17FE285C
IDOS->ChangeFilePosition(file=0x188092F2, position=10, offset=-1) return=0
IDOS->GetFilePosition(Self=0x6FFA05D0, fh=0x188092F2) return=0
IDOS->ChangeFilePosition(file=0x1880935E, position=10, offset=-1) return=1
IDOS->GetFilePosition(Self=0x6FFA05D0, fh=0x1880935E) return=10
Edited by kas1e on 2025/7/2 10:52:10
Edited by kas1e on 2025/7/2 11:12:43