Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiple formatting issues in MCL._StandalonePack #4

Open
wants to merge 2 commits into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions MCL.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ class MCL {
output .= t 'switch A_PtrSize {`n'

/** @type {MCL.CompiledCode} */
compiledCode := unset
compiledCode := unset, hasRelocations := false
for compiledCode in compiledCodes {
output .= t '`tcase ' compiledCode.bitness // 8 ': '

Expand Down Expand Up @@ -966,7 +966,7 @@ class MCL {

base64Wrapped := '""'
while StrLen(base64) {
base64Wrapped .= '`n. "' SubStr(base64, 1, 120 - 8) '"'
base64Wrapped .= '`n`t`t`t. "' SubStr(base64, 1, 120 - 8) '"'
base64 := SubStr(base64, (120 - 8) + 1)
}

Expand All @@ -978,7 +978,8 @@ class MCL {
if exports != '{}'
output .= 'exports := ' exports ', '
if relocations != '[]'
output .= 'relocations := ' relocations ', '
hasRelocations := true
output .= 'relocations := ' relocations ', '
output .= 'b64 := ' base64Wrapped '`n'

lastCompiledCode := compiledCode
Expand Down Expand Up @@ -1022,12 +1023,13 @@ class MCL {
)
}

if relocations != '[]' {
if hasRelocations {
output .= (
t 'for offset in relocations`n'
t '`tNumPut("Ptr", NumGet(code, offset, "Ptr") + code.Ptr, code, offset)`n'
)
}
} else
output := StrReplace(output, 'relocations := [], ')

output .= (
t 'if !DllCall("VirtualProtect", "Ptr", code, "Ptr", code.Size, "UInt", 0x40, "UInt*", &old := 0, "UInt")`n'
Expand Down Expand Up @@ -1083,8 +1085,9 @@ class MCL {
output .= ') => DllCall(exports.' name
for i, v in StrSplit(export.types, "$")
output .= ', ' (i & 1 ? '"' StrReplace(v, '_', ' ') '"' : v)
output .= ')`n'
output .= '),`n'
}
output := RTrim(output, ',`n') '`n'
output .= '`t}'
for name, export in exports['g'] {
output .= (
Expand Down