Created
November 7, 2021 04:52
-
-
Save ryank231231/72fe484a05b0414968380f7b942dd0ad to your computer and use it in GitHub Desktop.
`pkeycheck.tjs` in 9-nine- PKG
This file contains hidden or 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
function ProductKeyCheckOne(config, pk) { | |
try { | |
pk = string(pk).toUpperCase().replace(/[^A-Z0-9]/g, ""); | |
//System.inform(input); | |
var chk; | |
with (config) chk = ProductKeyCheck(.len, pk, .pub, .chk, .sig); | |
if (chk !== void && chk.length == config.bin) { | |
var tag1 = "%02X%02X%02X%02X".sprintf(chk[7], chk[6], chk[5], chk[4]); | |
var tag2 = "%08X".sprintf(config.tag); | |
return (tag1 == tag2); | |
} | |
} catch {} | |
} | |
function ProductKeyInput(keyname) { | |
return System.inputString(global.ENV_GameName, keyname+"を入力してください", ""); | |
} | |
function ProductKeyCheckAndInput() { | |
var config, keyname = "プロダクトキー"; | |
if (typeof global.ENV_PKeyName == "String" && global.ENV_PKeyName != "") keyname = global.ENV_PKeyName; | |
try { | |
Plugins.link("pkutil.dll"); | |
config = Scripts.evalStorage("pkeyconf.tjs"); | |
} catch { | |
throw new Exception(@"${keyname}チェック処理の初期化に失敗しました"); | |
} | |
// LCID check | |
try { | |
if (GetUserDefaultLCID() != 0x0411 && | |
GetSystemDefaultLCID() != 0x0411) | |
throw new Exception("** JAPAN SALES ONLY. **"); | |
} catch { | |
throw new Exception(@"${keyname}チェック処理の起動に失敗しました"); | |
} | |
// DATE check | |
if (typeof global.ENV_LaunchDate == "String" && global.ENV_LaunchDate != "") { | |
if ((new Date()).getTime() < (new Date(global.ENV_LaunchDate)).getTime()) { | |
throw new Exception(@"${keyname}チェック処理の起動に失敗しました。\nプログラムが実行できません"); | |
} | |
} | |
var key = @"\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${global.ENV_GameId}\\__ProductKey__"; | |
@if (FORCE_PRODUCTKEY) | |
ProductKeyWriteRegistory("HKEY_CURRENT_USER"+key, ""); | |
@endif | |
var pk = System.readRegValue("HKEY_LOCAL_MACHINE"+key); | |
if (pk != "" && ProductKeyCheckOne(config, pk)) return true; | |
/**/pk = System.readRegValue("HKEY_CURRENT_USER"+key); | |
if (pk != "" && ProductKeyCheckOne(config, pk)) return true; | |
while ((pk = ProductKeyInput(keyname)) !== void) { | |
if (pk != "" && ProductKeyCheckOne(config, pk)) { | |
ProductKeyWriteRegistory("HKEY_CURRENT_USER"+key, pk); | |
return true; | |
} | |
} | |
return false; | |
} | |
try { | |
if (!ProductKeyCheckAndInput()) System.exit(); | |
} catch (e) { | |
try { Plugins.unlink("pkutil.dll"); } catch {} | |
try { delete global.ProductKeyCheckOne; } catch {} | |
try { delete global.ProductKeyInput; } catch {} | |
try { delete global.ProductKeyCheckAndInput; } catch {} | |
throw e; | |
} | |
try { Plugins.unlink("pkutil.dll"); } catch {} | |
try { delete global.ProductKeyCheckOne; } catch {} | |
try { delete global.ProductKeyInput; } catch {} | |
try { delete global.ProductKeyCheckAndInput; } catch {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment