Ejemplo n.º 1
0
BOOL QSQL_DEF::UpdateOptions	/* ---- Update Options ------------------ */
( HWND                  hDlg            // window handle
)
/* Updates options. */
{ MemBlock		mb;		// memblock class
  OBJECTID              qsqlObj;        // qsql object
  Qsql                  *qsql;          // qsql core info

  qsqlObj = (OBJECTID) GetWindowLong(hDlg, DWL_USER);	// gets object id    
  qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);

  /* ---- updates row count ---- */
  qsql->rowCount = GetDlgItemInt(hDlg, IDE_ROWCOUNT, NULL, FALSE);

  /* ---- updates column separator ---- */
  if (IsDlgButtonChecked(hDlg, IDD_TAB))
    qsql->colSprtr = TAB;
  else
    if (IsDlgButtonChecked(hDlg, IDD_COMMA))
      qsql->colSprtr = COMMA;
    /* else Fall Through */

  /* ---- updates oem ---- */
  qsql->isOEM = IsDlgButtonChecked(hDlg, IDD_OEM);
  return TRUE;
} // UpdateOptions
Ejemplo n.º 2
0
static void SendQueuedMessages()
{
    byte        buf[MEMCOPY_THRESHOLD];
    size_t      dataLen;
    MemBlock *  block;

    for (;;) 
    {
        if (!gPipe)
            return;

        dataLen = 0;
        block = GetDataToSend(buf, dimof(buf), &dataLen);
        byte *dataToSend = buf;
        if (block) {
            dataToSend = block->UnsentData();
            dataLen = block->UnsentLen();
        }

        if (0 == dataLen) {
            CrashIf(block);
            return;
        }

        //lf("memtrace.dll: sending %d bytes", (int)dataLen);
        WriteToPipe(dataToSend, dataLen);
        if (block) {
            block->sent += dataLen;
            FreeBlock(block);
        }
    }
}
Ejemplo n.º 3
0
BOOL QSQL_DEF::InitOptionsDialog/* ---- Init Options -------------------- */
( HWND			hDlg,		// window handle
  OBJECTID		qsqlObj		// qsql object
)
/* Inits options. */
{ MemBlock		mb;		// memblock class
  Qsql			*qsql;		// qsql core info

	AUtlCenterDialog(hDlg, 0);
  SetWindowLong(hDlg, DWL_USER, (DWORD) qsqlObj);	// saves object id
  qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);

  /* ---- inits row count ---- */
  SetDlgItemInt(hDlg, IDE_ROWCOUNT, (WORD) qsql->rowCount, FALSE);

  /* ---- inits row separator ---- */
  switch (qsql->colSprtr)
  { case TAB:
      CheckRadioButton(hDlg, IDD_TAB, IDD_COMMA, IDD_TAB);
      break;
    case COMMA:
      CheckRadioButton(hDlg, IDD_TAB, IDD_COMMA, IDD_COMMA);
      break;
    /* default: Fall Through */
  } // switch

  /* ---- inits oem ---- */
  CheckDlgButton(hDlg, IDD_OEM, qsql->isOEM);
  return TRUE;
} // InitOptions
Ejemplo n.º 4
0
/*------------------------------------------------------------------------*\
 | METHOD       : OQcncShutdownMeth                                       |
 | DESCRIPTION  : ODBC Connection object's destructor.                    |
 | Novell, Inc., November 1, 1993.				       mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncShutdownMeth
( pAEvtInfo,				// event pointer
  pAObjMessage				// system pointer
)
{ MemBlock	mb;			// memblock class
  long          objIdx;         	// object index
  OBJECTID      qcncObj;		// qcnc object
  QcncCore      *qcncCore;      	// qcnc core info

  QCNC_FNC	fnc;			// qcnc_fnc class
  qeSTATUS	errorCode;		// error code		

  objIdx = AOBJ_GETFIRSTKEY;
  while((qcncObj = AObjGetNextObject(OTYPE_QCNC, &objIdx)) != 0)
  { /* ---- releases resources ---- */
    qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE);
    if (qcncCore->isConnected)
    { fnc.CloseCursor(qcncObj);		// closes the qsql cursors

      errorCode = (*qe_Disconnect)(qcncCore->hdbc);
      if (fnc.RecordError(qcncCore, errorCode))
	AEvtPostSignalAtMark(qcncObj, QCNCIFERROR);
      else
        qcncCore->isConnected = FALSE;
    } // if
    if (qcncCore->errorCode != qeSUCCESS)
    { qcncCore->errorCode = qeSUCCESS;
      MBFree(qcncCore->errorMsg);
    } // if
  } // while

  if (sqlLib.IsLoadLib())
    (*qe_LibTerm)();
} // OQcncShutdownMeth
Ejemplo n.º 5
0
BOOL QSQL_DEF::UpdateVars	/* ---- Update Variables ---------------- */
( HWND                  hDlg            // window handle
)
/* Updates variables. */
{ MemBlock		mb;		// memblock class
  OBJECTID              qsqlObj;        // qsql object
  WORD                  varCount;       // number of VARs
  Var                   huge *varPtr;   // VAR pointer
  char			huge *namePtr;	// name pointer	
  char			extName[EXTNAMESIZE];	// extended name
  char			*extNamePtr;		// extended name pointer

  WORD			i;              // counter

  qsqlObj = (OBJECTID) GetWindowLong(hDlg, DWL_USER);	// gets object id	

  varCount = SendDlgItemMessage(hDlg, IDL_VARS, LB_GETCOUNT, 0, 0) - 1;
  MemResizeObjectData(qsqlObj, QSQLVARS, varCount * sizeof(Var));
  varPtr = (Var *) mb.GetPointer(qsqlObj, QSQLVARS);

  /* ---- updates variables ---- */
  for (i = 0; i < varCount; i++, varPtr++)
  { namePtr = varPtr->name;
    SendDlgItemMessage(hDlg, IDL_VARS, LB_GETTEXT, i, (DWORD) extName);
    extNamePtr = extName;
    while (*extNamePtr != ':')
      *namePtr++ = *extNamePtr++;
    *namePtr = 0;

    varPtr->obj = (OBJECTID)
      SendDlgItemMessage(hDlg, IDL_VARS, LB_GETITEMDATA, i, 0);
    varPtr->type = AObjGetType(varPtr->obj);
  } // for
  return TRUE;
} // UpdateVars
Ejemplo n.º 6
0
void QCNC_FNC::CloseCursor	/* ---- Close Cursor -------------------- */
( OBJECTID	qcncObj 		// qcnc object
)
/* Closes the associated SQL cursors. */
{ MemBlock	mb;			// memblock class
  OBJECTID	qsqlObj;		// qsql object
  QsqlCore	*qsqlCore;		// qsql core info

  QSQL_FNC	fnc;			// qsql_fnc class
  long		objIdx;         	// object index
  qeSTATUS	errorCode;		// error code

  objIdx = AOBJ_GETFIRSTKEY;
  while((qsqlObj = AObjGetNextObject(OTYPE_QSQL, &objIdx)) != 0)
  { qsqlCore = (QsqlCore *) mb.GetPointer(qsqlObj, QSQLCORE);
    if (qsqlCore && qsqlCore->connectObj == qcncObj && qsqlCore->isCursor)
    { errorCode = (*qe_EndSQL)(qsqlCore->cursor);
      if (fnc.RecordError(qsqlCore, errorCode))
	AEvtPostSignalAtMark(qsqlObj, QSQLIFERROR);
      else
      { qsqlCore->isCursor = FALSE;
	fnc.Dispose(qsqlCore);
      } // else
    } // if
  } // while
} // CloseCursor
Ejemplo n.º 7
0
/*-----------------------------------------------------------------------------
*   free
*----------------------------------------------------------------------------*/
void m_free_( void *memptr, char *file, int lineno )
{
    MemBlock *block = NULL;
    Bool result;

    init_module();

    /* if input is NULL, do nothing */
    if ( memptr == NULL )
        return;

    block = find_block( memptr, file, lineno );
    check( block, "memory free at %s:%d failed", file, lineno );

    /* delete from list to avoid recursion atexit() if overflow */
    DL_DELETE(g_mem_blocks, block );

    /* check fences */
    result = check_fences( block );
    check( result, "memory free at %s:%d failed", file, lineno );

error:
    /* delete memory blocks */
    if ( block ) {
        if ( block->destructor )			/* destroy children */
            block->destructor( memptr );	/* user destructor */

        free( block );						/* destroy itself */
    }
}
Ejemplo n.º 8
0
BOOL QSQL_DEF::InitVarsDialog	/* ---- Init Variables Dialog ----------- */
( HWND                  hDlg,           // window handle
  OBJECTID              qsqlObj         // qsql object
)
/* Inits Variables group box. */
{ MemBlock		mb;		// memblock class
  WORD                  varCount;       // number of VARs
  Var                   huge *varPtr;   // VAR pointer
  int			extNameLen;		// extended name length
  char			extName[EXTNAMESIZE];	// extended name

  long			typeIdx;	// type index
  TYPEID		type;		// type
  char			name[MXVARSIZE];// name

  WORD			i;              // counter

	AUtlCenterDialog(hDlg, 0);
  SetWindowLong(hDlg, DWL_USER, (DWORD) qsqlObj);	// saves object id
  varCount = (WORD) (AObjGetDataSize(qsqlObj, QSQLVARS) / sizeof(Var));
  varPtr = (Var *) mb.GetPointer(qsqlObj, QSQLVARS);

  /* ---- inits variable ---- */
  for (i = 0; i < varCount; i++, varPtr++)
  { if (varPtr->obj && !AObjCheckType(varPtr->obj, 0))
      varPtr->obj = 0;

    extNameLen = (int) hstrlen(varPtr->name);
    hmemcpy(extName, varPtr->name, extNameLen);
    if (varPtr->obj)
    { lstrcpy(&extName[extNameLen], ": <");
      ATypeGetName(varPtr->type, &extName[extNameLen + 3], sizeof(name));
      lstrcat(&extName[extNameLen], ">");
    } // if
    else
      lstrcpy(&extName[extNameLen], ": <(None)>");
    SendDlgItemMessage(hDlg, IDL_VARS, LB_INSERTSTRING, i, (DWORD) extName);
    SendDlgItemMessage(hDlg, IDL_VARS, LB_SETITEMDATA,
                       i, (DWORD) varPtr->obj);
  } // for
  /* inserts an empty mask */
  SendDlgItemMessage(hDlg, IDL_VARS, LB_INSERTSTRING, i, (DWORD) "");
  SendDlgItemMessage(hDlg, IDL_VARS, LB_SETITEMDATA, i, 0);

  /* ---- inits type ---- */ 
  i = SendDlgItemMessage(hDlg, IDC_TYPE, CB_INSERTSTRING,
                         -1, (DWORD) "(None)");
  SendDlgItemMessage(hDlg, IDC_TYPE, CB_SETITEMDATA, i, 0);
  typeIdx = AOBJ_GETFIRSTKEY;
  while ((type = ATypeGetNext(&typeIdx)) != 0)
    if (type == OTYPE_TEXT || type == OTYPE_NUMBER ||
	type == OTYPE_DATE || type == OTYPE_TIME)
    { ATypeGetName(type, name, sizeof(name));
      i = SendDlgItemMessage(hDlg, IDC_TYPE, CB_INSERTSTRING,
                             -1, (DWORD) name);
      SendDlgItemMessage(hDlg, IDC_TYPE, CB_SETITEMDATA, i, (DWORD) type);
    } // if
  return TRUE;
} // InitVars
Ejemplo n.º 9
0
/// <summary>
/// Unlink memory VAD node
/// </summary>
/// <param name="imageMem">Image to purge</param>
/// <returns>bool on success</returns>
bool MMap::UnlinkVad( const MemBlock& imageMem )
{
    HANDLE hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL );

    // Load missing driver
    if (hFile == INVALID_HANDLE_VALUE)
    {
        std::wstring drvPath = Utils::GetExeDirectory() + L"\\";

        if (IsWindows8Point1OrGreater())
            drvPath += L"VadPurge81.sys";
        else if(IsWindows8OrGreater())
            drvPath += L"VadPurge8.sys";
        else if(IsWindows7OrGreater())
            drvPath += L"VadPurge7.sys";

        NTSTATUS status = Utils::LoadDriver( L"VadPurge", drvPath );

        if (status != ERROR_SUCCESS && status != STATUS_IMAGE_ALREADY_LOADED)
            return false;

        hFile = CreateFile( _T( "\\\\.\\VadPurge" ), GENERIC_ALL, 0, NULL, OPEN_EXISTING, 0, NULL );
    }

    //
    // Lock pages in working set before unlinking
    // UserMode page faults can't be resolved without VAD record
    //
    if (hFile != INVALID_HANDLE_VALUE)
    {
        //
        // Adjust working set and lock pages
        //
        SIZE_T sizeMin = 0, sizeMax = 0;
        BOOL ret = FALSE;

        GetProcessWorkingSetSize( _process.core().handle(), &sizeMin, &sizeMax );
        SetProcessWorkingSetSize( _process.core().handle(), sizeMin + imageMem.size(), sizeMax + imageMem.size() );

        PVOID pBase = imageMem.ptr<PVOID>();
        ULONG size = static_cast<ULONG>(imageMem.size());
        NTSTATUS status = GET_IMPORT( NtLockVirtualMemory )(_process.core().handle(), &pBase, &size, 1);

        // Continue only if pages are locked
        if (status == STATUS_SUCCESS)
        {
            PURGE_DATA data = { _process.core().pid(), 1, { imageMem.ptr<ULONGLONG>(), imageMem.size() } };
            DWORD junk = 0;

            ret = DeviceIoControl( hFile, static_cast<DWORD>(IOCTL_VADPURGE_PURGE), &data, sizeof(data), NULL, 0, &junk, NULL );
        }

        CloseHandle( hFile );

        return (status == STATUS_SUCCESS && ret == TRUE) ? true : false;
    }

    return false;
}
Ejemplo n.º 10
0
		int WriteFile(const TCHAR* filePath,const MemBlock& pMemBlock){
			HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_WRITE, FILE_SHARE_READ, NULL,
										CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
			UINT32 un32NumberOfBytesWritten;
			if (hFile != INVALID_HANDLE_VALUE){
				// Write the bitmap header and bitmap bits to the file
				BOOL ret = ::WriteFile(hFile, (LPCVOID) pMemBlock.GetDataPointer(), pMemBlock.GetSize(), (LPDWORD)&un32NumberOfBytesWritten, 0);
				if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Write Failed!"));
				CloseHandle(hFile);// Close the file
			}
			return 0;
		}
Ejemplo n.º 11
0
/*------------------------------------------------------------------------*\
 | FUNCTION     : OQcncGetErrorFunc                                       |
 | DESCRIPTION  : Returns the most recent ODBC error code, and the        |
 |		  associated error message.                               |
 | INPUT 1      : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
 |                object to get the error from.                           |
 | OUTPUT 1(OPT): Error Number: NUMBER -- The returned ODBC error code.   |
 | OUTPUT 2(OPT): Error Message: TEXT -- The returned ODBC error message. |
 | FLOW 1       : Fetched.                                                |
 | FLOW 2       : No Error.                                               |
 | Novell, Inc., November 1, 1993.                                     mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncGetErrorFunc
( pAEvtInfo,				// event pointer
  pAObjMessage	theSystem       	// system pointer
)
{ MemBlock	mb;			// memblock class
  OBJECTID      qcncObj;        	// qcnc object                (I: 1)
  QcncCore      *qcncCore;      	// qcnc core info
  OBJECTID      errorNmbrObj;    	// number object              [O: 1]
  OBJECTID      errorMsgObj;    	// text object                [O: 2]

  if (!sqlLib.IsLoadLib())		// no library
    if (!sqlLib.LoadLib())
    { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
	"Get Error: Couldn't find the Q+E ODBC DLL.");
      return;
    } // if

  /* ---- FUNCTION INPUT 1 ---- */
  qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
  if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Get Error: Couldn't get the ODBC Connection input parameter.");
    return;
  } // if

  if (qcncCore->errorCode == qeSUCCESS)
  { /* ---- FLOW 2 (No Error) ---- */
    AFuncReportResult(theSystem, 2, "");
    return;
  } // if

  /* ---- FUNCTION OUTPUT 1 ---- */
  if (!(errorNmbrObj = AObjCreate(OTYPE_NUMBER)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Get Error: Couldn't create the Error Code output parameter.");
    return;
  } // if
  ONmbrSetInteger(errorNmbrObj, qcncCore->errorCode, TRUE);
  AFuncSetParameter(1, errorNmbrObj);

  /* ---- FUNCTION OUTPUT 2 ---- */
  if (!(errorMsgObj = AObjCreate(OTYPE_TEXT)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Get Error: Couldn't create the Error Message output parameter.");
    return;
  } // if
  OTextSetValueFromBuffer(errorMsgObj, qcncCore->errorMsg);
  AFuncSetParameter(2, errorMsgObj);

  /* ---- FLOW 1 (Fetched) ---- */
  AFuncReportResult(theSystem, 1, "");
} // OQcncGetErrorFunc
Ejemplo n.º 12
0
/*------------------------------------------------------------------------*\
 | FUNCTION     : OQcncRollbackFunc                                       |
 | DESCRIPTION  : Rolls back the current transaction.  The current        |
 |                transaction is the set of SQL statements executed since |
 |		  the last successful call to either the Connect, Commit, |
 |		  or Rollback functions.                                  |
 | INPUT 1      : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
 |                object to roll back the changes for.                    |
 | OUTPUT       : None.                                                   |
 | FLOW 1       : Rolled Back.                                            |
 | FLOW 2       : Failed.                                                 |
 | Novell, Inc., November 1, 1993.                                     mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncRollbackFunc
( pAEvtInfo,				// event pointer
  pAObjMessage	theSystem       	// system pointer
)
{ MemBlock	mb;			// memblock class
  OBJECTID      qcncObj;        	// qcnc object                (I: 1)
  QcncCore      *qcncCore;      	// qcnc core info

  QCNC_FNC	fnc;			// qcnc_fnc class
  qeSTATUS	errorCode;		// error code

  if (!sqlLib.IsLoadLib())		// no library
    if (!sqlLib.LoadLib())
    { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
	"Rollback: Couldn't find the Q+E ODBC DLL.");
      return;
    } // if

  /* ---- FUNCTION INPUT 1 ---- */
  qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
  if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Rollback: Couldn't get the ODBC Connection input parameter.");
    return;
  } // if

  if (!qcncCore->isConnected)
  { /* ---- FLOW 2 (Failed) ---- */
    AFuncReportResult(theSystem, 2, "ODBC Connection\r\n"
      "Rollback: The database wasn't connected.");
    return;
  } // if

  if (!qcncCore->isAutoCommit)
  { errorCode = (*qe_Rollback)(qcncCore->hdbc);
    if (fnc.RecordError(qcncCore, errorCode))
    { AEvtPostSignalAtTail(qcncObj, QCNCIFERROR);

      /* ---- FLOW 2 (Failed) ---- */
      AFuncReportResult(theSystem, 2, "");
      return;
    } // if

    errorCode = (*qe_BeginTran)(qcncCore->hdbc);
    if (fnc.RecordError(qcncCore, errorCode))
      AEvtPostSignalAtMark(qcncObj, QCNCIFERROR);
  } // if

  /* ---- FLOW 1 (Rolled Back) ---- */
  AFuncReportResult(theSystem, 1, "");   
} // OQcncRollbackFunc
Ejemplo n.º 13
0
MemBlock::MemBlock(const MemBlock & memBlock)
{
	_allocator = memBlock._allocator;
	size_t iCapacity = memBlock.TotalSpace();
	_begin = (char*)_allocator->Create(iCapacity);
	if ( _begin == NULL ) 
    {
		return;
	}

	_end = _begin;
	_blockEnd = _begin + iCapacity;
	Append(memBlock._begin, memBlock.Size());
}
Ejemplo n.º 14
0
// transfers the data to a thread that does the actual sending
static void QueueMessageForSending(Vec<byte>& msg)
{
    size_t len = msg.Size();
    if (0 == len)
        return;

    MemBlock *block = GetBlock(len);
    if (block) {
        block->Append(msg.LendData(), len);
        SetEvent(gSendThreadEvent);
    } else {
        lf("memtrace.dll: QueueMessageForSending() couldn't queu %d bytes", (int)len);
    }
}
Ejemplo n.º 15
0
 MemBlock(const MemBlock& rv) {
     memcpy(c, rv.c, size);
     refcount = 1;
     blocknum = blockcount++;
     print("copied block");
     out << endl;
     rv.print("from block");
 }
Ejemplo n.º 16
0
static
int checkErrorPropogation( const shared_ptr<Cipher> &cipher,
    int size, int byteToChange, const CipherKey &key )
{
  MemBlock orig;
  orig.allocate(size);
  MemBlock data;
  data.allocate(size);

  for(int i=0; i<size; ++i)
  {
    unsigned char tmp = rand();
    orig.data[i] = tmp;
    data.data[i] = tmp;
  }

  if(size != FSBlockSize)
    cipher->streamEncode( data.data, size, 0, key );
  else
    cipher->blockEncode( data.data, size, 0, key );

  // intoduce an error in the encoded data, so we can check error propogation
  if(byteToChange >= 0 && byteToChange < size)
  {
    unsigned char previousValue = data.data[byteToChange];
    do
    {
      data.data[byteToChange] = rand();
    } while(data.data[byteToChange] == previousValue);
  }

  if(size != FSBlockSize)
    cipher->streamDecode( data.data, size, 0, key );
  else
    cipher->blockDecode( data.data, size, 0, key );

  int numByteErrors = 0;
  for(int i=0; i<size; ++i)
  {
    if( data.data[i] != orig.data[i] )
      ++numByteErrors;
  }

  return numByteErrors;
}
Ejemplo n.º 17
0
/*------------------------------------------------------------------------*\
 | FUNCTION     : OQcncStatusFunc                                         |
 | DESCRIPTION  : Returns whether the ODBC Connection object is currently |
 |                connected to the DBMS.                                  |
 | INPUT 1      : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
 |		  object to get the status from.                          |
 | OUTPUT       : None.                                                   |
 | FLOW 1       : Connected.                                              |
 | FLOW 2       : Not Connected.                                          |
 | Novell, Inc., November 1, 1993.				       mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncStatusFunc
( pAEvtInfo,				// event pointer
  pAObjMessage	theSystem       	// system pointer
)
{ MemBlock	mb;			// memblock class
  OBJECTID      qcncObj;        	// qcnc object		      (I: 1)
  QcncCore      *qcncCore;      	// qcnc core info

  /* ---- FUNCTION INPUT 1 ---- */
  qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
  if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Status: Couldn't get the ODBC Connection input parameter.");
    return;
  } // if

  /* ---- FLOW 1 (Connected), OR FLOW 2 (Not Connected) ---- */
  AFuncReportResult(theSystem, 1 + (qcncCore->isConnected == FALSE), "");
} // OQcncStatusFunc
Ejemplo n.º 18
0
		int ReadFile(const TCHAR* filePath,MemBlock& pMemBlock){

			HANDLE hFile = CreateFile((TCHAR*) filePath, GENERIC_READ, FILE_SHARE_READ, NULL,
										OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
			if (hFile != INVALID_HANDLE_VALUE){
				//Maximum File Size 4GB (2^32);
				UINT32 un32FileSize;
				UINT32 un32NumberOfBytesRead ;
				un32FileSize =GetFileSize(hFile,NULL);
				if(un32FileSize){
					pMemBlock.SetSize(un32FileSize);
				}
				BOOL ret = ::ReadFile(hFile,(LPVOID) pMemBlock.GetDataPointer(), un32FileSize,(LPDWORD) &un32NumberOfBytesRead,0);
				//
				if(ret==0) woodychang0611::diagnostics::SendWarning(_T("File Read Failed!"));
				CloseHandle(hFile);// Close the file
				return 0;
			}
			return -1;
		}
Ejemplo n.º 19
0
/*------------------------------------------------------------------------*\
 | METHOD       : OQcncStartupMeth                                        |
 | DESCRIPTION  : ODBC Connection object's constructor.                   |
 | Novell, Inc., November 1, 1993.				       mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncStartupMeth
( pAEvtInfo,				// event pointer
  pAObjMessage	theSystem		// system pointer
)
{ MemBlock	mb;			// memblock class
  long          objIdx;         	// object index
  OBJECTID      qcncObj;		// qcnc object
  QcncCore      *qcncCore;		// qcnc core info

  objIdx = AOBJ_GETFIRSTKEY;
  while((qcncObj = AObjGetNextObject(OTYPE_QCNC, &objIdx)) != 0)
  { /* ---- inits resources ---- */
    MemResizeObjectData(qcncObj, QCNCCORE, sizeof(QcncCore));
    qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE);
    qcncCore->errorCode = qeSUCCESS;
    qcncCore->isConnected = FALSE;
  } // while

  if (!sqlLib.LoadLib())
    lstrcpy(theSystem->errorMessage,
	    "ODBC Connection: Couldn't find the Q+E ODBC DLL.");
  else
    (*qe_LibInit)();
} // OQcncStartupMeth
Ejemplo n.º 20
0
BOOL QSQL_DEF::UpdateObject	/* ---- Update Object Dialog ------------ */
( HWND                  hDlg            // window handle
)
/* Updates object dialog. */
{ MemBlock		mb;		// memblock class
  OBJECTID              qsqlObj;        // qsql object
  Qsql                  *qsql;          // qsql core info

  WORD			i;              // counter

  qsqlObj = (OBJECTID) GetWindowLong(hDlg, DWL_USER);	// gets object id
  qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);

  /* ----  updates connection ---- */
  i = SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_GETCURSEL, 0, 0);
  qsql->connectObj = (OBJECTID)
    SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_GETITEMDATA, i, 0);

  /* ---- updates sql statement ---- */
  i = SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_GETCURSEL, 0, 0);
  qsql->sqlObj = (OBJECTID)
    SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_GETITEMDATA, i, 0);
  return TRUE;
} // UpdateObject
Ejemplo n.º 21
0
	NTSTATUS MMap::ConcealVad(const MemBlock& imageMem) {
		return Driver().ConcealVAD(_process.Id(), imageMem.Ptr(), static_cast<uint32_t>(imageMem.Size()));
	}
Ejemplo n.º 22
0
BOOL QSQL_DEF::InitObjectDialog	/* ---- Init Object Dialog -------------- */
( HWND                  hDlg,           // window handle
  OBJECTID              qsqlObj         // qsql object
)
/* Inits Q+E SQL Object dialog. */
{ MemBlock		mb;		// memblock class
  Qsql			*qsql;		// qsql class
  char			str[MXSTRSIZE];	// string

  long			objIdx;		// object index
  OBJECTID		obj;		// object
  char			name[MXVARSIZE];// name

  WORD			i;		// counter
  			
  SetWindowLong(hDlg, DWL_USER, (DWORD) qsqlObj);	// saves object id
  qsql = (Qsql *) mb.GetPointer(qsqlObj, QSQLCORE);

  /* ---- inits qsql object type name, and qsql object name ---- */
  AUtlSetTitleFont(OTYPE_QSQL, NULL, GetDlgItem(hDlg, IDD_OBJECT));
	AUtlCenterDialog(hDlg, 0);
  AObjGetName(qsqlObj, str, sizeof(str));
  SetWindowText(hDlg, str);

  /* ---- inits connection ---- */
  i = SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_INSERTSTRING,
                         -1, (DWORD) "(None)");
  SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_SETITEMDATA, i, 0);
  if (!qsql->connectObj ||
      !AObjCheckType(qsql->connectObj, OTYPE_QCNC))
    SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_SETCURSEL, i, 0);

  objIdx = AOBJ_GETFIRSTKEY;
  while((obj = AObjGetNextObject(OTYPE_QCNC, &objIdx)) != 0)
  { AObjGetName(obj, name, sizeof(name));
    i = SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_INSERTSTRING,
			   -1, (DWORD) name);
    SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_SETITEMDATA, i, (DWORD) obj);
    if (qsql->connectObj == obj)
      SendDlgItemMessage(hDlg, IDC_CONNOBJ, CB_SETCURSEL, i, 0);
  } // while

  /* ---- inits sql statement ---- */
  i = SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_INSERTSTRING,
                         -1, (DWORD) "(None)");
  SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_SETITEMDATA, i, 0);
  if (!qsql->sqlObj ||
      !AObjCheckType(qsql->sqlObj, OTYPE_TEXT))
    SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_SETCURSEL, i, 0);

  objIdx = AOBJ_GETFIRSTKEY;
  while((obj = AObjGetNextObject(OTYPE_TEXT, &objIdx)) != 0)
  { AObjGetName(obj, name, sizeof(name));
    i = SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_INSERTSTRING,
                           -1, (DWORD) name);
    SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_SETITEMDATA, i, (DWORD) obj);
    if (qsql->sqlObj == obj)
      SendDlgItemMessage(hDlg, IDC_SQLOBJ, CB_SETCURSEL, i, 0);
  } // while
  return TRUE;
} // InitObject
Ejemplo n.º 23
0
/*------------------------------------------------------------------------*\
 | FUNCTION     : OQcncConnectFunc                                        |
 | DESCRIPTION  : Establishes a connection between the Q+E Connection     |
 |		  object, and the DBMS.                                   |
 | INPUT 1      : ODBC Connection: ODBC CONNECTION -- The ODBC Connection |
 |                object to use to make connection.                       |
 | OUTPUT       : None.                                                   |
 | FLOW 1       : Connected.                                              |
 | FLOW 2       : Failed.                                                 |
 | Novell, Inc., November 1, 1993.				       mw |
\*------------------------------------------------------------------------*/
void ALMAPI OQcncConnectFunc
( pAEvtInfo,				// event pointer
  pAObjMessage	theSystem       	// system pointer
)
{ MemBlock	mb;			// memblock class
  OBJECTID      qcncObj;        	// ocnc object                (I: 1)
  QcncCore      *qcncCore;      	// ocnc core info
  WORD		usernameLen;		// username length
  WORD		passwordLen;		// password length
  WORD		paramsLen;		// parameters length

  QCNC_FNC	fnc;			// qcnc_fnc class
  WORD		cncStrLen;		// connect string length
  char		*cncStr;		// connection string
  char		*cncStr2;		// connection string 2
  qeSTATUS	errorCode;		// error code

  if (!sqlLib.IsLoadLib())		// no library
    if (!sqlLib.LoadLib())
    { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
	"Connect: Couldn't find the Q+E ODBC DLL.");
      return;
    } // if

  /* ---- FUNCTION INPUT 1 ---- */
  qcncObj = AFuncGetTypedParameter(1, OTYPE_QCNC);
  if (!(qcncCore = (QcncCore *) mb.GetPointer(qcncObj, QCNCCORE)))
  { AFuncReportResult(theSystem, 0, "ODBC Connection\r\n"
      "Connect: Couldn't get the ODBC Connection input parameter.");
    return;
  } // if

  /* ---- calculates connection string size ---- */
  cncStrLen = 1;			// 0 terminated string

  /* ---- username ---- */
  if (qcncCore->usernameObj)
  { usernameLen = OTextGetLength(qcncCore->usernameObj);
    cncStrLen += 4 + usernameLen;	// "UID="
  } // if

  /* ---- password ---- */
  if (qcncCore->passwordObj)
  { passwordLen = OTextGetLength(qcncCore->passwordObj);
    if (qcncCore->usernameObj)
      cncStrLen += 5 + passwordLen;	// ";PWD="
    else
      cncStrLen += 4 + passwordLen;	// "PWD="
  } // if

  /* ---- other params ---- */
  if (qcncCore->paramsObj)
  { paramsLen = OTextGetLength(qcncCore->paramsObj);
    if (qcncCore->usernameObj || qcncCore->passwordObj)
      cncStrLen += 1 + paramsLen;	// ";"
    else
      cncStrLen += paramsLen;
  } // if

  /* ---- writes connection string ---- */
  cncStr = cncStr2 = (char *) mb.Alloc(cncStrLen);

  /* ---- username ---- */
  if (qcncCore->usernameObj)
  { memcpy(cncStr2, "UID=", 4);
    cncStr2 += 4;
    OTextGetToBuffer(qcncCore->usernameObj, cncStr2, usernameLen + 1);
    cncStr2 += usernameLen;
  } // if

  /* ---- password ---- */
  if (qcncCore->passwordObj)
  { if (qcncCore->usernameObj)
    { memcpy(cncStr2, ";PWD=", 5);
      cncStr2 += 5;
    } // if
    else
    { memcpy(cncStr2, "PWD=", 4);
      cncStr2 += 4;
    } // else
    OTextGetToBuffer(qcncCore->passwordObj, cncStr2, passwordLen + 1);
    cncStr2 += passwordLen;
  } // if

  /* ---- other params ---- */
  if (qcncCore->paramsObj)
  { if (qcncCore->usernameObj || qcncCore->passwordObj)
    { memcpy(cncStr2, ";", 1);
      cncStr2 += 1;
    } // if
    OTextGetToBuffer(qcncCore->paramsObj, cncStr2, paramsLen + 1);
    cncStr2 += paramsLen;
  } // if

  *cncStr2 = '\0';			// 0 terminated string

  if (qcncCore->isConnected)
  { /* ---- closes cursors ---- */
    fnc.CloseCursor(qcncObj);		// closes the sql cursors

    errorCode = (*qe_Disconnect)(qcncCore->hdbc);
    if (fnc.RecordError(qcncCore, errorCode))
    { AEvtPostSignalAtTail(qcncObj, QCNCIFERROR);

      /* ---- FLOW 2 (Failed) ---- */
      AFuncReportResult(theSystem, 2, "");
      return;
    } // if
    qcncCore->isConnected = FALSE;
  } // if

  if (!(qcncCore->hdbc = (*qe_Connect)(cncStr)))
  { errorCode = (*qe_Err)();
    if (fnc.RecordError(qcncCore, errorCode))
      AEvtPostSignalAtTail(qcncObj, QCNCIFERROR);

    /* ---- FLOW 2 (Failed) ---- */
    AFuncReportResult(theSystem, 2, ""); 
    return;
  } // if
  qcncCore->isConnected = TRUE;

  if (!qcncCore->isAutoCommit)		// not auto commit
  { errorCode = (*qe_BeginTran)(qcncCore->hdbc);
    if (fnc.RecordError(qcncCore, errorCode))
      AEvtPostSignalAtMark(qcncObj, QCNCIFERROR);
  } // if

  if (qcncCore->isDView)		// is database view
  { errorCode = (*qe_SetSelectOptions)(qcncCore->hdbc, qeFETCH_ANY_DIR);
    if (fnc.RecordError(qcncCore, errorCode))
      AEvtPostSignalAtMark(qcncObj, QCNCIFERROR);
  } // if

  /* ---- FLOW 1 (Connected) ---- */
  AFuncReportResult(theSystem, 1, "");
} // OQcncConnectFunc