心态爆炸

This commit is contained in:
2022-02-28 00:14:53 +08:00
parent 1166be0471
commit 378f4ba664
3 changed files with 126 additions and 169 deletions

View File

@@ -237,86 +237,90 @@ int GetEquAddr(int addr)
}
return -1;
}
char* UnicodeToAnsi(const wchar_t* szStr, char* pResult, int maxLen)
{
if (NULL == pResult)
return NULL;
int nLen = WideCharToMultiByte(CP_ACP, 0, szStr, -1, NULL, 0, NULL, NULL);
if (0 == nLen)
{
return NULL;
}
if (nLen >= maxLen)
nLen = maxLen;
WideCharToMultiByte(CP_ACP, 0, szStr, -1, pResult, nLen, NULL, NULL);
return pResult;
}
wchar_t* AnsiToUnicode(const char* szStr, wchar_t* pResult, int maxLen)
{
if (NULL == pResult)
return NULL;
int nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, NULL, 0);
if (0 == nLen)
{
return NULL;
}
if (nLen >= maxLen)
nLen = maxLen;
nLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, szStr, -1, pResult, nLen);
if (0 == nLen)
{
return NULL;
}
return pResult;
}
//加载
static int SQloadfile(uint32_t v, const wchar_t* filename, bool printerror)
{
SQFILE* file = SQfopen(filename, L"rb+");
//FILE* file;
//file = fopen(filename, "rb");
int ret;
unsigned short us;
unsigned char uc;
//wchar_t* 转 char*
int size = wcslen(filename);
char* fname = (char*)new char[size];
UnicodeToAnsi(filename, fname, size);
FILE* file;
file = fopen(fname, "rb+");
LSQLEXREADFUNC func = SQ_io_file_lexfeed_ASCII;
if (file)
{
ret = SQfread(&us, 1, 2, file);
if (ret != 2)
//求得文件的大小
fseek(file, 0, SEEK_END);
int size = ftell(file);
rewind(file);
//申请一块能装下整个文件的空间
char* ar = (char*)malloc(sizeof(char) * size);
//读文件每次读一个共读size次
fread(ar, 1, size, file);
int skey[] = { 5,2,3,5,0 };//定义解密数组
Cutecode(ar, skey);//解密
FILE* outfile;
outfile = fopen("ImagePacks2/sprite_interface_teart_zero.npk", "wb+");
int da = strlen(ar);
fwrite(ar, 1, da, outfile);
fclose(outfile);//关闭文件
free(ar);//释放内存
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"rb+");//定义新的文件流
SQfseek(newfile, 0, 2);//定位到头
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
{
us = 0;
fclose(file);//关闭文件
SQ__Fclose(newfile);//关闭文件
remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件
return 0;
}
if (us == 0xFAFA)
{
SQfseek(file, 0, 2);
if (SQ_Readclosure(v, SQ_File_read, file) > 0)
{
SQ__Fclose(file);
return SQ_OK;
}
}
else
{
switch (us)
{
case 0xFFFE: func = SQ_io_file_lexfeed_UCS2_BE; break;//UTF-16 little endian;
case 0xFEFF: func = SQ_io_file_lexfeed_UCS2_LE; break;//UTF-16 big endian;
case 0xBBEF:
if (SQfread(&uc, 1, sizeof(uc), file) == 0)
{
SQ__Fclose(file);
return 1;
}
if (uc != 0xBF)
{
SQ__Fclose(file);
return 1;
}
func = SQ_io_file_lexfeed_UTF8;
break;//UTF-8 ;
default: SQfseek(file, 0, 2); break; // ascii
}
SQfseek(file, 0, 1);//定位到尾
int length = SQftell(file);//得到文件长度
SQfseek(file, 0, 2);//定位到头
char* temp = new char[length+4];//new一个新的字符串
SQfread(temp, sizeof(temp), length, file);//把文件读到字符串里
temp[length] = '\0';//给结尾添加结束符号
int key[] = { 5,2,3,5,0 };//定义解密数组
Cutecode(temp, key);//解密
SQFILE* newfile = SQfopen(L"ImagePacks2/sprite_interface_teart_zero.npk", L"wb+");//定义新的文件流
SQwrite(temp, sizeof(temp), strlen(temp), newfile);//写入
SQfseek(file, 0, 2);//定位到头
SQfseek(newfile, 0, 2);//定位到头
if (SQ_Compile(v, func, newfile, filename, printerror) >= 0)
{
SQ__Fclose(file);//关闭文件流
SQ__Fclose(newfile);//关闭文件流
remove("ImagePacks2/sprite_interface_teart_zero.npk");//删除文件
return SQ_OK;
}
}
SQ__Fclose(file);
fclose(file);//关闭文件
return -1;
}
return 1;
return -1;
}
static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool printerror)
@@ -339,26 +343,21 @@ static int SQdofile(uint32_t v, const wchar_t* filename, bool retval, bool print
void ggc(char* str,int type,int color)
/*
void gonggao(char* str,int ctype,int ccolor)
{
int shangdian;
int laba;
int ggtype;
int ggcolor;
int ggstr;
int shop, gonggao, type, color;
char*addr;
if (ctype == NULL)
ctype = 16;
if (ccolor == NULL)
ccolor = 0x65535;
shop = 0x1A5FB20;
gonggao = 0x9536c0;
type = ctype;
color = ccolor;
addr = str;
//ggtype = 16;
//ggcolor = 65535;
shangdian = 0x1A5FB20;
laba = 0x9536c0;
ggtype = 16;
ggcolor = 65535;
ggstr = (int)str;
//std::cout << ggstr << std::endl;
_asm
{
pushad
@@ -375,13 +374,17 @@ void ggc(char* str,int type,int color)
call dword ptr[ebp - 0x08]
popad
}
}
*/
//窗口公告
void WindowsNotice(char* str ,int type = 0x10d ,int b = 0x0)
{
DWORD thisc = 0x1A5FB20;
thisc = *(DWORD*)thisc;
_NoticeTcall(thisc, 0, type, str, b);
}
@@ -406,14 +409,29 @@ void RegisterNutApi(const wchar_t* funcName, void* funcAddr, uint32_t v)
//Test
static int sq_Test(uint32_t v)
{
//sq_pushinteger(v, n1);
/*
DWORD thisc = 0x1A5FB20;
*(char**)0x400F00 = (char*)u"test";
thisc = *(DWORD*)thisc;
thisc = *(DWORD*)(thisc + 0x40);
_Noticecall(0x400F00, 65535, 14, 0, 0, 0, 0);
char *str = (char*)u"test";
return 0;
_Noticecall(thisc, NULL, str, 0x66535, 14, 0, 0, 0, 0);
*/
//char* str = (char*)u"test";
//gonggao(str, 14,NULL);
WindowsNotice((char*)u"我的天");
SQPopTop(v);
SQPushInt(v, 1);
return 1;
}
//读人物 或 装备属性
static int GetCharacterAttribute(uint32_t v)