环境搭建2(游戏逆向)
#include<iostream>
#include<windows.h>
#include<tchar.h>
#include<stdio.h>
#pragma warning(disable:4996)
//exe应用程序
VOID PrintUI(CONST CHAR* ExeName, CONST CHAR* UIName, CONST CHAR* color, SHORT X坐标, SHORT y坐标, WORD UIwide, WORD UIHigh)
{
AllocConsole();
freopen("conin$", "r+t", stdin);
freopen("conout$", "w+t", stdout);
SetConsoleTitleA(UIName);
system(color);
CHAR oldPathName[1024];
CHAR NewPathName[1024];
CHAR a[1024];
GetModuleFileName(NULL,(LPWSTR)oldPathName, 1024);/获取当前生成的exe程序的路径,不过我这里有问题估计是因为我给的文件夹的名字是中文
strcpy(NewPathName,oldPathName);
for (size_t i = strlen(oldPathName); i > 0; i--)
{
if (NewPathName[i-1] == '\\')
{
NewPathName[i] = 0;
strcat(NewPathName, ExeName);
break;
}
}
CHAR c_ommand[MAXBYTE] = { 0 };
strcat(c_ommand,"del/f/q\"");
strcat(c_ommand, NewPathName);
strcat(c_ommand, "\">nul 2>nul");
system(c_ommand);
rename(oldPathName, NewPathName);
HWND PrinUI = GetConsoleWindow();
SetWindowPos(PrinUI, 0, 0, 0, UIwide,UIHigh,SWP_NOMOVE);
SetWindowPos(PrinUI, 0, X坐标, y坐标, UIwide, UIHigh, SWP_NOMOVE);
std::wcout.imbue(std::locale("CHS"));
}
int _tmain(int argc, _TCHAR* argv[])
{
PrintUI("new.exe", "MYWINDOW","color 09", 500, 500, 800, 800);
printf("你好,hello\r\n");
Sleep(200000);
}
给个断点调试一下
strcpy函数出问题了
是不是因为文件夹的路径是中文的原因导致有乱码
换个名字试试
貌似strcpy不是因为英文名字的问题,而是遇到""截断了
后续再看看报错吧
解决问题了
GetModuleFileNameA和GetMouduleFile
ANIS和Unicode不一样