// UNDONE !!!! this tes failed because we have now singleton engine and should reset hook for each test
// Also Loading/unloading(when i finished it) should help 
TEST(IncrimentalLinking, DISABLED_stdcallSimpleInstall) 
{
	HMODULE dll = loadTarget(); 
	ASSERT_NE((HMODULE)0, dll);
	uint32_t original = (uint32_t)GetProcAddress(dll, "stdcallSampleFunction");
	ASSERT_NE(0, original);
	ASSERT_EQ(42, ((int(__stdcall *)(int))original)(0));
	ASSERT_EQ(42, ((int(__stdcall *)(int))original)(10));

	ASSERT_TRUE(HookEngine::instance()->fasthook(dll, "stdcallSampleFunction", stdcallSampleFunctionHook2));

	ASSERT_EQ(42, ((int(__stdcall *)(int))original)(0));
	ASSERT_EQ(52, ((int(__stdcall *)(int))original)(10));
	unloadTarget();
}
TEST(IncrimentalLinking, cdeclTest) 
{
	HMODULE dll = loadTarget(); 
	ASSERT_NE((HMODULE)0, dll);
	uint32_t original = (uint32_t)GetProcAddress(dll, "cdeclSampleFunction");
	ASSERT_NE(0, original);
	ASSERT_EQ(42, ((int(__cdecl *)(int))original)(0));
	ASSERT_EQ(42, ((int(__cdecl *)(int))original)(10));

	uint32_t target = (uint32_t)cdeclSampleFunctionHook;
	ASSERT_TRUE(HookEngine::instance()->installHook(original, target, &cdeclInfo));

	ASSERT_EQ(42, ((int(__cdecl *)(int))original)(0));
	ASSERT_EQ(52, ((int(__cdecl *)(int))original)(10));
	unloadTarget();
}
Example #3
0
void MangoExact::loadTarget (const char *target)
{
   BufferScanner scanner(target);

   loadTarget(scanner);
}
Example #4
0
void MangoExact::loadTarget (const Array<char> &target_buf)
{
   BufferScanner scanner(target_buf);

   loadTarget(scanner);
}
Example #5
0
void MangoTautomer::loadTarget (const Array<char> &molfile_buf)
{
   BufferScanner scanner(molfile_buf);

   loadTarget(scanner);
}
Example #6
0
void MangoTautomer::loadTarget (const char *target)
{
   BufferScanner scanner(target);

   loadTarget(scanner);
}
void MangoSubstructure::loadTarget (const char *target)
{
    BufferScanner scanner(target);

    loadTarget(scanner);
}
void MangoSubstructure::loadTarget (const Array<char> &molfile_buf)
{
    BufferScanner scanner(molfile_buf);

    loadTarget(scanner);
}
Example #9
0
/*************************************************************************
 * uLoad
 *   "Parse" a uCode source program (using flex to scan it).
 *************************************************************************/
int uLoad(uINSTRUCTION code[], int label[])
{
  uINSTRUCTION *currInstr;
  int codeLine = 0;

  int i, lab;

  do {
    currInstr = &(code[codeLine]);
    clearInstruction(currInstr);
    codeFlag = valid;
    loadOpcode(currInstr);
    if (codeFlag == valid) {
      switch (yytok) {
        case tHLT:
          break;

        case tRD:
        case tRDF:
        case tRDS:
          loadTarget(currInstr, 0);
          break;

        case tWRT:
        case tWRTLN:
          loadSource(currInstr, 0);
          break;

        case tWRTS:
        case tWRTLNS:
          break;

        case tMOV  :
        case tNEG  :
        case tNEGF :
        case tCASTI:
        case tCASTF:
          loadSource(currInstr, 0);
          loadTarget(currInstr, 1);
          break;

        case tADD :
        case tSUB :
        case tMUL :
        case tDIV :
        case tMOD :
        case tADDF :
        case tSUBF :
        case tMULF :
        case tDIVF :
          loadSource(currInstr, 0);
          loadSource(currInstr, 1);
          loadTarget(currInstr, 2);
          break;

        case tPUSH:
          loadSource(currInstr, 0);
          break;

        case tPOP :
          loadTarget(currInstr, 0);
          break;

        case tNEGS:
        case tADDS:
        case tSUBS:
        case tMULS:
        case tDIVS:
        case tMODS:
        case tNEGSF:
        case tADDSF:
        case tSUBSF:
        case tMULSF:
        case tDIVSF:
        case tCASTSI:
        case tCASTSF:
          break;

        /* Label instruction must be handled at load time */
        case tLAB :
        {
          sscanf(yytext, "%*[Ll]%d:", &lab);

          currInstr->Operand[0].Mode  = mLabel;
          setOperandValue(&(currInstr->Operand[0]), lab); 
          validateLabel(lab);

          if (codeFlag == valid) {
            if (label[lab] != undefinedLabel) {
              sprintf(loadMessage, "L%d REDEFINED", lab);
              codeFlag = badLabel;
            } else {
              label[lab] = codeLine;
            }
          }

          break;
        }
    
        case tANDS:
        case tORS:
        case tNOTS:
          break;

        case tCMPEQS:
        case tCMPGES:
        case tCMPGTS:
        case tCMPLES:
        case tCMPLTS:
        case tCMPNES:
        case tCMPEQSF:
        case tCMPGESF:
        case tCMPGTSF:
        case tCMPLESF:
        case tCMPLTSF:
        case tCMPNESF:
          break;

        case tBRTS:
        case tBRFS:
          loadLabel(currInstr, 0);
          break;

        case tBR  :
          loadLabel(currInstr, 0);
          break;

        case tBEQ :
        case tBGE :
        case tBGT :
        case tBLE :
        case tBLT :
        case tBNE :
        case tBEQF :
        case tBGEF :
        case tBGTF :
        case tBLEF :
        case tBLTF :
        case tBNEF :
          loadSource(currInstr, 0);
          loadSource(currInstr, 1);
          loadLabel (currInstr, 2);
          break;

        case tCALL:
          loadLabel(currInstr, 0);
          break;

        case tRET :
          break;

        case tEOF :
          break;

        case tPRTS:
        case tPRTR:
          break;

        default:
          perror(">>> INTERNAL ERROR IN LOAD_uCODE <<<");
          exit(1);
      }

    loadEnd();
  }


    /* Print an error message if an error occured */
    if (codeFlag != valid) {
      loadError(loadText, loadLine, loadMessage);
      switch (codeFlag) {
        case invalidOpcode:
          break;

        case invalidForm:
          printCorrectForm(currInstr->Opcode);
          break;

        case invalidRegister:
          fprintf(stderr, "\n   VALID RegisterS RANGE FROM 0 to ");
          fprintf(stderr, "%d", registerCount);
          fprintf(stderr, "\n");
          break;

        case invalidLabel:
          fprintf(stderr, "\n   VALID LABELS RANGE FROM 0 to ");
          fprintf(stderr, "%d", labelCount);
          fprintf(stderr, "\n");
          break;

        case badLabel:
        case invalidString:
          break;

        default:
          perror(">>> INTERNAL ERROR IN uLOAD <<<");
          exit(1);
      }
    }

    /* Process debugging information and update counters */
    fillInformation(currInstr, loadText, loadLine);

    loadText[0] = '\0';
    loadLine++;
    codeLine++;

    if (codeLine >= codeSize) {
      fprintf(stderr, ">>> CODE MEMORY OVERFLOW <<<\n");
      exit(1);
    }
  } while (yytok != tEOF);


  /* Resolve labels if source was loaded successfully */
  if (loadFlag == valid) {
    for (i = 0; i < labelCount; i++) {
      lab = label[i];

      while ((lab < 0) && (lab != undefinedLabel)) {
        label[i] = label[-label[i]];
        lab = label[i];
      }
    }
  }

  return (loadFlag == valid) ?1 :0;
}