mirror of
https://github.com/HIllya51/LunaHook.git
synced 2024-12-26 21:24:12 +08:00
tyrano name
This commit is contained in:
parent
98e47b46cb
commit
e063c5346a
@ -7,23 +7,30 @@
|
|||||||
#include"embed_util.h"
|
#include"embed_util.h"
|
||||||
#include"stackoffset.hpp"
|
#include"stackoffset.hpp"
|
||||||
namespace{
|
namespace{
|
||||||
|
constexpr auto magicsend =L"\x01LUNAFROMJS\x01";
|
||||||
|
constexpr auto magicrecv =L"\x01LUNAFROMHOST\x01";
|
||||||
bool hookClipboard(){
|
bool hookClipboard(){
|
||||||
HookParam hp;
|
HookParam hp;
|
||||||
hp.address=(uintptr_t)SetClipboardData;
|
hp.address=(uintptr_t)SetClipboardData;
|
||||||
hp.type= USING_STRING|CODEC_UTF16|EMBED_ABLE|EMBED_BEFORE_SIMPLE;
|
hp.type= USING_STRING|CODEC_UTF16|EMBED_ABLE|EMBED_BEFORE_SIMPLE;
|
||||||
hp.text_fun=[](hook_stack* stack, HookParam *hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
hp.text_fun=[](hook_stack* stack, HookParam *hp, uintptr_t* data, uintptr_t* split, size_t* len){
|
||||||
HGLOBAL hClipboardData=(HGLOBAL)stack->ARG2;
|
HGLOBAL hClipboardData=(HGLOBAL)stack->ARG2;
|
||||||
*data=(uintptr_t)GlobalLock(hClipboardData);
|
auto text=(wchar_t*)GlobalLock(hClipboardData);
|
||||||
*len=wcslen((wchar_t*)*data)*2;
|
if(startWith(text,magicsend)){
|
||||||
|
text+=wcslen(magicsend);
|
||||||
|
auto spl=wcschr(text,L'\x02');
|
||||||
|
*split=std::stoi(std::wstring(text,spl-text));
|
||||||
|
text=spl+1;
|
||||||
|
*data=(uintptr_t)text;
|
||||||
|
*len=wcslen(text)*2;
|
||||||
|
}
|
||||||
|
|
||||||
GlobalUnlock(hClipboardData);
|
GlobalUnlock(hClipboardData);
|
||||||
};
|
};
|
||||||
hp.hook_after=[](hook_stack*s,void* data, size_t len){
|
hp.hook_after=[](hook_stack*s,void* data, size_t len){
|
||||||
|
std::wstring transwithfont=magicrecv;
|
||||||
std::wstring transwithfont;
|
|
||||||
transwithfont+=L'\x01';
|
|
||||||
transwithfont+=embedsharedmem->fontFamily;
|
transwithfont+=embedsharedmem->fontFamily;
|
||||||
transwithfont+=L'\x01';
|
transwithfont+=L'\x02';
|
||||||
transwithfont+=std::wstring((wchar_t*)data,len/2);
|
transwithfont+=std::wstring((wchar_t*)data,len/2);
|
||||||
HGLOBAL hClipboardData = GlobalAlloc(GMEM_MOVEABLE, transwithfont.size()*2 +2);
|
HGLOBAL hClipboardData = GlobalAlloc(GMEM_MOVEABLE, transwithfont.size()*2 +2);
|
||||||
auto pchData = (wchar_t*)GlobalLock(hClipboardData);
|
auto pchData = (wchar_t*)GlobalLock(hClipboardData);
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
var fontface='';
|
var fontface='';
|
||||||
|
const magicsend='\x01LUNAFROMJS\x01'
|
||||||
|
const magicrecv='\x01LUNAFROMHOST\x01'
|
||||||
function splitfonttext(transwithfont){
|
function splitfonttext(transwithfont){
|
||||||
if(transwithfont[0]=='\x01'){
|
if(transwithfont.substr(0,magicsend.length)==magicsend) //not trans
|
||||||
transwithfont=transwithfont.substr(1)
|
{
|
||||||
split=transwithfont.search('\x01')
|
split=transwithfont.search('\x02')
|
||||||
if(split==-1)return transwithfont;
|
return transwithfont.substr(split+1);
|
||||||
|
}
|
||||||
|
else if(transwithfont.substr(0,magicrecv.length)==magicrecv)
|
||||||
|
{
|
||||||
|
transwithfont=transwithfont.substr(magicrecv.length)
|
||||||
|
//magic font \x02 text
|
||||||
|
split=transwithfont.search('\x02')
|
||||||
fontface=transwithfont.substr(0,split)
|
fontface=transwithfont.substr(0,split)
|
||||||
text=transwithfont.substr(split+1)
|
text=transwithfont.substr(split+1)
|
||||||
return text;
|
return text;
|
||||||
@ -13,7 +20,10 @@ function splitfonttext(transwithfont){
|
|||||||
return transwithfont;
|
return transwithfont;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function clipboardsender(s){
|
function clipboardsender(s,lpsplit){
|
||||||
|
lpsplit = typeof lpsplit !== 'undefined' ? lpsplit : 0
|
||||||
|
//magic split \x02 text
|
||||||
|
s=magicsend+lpsplit.toString()+'\x02'+s;
|
||||||
try{
|
try{
|
||||||
const _clipboard = require('nw.gui').Clipboard.get();
|
const _clipboard = require('nw.gui').Clipboard.get();
|
||||||
_clipboard.set(s, 'text');
|
_clipboard.set(s, 'text');
|
||||||
@ -21,7 +31,6 @@ function clipboardsender(s){
|
|||||||
}
|
}
|
||||||
catch(err){
|
catch(err){
|
||||||
try{
|
try{
|
||||||
|
|
||||||
const clipboard = require('electron').clipboard;
|
const clipboard = require('electron').clipboard;
|
||||||
clipboard.writeText(s);
|
clipboard.writeText(s);
|
||||||
transwithfont= clipboard.readText();
|
transwithfont= clipboard.readText();
|
||||||
@ -56,6 +65,7 @@ function tyranohook() {
|
|||||||
|
|
||||||
if(tyrano.plugin.kag.tag.text.originstart)return;
|
if(tyrano.plugin.kag.tag.text.originstart)return;
|
||||||
tyrano.plugin.kag.tag.text.originstart=tyrano.plugin.kag.tag.text.start;
|
tyrano.plugin.kag.tag.text.originstart=tyrano.plugin.kag.tag.text.start;
|
||||||
|
tyrano.plugin.kag.tag.chara_ptext.startorigin=tyrano.plugin.kag.tag.chara_ptext.start;
|
||||||
tyrano.plugin.kag.tag.text.start = function (pm) {
|
tyrano.plugin.kag.tag.text.start = function (pm) {
|
||||||
if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) {
|
if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) {
|
||||||
pm.val=clipboardsender(pm.val);
|
pm.val=clipboardsender(pm.val);
|
||||||
@ -65,6 +75,10 @@ function tyranohook() {
|
|||||||
}
|
}
|
||||||
return this.originstart(pm)
|
return this.originstart(pm)
|
||||||
}
|
}
|
||||||
|
tyrano.plugin.kag.tag.chara_ptext.start = function (pm) {
|
||||||
|
pm.name=clipboardsender(pm.name,1)
|
||||||
|
return this.startorigin(pm)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function retryinject(times){
|
function retryinject(times){
|
||||||
if(times==0)return;
|
if(times==0)return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user