[C++] 纯文本查看 复制代码 #include <stdio.h>
#include <conio.h>
#include <windows.h>
int main(void)
{
HANDLE hPipe;
HANDLE hPipe1;
DWORD written;
DWORD read;
HANDLE hEvent;
OVERLAPPED olp;
unsigned char data[512] = {0};
unsigned char ZeroData[sizeof(data)] = {0};
char *success = "成功";
SetConsoleTitleA("Patcher Coded by _KaQqi");
hPipe = CreateNamedPipeA("\\\\.\\pipe\\IM SON",PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,0,1,1024,1024,0,NULL);
if(hPipe == INVALID_HANDLE_VALUE)
return 0;
hEvent = CreateEventW(NULL,TRUE,FALSE,NULL);
if(!hEvent)
{
CloseHandle(hPipe);
CloseHandle(hEvent);
return 0;
}
ZeroMemory(&olp,sizeof(OVERLAPPED));
olp.hEvent = hEvent;
if(!ConnectNamedPipe(hPipe,&olp))
{
if(GetLastError() != ERROR_IO_PENDING)
{
CloseHandle(hPipe);
CloseHandle(hEvent);
return 0;
}
}
if(WaitForSingleObject(hEvent,INFINITE) == WAIT_FAILED)
{
CloseHandle(hPipe);
CloseHandle(hEvent);
return 0;
}
CloseHandle(hEvent);
if (!WaitNamedPipeA("\\\\.\\pipe\\IM DAD",NMPWAIT_WAIT_FOREVER))
{
CloseHandle(hPipe);
return 0;
}
hPipe1 = CreateFileA("\\\\.\\pipe\\IM DAD",GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,NULL,NULL);
if (hPipe1 == INVALID_HANDLE_VALUE)
{
CloseHandle(hPipe);
CloseHandle(hPipe1);
return 0;
}
while(1)
{
if(ReadFile(hPipe1,data,sizeof(data),&read,NULL) == FALSE)
{
CloseHandle(hPipe);
CloseHandle(hPipe1);
return 0;
}
if(memcmp(data,ZeroData,sizeof(data)))
break;
}
if(WriteFile(hPipe,success,sizeof(success),&written,NULL) == TRUE)
puts("Cracked!");
else
puts("Error!");
getch();
CloseHandle(hPipe);
CloseHandle(hPipe1);
return 0;
}
这段代码编译以后
先打开编译后的程序再打开cm就能注册了。 |