Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
HIllya51 committed Jan 7, 2025
1 parent 0a77c9c commit 1a7f27b
Show file tree
Hide file tree
Showing 14 changed files with 163 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else()
Syuntada Pensil Anim hibiki Nitroplus Reallive Siglus Taskforce2 RUGP IronGameSystem Anex86
ShinyDaysGame MarineHeart ShinaRio CaramelBox UnisonShift Escude Ryokucha Alice Footy2
utawarerumono System4x Abalone Abel 5pb HorkEye XUSE Leaf Nekopack AXL AGS AdobeFlash10
FocasLens Tamamo Ages3ResT H_do_C)
FocasLens Tamamo Ages3ResT H_do_C RScript)
set(enginepath "engine32")
set(collector "enginecollection32.cpp")
endif()
Expand Down
10 changes: 5 additions & 5 deletions cpp/LunaHook/LunaHook/engine32/BKEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace{
bool _1(){
BYTE sig[]={0x64,0xa3,0x00,0x00,0x00,0x00,0x8b,0xf1,0x8b,0x45,0x08,0x0f,0x57,0xc0,0xc7,0x06,0x02,0x00,0x00,0x00};
auto addr=MemDbg::findBytes(sig, sizeof(sig), processStartAddress, processStopAddress);
if(addr==0)return 0;
if(!addr)return 0;
addr=MemDbg::findEnclosingAlignedFunction(addr);
if(addr==0)return 0;
if(!addr)return 0;
HookParam hp;
hp.address = addr;
hp.type = CODEC_UTF16|DATA_INDIRECT;
Expand All @@ -18,9 +18,9 @@ namespace{
bool _2(){
BYTE sig[]={0xb8,0xff,0x00,0x00,0x00,0x66,0x3b,0x06,0x1b,0xc0,0xf7,0xd8,0x40};
auto addr=MemDbg::findBytes(sig, sizeof(sig), processStartAddress, processStopAddress);
if(addr==0)return 0;
if(!addr)return 0;
addr=MemDbg::findEnclosingAlignedFunction(addr);
if(addr==0)return 0;
if(!addr)return 0;
HookParam hp;
hp.address = addr;
hp.type = CODEC_UTF16|DATA_INDIRECT|NO_CONTEXT;
Expand All @@ -35,7 +35,7 @@ namespace{
DWORD maxaddr=0;int maxi=0;
for(auto addr:Util::SearchMemory(sig, sizeof(sig),PAGE_EXECUTE, processStartAddress, processStopAddress)){
addr=MemDbg::findEnclosingAlignedFunction(addr);
if(addr==0)continue;
if(!addr)continue;
if(mp.find(addr)==mp.end())mp[addr]=0;
mp[addr]+=1;
if(mp[addr]>maxi){maxi=mp[addr];maxaddr=addr;}
Expand Down
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/FrontWing.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FrontWing2 : public ENGINE
{
//[071227][フロントウイング] タイムリープ
check_by = CHECK_BY::FILE_ALL;
check_by_target = check_by_list{L"MDT/*.dat", L"BGM.dat", L"CHIP.dat", L"ef.dat", L"Init.dat", L"SE.dat"};
check_by_target = check_by_list{L"MDT\\*.dat", L"BGM.dat", L"CHIP.dat", L"ef.dat", L"Init.dat", L"SE.dat"};
};
bool attach_function();
};
10 changes: 5 additions & 5 deletions cpp/LunaHook/LunaHook/engine32/GSX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ bool GSX1() {
//http://www.mirai-soft.com/products/persona/download.html
//https://dlsoft.dmm.co.jp/detail/stone_0015/
ULONG addr = MemDbg::findCallerAddress((ULONG)::GetCharWidth32W, 0xec8b55, processStartAddress, processStopAddress);
if(addr==0)return false;
if(!addr)return false;
HookParam hp;
hp.address=addr;
hp.type=USING_CHAR|CODEC_UTF16|DATA_INDIRECT;
Expand All @@ -36,22 +36,22 @@ bool GSX2() {
//仁義なき乙女 体验版
//https://dlsoft.dmm.co.jp/detail/stone_0031/
ULONG addr = findiatcallormov((DWORD)GetGlyphOutlineA,processStartAddress, processStartAddress, processStopAddress,false,XX);
if(addr==0)
if(!addr)
addr = findiatcallormov((DWORD)GetGlyphOutlineA,processStartAddress, processStartAddress, processStopAddress);
if(addr==0)return false;
if(!addr)return false;
auto addr1=findfuncstart(addr);
auto addr2=MemDbg::findEnclosingAlignedFunction(addr);
if(addr1) addr=addr1;
else addr=addr2;
if(addr==0)return false;
if(!addr)return false;
auto xrefs=findxref_reverse_checkcallop(addr,processStartAddress,processStopAddress,0xe8);
if(xrefs.size()!=2)return false;
addr=xrefs[1];
addr1=findfuncstart(addr,0x180);
addr2=MemDbg::findEnclosingAlignedFunction(addr);
if(addr1)addr=addr1;
else addr=addr2;
if(addr==0)return false;
if(!addr)return false;
ConsoleOutput("%p",addr);
HookParam hp;
hp.address=addr;
Expand Down
4 changes: 2 additions & 2 deletions cpp/LunaHook/LunaHook/engine32/HXP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ bool HXP::attach_function() {
//https://vndb.org/v172
//エクソダスギルティー・オルタナティブ
auto addr=MemDbg::findCallerAddress((DWORD)TextOutA, 0x01003d66,processStartAddress, processStopAddress);
if(addr==0)return false;
if(!addr)return false;
addr=MemDbg::findEnclosingAlignedFunction(addr);
if(addr==0)return false;
if(!addr)return false;
HookParam hp;
hp.address = (DWORD)addr;
hp.offset=stackoffset(2);
Expand Down
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ bool Nijyuei::attach_function() {

};
auto addr=MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
if(addr==0)return false;
if(!addr)return false;

HookParam hp;
hp.address = addr+5;
Expand Down
80 changes: 80 additions & 0 deletions cpp/LunaHook/LunaHook/engine32/RScript.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include "RScript.h"

bool RScript::attach_function()
{
/*
void __thiscall CSelTxtEx::SetSels(CSelTxtEx *this, char *a2)
while ( *a2 )
{
if ( _ismbblead(*a2) && (v8 = _ismbbtrail(a2[1])) != 0 )
{
if ( *((_WORD *)this + 42) >= *((_WORD *)this + 43) )
return;
LOWORD(v8) = (unsigned __int8)*a2;
LOWORD(v9) = (unsigned __int8)a2[1];
*(_WORD *)(*((_DWORD *)this + 96) + 2 * *((unsigned __int16 *)this + 42)) = v3;
CSelTxtEx::SetSel(this, v9 + (v8 << 8), v23, v4, v22, v21);
a2 += 2;
}
else if ( *a2 == 94 )
{
v10 = *++a2;
if ( !v10 )
return;
switch ( v10 )
{
case 'A':
case 'a':
*/
BYTE bytes[] = {
0x80, 0x3f, 0x5e,
0x0f, 0x85, XX4,
0x8a, 0x47, 0x01,
0x47, 0x84, 0xc0,
0x0f, 0x84, XX4,
0x0f, 0xbe, 0xc0,
0x83, 0xc0, 0xbf,
0x83, 0xf8, 0x32};
auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress);
if (!addr)
return false;
auto faddr = MemDbg::findEnclosingAlignedFunction(addr);
if (!faddr)
return false;
BYTE bytes2[] = {
0x8a, 0x07,
0x84, 0xc0,
0x0f, 0x84, XX4,
0x0f, 0xbe, 0xd0,
0x52,
0xe8, XX4, // call __ismbblead
0x83, 0xc4, 0x04,
0x85, 0xc0,
0x74, XX,
0x0f, 0xbe, 0x47, 0x01,
0x50,
0xe8, XX4, // call __ismbbtrail
};
auto addrX = MemDbg::findBytes(bytes2, sizeof(bytes2), faddr, addr);
if (!addrX)
return false;
static auto __ismbblead = *(int *)(addrX + 2 + 2 + 6 + 3 + 1 + 1) + addrX + 2 + 2 + 6 + 3 + 1 + 5;
static auto __ismbbtrail = *(int *)(addrX + sizeof(bytes2) - 4) + addrX + sizeof(bytes2);
ConsoleOutput("%p", __ismbblead);
ConsoleOutput("%p", __ismbbtrail);
HookParam hp;
hp.address = faddr;
hp.offset = stackoffset(1);
hp.type = USING_STRING | EMBED_ABLE | EMBED_AFTER_NEW | EMBED_DYNA_SJIS;
hp.embed_hook_font = F_GetGlyphOutlineA | F_GetTextExtentPoint32A;
hp.lineSeparator = L"^n";
patch_fun = []()
{
ReplaceFunction((void *)__ismbblead, +[](BYTE b)
{ return b != '^'; });
ReplaceFunction((void *)__ismbbtrail, +[](BYTE b)
{ return b != '^'; });
};
return NewHook(hp, "RScript");
}
56 changes: 56 additions & 0 deletions cpp/LunaHook/LunaHook/engine32/RScript.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

/*
FILEVERSION 1,0,0,0
PRODUCTVERSION 3,0,0,0
FILEFLAGSMASK 0x3F
FILEFLAGS 0x0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0
{
BLOCK "StringFileInfo"
{
BLOCK "041104b0"
{
VALUE "Comments"
VALUE "CompanyName", "LiarSoft"
VALUE "FileDescription", "RScript"
VALUE "FileVersion", "1, 0, 0, 0"
VALUE "InternalName", "RScript"
VALUE "LegalCopyright", "Copyright (C)LiarSoft 2001"
VALUE "LegalTrademarks"
VALUE "OriginalFilename", "RScript.exe"
VALUE "PrivateBuild"
VALUE "ProductName", "WindWing RScript"
VALUE "ProductVersion", "3, 0, 0, 0"
VALUE "SpecialBuild"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x411, 1200
}
}
*/
class RScript : public ENGINE
{
public:
RScript()
{
check_by = CHECK_BY::CUSTOM;
check_by_target = []()
{
auto _ = {
L"grpe\\*.lim",
L"grps\\*.lim",
L"grpo\\*.lim",
L"scr\\*.gsc",
};
auto checkfile = std::all_of(_.begin(), _.end(), Util::CheckFile);
return checkfile && Util::SearchResourceString(L"RScript");
};
is_engine_certain = false;
};
bool attach_function();
};
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ bool SRPGStudio::attach_function() {
auto dll=GetModuleHandleW(L"OLEAUT32.dll");
if(dll==0)return 0;
auto addr=GetProcAddress(dll,"SysAllocString");
if(addr==0)return 0;
if(!addr)return 0;
HookParam hp;
hp.address = (DWORD)addr;
hp.offset=stackoffset(1);
Expand Down
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/Speed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bool Speed::attach_function() {
BYTE sig4[]={ 0xFF,0xD6 };
for(auto p:std::vector<std::pair<BYTE*,int>>{{sig1,sizeof(sig1)},{sig2,sizeof(sig2)},{sig3,sizeof(sig3)},{sig4,sizeof(sig4)}}){
addr=MemDbg::findBytes(p.first, p.second, addr, addr+0x40);
if(addr==0)return false;
if(!addr)return false;
}
addr = MemDbg::findEnclosingAlignedFunction(addr);
if (addr == 0)return false;
Expand Down
2 changes: 1 addition & 1 deletion cpp/LunaHook/LunaHook/engine32/TSSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bool TSSystem::attach_function() {
auto addrs = Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStopAddress);
for (auto addr : addrs) {
addr=MemDbg::findEnclosingAlignedFunction(addr);
if(addr==0)continue;
if(!addr)continue;
HookParam hp;
hp.address = addr;
hp.offset=stackoffset(1);
Expand Down
4 changes: 2 additions & 2 deletions cpp/LunaHook/LunaHook/engine32/ransel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ bool ransel::attach_function() {
0xe8,XX4 //SendMessageA->__imp_SendMessageA
};
auto addr=MemDbg::findBytes(sig,sizeof(sig),processStartAddress,processStopAddress);
if(addr==0)return false;
if(!addr)return false;
addr=findfuncstart(addr,0x20);
if(addr==0)return false;
if(!addr)return false;
HookParam hp;
hp.address=addr;
hp.type=USING_STRING;
Expand Down
10 changes: 5 additions & 5 deletions cpp/LunaHook/LunaHook/engine64/V8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ namespace{
BYTE sig4[]={XX,0x00,0x24,0xA0,0xFC};

addr=forwardsearch(sig1,sizeof(sig1),addr,0x20);
if(addr==0)continue;
if(!addr)continue;

addr=forwardsearch(sig2,sizeof(sig2),addr,0x100);
if(addr==0)continue;
if(!addr)continue;

addr=forwardsearch(sig3,sizeof(sig3),addr,0x20);
if(addr==0)continue;
if(!addr)continue;

addr=forwardsearch(sig4,sizeof(sig4),addr,0x20);
if(addr==0)continue;
if(!addr)continue;
auto off=andregimm((BYTE*)addrsave);
if(off==regs::invalid)continue;
HookParam hp;
Expand Down Expand Up @@ -164,7 +164,7 @@ namespace{
char innerHTML[]="innerHTML";
auto addr = MemDbg::findBytes(innerHTML, sizeof(innerHTML), processStartAddress, processStopAddress);
ConsoleOutput("%x",addr);
if(addr==0)return false;
if(!addr)return false;
bool ok=false;
for(auto _addr=processStartAddress+4;_addr<processStopAddress;_addr+=1){
if((_addr+*(int*)(_addr-4) )==addr){
Expand Down
2 changes: 2 additions & 0 deletions cpp/LunaHook/LunaHook/enginecollection32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "engine32/VALKYRIA.h"
#include "engine32/Moonstone.h"
#include "engine32/mirage.h"
#include "engine32/RScript.h"
#include "engine32/Sprite.h"
#include "engine32/PONScripter.h"
#include "engine32/Stronger.h"
Expand Down Expand Up @@ -431,5 +432,6 @@ std::vector<ENGINE *> check_engines()
new H_do_C,
new Mink3,
new FrontWing2,
new RScript,
};
}

0 comments on commit 1a7f27b

Please sign in to comment.