Exemplo n.º 1
0
int KillProcesses(DWORD *pids, unsigned n)
{
	int killed = 0;
	unsigned i = 0;
	while (i < n)
	{
		HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pids[i]);
		if (process == NULL)
		{
			DebugOutput("open failed");
			break;
		}
		BOOL terminated = TerminateProcess(process, 0);
		CloseHandle(process);
		if (terminated)
		{
			++killed;
			++i;
		}
		else
		{
			DebugOutput("Kill failed");
			break;
		}
	}
	return killed;
}
Exemplo n.º 2
0
void __fastcall TFormMain::AutoRunClick(TObject *Sender)
{
	TRegistry *regedit = new TRegistry();
	regedit->RootKey = HKEY_CURRENT_USER;
	regedit->OpenKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
	if (this->AutoRun->Checked == true) {
		try {
			regedit->WriteString("ScreenShot", Application->ExeName);
			ShowMessage("Given program will be launched at start computer");
		} catch (Exception *e) {
			ShowMessage("Error: I can not remove autorun");
			DebugOutput(e->Message);
		}
	} else {
		try {
			regedit->DeleteValue("ScreenShot");
			ShowMessage("Autorun was deleted");
		} catch (Exception *e) {
			ShowMessage("Error: i Can't delete a autorun");
            DebugOutput(e->Message);
		}
	}
	regedit->CloseKey();
	regedit->Free();
}
Exemplo n.º 3
0
// Validates the buddy.
//
void NEAR PASCAL isgoodbuddy(PUDSTATE np)
{
    if (!np->hwndBuddy)
        return;
    if (!IsWindow(np->hwndBuddy))
    {
#if defined(DEBUG) && !defined(WIN32)
        DebugOutput(DBF_ERROR | DBF_USER,
                    TEXT("UpDown: invalid buddy handle 0x04X; ")
                    TEXT("resetting to NULL"), np->hwndBuddy);
#endif
        np->hwndBuddy = NULL;
        np->uClass = CLASS_UNKNOWN;
    }
    if (GetParent(np->hwndBuddy) != np->ci.hwndParent)
    {
#if defined(DEBUG) && !defined(WIN32)
        DebugOutput(DBF_ERROR | DBF_USER,
                    TEXT("UpDown: buddy has different parent; ")
                    TEXT("resetting to NULL"));
#endif
        np->hwndBuddy = NULL;
        np->uClass = CLASS_UNKNOWN;
    }
}
Exemplo n.º 4
0
ssize_t ReadInBytesTo_t_bytes_buffer(t_bytes_buffer * container, int fdin, int bytes)
{
    ssize_t readCount;
    readCount = 0;
    if (container->size != bytes)
    {
        if (container->size < bytes)
        {
            DebugOutput(3, "Enlarging bytes buffer on file read to avoid buffer overflow.\n");
        }
        else // We've ruled out equal, we are reading less than the buffer size
        {
            DebugOutput(3, "Shrinking bytes buffer on file read to avoid possible garbage at end of buffer.\n");
        }
        // Alloc atomatically cleans up buffer before setting new size
        Allocate_t_bytes_buffer(container, bytes);
    }
    
    readCount = read(fdin, container->bytes, bytes);
    if (bytes != readCount)
    {
        if (-1 == readCount)
        {
            DebugOutput(2, "Failed to read anything from file into t_bytes_buffer.\n");
        }
        else
        {
            DebugOutput(2, "Read %d bytes from file into t_bytes_buffer instead of %d bytes requested.\n", readCount, bytes);
        }
    }
    return readCount;
}
Exemplo n.º 5
0
void
XDLink::SendRaw
	(
	const JCharacter* text
	)
{
	if (itsLink != NULL)
		{
		JString s = text;
		s.TrimWhitespace();

		JIndex i;
		while (s.LocateSubstring("  ", &i))
			{
			s.ReplaceSubstring(i, i+1, " ");
			}

		itsLink->SendMessage(s);
		itsLink->StartTimer();

		if (!itsDebuggerBusyFlag)
			{
			itsDebuggerBusyFlag = kJTrue;
			Broadcast(DebuggerBusy());
			}

		Broadcast(DebugOutput(s, kCommandType));
		}
}
Exemplo n.º 6
0
void OpTestWall::Execute(MachineState& state)
{
	DebugOutput(state);

	state.m_Test = false;

	if (state.m_Facing == MachineState::UP && state.y == 0)
	{
		state.m_Test = true;
	}
	if (state.m_Facing == MachineState::DOWN && state.y == 19)
	{
		state.m_Test = true;
	}
	if (state.m_Facing == MachineState::LEFT && state.x == 0)
	{
		state.m_Test = true;
	}
	if (state.m_Facing == MachineState::RIGHT && state.x == 19)
	{
		state.m_Test = true;
	}

	state.m_ProgramCounter++;
}
Exemplo n.º 7
0
void Debug::CheckDebugLog()
{
	unsigned int count = 10; // max. num. of messages that will be read from the log
	int bufsize = 2048;

	unsigned int* sources      = new unsigned int[count];
	unsigned int* types        = new unsigned int[count];
	unsigned int* ids          = new unsigned int[count];
	unsigned int* severities   = new unsigned int[count];
	int* lengths = new int[count];

	char* messageLog = new char[bufsize];

	unsigned int retVal = glGetDebugMessageLogARB(count, bufsize, sources, types, ids,
		severities, lengths, messageLog);
	if (retVal > 0)
	{
		unsigned int pos = 0;
		for (unsigned int i=0; i < retVal; i++)
		{
			DebugOutput(sources[i], types[i], ids[i], severities[i], &messageLog[pos]);
			pos += lengths[i];
		}
	}
	delete[] sources;
	delete[] types;
	delete[] ids;
	delete[] severities;
	delete[] lengths;
	delete[] messageLog;
}
Exemplo n.º 8
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    std::streambuf* old_rdbuf = std::cout.rdbuf ();

    int ret = 0;
#if defined(_DEBUG)
    // Redirect cout to VS debug output when running in debug mode
    {
        boost::iostreams::stream_buffer<DebugOutput> sb;
        sb.open(DebugOutput());
#else
    // Redirect cout to openmw.log
    std::ofstream logfile ("openmw.log");
    {
        boost::iostreams::stream_buffer<Logger> sb;
        sb.open (Logger (logfile));
#endif
        std::cout.rdbuf (&sb);

        ret = main (__argc, __argv);

        std::cout.rdbuf(old_rdbuf);
    }
    return ret;
}
Exemplo n.º 9
0
t_int_otar_header * Copy_otar_hdr_t_To_t_int_otar_header(otar_hdr_t * in)
{
    t_int_otar_header * out = malloc(sizeof(t_int_otar_header));
    Construct_t_int_otar_header(out);
    
    out->fname_len = nuatoi(in->otar_fname_len, OTAR_FNAME_LEN_SIZE);
    out->fname = strndup(in->otar_fname, MIN(OTAR_MAX_FILE_NAME_LEN, out->fname_len));
    // Length, as determined by null termination
    out->fname_len = MIN(strlen(out->fname), out->fname_len);
    
    out->adate = nuatol(in->otar_adate, OTAR_DATE_SIZE);
    out->mdate = nuatol(in->otar_mdate, OTAR_DATE_SIZE);

    out->uid = nuatoi(in->otar_uid, OTAR_GUID_SIZE);
    out->gid = nuatoi(in->otar_gid, OTAR_GUID_SIZE);
    
    out->mode = nuatoiOctal(in->otar_mode, OTAR_MODE_SIZE);
    out->size = MIN(nuatoi(in->otar_size, OTAR_FILE_SIZE), OTAR_MAX_MEMBER_FILE_SIZE);
    
    if (0 != memcmp(OTAR_HDR_END, in->otar_hdr_end, OTAR_HDR_END_LEN))
    {
        fprintf(stderr, "Corrupt archive.\n");
        DebugOutput(1, "Not a valid otar file because a member file header has an incorrect signature.\n");
        exit(OTAR_FILE_CORRUPT);
    }
    
    return out;
}
Exemplo n.º 10
0
static int SSLNetClose(int net_hd)
{
	int iRet;
	iRet = NetCloseSocket(net_hd);
	DebugOutput("%s--%d--%s, iRet:%d\n", __FILE__, __LINE__, __FUNCTION__,  iRet);//linzhao
	
	return 0;
}
Exemplo n.º 11
0
void CheckHeader(int fd)
{
    if (!readOtarMainHeader(fd))
    {
        DebugOutput(1, "Not a valid otar file.\n");
        exit(OTAR_FILE_CORRUPT);
    }
}
Exemplo n.º 12
0
void Level::CheckAndStartCutscene( LuaManager *luaScript )
{
    DebugOutput( "CheckAndStartCutscene()" );
    if ( cutscene[0].played == false )
    {
        luaScript->PlayCutscene( cutscene[0].name );
    }
}
Exemplo n.º 13
0
void
CMLink::Log
	(
	const JCharacter* log
	)
{
	(CMGetLink())->Broadcast(DebugOutput(log, kLogType));
}
Exemplo n.º 14
0
void CheckOpen(int fd)
{
    if (-1 == fd)
    {
        DebugOutput(1, "Couldn't open the requested file.\n");
        exit(OTAR_FILE_COULD_NOT_OPEN);
    }    
}
Exemplo n.º 15
0
//---------------------------------------------------------------------------
void __fastcall TFormMain::Process() {
	this->WindowState = wsMinimized;
	this->Resize();

	if (RegisterHotKey(this->Handle, IDHOTKEY, MOD_CONTROL, VK_SNAPSHOT) == false) {
		DebugOutput("RegisterHotKey return false "+(GetLastError()));
		ShowMessage("Fatal error");
	}
}
Exemplo n.º 16
0
void OpRangedAttack::Execute(MachineState& state)
{
	DebugOutput(state);

	int dest_x, dest_y;

	switch (state.m_Facing)
	{
	case (MachineState::UP) :
		dest_y = state.y - 2;
		dest_x = state.x;
		break;
	case(MachineState::DOWN) :
		dest_y = state.y + 2;
		dest_x = state.x;
		break;
	case(MachineState::LEFT) :
		dest_y = state.y;
		dest_x = state.x - 2;
		break;
	case(MachineState::RIGHT) :
		dest_y = state.y;
		dest_x = state.x + 2;
		break;
	default:
		break;
	}

	// find the creature being attacked

	
	auto it = world::get().zombies.begin();
	while (it != world::get().zombies.end())
	{
		if ((*it)->x == dest_x && (*it)->y == dest_y)
		{
			//it = world::get().zombies.erase(it);
			(*it)->m_dead = true;
		}
		++it;
	}

	it = world::get().humans.begin();
	while (it != world::get().humans.end())
	{
		if ((*it)->x == dest_x && (*it)->y == dest_y)
		{
			//it = world::get().humans.erase(it);
			(*it)->m_dead = true;
		}

		++it;
	}

	state.m_ProgramCounter++;
	state.m_ActionsTaken++;
}
Exemplo n.º 17
0
int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
 	HANDLE pwp_mutex = CreateMutex(NULL, true, "pwp_mutex");
	if (pwp_mutex == NULL)
	{
		DebugOutput("mutex null");
		return 1;
	}

	int status;
	if (GetLastError() == ERROR_ALREADY_EXISTS)
	{
		DebugOutput("mutex exists");
	}
	else
	{
		DWORD pids[256];
		__try
		{
			int pidCount;
			while (true)
			{
				pidCount = FindInstances("elementclient.e", pids);
				if (pidCount == 0)
				{
					DebugOutput("no client");
					__leave;
				}
				Sleep(4000);
				status = DetectAndKillCheats();
				Sleep(11000);
			}
		}
		__finally
		{

		}
	}

	return !(CloseHandle(pwp_mutex) != 0);
}
Exemplo n.º 18
0
int Ssl_OnHook( void )
{
	int iRet;
	

	DebugOutput("%s--%d, sslClose start\n", __FILE__, __LINE__);
	iRet = SslClose( iSSLSocket );
	//linzhao
	if (0==iRet)
	{
		DebugOutput("%s--%d, sslClose=0\n", __FILE__, __LINE__);
		iSSLSocket = -1;
		s_iSocket = -1;//linzhao
		return iRet;
	}
	else if ( iRet < 0 )
	{
		return iRet;
	}

}
Exemplo n.º 19
0
void printCurrentTime(const string& str)
{
#ifdef _WIN32

#else
  time_t now = time(0);
  
  tm* localtm = localtime(&now);
  //cout << str << asctime(localtm) << endl;
  DebugOutput("%s %s.\n", str.c_str(), asctime(localtm));
#endif
}
Exemplo n.º 20
0
void OpGoto::Execute(MachineState& state)
{
	DebugOutput(state);

	if (m_Param < 1 || m_Param > state.num_ops || m_Param == state.m_ProgramCounter)
	{
		WrongLineNumberError wrongline;
		throw wrongline;
	}

	state.m_ProgramCounter = m_Param;
}
Exemplo n.º 21
0
static int SSLNetOpen(char *remote_addr, short remote_port, short local_port, long flag)
{
	int iErrMsg, iRet; 
	NET_SOCKADDR stSocketAddr;

	if(s_iSocket>= 0)
	{
		DebugOutput("%s--%d, s_iSocket:%d\n", __FILE__, __LINE__, s_iSocket);
		return s_iSocket;
	}
	

	s_iSocket = NetSocket(NET_AF_INET, NET_SOCK_STREAM, 0);
	DebugOutput("%s--%d--%s, s_iSocket:%d\n", __FILE__, __LINE__, __FUNCTION__, s_iSocket);//linzhao
	if (s_iSocket < 0)
	{
		return s_iSocket;	
	}
	SockAddrSet(&stSocketAddr, remote_addr, remote_port);
	iErrMsg = NetConnect(s_iSocket, &stSocketAddr, sizeof(stSocketAddr));	
	DebugOutput("%s--%d--%s, iErrMsg:%d\n", __FILE__, __LINE__, __FUNCTION__, iErrMsg);//linzhao
	if (iErrMsg < 0)
	{
		iRet = NetCloseSocket(s_iSocket);	
		DebugOutput("%s--%d, iRet;%d, s_iSocket:%d\n", __FILE__, __LINE__, iRet, s_iSocket);
		//linzhao
		//if (0==iRet)
		//	s_iSocket = -1;
		switch (iErrMsg)
		{
		case NET_ERR_TIMEOUT:
			return -ERR_SSL_TIMEOUT;
		case NET_ERR_RST:
			return -ERR_SSL_NET;
		default:
			return iErrMsg;
		}
	}
	return s_iSocket;
}
Exemplo n.º 22
0
void OpTestZombie::Execute(MachineState& state)
{
	DebugOutput(state);

	int dest_x, dest_y;

	switch (state.m_Facing)
	{
	case (MachineState::UP) :
		dest_y = state.y - m_Param;
		dest_x = state.x;
		break;
	case(MachineState::DOWN) :
		dest_y = state.y + m_Param;
		dest_x = state.x;
		break;
	case(MachineState::LEFT) :
		dest_y = state.y;
		dest_x = state.x - m_Param;
		break;
	case(MachineState::RIGHT) :
		dest_y = state.y;
		dest_x = state.x + m_Param;
		break;
	default:
		break;
	}

	state.m_Test = false;

	auto it = world::get().zombies.begin();
	while (it != world::get().zombies.end())
	{
		if ((*it)->x == dest_x && (*it)->y == dest_y)
		{
			state.m_Test = true;
		}

		++it;
	}
	/*
	for (auto it = world::get().zombies.begin(); it != world::get().zombies.end(); ++it)
	{
		if ((*it)->x == dest_x && (*it)->y == dest_y)
		{
			state.m_Test = true;
		}
	}
	*/

	state.m_ProgramCounter++;
}
Exemplo n.º 23
0
void OpSet::Execute(MachineState& state)
{
	DebugOutput(state);

	if (state.current_mem < 0 || state.current_mem > state.GetMaxMemory() - 1)
	{
		MemoryAccessError mem_error;
		throw mem_error;
	}

	state.SetMemory(state.current_mem, m_Param);
	state.m_ProgramCounter++;
}
Exemplo n.º 24
0
void OpSaveLoc::Execute(MachineState& state)
{
	if (state.current_mem < 0 || state.current_mem > state.GetMaxMemory() - 1)
	{
		MemoryAccessError mem_error;
		throw mem_error;
	}
	DebugOutput(state);
	state.SetMemory(0, state.x);
	state.SetMemory(1, state.y);

	state.m_ProgramCounter++;
}
Exemplo n.º 25
0
void LogOutput(char* buffer)
{
    // Strip any unnecessary newline characters at the end of the buffer
    int i = strlen(buffer);
    if(i == 0)
        return;
    if(buffer[i - 1] == '\n')
        buffer[i - 1] = 0;

    m_logStream << buffer << '\n';

    DebugOutput(buffer);
}
Exemplo n.º 26
0
/*
 * Class:     org_apache_trafodion_jdbc_t2_JdbcDebug
 * Method:    traceOut
 * Signature: (IILjava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_apache_trafodion_jdbc_t2_JdbcDebug_traceOut(JNIEnv *jenv, jclass jcls,
																	jlong debug_handle,
																	jint debug_level,
																	jstring comment)
{
#if defined(_DEBUG)
	const char *commentStr;
	if (comment) commentStr = jenv->GetStringUTFChars(comment,NULL);
	else commentStr = NULL;
	if (DebugActive(debug_level,NULL,0)) DebugOutput(commentStr , NULL, 0);
	if (commentStr) jenv->ReleaseStringUTFChars(comment,commentStr);
#endif /* _DEBUG */
}
Exemplo n.º 27
0
void OpRotate::Execute(MachineState& state)
{
	DebugOutput(state);
	switch (state.m_Facing)
	{
	case (MachineState::UP) :
		if (m_Param == 0)
		{
			state.m_Facing = MachineState::RIGHT;
		}
		else
		{
			state.m_Facing = MachineState::LEFT;
		}
		break;
	case (MachineState::RIGHT) :
		if (m_Param == 0)
		{
			state.m_Facing = MachineState::DOWN;
		}
		else
		{
			state.m_Facing = MachineState::UP;
		}
		break;
	case (MachineState::DOWN) :
		if (m_Param == 0)
		{
			state.m_Facing = MachineState::LEFT;
		}
		else
		{
			state.m_Facing = MachineState::RIGHT;
		}
		break;
	default:
	case (MachineState::LEFT) :
		if (m_Param == 0)
		{
			state.m_Facing = MachineState::UP;
		}
		else
		{
			state.m_Facing = MachineState::DOWN;
		}
		break;
	}

	state.m_ProgramCounter++;
	state.m_ActionsTaken++;
}
Exemplo n.º 28
0
//---------------------------------------------------------------------------
void __fastcall TFormMain::ApplicationEventsMessage(tagMSG &Msg, bool &Handled)
{
	try {
		if (Msg.message == WM_HOTKEY && Msg.wParam == IDHOTKEY) {
			DebugOutput("ReghotKey press");
			TBitmap *screenshot = new TBitmap;
			this->WinGrab(screenshot);
			if (this->Ftp->Connected() == false)
				this->Ftp->Connect();
			if (this->Ftp->Connected() == false)
				throw new Exception("Ftp not connected");

			TMemoryStream *mem = new TMemoryStream;
			screenshot->SaveToStream(mem);
			this->Ftp->Put(mem, this->EditPwd->Text+"/"+Now().DateString()+"_"+
										Now().TimeString()+".jpg", false, 0);
            ShowMessage("”спех.");
		}
	} catch (Exception *e) {
		DebugOutput(e->Message);
		ShowMessage("Error.");
	}
}
Exemplo n.º 29
0
void OpMem::Execute(MachineState& state)
{
	DebugOutput(state);

	if (m_Param < 0 || m_Param > state.GetMaxMemory()-1)
	{
		MemoryAccessError mem_error;
		throw mem_error;
	}


	state.current_mem = m_Param;
	state.m_ProgramCounter++;
}
Exemplo n.º 30
0
int Wifi_Connect()
{
	int ret;

#ifdef DEBUG_USE
	return 0;
#endif
	
	ret = wifiConnect(glSysCtrl.szRemoteIP, glSysCtrl.szRemotePort);
	if(glSysCtrl.bDebugOpt)
	{
		DebugOutput("%s--%d, wifi connect[%s:%s] = [%d]", __FILE__, __LINE__, glSysCtrl.szRemoteIP, glSysCtrl.szRemotePort, ret);
	}
	return ret;
}