Skip to content

Commit

Permalink
Update BreaksCoreInterop.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ogamespec committed Feb 10, 2023
1 parent 3a7d8b3 commit 1ae850a
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion Breaknes/Breaknes/BreaksCoreInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public class DebugInfoEntry
[DllImport("BreaksCore.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void GetDebugInfo(DebugInfoType type, IntPtr entries);

[DllImport("NSFPlayerInterop.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int GetDebugInfoByName(DebugInfoType type, ref DebugInfoEntryRaw entry);

[DllImport("NSFPlayerInterop.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int SetDebugInfoByName(DebugInfoType type, ref DebugInfoEntryRaw entry);

[DllImport("BreaksCore.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int GetMemLayout();

Expand Down Expand Up @@ -214,6 +220,55 @@ public static List<DebugInfoEntry> GetTestDebugInfo()

return list;
}
}

public static UInt32 GetDebugInfoByName(DebugInfoType type, string category, string name)
{
DebugInfoEntryRaw entry = new();

unsafe
{
for (int i = 0; i < 32; i++)
{
if (i < category.Length)
entry.category[i] = (byte)category[i];
else
entry.category[i] = 0;

if (i < name.Length)
entry.name[i] = (byte)name[i];
else
entry.name[i] = 0;
}
}

GetDebugInfoByName(type, ref entry);

return entry.value;
}

public static void SetDebugInfoByName(DebugInfoType type, string category, string name, UInt32 value)
{
DebugInfoEntryRaw entry = new();

unsafe
{
for (int i = 0; i < 32; i++)
{
if (i < category.Length)
entry.category[i] = (byte)category[i];
else
entry.category[i] = 0;

if (i < name.Length)
entry.name[i] = (byte)name[i];
else
entry.name[i] = 0;
}
}

entry.value = value;

SetDebugInfoByName(type, ref entry);
}
}
}

0 comments on commit 1ae850a

Please sign in to comment.