Example #1
0
BOOL IsFunctionHooked(LPTSTR ModuleName, LPCSTR FunctionName)
{
	PVOID oldFunction = NULL;
	DWORD OldProtect = 0;
	DWORD index = 0;
	TCHAR tzTemp[MAX_PATH] = {0};

	oldFunction = GetProcAddress(GetModuleHandle(ModuleName), FunctionName);
	if (!oldFunction)
	{
		wsprintf(tzTemp, TEXT("Failed to find the function: %hs\n"), FunctionName);
		OutputDebugText(tzTemp);
		return FALSE;
	}

	for (index = 0; index < JumpCodeSize; ++index)
	{
		if (((LPBYTE)oldFunction)[index] != JumpCode[index])
		{
			wsprintf(tzTemp, TEXT("Function: %hs is not hooked\n"), FunctionName);
			OutputDebugText(tzTemp);
			return FALSE;
		}
	}

	return TRUE;
}
Example #2
0
inline BOOL WINAPI Load()
{
	TCHAR tzPath[MAX_PATH];
	TCHAR tzTemp[MAX_PATH * 2];

	GetSystemDirectory(tzPath, MAX_PATH);
	lstrcat(tzPath, TEXT("\\msimg32.dll"));
	hModule = LoadLibrary(tzPath);
	if (hModule == NULL)
	{
		wsprintf(tzTemp, TEXT("Failed to load %s\n"), tzPath);
		OutputDebugText(tzTemp);
		ExitProcess(1);
	}

	GetModuleFileName(NULL, tzTemp, sizeof(tzTemp));
	wsprintf(tzTemp, TEXT("%s is loading msimg32.dll\n"), tzTemp);
	OutputDebugText(tzTemp);

	vSetDdrawflagAddr = GetFuncAddress("vSetDdrawflag");
	AlphaBlendAddr = GetFuncAddress("AlphaBlend");
	DllInitializeAddr = GetFuncAddress("DllInitialize");
	GradientFillAddr = GetFuncAddress("GradientFill");
	TransparentBltAddr = GetFuncAddress("TransparentBlt");

	return TRUE;
}
Example #3
0
BOOL UnhookFunction(LPTSTR ModuleName, LPCSTR FunctionName, PVOID proxyFunction)
{
	PVOID oldFunction = NULL;
	DWORD oldProtect = 0;
	TCHAR tzTemp[MAX_PATH] = {0};

	oldFunction = GetProcAddress(GetModuleHandle(ModuleName), FunctionName);
	if (!oldFunction)
	{
		wsprintf(tzTemp, TEXT("Failed to find the function: %hs\n"), FunctionName);
		OutputDebugText(tzTemp);
		return FALSE;
	}

	// Recover the function
	VirtualProtect(oldFunction, JumpCodeSize, PAGE_EXECUTE_READWRITE, &oldProtect);
	RtlCopyMemory(oldFunction, proxyFunction, JumpCodeSize);
	VirtualProtect(oldFunction, JumpCodeSize, oldProtect, &oldProtect);
	FlushInstructionCache(GetModuleHandle(NULL), oldFunction, JumpCodeSize);

	if (!VirtualFree(proxyFunction, 0, MEM_RELEASE))
	{
		wsprintf(tzTemp, TEXT("Failed to free memory for the function: %hs\n"), FunctionName);
		OutputDebugText(tzTemp);
	}

	return TRUE;
}
Example #4
0
BOOL APIENTRY DllMain( HINSTANCE hinstDLL,
					  DWORD fdwReason,
					  LPVOID lpvReserved
					  )
{
	HMODULE hHookQQ = NULL;
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		DisableThreadLibraryCalls(hModule);
		Load();

		hHookQQ = LoadLibrary(TEXT("HookQQ.dll"));
		if (hHookQQ == NULL)
		{
			OutputDebugText(TEXT("Failed to load HookQQ.dll\n"));
			return FALSE;
		}
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_THREAD_DETACH:
		break;
	case DLL_PROCESS_DETACH:
		Free();
		break;
	}
	return TRUE;
}
Example #5
0
bool OutputDeclaration(TIntermDeclaration* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    TVariable* v = node->getVariable();

    if (v->getType().getBasicType() == EbtInvariant) {
        out.debug << "redeclare '" << v->getName() << "' as invariant";
    } else if (v->getType().getBasicType() != EbtStruct) {
        out.debug << "declare '" << v->getName() << "' (" <<
                  v->getType().getCompleteString() <<
                  ") [id: " << v->getUniqueId() << "]";
    } else {
        out.debug << "declare '" << v->getName() << "' (" <<
                  v->getType().getCompleteString() << " '" <<
                  v->getType().getTypeName() << "') [id: " <<
                  v->getUniqueId() << "]";
    }

    out.debug << " {" << node->isFirst() << "}";
    OutputDebugText(out, node);
    out.debug << "\n";

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    return true;
}
Example #6
0
PVOID HookFunction(LPTSTR ModuleName, LPCSTR FunctionName, PVOID MyFunction)
{
	PVOID oldFunction = NULL;
	PVOID proxyFunction = NULL;
	LPBYTE opCode = NULL;
	DWORD backupLen = 0;
	DWORD oldProtect = 0;
	TCHAR tzTemp[MAX_PATH] = {0};

	// Get original function address
	oldFunction = GetProcAddress(GetModuleHandle(ModuleName), FunctionName);
	if (!oldFunction)
	{
		wsprintf(tzTemp, TEXT("Failed to find the function: %hs\n"), FunctionName);
		OutputDebugText(tzTemp);
		return NULL;
	}

	// Get the exact length
	while (backupLen < JumpCodeSize)
		backupLen += size_of_code((LPBYTE)((DWORD)oldFunction + backupLen), &opCode);

	// Fill the data
	*(DWORD *)(JumpCode + 1) = (DWORD)MyFunction;
	*(DWORD *)(JumpbackCode + 1) = (DWORD)oldFunction + backupLen;

	// Allocate space for proxy function
	proxyFunction = VirtualAlloc(NULL, backupLen + JumpCodeSize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
	if (!proxyFunction)
	{
		wsprintf(tzTemp, TEXT("Failed to allocate space for the function: %hs\n"), FunctionName);
		OutputDebugText(tzTemp);
		return NULL;
	}
	 // Fill proxy function and flush instructions
	RtlCopyMemory(proxyFunction, oldFunction, backupLen);
	RtlCopyMemory((PVOID)((DWORD)proxyFunction + backupLen), JumpbackCode, JumpbackCodeSize);
	FlushInstructionCache(GetModuleHandle(NULL), proxyFunction, backupLen + JumpCodeSize);

	// Modify original function
	VirtualProtect(oldFunction, JumpCodeSize, PAGE_EXECUTE_READWRITE, &oldProtect);
	RtlCopyMemory(oldFunction, JumpCode, JumpCodeSize);
	VirtualProtect(oldFunction, JumpCodeSize, oldProtect, &oldProtect);
	FlushInstructionCache(GetModuleHandle(NULL), oldFunction, JumpCodeSize);

	return proxyFunction;
}
Example #7
0
bool OutputSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    out.debug << "Test condition and select";
    out.debug << " (" << node->getCompleteString() << ")";
    OutputDebugText(out, node);
    out.debug << " <<";
    out.debug << getDbgSelectionStatus(node->getDbgInternalState());
    out.debug << ">>\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif
#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    ++oit->depth;

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    out.debug << "Condition\n";
    node->getCondition()->traverse(it);

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    if (node->getTrueBlock()) {
        out.debug << "true case\n";
        node->getTrueBlock()->traverse(it);
    } else
        out.debug << "true case is null\n";

    if (node->getFalseBlock()) {
        OutputExtensionText(out, node);
        OutputTreeText(oit->infoSink, node, oit->depth);
        out.debug << "false case\n";
        node->getFalseBlock()->traverse(it);
    }

    --oit->depth;

    return false;
}
Example #8
0
FARPROC WINAPI GetFuncAddress(PCSTR pszFuncName)
{
	FARPROC fpAddress;
	TCHAR tzTemp[MAX_PATH];

	fpAddress = GetProcAddress(hModule, pszFuncName);
	if (fpAddress == NULL)
	{
		wsprintf(tzTemp, TEXT("Function %hs is not found\n"), pszFuncName);
		OutputDebugText(tzTemp);
		ExitProcess(1);
	}
	//wsprintf(tzTemp, TEXT("Function %hs address: %p\n"), pszFuncName, fpAddress);
	//OutputDebugText(tzTemp);

	return fpAddress;
}
Example #9
0
void OutputDummy(TIntermDummy* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    out.debug << "dummy ";

    OutputDebugText(out, node);
    out.debug << "\n";

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif
}
Example #10
0
bool OutputCase(bool /* preVisit */, TIntermCase* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    out.debug << "Case";
    out.debug << " (" << node->getCompleteString() << ")";
    OutputDebugText(out, node);
    out.debug << "\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif
#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    ++oit->depth;
    if (node->getExpression()) {
        node->getExpression()->traverse(it);
    } else {
        OutputExtensionText(out, node);
        OutputTreeText(out, node, oit->depth);
        out.debug << "Default Case\n" ;
    }

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);
    out.debug << "Body\n";

    ++oit->depth;
    if (node->getCaseBody()) {
        node->getCaseBody()->traverse(it);
    }

    --oit->depth;
    --oit->depth;



    return false;
}
Example #11
0
bool OutputSwitch(bool /* preVisit */, TIntermSwitch* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    out.debug << "Test condition and switch";
    out.debug << " (" << node->getCompleteString() << ")";
    OutputDebugText(out, node);
    out.debug << " <<";
    out.debug << getDbgSelectionStatus(node->getDbgInternalState());
    out.debug << ">>\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif
#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    ++oit->depth;

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    out.debug << "Condition\n";
    ++oit->depth;
    node->getCondition()->traverse(it);
    --oit->depth;

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    out.debug << "Case List\n";
    ++oit->depth;
    if (node->getCaseList()) {
        node->getCaseList()->traverse(it);
    }
    --oit->depth;

    --oit->depth;

    return false;
}
Example #12
0
bool OutputBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    switch (node->getFlowOp()) {
    case EOpKill:
        out.debug << "Branch: Kill";
        break;
    case EOpBreak:
        out.debug << "Branch: Break";
        break;
    case EOpContinue:
        out.debug << "Branch: Continue";
        break;
    case EOpReturn:
        out.debug << "Branch: Return";
        break;
    default:
        out.debug << "Branch: Unknown Branch";
        break;
    }

    if (node->getExpression()) {
        out.debug << " with expression";
        OutputDebugText(out, node);
        out.debug << "\n";

#if DEBUG_SCOPE == 1
        OutputScopeText(oit->infoSink, node, oit->depth);
#endif

        ++oit->depth;
        node->getExpression()->traverse(it);
        --oit->depth;
    } else
        out.debug << "\n";

    return false;
}
Example #13
0
bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    if (node->getOp() == EOpNull) {
        out.debug.message(EPrefixError, "node is still EOpNull!");
        return true;
    }

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    switch (node->getOp()) {
    case EOpSequence:
        out.debug << "Sequence ";
        break;
    case EOpDeclaration:
        out.debug << "Declaration ";
        break;
    case EOpSpecification:
        out.debug << "Specification ";
        break;
    case EOpParameter:
        out.debug << "Parameter ";
        break;
    case EOpComma:
        out.debug << "Comma ";
        break;
    case EOpFunction:
        out.debug << "Function Definition: "<<node->getName();
        break;
    case EOpFunctionCall:
        out.debug << "Function Call: " << node->getName();
        break;
    case EOpParameters:
        out.debug << "Function Parameters: ";
        break;
    case EOpInstances:
        out.debug << "Declaration of instances: ";
        break;

    case EOpConstructFloat:
        out.debug << "Construct float";
        break;
    case EOpConstructVec2:
        out.debug << "Construct vec2";
        break;
    case EOpConstructVec3:
        out.debug << "Construct vec3";
        break;
    case EOpConstructVec4:
        out.debug << "Construct vec4";
        break;
    case EOpConstructBool:
        out.debug << "Construct bool";
        break;
    case EOpConstructBVec2:
        out.debug << "Construct bvec2";
        break;
    case EOpConstructBVec3:
        out.debug << "Construct bvec3";
        break;
    case EOpConstructBVec4:
        out.debug << "Construct bvec4";
        break;
    case EOpConstructInt:
        out.debug << "Construct int";
        break;
    case EOpConstructUInt:
        out.debug << "Construct unsigned int";
        break;
    case EOpConstructIVec2:
        out.debug << "Construct ivec2";
        break;
    case EOpConstructIVec3:
        out.debug << "Construct ivec3";
        break;
    case EOpConstructIVec4:
        out.debug << "Construct ivec4";
        break;
    case EOpConstructUVec2:
        out.debug << "Construct unsigned ivec2";
        break;
    case EOpConstructUVec3:
        out.debug << "Construct unsigned ivec3";
        break;
    case EOpConstructUVec4:
        out.debug << "Construct unsigned ivec4";
        break;
    case EOpConstructMat2:
        out.debug << "Construct mat2";
        break;
    case EOpConstructMat2x3:
        out.debug << "Construct mat2x3";
        break;
    case EOpConstructMat2x4:
        out.debug << "Construct mat2x4";
        break;
    case EOpConstructMat3x2:
        out.debug << "Construct mat3x2";
        break;
    case EOpConstructMat3:
        out.debug << "Construct mat3";
        break;
    case EOpConstructMat3x4:
        out.debug << "Construct mat3x4";
        break;
    case EOpConstructMat4x2:
        out.debug << "Construct mat4x2";
        break;
    case EOpConstructMat4x3:
        out.debug << "Construct mat4x3";
        break;
    case EOpConstructMat4:
        out.debug << "Construct mat4";
        break;
    case EOpConstructStruct:
        out.debug << "Construct structure";
        break;

    case EOpLessThan:
        out.debug << "Compare Less Than";
        break;
    case EOpGreaterThan:
        out.debug << "Compare Greater Than";
        break;
    case EOpLessThanEqual:
        out.debug << "Compare Less Than or Equal";
        break;
    case EOpGreaterThanEqual:
        out.debug << "Compare Greater Than or Equal";
        break;
    case EOpVectorEqual:
        out.debug << "Equal";
        break;
    case EOpVectorNotEqual:
        out.debug << "NotEqual";
        break;

    case EOpMod:
        out.debug << "mod";
        break;
    case EOpPow:
        out.debug << "pow";
        break;

    case EOpAtan:
        out.debug << "arc tangent";
        break;

    case EOpMin:
        out.debug << "min";
        break;
    case EOpMax:
        out.debug << "max";
        break;
    case EOpClamp:
        out.debug << "clamp";
        break;
    case EOpMix:
        out.debug << "mix";
        break;
    case EOpStep:
        out.debug << "step";
        break;
    case EOpSmoothStep:
        out.debug << "smoothstep";
        break;
    case EOpTruncate:
        out.debug << "truncate";
        break;
    case EOpRound:
        out.debug << "round";
        break;

    case EOpDistance:
        out.debug << "distance";
        break;
    case EOpDot:
        out.debug << "dot-product";
        break;
    case EOpCross:
        out.debug << "cross-product";
        break;
    case EOpFaceForward:
        out.debug << "face-forward";
        break;
    case EOpReflect:
        out.debug << "reflect";
        break;
    case EOpRefract:
        out.debug << "refract";
        break;
    case EOpMul:
        out.debug << "component-wise multiply";
        break;
    case EOpMatrixOuterProduct:
        out.debug << "outer product";
        break;

    case EOpItof:
        out.debug << "itof";
        break;
    case EOpFtoi:
        out.debug << "ftoi";
        break;
    case EOpSkipPixels:
        out.debug << "skipPixels";
        break;
    case EOpReadInput:
        out.debug << "readInput";
        break;
    case EOpWritePixel:
        out.debug << "writePixel";
        break;
    case EOpBitmapLsb:
        out.debug << "bitmapLSB";
        break;
    case EOpBitmapMsb:
        out.debug << "bitmapMSB";
        break;
    case EOpWriteOutput:
        out.debug << "writeOutput";
        break;
    case EOpReadPixel:
        out.debug << "readPixel";
        break;

    case EOpSwizzles:
        out.debug << "swizzles";
        break;

    default:
        out.debug.message(EPrefixError, "Bad aggregation op");
    }

    if (node->getOp() != EOpSequence
            && node->getOp() != EOpComma
            && node->getOp() != EOpSpecification
            && node->getOp() != EOpDeclaration
            && node->getOp() != EOpParameters
            && node->getOp() != EOpInstances
            && node->getOp() != EOpSwizzles )
        out.debug << " (" << node->getCompleteString() << ")";

    OutputDebugText(out, node);
    out.debug << "\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif


    return true;
}
Example #14
0
bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    switch (node->getOp()) {
    case EOpNegative:
        out.debug << "Negate value";
        break;
    case EOpVectorLogicalNot:
    case EOpLogicalNot:
        out.debug << "Negate conditional";
        break;
    case EOpBitwiseNot:
        out.debug << "Bitwise not";
        break;

    case EOpPostIncrement:
        out.debug << "Post-Increment";
        break;
    case EOpPostDecrement:
        out.debug << "Post-Decrement";
        break;
    case EOpPreIncrement:
        out.debug << "Pre-Increment";
        break;
    case EOpPreDecrement:
        out.debug << "Pre-Decrement";
        break;

    case EOpConvIntToBool:
        out.debug << "Convert int to bool";
        break;
    case EOpConvUIntToBool:
        out.debug << "Convert unsigne int to bool";
        break;
    case EOpConvFloatToBool:
        out.debug << "Convert float to bool";
        break;

    case EOpConvBoolToFloat:
        out.debug << "Convert bool to float";
        break;
    case EOpConvIntToFloat:
        out.debug << "Convert int to float";
        break;
    case EOpConvUIntToFloat:
        out.debug << "Convert unsigned int to float";
        break;

    case EOpConvFloatToInt:
        out.debug << "Convert float to int";
        break;
    case EOpConvBoolToInt:
        out.debug << "Convert bool to int";
        break;
    case EOpConvUIntToInt:
        out.debug << "Convert unsigned int to int";
        break;

    case EOpConvFloatToUInt:
        out.debug << "Convert float to unsigned int";
        break;
    case EOpConvBoolToUInt:
        out.debug << "Convert bool to unsigned int";
        break;
    case EOpConvIntToUInt:
        out.debug << "Convert int to unsigned int";
        break;

    case EOpRadians:
        out.debug << "radians";
        break;
    case EOpDegrees:
        out.debug << "degrees";
        break;
    case EOpSin:
        out.debug << "sine";
        break;
    case EOpCos:
        out.debug << "cosine";
        break;
    case EOpTan:
        out.debug << "tangent";
        break;
    case EOpAsin:
        out.debug << "arc sine";
        break;
    case EOpAcos:
        out.debug << "arc cosine";
        break;
    case EOpAtan:
        out.debug << "arc tangent";
        break;

    case EOpExp:
        out.debug << "exp";
        break;
    case EOpLog:
        out.debug << "log";
        break;
    case EOpExp2:
        out.debug << "exp2";
        break;
    case EOpLog2:
        out.debug << "log2";
        break;
    case EOpSqrt:
        out.debug << "sqrt";
        break;
    case EOpInverseSqrt:
        out.debug << "inverse sqrt";
        break;

    case EOpAbs:
        out.debug << "Absolute value";
        break;
    case EOpSign:
        out.debug << "Sign";
        break;
    case EOpFloor:
        out.debug << "Floor";
        break;
    case EOpCeil:
        out.debug << "Ceiling";
        break;
    case EOpFract:
        out.debug << "Fraction";
        break;

    case EOpLength:
        out.debug << "length";
        break;
    case EOpNormalize:
        out.debug << "normalize";
        break;
    case EOpDPdx:
        out.debug << "dPdx";
        break;
    case EOpDPdy:
        out.debug << "dPdy";
        break;
    case EOpFwidth:
        out.debug << "fwidth";
        break;

    case EOpAny:
        out.debug << "any";
        break;
    case EOpAll:
        out.debug << "all";
        break;

    case EOpMatrixTranspose:
        out.debug << "transpose";
        break;

    default:
        out.debug.message(EPrefixError, "Bad unary op");
    }

    out.debug << " (" << node->getCompleteString() << ")";
    OutputDebugText(out, node);

    out.debug << "\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    return true;
}
Example #15
0
bool OutputBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    switch (node->getOp()) {
    case EOpAssign:
        out.debug << "move second child to first child";
        break;
    case EOpAddAssign:
        out.debug << "add second child into first child";
        break;
    case EOpSubAssign:
        out.debug << "subtract second child into first child";
        break;
    case EOpMulAssign:
        out.debug << "multiply second child into first child";
        break;
    case EOpVectorTimesMatrixAssign:
        out.debug << "matrix mult second child into first child";
        break;
    case EOpVectorTimesScalarAssign:
        out.debug << "vector scale second child into first child";
        break;
    case EOpMatrixTimesScalarAssign:
        out.debug << "matrix scale second child into first child";
        break;
    case EOpMatrixTimesMatrixAssign:
        out.debug << "matrix mult second child into first child";
        break;
    case EOpDivAssign:
        out.debug << "divide second child into first child";
        break;
    case EOpModAssign:
        out.debug << "mod second child into first child";
        break;
    case EOpAndAssign:
        out.debug << "and second child into first child";
        break;
    case EOpInclusiveOrAssign:
        out.debug << "or second child into first child";
        break;
    case EOpExclusiveOrAssign:
        out.debug << "exclusive or second child into first child";
        break;
    case EOpLeftShiftAssign:
        out.debug << "left shift second child into first child";
        break;
    case EOpRightShiftAssign:
        out.debug << "right shift second child into first child";
        break;

    case EOpIndexDirect:
        out.debug << "direct index";
        break;
    case EOpIndexIndirect:
        out.debug << "indirect index";
        break;
    case EOpIndexDirectStruct:
        out.debug << "direct index for structure";
        break;
    case EOpVectorSwizzle:
        out.debug << "vector swizzle";
        break;

    case EOpAdd:
        out.debug << "add";
        break;
    case EOpSub:
        out.debug << "subtract";
        break;
    case EOpMul:
        out.debug << "component-wise multiply";
        break;
    case EOpDiv:
        out.debug << "divide";
        break;
    case EOpMod:
        out.debug << "mod";
        break;
    case EOpRightShift:
        out.debug << "right-shift";
        break;
    case EOpLeftShift:
        out.debug << "left-shift";
        break;
    case EOpAnd:
        out.debug << "bitwise and";
        break;
    case EOpInclusiveOr:
        out.debug << "inclusive-or";
        break;
    case EOpExclusiveOr:
        out.debug << "exclusive-or";
        break;
    case EOpEqual:
        out.debug << "Compare Equal";
        break;
    case EOpNotEqual:
        out.debug << "Compare Not Equal";
        break;
    case EOpLessThan:
        out.debug << "Compare Less Than";
        break;
    case EOpGreaterThan:
        out.debug << "Compare Greater Than";
        break;
    case EOpLessThanEqual:
        out.debug << "Compare Less Than or Equal";
        break;
    case EOpGreaterThanEqual:
        out.debug << "Compare Greater Than or Equal";
        break;

    case EOpVectorTimesScalar:
        out.debug << "vector-scale";
        break;
    case EOpVectorTimesMatrix:
        out.debug << "vector-times-matrix";
        break;
    case EOpMatrixTimesVector:
        out.debug << "matrix-times-vector";
        break;
    case EOpMatrixTimesScalar:
        out.debug << "matrix-scale";
        break;
    case EOpMatrixTimesMatrix:
        out.debug << "matrix-multiply";
        break;

    case EOpLogicalOr:
        out.debug << "logical-or";
        break;
    case EOpLogicalXor:
        out.debug << "logical-xor";
        break;
    case EOpLogicalAnd:
        out.debug << "logical-and";
        break;
    default:
        out.debug << "<unknown op>";
    }

    out.debug << " (" << node->getCompleteString() << ")";
    OutputDebugText(out, node);

    out.debug << "\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif

#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    return true;
}
Example #16
0
bool OutputLoop(bool /* preVisit */, TIntermLoop* node, TIntermTraverser* it)
{
    TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
    TInfoSink& out = oit->infoSink;

    OutputExtensionText(out, node);
    OutputTreeText(out, node, oit->depth);

    out.debug << "Loop with condition of type  ";
    switch (node->getLoopType()) {
    case LOOP_WHILE:
        out.debug << "'while'";
        break;
    case LOOP_DO:
        out.debug << "'do'";
        break;
    case LOOP_FOR:
        out.debug << "'for'";
        break;
    }
    out.debug << " ";
    OutputDebugText(out, node);
    out.debug << " <<";
    out.debug << getDbgLoopStatus(node->getDbgInternalState());
    out.debug << ">> ";
    out.debug << "{";
    out.debug << node->getDbgIter();
    out.debug << "}\n";

#if DEBUG_SCOPE == 1
    OutputScopeText(oit->infoSink, node, oit->depth);
#endif
#if DEBUG_CHANGEABLE == 1
    OutputChangeableText(oit->infoSink, node, oit->depth, 0);
#endif

    ++oit->depth;

    if (node->getInit()) {
        OutputExtensionText(out, node);
        OutputTreeText(oit->infoSink, node, oit->depth);
        out.debug << "Loop Initialization\n";
        node->getInit()->traverse(it);
    }

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    if (node->getTest()) {
        out.debug << "Loop Condition\n";
        node->getTest()->traverse(it);
    } else
        out.debug << "No loop condition\n";

    OutputExtensionText(out, node);
    OutputTreeText(oit->infoSink, node, oit->depth);
    if (node->getBody()) {
        out.debug << "Loop Body\n";
        node->getBody()->traverse(it);
    } else
        out.debug << "No loop body\n";

    if (node->getTerminal()) {
        OutputExtensionText(out, node);
        OutputTreeText(oit->infoSink, node, oit->depth);
        out.debug << "Loop Terminal Expression\n";
        node->getTerminal()->traverse(it);
    }

    --oit->depth;

    return false;
}