mirror of
https://github.com/tiennm99/time-mocker.git
synced 2026-10-14 22:17:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c71d84861 | ||
|
|
a9a76fb541 | ||
|
|
add9912ddd | ||
|
|
d394f6f589 |
No files matched your search
Vendored
+22
-6
@@ -10,22 +10,38 @@ permissions:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
build-and-release:
|
||||||
runs-on: windows-2019
|
runs-on: windows-2025-vs2026
|
||||||
|
|
||||||
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 Hook DLL (x86)
|
||||||
run: msbuild TimeMocker.sln -p:Configuration=Release -p:Platform=x64 -m
|
run: dotnet build TimeMocker.Hook\TimeMocker.Hook.csproj -c Release -p:Platform=x86
|
||||||
|
|
||||||
|
- name: Build Hook DLL (x64)
|
||||||
|
run: dotnet build TimeMocker.Hook\TimeMocker.Hook.csproj -c Release -p:Platform=x64
|
||||||
|
|
||||||
|
- name: Build UI
|
||||||
|
run: dotnet build TimeMocker.UI\TimeMocker.UI.csproj -c Release -p:Platform=x64
|
||||||
|
|
||||||
|
- name: Verify Hook DLL sizes
|
||||||
|
run: |
|
||||||
|
$x64 = (Get-Item "TimeMocker.Hook\bin\x64\Release\net48\TimeMocker.Hook.dll").Length
|
||||||
|
$x86 = (Get-Item "TimeMocker.Hook\bin\x86\Release\net48\TimeMocker.Hook.dll").Length
|
||||||
|
Write-Host "x64 hook DLL: $x64 bytes"
|
||||||
|
Write-Host "x86 hook DLL: $x86 bytes"
|
||||||
|
if ($x64 -lt 20000) { throw "x64 hook DLL too small - build failed silently" }
|
||||||
|
if ($x86 -lt 20000) { throw "x86 hook DLL too small - build failed silently" }
|
||||||
|
|
||||||
- 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\*.dll 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\*.exe release\
|
||||||
copy TimeMocker.UI\bin\x64\Release\net48\*.config release\
|
copy TimeMocker.UI\bin\x64\Release\net48\*.config release\
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -95,17 +95,28 @@ namespace TimeMocker.UI.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
|
private static extern bool IsWow64Process2(
|
||||||
|
IntPtr hProcess,
|
||||||
|
out ushort pProcessMachine,
|
||||||
|
out ushort pNativeMachine);
|
||||||
|
|
||||||
private static bool Is64BitProcess(Process process)
|
private static bool Is64BitProcess(Process process)
|
||||||
{
|
{
|
||||||
if (!Environment.Is64BitOperatingSystem)
|
if (!Environment.Is64BitOperatingSystem)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool isWow64;
|
ushort processMachine, nativeMachine;
|
||||||
if (!IsWow64Process(process.Handle, out isWow64))
|
if (IsWow64Process2(process.Handle, out processMachine, out nativeMachine))
|
||||||
return false;
|
{
|
||||||
|
// IMAGE_FILE_MACHINE_UNKNOWN (0) means it's a native 64-bit process
|
||||||
|
// IMAGE_FILE_MACHINE_I386 (0x014c) means it's 32-bit on 64-bit Windows
|
||||||
|
return processMachine == 0x0000; // 0 = native, not emulated
|
||||||
|
}
|
||||||
|
|
||||||
// If IsWow64Process returns false, it's a 64-bit process
|
// Fallback
|
||||||
// If it returns true, it's a 32-bit process running on 64-bit Windows
|
bool isWow64;
|
||||||
|
IsWow64Process(process.Handle, out isWow64);
|
||||||
return !isWow64;
|
return !isWow64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user