-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
188 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,147 +1,188 @@ | ||
|
||
class cJson | ||
{ | ||
static version := "0.2.1-git-built" | ||
|
||
_init() | ||
{ | ||
if (this.lib) | ||
return | ||
this.lib := this._LoadLib() | ||
|
||
; Populate globals | ||
NumPut(&this.True, this.lib.objTrue+0, "UPtr") | ||
NumPut(&this.False, this.lib.objFalse+0, "UPtr") | ||
NumPut(&this.Null, this.lib.objNull+0, "UPtr") | ||
|
||
this.fnGetObj := Func("Object") | ||
NumPut(&this.fnGetObj, this.lib.fnGetObj+0, "UPtr") | ||
} | ||
|
||
_LoadLib() { | ||
; | ||
; cJson.ahk 0.2.2-git-built | ||
; Copyright (c) 2021 Philip Taylor (known also as GeekDude, G33kDude) | ||
; https://github.com/G33kDude/cJson.ahk | ||
; | ||
; MIT License | ||
; | ||
; Permission is hereby granted, free of charge, to any person obtaining a copy | ||
; of this software and associated documentation files (the "Software"), to deal | ||
; in the Software without restriction, including without limitation the rights | ||
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
; copies of the Software, and to permit persons to whom the Software is | ||
; furnished to do so, subject to the following conditions: | ||
; | ||
; The above copyright notice and this permission notice shall be included in all | ||
; copies or substantial portions of the Software. | ||
; | ||
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
; SOFTWARE. | ||
; | ||
|
||
class cJson | ||
{ | ||
static version := "0.2.2-git-built" | ||
|
||
_init() | ||
{ | ||
if (this.lib) | ||
return | ||
this.lib := this._LoadLib() | ||
|
||
; Populate globals | ||
NumPut(&this.True, this.lib.objTrue+0, "UPtr") | ||
NumPut(&this.False, this.lib.objFalse+0, "UPtr") | ||
NumPut(&this.Null, this.lib.objNull+0, "UPtr") | ||
|
||
this.fnGetObj := Func("Object") | ||
NumPut(&this.fnGetObj, this.lib.fnGetObj+0, "UPtr") | ||
|
||
this.fnCastString := Func("Format").Bind("{}") | ||
NumPut(&this.fnCastString, this.lib.fnCastString, "UPtr") | ||
} | ||
|
||
_LoadLib() { | ||
static CodeBase64 := "" | ||
. "TLUCAAwAVUiJ5UiDAOxwSIlNEEiJAFUYTIlFIEyJAE0oSItFEEiLAQAIRThIiwBIORDCD4S0ALjHRfwBAWrrR0iDfRgAAHQti0X8SJhIAI0VNRoA" | ||
. "AEQPFLYEAWAYAWCNSAIASItVGEiJCmYAQQ++0GaJEOsCDwA2IIsAjVABgQEIiRCDRfwBBT8Q9RkAAAE+hMB1EqUDek0gAT9JicgASInB6CYfAACF" | ||
. "A3EZEGDHACIADl0CuAGn6S4GAADGSEX7AANTUDADB0ASIABodVsADAHHRQr0Amg1hBAYi0X0AYBIweAFSAHQSJiJRdCAC4ABUBCACxiDwAEADQCF" | ||
. "lMCIAEX7g0X0AYB90PsAdBMBGWMBFAUtFHyyA1Ysgg8IQbjCWwExBkG4e4ADEGBERImPX8dF8IJgDhYFAhmETfCJTciDfdDwAH5eGYwsDyyZCxIg" | ||
. "jwsPtoA68AGEgMAPhNgBAACBIOXGOjABQ42BATUrZ0ABpsjAD415Px1FEhxUEszp9kNQC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GOkIBIAeiy3p9AMBggkQD7cAZoP4KCJ1ZoMhGZIhXABbDk4cOZADLwo5fAo5" | ||
. "XKFKOVwA6R2QHAmKHAYIvxyIC2IA6aoCbY8clsMEhBwMvxyIC2aoAOk3kBwjihwKvxxBiAtuAOnEAY8csBvDBIQcDb8ciAtyAOnqUZAcPYocCV8O" | ||
. "Xw7GBbB0AOneQWxMDspjAhFEDh9+DYcBfn58N/8P8A/TBXXQBUMND7cawCCSIEEFAJqJwejSjGAS6zSDCR6PCcAAhcAGEvGJSINFEMAEASMYhcAP" | ||
. "hfz7/6r/uRIirxKQoJAgoJAvBwDlkQClpJFmgaONBQQd9aALiUXwx0UC/MGX6zIPt0UQiIPgD6Gxi0XwQLEAD7YAZg++0IsURfxjr+ghBGbB6CIE" | ||
. "IQiDRfygn/wDIH7Ix0X4wHgA6wo/YxUl4KxImEQPELdERejPFkSJwg16qbtlqaUY" | ||
static Code := false if ((A_PtrSize * 8) != 64) { | ||
Throw Exception("_LoadLib does not support " (A_PtrSize * 8) " bit AHK, please run using 64 bit AHK") | ||
} ; MCL standalone loader https://github.com/G33kDude/MCLib.ahk | ||
; Copyright (c) 2021 G33kDude, CloakerSmoker (CC-BY-4.0) | ||
; https://creativecommons.org/licenses/by/4.0/ if (!Code) { | ||
if !DllCall("Crypt32\CryptStringToBinary", "Str", CodeBase64, "UInt", 0, "UInt", 1, "UPtr", 0, "UInt*", CompressedSize, "Ptr", 0, "Ptr", 0, "UInt") | ||
throw Exception("Failed to parse MCLib b64 to binary") CompressedSize := VarSetCapacity(DecompressionBuffer, CompressedSize, 0) if !DllCall("Crypt32\CryptStringToBinary", "Str", CodeBase64, "UInt", 0, "UInt", 1, "Ptr", &DecompressionBuffer, "UInt*", CompressedSize, "Ptr", 0, "Ptr", 0, "UInt") | ||
throw Exception("Failed to convert MCLib b64 to binary") if !(pCode := DllCall("GlobalAlloc", "UInt", 0, "Ptr", 9808, "Ptr")) | ||
throw Exception("Failed to reserve MCLib memory") if (DllCall("ntdll\RtlDecompressBuffer", "UShort", 0x102, "Ptr", pCode, "UInt", 9808, "Ptr", &DecompressionBuffer, "UInt", CompressedSize, "UInt*", DecompressedSize, "UInt")) | ||
throw Exception("Error calling RtlDecompressBuffer",, Format("0x{:08x}", r)) if !DllCall("VirtualProtect", "Ptr", pCode, "Ptr", 9808, "UInt", 0x40, "UInt*", OldProtect, "UInt") | ||
Throw Exception("Failed to mark MCLib memory as executable") Exports := {} for ExportName, ExportOffset in {"BIGINTS_AS_FLOATS": 0, "dumps": 16, "fnGetObj": 1840, "loads": 1856, "objFalse": 6752, "objNull": 6768, "objTrue": 6784} { | ||
Exports[ExportName] := pCode + ExportOffset | ||
} Code := Exports } return Code | ||
} | ||
|
||
Dumps(obj) | ||
{ | ||
this._init() | ||
if (!IsObject(obj)) | ||
throw Exception("Input must be object") | ||
size := 0 | ||
DllCall(this.lib.dumps, "Ptr", &obj, "Ptr", 0, "Int*", size | ||
, "Ptr", &this.True, "Ptr", &this.False, "Ptr", &this.Null, "CDecl Ptr") | ||
VarSetCapacity(buf, size*2+2, 0) | ||
DllCall(this.lib.dumps, "Ptr", &obj, "Ptr*", &buf, "Int*", size | ||
, "Ptr", &this.True, "Ptr", &this.False, "Ptr", &this.Null, "CDecl Ptr") | ||
return StrGet(&buf, size, "UTF-16") | ||
} | ||
|
||
Loads(ByRef json) | ||
{ | ||
this._init() | ||
|
||
_json := " " json ; Prefix with a space to provide room for BSTR prefixes | ||
VarSetCapacity(pJson, A_PtrSize) | ||
NumPut(&_json, &pJson, 0, "Ptr") | ||
|
||
VarSetCapacity(pResult, 24) | ||
|
||
if (r := DllCall(this.lib.loads, "Ptr", &pJson, "Ptr", &pResult , "CDecl Int")) || ErrorLevel | ||
{ | ||
throw Exception("Failed to parse JSON (" r "," ErrorLevel ")", -1 | ||
, Format("Unexpected character at position {}: '{}'" | ||
, (NumGet(pJson)-&_json)//2, Chr(NumGet(NumGet(pJson), "short")))) | ||
} | ||
|
||
result := ComObject(0x400C, &pResult)[] | ||
if (IsObject(result)) | ||
ObjRelease(&result) | ||
return result | ||
} | ||
|
||
True[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": true, "name": "true"} | ||
return _ | ||
} | ||
} | ||
|
||
False[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": false, "name": "false"} | ||
return _ | ||
} | ||
} | ||
|
||
Null[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": "", "name": "null"} | ||
return _ | ||
} | ||
} | ||
} | ||
|
||
. "qLUAVUiJ5UiB7OAAAAAASIlNEEgAiVUYTIlFIEwAiU0oSItFEEgCiwAIRThIiwBIIDnCD4S0AJjHRQL8ABQA60dIg30AGAB0LYtF/EgAmEiNFXIb" | ||
. "AABQRA+2BAFgGAFgjQBIAkiLVRhIiQAKZkEPvtBmiQgQ6w8ANiCLAI0EUAEBEIkQg0X8GgEFPzIAPwE+hMB1EqUDek0gAT9JicjASInB6GMgAKEC" | ||
. "cUIZEGDHACIADl24AQGn6VsHAADGRST7AANTUDADB0AgCQDQdVsAGAHHRfSFAmg1hBAYi0X0gEgAweAFSAHQSIlMRdCAC4ABUBCAC4MMwAEADQCF" | ||
. "lMCIRQD7g0X0AYB9+2gAdBMBGWMBFAUtfAqyA1Ysgg8IQbhbYQExBkG4e4G0D2BEIomPX8dF8IJgOwYLAhmETfCJTciDffBoAH5eGYwsDywZFyAJ" | ||
. "jwsPtoA68AGEwMAPhNgBAACBIMY6cjABQ42BATUrZ0AByFPAD415fB5FEhxUEulm9kNQCRPp4sAEyiU4VcIlsMKr7Myr7MKb09oY8avswKvDD5PA" | ||
. "D8irKREzrx2eRSxMGOsbbdQSgwZG0xI6vnkBDw+AtkAYPAF1H4MQk8AsahDfHKBRqQPCL2FDBQYPhZRAQsUFOYBFKHVpx0XoDC6y6AImaxcfLg8u" | ||
. "6AAuzeMHK+AHBS7pI6QQow4qMKEO5KwO5KIG+hbbvw6vDuSgDuMHuuAHpg50rQKpDjihDiGnqQ7gbaIGir8OsA7go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RT0" | ||
. "A8IEEIFvg/gilHVmwxAZ0hBcAA4nrZwckIMXihx8ihxcvxypigvpHZAcCYocCL8cQYgLYgDpqgKPHJYbwwSEHAy/HMgFZgDp6jdQDiNKDgpfDl8O" | ||
. "xgWwbgDpxMB3TQ6wYwIdRA4NXw5fDsYFcgDp6lFQDj1KDglfDl8OxgXwdADp3mOtSg7kr0QOiB9+DYcBfn58/w8b8A/TBXXQBUMND7fACyCSIakY" | ||
. "AJqJweiMdWGpNIMJHo8JwADABhJh8YlIg0UQwAQjGIWAwA+F/Pv//7kS6iKvEpCgkCCgkAcA5ZELAKWkkWaBo40FHfWBoAuJRfDHRfzBlwDrMg+3" | ||
. "RRCD4CIPobGLRfBBx7YAsGYPvtBhwmKv6CEEMGbB6AQhCKHFg30w/AN+yCC/wHgA6wo/YxUl4KxImEQPELdERejPFkSJwg16qbtlqaUY" | ||
static Code := false | ||
if ((A_PtrSize * 8) != 64) { | ||
Throw Exception("_LoadLib does not support " (A_PtrSize * 8) " bit AHK, please run using 64 bit AHK") | ||
} | ||
; MCL standalone loader https://github.com/G33kDude/MCLib.ahk | ||
; Copyright (c) 2021 G33kDude, CloakerSmoker (CC-BY-4.0) | ||
; https://creativecommons.org/licenses/by/4.0/ | ||
if (!Code) { | ||
CompressedSize := VarSetCapacity(DecompressionBuffer, 3942, 0) | ||
if !DllCall("Crypt32\CryptStringToBinary", "Str", CodeBase64, "UInt", 0, "UInt", 1, "Ptr", &DecompressionBuffer, "UInt*", CompressedSize, "Ptr", 0, "Ptr", 0, "UInt") | ||
throw Exception("Failed to convert MCLib b64 to binary") | ||
if !(pCode := DllCall("GlobalAlloc", "UInt", 0, "Ptr", 10112, "Ptr")) | ||
throw Exception("Failed to reserve MCLib memory") | ||
if (DllCall("ntdll\RtlDecompressBuffer", "UShort", 0x102, "Ptr", pCode, "UInt", 10112, "Ptr", &DecompressionBuffer, "UInt", CompressedSize, "UInt*", DecompressedSize, "UInt")) | ||
throw Exception("Error calling RtlDecompressBuffer",, Format("0x{:08x}", r)) | ||
if !DllCall("VirtualProtect", "Ptr", pCode, "Ptr", 10112, "UInt", 0x40, "UInt*", OldProtect, "UInt") | ||
Throw Exception("Failed to mark MCLib memory as executable") | ||
Exports := {} | ||
for ExportName, ExportOffset in {"dumps": 0, "fnCastString": 2128, "fnGetObj": 2144, "loads": 2160, "objFalse": 7056, "objNull": 7072, "objTrue": 7088} { | ||
Exports[ExportName] := pCode + ExportOffset | ||
} | ||
Code := Exports | ||
} | ||
return Code | ||
} | ||
|
||
Dumps(obj) | ||
{ | ||
this._init() | ||
if (!IsObject(obj)) | ||
throw Exception("Input must be object") | ||
size := 0 | ||
DllCall(this.lib.dumps, "Ptr", &obj, "Ptr", 0, "Int*", size | ||
, "Ptr", &this.True, "Ptr", &this.False, "Ptr", &this.Null, "CDecl Ptr") | ||
VarSetCapacity(buf, size*2+2, 0) | ||
DllCall(this.lib.dumps, "Ptr", &obj, "Ptr*", &buf, "Int*", size | ||
, "Ptr", &this.True, "Ptr", &this.False, "Ptr", &this.Null, "CDecl Ptr") | ||
return StrGet(&buf, size, "UTF-16") | ||
} | ||
|
||
Loads(ByRef json) | ||
{ | ||
this._init() | ||
|
||
_json := " " json ; Prefix with a space to provide room for BSTR prefixes | ||
VarSetCapacity(pJson, A_PtrSize) | ||
NumPut(&_json, &pJson, 0, "Ptr") | ||
|
||
VarSetCapacity(pResult, 24) | ||
|
||
if (r := DllCall(this.lib.loads, "Ptr", &pJson, "Ptr", &pResult , "CDecl Int")) || ErrorLevel | ||
{ | ||
throw Exception("Failed to parse JSON (" r "," ErrorLevel ")", -1 | ||
, Format("Unexpected character at position {}: '{}'" | ||
, (NumGet(pJson)-&_json)//2, Chr(NumGet(NumGet(pJson), "short")))) | ||
} | ||
|
||
result := ComObject(0x400C, &pResult)[] | ||
if (IsObject(result)) | ||
ObjRelease(&result) | ||
return result | ||
} | ||
|
||
True[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": true, "name": "true"} | ||
return _ | ||
} | ||
} | ||
|
||
False[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": false, "name": "false"} | ||
return _ | ||
} | ||
} | ||
|
||
Null[] | ||
{ | ||
get | ||
{ | ||
static _ := {"value": "", "name": "null"} | ||
return _ | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
|
||
class cJson | ||
{ | ||
static version := "0.2.1-git-dev" | ||
static version := "0.2.2-git-dev" | ||
|
||
_init() | ||
{ | ||
|