-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.ps1
82 lines (67 loc) · 2.52 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Lockdown Browser in Windows Sandbox
# https://github.com/gucci-on-fleek/lockdown-browser
# SPDX-License-Identifier: MPL-2.0+
# SPDX-FileCopyrightText: 2020-2022 gucci-on-fleek
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 3
cd $PSScriptRoot
function initialize_vs {
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module VSSetup -Scope CurrentUser
pushd (Get-VSSetupInstance)[0].InstallationPath
$cmd_args = '/c .\VC\Auxiliary\Build\vcvars32.bat'
$cmd_args += ' & set "'# 'set "' (with the trailing quotation mark) also shows the hidden variables
$cmd_out = & 'cmd' $cmd_args
popd
$env_vars = @{}
$cmd_out | % {
if ($_ -match '=') {
$key, $value = $_ -split '='
$env_vars[$key] = $value
}
}
$env_vars.Keys | % {
if ($_ -and $env_vars[$_]) {
set-item -force -path "env:\$($_)" -value "$($env_vars[$_])"
}
}
}
function build_detours {
git submodule init
git submodule update
pushd Detours
pushd src
nmake
popd
pushd samples\syelog
nmake
popd
pushd samples\withdll
nmake
popd
popd
}
function build_hook {
mkdir './build' -Force
pushd build
cl '/EHsc' '/LD' '/Fe:GetSystemMetrics-Hook.dll' '../src/GetSystemMetrics-Hook.cpp' '/I../Detours/include' '/link' '/nodefaultlib:oldnames.lib' '/export:DetourFinishHelperProcess,@1,NONAME' '/export:GetSystemMetrics' '../Detours\lib.X86\detours.lib' '../Detours\lib.X86\syelog.lib' 'user32.lib' # Most of these are pretty standard VS C++ compiler options, but of note is "/export:DetourFinishHelperProcess,@1,NONAME". The program will not be functional without this argument, but it isn't that well documented.
popd
}
function build_sandbox {
# Sadly, the Sandbox doesn't support relative host paths, so we have to find-and-replace at build time.
(Get-Content ./src/Sandbox.wsb).replace('{{HOST_FOLDER}}', $PSScriptRoot + '\runtime_directory') | Set-Content ./build/Sandbox.wsb
(Get-Content ./src/Sandbox-with-Microphone-Camera.wsb).replace('{{HOST_FOLDER}}', $PSScriptRoot + '\runtime_directory') | Set-Content ./build/Sandbox-with-Microphone-Camera.wsb
}
function copy_files {
pushd runtime_directory
cp ../Detours/bin.X86/withdll.exe . # This is the program that actually injects the DLL
cp ../build/GetSystemMetrics-Hook.dll .
cp ../build/Sandbox.wsb .
cp ../build/Sandbox-with-Microphone-Camera.wsb .
popd
}
initialize_vs
build_detours
build_hook
build_sandbox
copy_files