7 Commits
Author SHA1 Message Date
tiennm99 fc1ba194d1 feat: cleanup 2026-02-27 16:50:21 +07:00
tiennm99 46c13d0533 Update global.json 2026-02-27 16:37:05 +07:00
tiennm99 06e195c5a2 Revert "Update release.yml"
This reverts commit d89ad156c8b68edf147bda50103867ae8c86df73.
2026-02-27 16:20:20 +07:00
tiennm99 9c71d84861 Update release.yml 2026-02-27 16:11:00 +07:00
tiennm99 a9a76fb541 Update InjectionManager.cs 2026-02-27 15:56:25 +07:00
tiennm99 add9912ddd Update release.yml 2026-02-27 15:35:08 +07:00
tiennm99 d394f6f589 Revert "feat: update actions"
This reverts commit ad9624f1d72b1c75b65a3c7876ef75d3171df874.
2026-02-27 15:29:26 +07:00
4 changed files with 15 additions and 66 deletions

No files matched your search

+7 -8
View File
@@ -10,25 +10,24 @@ permissions:
jobs: jobs:
build-and-release: build-and-release:
runs-on: windows-2019 runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: Setup MSBuild - name: Setup .NET
uses: microsoft/setup-msbuild@v2 uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Build Solution - name: Build Solution
run: msbuild TimeMocker.sln -p:Configuration=Release -p:Platform=x64 -m run: dotnet build TimeMocker.sln -c Release -p:Platform=x64
- name: Prepare Release Artifacts - name: Prepare Release Artifacts
run: | run: |
mkdir release mkdir release
# Copy all DLLs from the build output copy TimeMocker.UI\bin\x64\Release\net48\* release\
copy TimeMocker.UI\bin\x64\Release\net48\*.dll release\
copy TimeMocker.UI\bin\x64\Release\net48\*.exe release\
copy TimeMocker.UI\bin\x64\Release\net48\*.config release\
- name: Zip Release - name: Zip Release
run: Compress-Archive -Path release\* -DestinationPath TimeMocker-x64.zip run: Compress-Archive -Path release\* -DestinationPath TimeMocker-x64.zip
@@ -65,29 +65,23 @@ namespace TimeMocker.Hook
public void Run(RemoteHooking.IContext context, string mmfName) public void Run(RemoteHooking.IContext context, string mmfName)
{ {
string logPath = Path.Combine(Path.GetTempPath(), "TimeMocker.Hook.log");
try try
{ {
File.AppendAllText(logPath, $"[{DateTime.Now}] Starting hook, MMF: {mmfName}\r\n");
// Open the shared memory created by the UI process // Open the shared memory created by the UI process
_mmf = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(mmfName); _mmf = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(mmfName);
_view = _mmf.CreateViewAccessor(0, Marshal.SizeOf<MockTimeInfo>()); _view = _mmf.CreateViewAccessor(0, Marshal.SizeOf<MockTimeInfo>());
File.AppendAllText(logPath, $"[{DateTime.Now}] MMF opened successfully\r\n");
InstallHooks(); InstallHooks();
File.AppendAllText(logPath, $"[{DateTime.Now}] Hooks installed successfully\r\n");
RemoteHooking.WakeUpProcess(); RemoteHooking.WakeUpProcess();
File.AppendAllText(logPath, $"[{DateTime.Now}] Process woken up\r\n");
// Keep alive until process exits // Keep alive until process exits
while (true) Thread.Sleep(500); while (true) Thread.Sleep(500);
} }
catch (Exception ex) catch (Exception ex)
{ {
File.AppendAllText(logPath, $"[{DateTime.Now}] ERROR: {ex.GetType().Name}: {ex.Message}\r\n{ex.StackTrace}\r\n"); File.AppendAllText(
Path.Combine(Path.GetTempPath(), "TimeMocker.Hook.log"),
$"[{DateTime.Now}] ERROR: {ex}\r\n");
} }
finally finally
{ {
+3 -47
View File
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using EasyHook; using EasyHook;
namespace TimeMocker.UI.Core namespace TimeMocker.UI.Core
@@ -27,9 +26,6 @@ namespace TimeMocker.UI.Core
private static readonly string HookDllPathX86 = private static readonly string HookDllPathX86 =
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TimeMocker.Hook.x86.dll"); Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TimeMocker.Hook.x86.dll");
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool IsWow64Process(IntPtr hProcess, out bool wow64Process);
public event Action<string> LogMessage; public event Action<string> LogMessage;
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -53,19 +49,16 @@ namespace TimeMocker.UI.Core
// Write initial delta (zero = real time) before hook starts reading // Write initial delta (zero = real time) before hook starts reading
entry.Shm.Write(new MockTimeInfo { DeltaTicks = 0 }); entry.Shm.Write(new MockTimeInfo { DeltaTicks = 0 });
// Determine which DLL to use based on target process architecture
string hookDllPath = GetHookDllPath(process);
RemoteHooking.Inject( RemoteHooking.Inject(
process.Id, process.Id,
InjectionOptions.DoNotRequireStrongName, InjectionOptions.DoNotRequireStrongName,
hookDllPath, HookDllPathX86,
hookDllPath, HookDllPathX64,
entry.Shm.MmfName); entry.Shm.MmfName);
entry.IsInjected = true; entry.IsInjected = true;
_injected[process.Id] = entry; _injected[process.Id] = entry;
Log($"Injected into [{process.Id}] {process.ProcessName} ({GetArchitectureName(process)})"); Log($"Injected into [{process.Id}] {process.ProcessName}");
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -77,43 +70,6 @@ namespace TimeMocker.UI.Core
return entry; return entry;
} }
private static string GetHookDllPath(Process process)
{
bool is64BitTarget = Is64BitProcess(process);
if (is64BitTarget)
{
if (!File.Exists(HookDllPathX64))
throw new FileNotFoundException($"x64 hook DLL not found: {HookDllPathX64}");
return HookDllPathX64;
}
else
{
if (!File.Exists(HookDllPathX86))
throw new FileNotFoundException($"x86 hook DLL not found: {HookDllPathX86}");
return HookDllPathX86;
}
}
private static bool Is64BitProcess(Process process)
{
if (!Environment.Is64BitOperatingSystem)
return false;
bool isWow64;
if (!IsWow64Process(process.Handle, out isWow64))
return false;
// If IsWow64Process returns false, it's a 64-bit process
// If it returns true, it's a 32-bit process running on 64-bit Windows
return !isWow64;
}
private static string GetArchitectureName(Process process)
{
return Is64BitProcess(process) ? "x64" : "x86";
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Update fake time for a process // Update fake time for a process
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"sdk": { "sdk": {
"version": "10.0.0", "version": "10.0.100",
"rollForward": "latestMajor", "rollForward": "latestMajor",
"allowPrerelease": true "allowPrerelease": true
} }
} }