void VEmitContext::EmitPushNumber(int Val)
{
	if (Val == 0)
		AddStatement(OPC_PushNumber0);
	else if (Val == 1)
		AddStatement(OPC_PushNumber1);
	else if (Val >= 0 && Val < 256)
		AddStatement(OPC_PushNumberB, Val);
	else if (Val >= MIN_VINT16 && Val <= MAX_VINT16)
		AddStatement(OPC_PushNumberS, Val);
	else
		AddStatement(OPC_PushNumber, Val);
}
Example #2
0
int ParseConfigConfirm(TCHAR *pszLine, CONFIG *pConfig)
{
	if (NoRemainingTokens(pszLine))
		return AddStatement(pConfig, COMMAND_CONFIRM, NULL);
	else
		return -1;
}
Example #3
0
BOOL SFMSSQL::RegisterStatement(SFStatement& statement)
{
	if(!AddStatement(statement))
		return FALSE;

	return TRUE;
}
Example #4
0
int ParseConfigInjectDLL(TCHAR *pszLine, CONFIG *pConfig)
{
	TCHAR *pszToken;
	TCHAR *pszFilename;
	struct Command1psz *pC1P;

	if (!OneRemainingToken(pszLine, &pszToken))
    return -1;

	pszFilename = ParseFilename(pszToken);
	if (NULL == pszFilename)
	{
		free(pszToken);
		return -2;
	}
	
	free(pszToken);

	pC1P = malloc(sizeof(struct Command1psz));
	if (NULL == pC1P)
	{
		free(pszFilename);
		return -3;
	}
	pC1P->pszArgument = pszFilename;
	return AddStatement(pConfig, COMMAND_INJECT_DLL, pC1P);
}
Example #5
0
int ParseConfigResume(TCHAR *pszLine, CONFIG *pConfig)
{
	if (NoRemainingTokens(pszLine))
		return AddStatement(pConfig, COMMAND_RESUME, NULL);
	else
		return -1;
}
Example #6
0
int ParseConfigTestFunction(TCHAR *pszLine, CONFIG *pConfig)
{
	if (NoRemainingTokens(pszLine))
		return AddStatement(pConfig, COMMAND_TEST_FUNCTION, NULL);
	else
		return -1;
}
Example #7
0
int ParseConfigSuspend(TCHAR *pszLine, CONFIG *pConfig)
{
	if (NoRemainingTokens(pszLine))
		return AddStatement(pConfig, COMMAND_SUSPEND, NULL);
	else
		return -1;
}
Example #8
0
int ParseConfigSearchAndWrite(TCHAR *pszLine, CONFIG *pConfig)
{
	int iStart;
	int iLen;
	OPTIONS sO;
	TCHAR *pszSearch;
	TCHAR *pszWrite;
	unsigned char *pucArgumentSearch;
	int iBytesSearch;
	unsigned char *pucArgumentWrite;
	int iBytesWrite;
	struct CommandSearchAndWrite *pCSAW;
	int iTokenArgument;
	
	iStart = GetToken(0, pszLine, &iLen, NULL);
	if (-1 == iStart)
		return -1;

  ZeroMemory(&sO, sizeof(OPTIONS));
  sO.bModule = TRUE;
  sO.bMemory = TRUE;
  iStart = ParseOptions(pszLine+iStart, &sO);
	if (-1 == iStart)
		return -1;

	if (NULL != sO.pszModule && NULL != sO.pszMemory)
		return -1;
		
	if (!TwoRemainingTokens(pszLine+iStart, &pszSearch, &pszWrite))
		return -1;
	iTokenArgument = ParseArgument(pszSearch, &pucArgumentSearch, &iBytesSearch);
	free(pszSearch);
	if (0 == iBytesSearch || (TOK_HEX != iTokenArgument && TOK_ASCII != iTokenArgument && TOK_UNICODE != iTokenArgument))
		return -1;
	iTokenArgument = ParseArgument(pszWrite, &pucArgumentWrite, &iBytesWrite);
	free(pszWrite);
	if (0 == iBytesWrite || (TOK_HEX != iTokenArgument && TOK_ASCII != iTokenArgument && TOK_UNICODE != iTokenArgument))
		return -1;

	pCSAW = malloc(sizeof(struct CommandSearchAndWrite));
	if (NULL == pCSAW)
    return -1;
	pCSAW->searchLen = iBytesSearch;
	pCSAW->searchBytes = pucArgumentSearch;
	pCSAW->writeLen = iBytesWrite;
	pCSAW->writeBytes = pucArgumentWrite;
	pCSAW->pszModule = sO.pszModule;
	if (NULL != sO.pszMemory)
		if (TOK_WRITABLE == LookupToken(sO.pszMemory))
			pCSAW->dwMemory = PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY|PAGE_READWRITE|PAGE_WRITECOPY;
		else
				return -1;
	else
		pCSAW->dwMemory = 0;
	return AddStatement(pConfig, COMMAND_SEARCH_AND_WRITE, pCSAW);
}
void VEmitContext::EmitClearStrings(int Start, int End)
{
	for (int i = Start; i < End; i++)
	{
		//	Don't touch out parameters.
		if (LocalDefs[i].ParamFlags & FPARM_Out)
		{
			continue;
		}

		if (LocalDefs[i].Type.Type == TYPE_String)
		{
			EmitLocalAddress(LocalDefs[i].Offset);
			AddStatement(OPC_ClearPointedStr);
		}
		if (LocalDefs[i].Type.Type == TYPE_DynamicArray)
		{
			EmitLocalAddress(LocalDefs[i].Offset);
			AddStatement(OPC_PushNumber0);
			AddStatement(OPC_DynArraySetNum, LocalDefs[i].Type.GetArrayInnerType());
		}
		if (LocalDefs[i].Type.Type == TYPE_Struct &&
			LocalDefs[i].Type.Struct->NeedsDestructor())
		{
			EmitLocalAddress(LocalDefs[i].Offset);
			AddStatement(OPC_ClearPointedStruct, LocalDefs[i].Type.Struct);
		}
		if (LocalDefs[i].Type.Type == TYPE_Array)
		{
			if (LocalDefs[i].Type.ArrayInnerType == TYPE_String)
			{
				for (int j = 0; j < LocalDefs[i].Type.ArrayDim; j++)
				{
					EmitLocalAddress(LocalDefs[i].Offset);
					EmitPushNumber(j);
					AddStatement(OPC_ArrayElement, LocalDefs[i].Type.GetArrayInnerType());
					AddStatement(OPC_ClearPointedStr);
				}
			}
			else if (LocalDefs[i].Type.ArrayInnerType == TYPE_Struct &&
				LocalDefs[i].Type.Struct->NeedsDestructor())
			{
				for (int j = 0; j < LocalDefs[i].Type.ArrayDim; j++)
				{
					EmitLocalAddress(LocalDefs[i].Offset);
					EmitPushNumber(j);
					AddStatement(OPC_ArrayElement, LocalDefs[i].Type.GetArrayInnerType());
					AddStatement(OPC_ClearPointedStruct, LocalDefs[i].Type.Struct);
				}
			}
		}
	}
}
Example #10
0
	void BeginGroup(GroupStatement* group)
	{
		const char* translation = group->GetGroupTranslation();
		const char* name = group->GetGroupName();
		
		const char* text = NULL;
		if (translation != NULL) {
			text = translation;
		} else {
			text = name;
		}
		
		AddStatement(text, group->GetStatement());
	}
Example #11
0
int ParseConfigAdjustTokenPrivileges(TCHAR *pszLine, CONFIG *pConfig)
{
	TCHAR *pszToken;
	int iToken;
	
	if (!OneRemainingToken(pszLine, &pszToken))
    return -1;

  iToken = LookupToken(pszToken);
  free(pszToken);
  if (TOK_ME != iToken)
    return -2;

	return AddStatement(pConfig, COMMAND_ADJUST_TOKE_PRIVILEGES, NULL);
}
Example #12
0
int ParseConfigPrint(TCHAR *pszLine, CONFIG *pConfig)
{
	int iStart;
	int iLen;
	TCHAR *pszArgument;
	struct Command1psz *pC1P;
	
	iStart = GetToken(0, pszLine, &iLen, NULL);
	pC1P = malloc(sizeof(struct Command1psz));
	if (NULL == pC1P)
    return -1;
	if (-1 == iStart)
		pszArgument = NULL;
	else
		pszArgument = _tcsdup(pszLine+iStart);
	pC1P->pszArgument = pszArgument;
	return AddStatement(pConfig, COMMAND_PRINT, pC1P);
}
Example #13
0
int ParseConfigWrite(TCHAR *pszLine, CONFIG *pConfig)
{
	int iStart;
	int iLen;
	OPTIONS sO;
	TCHAR *pszAddress;
	TCHAR *pszData;
	struct CommandWrite *pCW;
	DWORD dwAddress;
	unsigned char *pucBytes;
	int iBytes;
	int iTokenArgument;
	
	iStart = GetToken(0, pszLine, &iLen, NULL);
	if (-1 == iStart)
		return -1;

  ZeroMemory(&sO, sizeof(OPTIONS));
  sO.bVersion = TRUE;
  iStart = ParseOptions(pszLine+iStart, &sO);
	if (-1 == iStart)
		return -1;

	if (!TwoRemainingTokens(pszLine+iStart, &pszAddress, &pszData))
		return -1;
	dwAddress = ParseAddress(pszAddress);
	free(pszAddress);
	iTokenArgument = ParseArgument(pszData, &pucBytes, &iBytes);
	free(pszData);
	if (0 == dwAddress || 0 == iBytes || (TOK_HEX != iTokenArgument && TOK_ASCII != iTokenArgument && TOK_UNICODE != iTokenArgument))
		return -1;
		
	pCW = malloc(sizeof(struct CommandWrite));
	if (NULL == pCW)
		return -1;
	pCW->address = dwAddress;
	pCW->len = iBytes;
	pCW->bytes = pucBytes;
	pCW->pszVersion = sO.pszVersion;
	return AddStatement(pConfig, COMMAND_WRITE, pCW);
}
Example #14
0
DACEntry * DACGenerator::AddStatement(OpKind opKind, Symbol * sym) {
	return AddStatement(opKind, sym, nullptr);
}
Example #15
0
//a// Release Memory!
int ParseConfigStrings(TCHAR *pszLine, CONFIG *pConfig)
{
	OPTIONS sO;
	int iStart;
	struct CommandStrings *pCS;

  ZeroMemory(&sO, sizeof(OPTIONS));
  sO.bModule = TRUE;
  sO.bAddress = TRUE;
  sO.bMinimumLength = TRUE;
  sO.bStartAddress = TRUE;
  sO.bEndAddress = TRUE;
  sO.bAlphaPercentage = TRUE;
  sO.bRegex = TRUE;
  sO.bFilter = TRUE;
  sO.bMemory = TRUE;
  iStart = ParseOptions(pszLine, &sO);
	if (iStart != -1)
		return -1;

	if (NULL != sO.pszModule && NULL != sO.pszMemory)
		return -7;
		
	pCS = malloc(sizeof(struct CommandStrings));
	if (NULL == pCS)
    return -1;

	pCS->pszModule = sO.pszModule;
	
	if (NULL != sO.pszAddress)
		switch(LookupToken(sO.pszAddress))
		{
			case TOK_ON:
				pCS->bAddress = TRUE;
				break;
				
			case TOK_OFF:
				pCS->bAddress = FALSE;
				break;

			default:
				return -2;
		}
	else
		pCS->bAddress = FALSE;
		
	if (NULL != sO.pszMinimumLength)
	{
		if (ParseUnsignedNumber(sO.pszMinimumLength, &(pCS->uiMinimumLength)) < 0)
			return -3;
	}
	else
		pCS->uiMinimumLength = 4;
		
	if (NULL != sO.pszStartAddress)
	{
		sscanf(sO.pszStartAddress, "%8x", &(pCS->dwStartAddress)); //a// check hex
	}
	else
		pCS->dwStartAddress = 0;
		
	if (NULL != sO.pszEndAddress)
	{
		sscanf(sO.pszEndAddress, "%8x", &(pCS->dwEndAddress)); //a// check hex
	}
	else
		pCS->dwEndAddress = 0xFFFFFFFF;
		
	if (NULL != sO.pszAlphaPercentage)
	{
		if (ParseUnsignedNumber(sO.pszAlphaPercentage, &(pCS->uiAlphaPercentage)) < 0)
			return -4;
		if (pCS->uiAlphaPercentage > 100)
			return -5;
	}
	else
		pCS->uiAlphaPercentage = 0;

	pCS->pszRegex = sO.pszRegex;
	pCS->pPCRE = NULL;
	
	pCS->pszFilter = sO.pszFilter;

	if (NULL != sO.pszMemory)
		if (TOK_WRITABLE == LookupToken(sO.pszMemory))
			pCS->dwMemory = PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY|PAGE_READWRITE|PAGE_WRITECOPY;
		else
				return -6;
	else
		pCS->dwMemory = 0;
		
	return AddStatement(pConfig, COMMAND_STRINGS, pCS);
}
PostgresPreparedStatement::PostgresPreparedStatement(PostgresInterface* pInterface, PGconn* pDatabase, const wxString& strSQL, const wxString& strStatementName)
 : PreparedStatement()
{
  m_pInterface = pInterface;
  AddStatement(pDatabase, strSQL, strStatementName);
}
void VEmitContext::EmitLocalAddress(int Ofs)
{
	if (Ofs == 0)
		AddStatement(OPC_LocalAddress0);
	else if (Ofs == 1)
		AddStatement(OPC_LocalAddress1);
	else if (Ofs == 2)
		AddStatement(OPC_LocalAddress2);
	else if (Ofs == 3)
		AddStatement(OPC_LocalAddress3);
	else if (Ofs == 4)
		AddStatement(OPC_LocalAddress4);
	else if (Ofs == 5)
		AddStatement(OPC_LocalAddress5);
	else if (Ofs == 6)
		AddStatement(OPC_LocalAddress6);
	else if (Ofs == 7)
		AddStatement(OPC_LocalAddress7);
	else if (Ofs < 256)
		AddStatement(OPC_LocalAddressB, Ofs);
	else if (Ofs < MAX_VINT16)
		AddStatement(OPC_LocalAddressS, Ofs);
	else
		AddStatement(OPC_LocalAddress, Ofs);
}
Example #18
0
int ParseConfigInjectCode(TCHAR *pszLine, CONFIG *pConfig)
{
	TCHAR *pszToken;
	struct CommandInjectCode *pCInjectCode;
	unsigned char *pucBytes;
	int iBytes;
	OPTIONS sO;
	int iStart;
	int iTokenArgument;

  ZeroMemory(&sO, sizeof(OPTIONS));
  sO.bMinimumLength = TRUE;
  sO.bExecute = TRUE;
  iStart = ParseOptions(pszLine, &sO);
	if (iStart < 0)
		return -1;

	if (!OneRemainingToken(pszLine+iStart, &pszToken))
    return -2;

	iTokenArgument = ParseArgument(pszToken, &pucBytes, &iBytes);
	free(pszToken);
	if (0 == iBytes || (TOK_HEX != iTokenArgument && TOK_ASCII != iTokenArgument && TOK_UNICODE != iTokenArgument && TOK_FILE != iTokenArgument))
	{
		free(pucBytes);
		return -3;
	}
	
	pCInjectCode = malloc(sizeof(struct CommandInjectCode));
	if (NULL == pCInjectCode)
	{
		free(pucBytes);
		return -4;
	}
	pCInjectCode->pbBytes = pucBytes;
	pCInjectCode->lBytesSize = iBytes;
	pCInjectCode->bFilename = TOK_FILE == iTokenArgument;
	if (NULL != sO.pszMinimumLength)
	{
		if (ParseUnsignedNumber(sO.pszMinimumLength, &(pCInjectCode->uiMinimumBytesSize)) < 0)
			return -5;
	}
	else
		pCInjectCode->uiMinimumBytesSize = 0;
	if (NULL != sO.pszExecute)
		switch(LookupToken(sO.pszExecute))
		{
			case TOK_YES:
				pCInjectCode->bExecute = TRUE;
				break;
				
			case TOK_NO:
				pCInjectCode->bExecute = FALSE;
				break;

			default:
				return -2;
		}
	else
		pCInjectCode->bExecute = TRUE;
		

	return AddStatement(pConfig, COMMAND_INJECT_CODE, pCInjectCode);
}