コード例 #1
1
void lzham_debug_break(void)
{
#if LZHAM_USE_WIN32_API
   DebugBreak();
#endif   
}
コード例 #2
0
ファイル: ntpd.c プロジェクト: kernel9709/gsoc-ntp-2013
/*
 * library_fatal_error - Handle fatal errors from our libraries.
 */
static void
library_fatal_error(
	const char *file,
	int line,
	const char *format,
	va_list args
	)
{
	char errbuf[256];

	isc_error_setfatal(NULL);  /* Avoid recursion */

	msyslog(LOG_ERR, "%s:%d: fatal error:", file, line);
	vsnprintf(errbuf, sizeof(errbuf), format, args);
	msyslog(LOG_ERR, "%s", errbuf);
	msyslog(LOG_ERR, "exiting (due to fatal error in library)");

#if defined(DEBUG) && defined(SYS_WINNT)
	if (debug)
		DebugBreak();
#endif

	abort();
}
コード例 #3
0
ファイル: mem.c プロジェクト: chunhualiu/OpenNT
/****************************************************************************
 *                                                                          *
 *  FUNCTION   : DbgFree()                                                  *
 *                                                                          *
 *  PURPOSE    : To free an object allocated with DbgAlloc().  Checks the   *
 *               object array to make sure an object isn't freed twice.     *
 *                                                                          *
 *  RETURNS    :                                                            *
 *                                                                          *
 ****************************************************************************/
PSTR DbgFree(
register PSTR p)
{
    register WORD i;

    if (p == NULL) 
        return p;
        
    for (i = 0; i < cptrs; i++) {
        if (aptrs[i] == p) {
            aptrs[i] = aptrs[cptrs - 1];
            break;
        }
    }
    if (i == cptrs) {
        OutputDebugString("Free on non-allocated object");
        DebugBreak();
    } else {
        LocalUnlock((HANDLE)p);
        p = (PSTR)LocalFree((HANDLE)p);
    }
    cptrs--;
    return p;
}
コード例 #4
0
ファイル: global.cpp プロジェクト: 18859966862/ppsspp
bool CompilePixelShader(const char * code, LPDIRECT3DPIXELSHADER9 * pShader, LPD3DXCONSTANTTABLE * pShaderTable) {
	LPD3DXCONSTANTTABLE shaderTable = *pShaderTable;

	ID3DXBuffer* pShaderCode = NULL;
	ID3DXBuffer* pErrorMsg = NULL;

	HRESULT hr = -1;

#ifdef _XBOX
	// Compile pixel shader.
	hr = D3DXCompileShader( code, 
		(UINT)strlen( code ),
		NULL, 
		NULL, 
		"main", 
		"ps_3_0", 
		0, 
		&pShaderCode, 
		&pErrorMsg,
		pShaderTable );
#endif
	if( FAILED(hr) )
	{
		OutputDebugStringA((CHAR*)pErrorMsg->GetBufferPointer());
		DebugBreak();
		return false;
	}

	// Create pixel shader.
	pD3Ddevice->CreatePixelShader( (DWORD*)pShaderCode->GetBufferPointer(), 
		pShader );

	pShaderCode->Release();

	return true;
}
コード例 #5
0
ファイル: GifSmileyCtrl.cpp プロジェクト: hgl888/TeamTalk
Bitmap * ImageItem::LoadImageFromFile(ATL::CString& strFilename, int nWidth, int nHeight)
{
	if ( !m_strFilename.CompareNoCase(strFilename) && nHeight==m_nHeight )
	{
		m_nRef++;
		return m_pBitmap;
	}
	else if ( m_pBitmap==NULL && m_nRef==0)
	{
		Size ImageSize(nWidth, nHeight);
		if (GetBitmapFromFile(m_pBitmap, strFilename, m_nFrameCount, m_FrameSize, ImageSize, m_pFrameDelays ))
		{
			m_nHeight = nHeight;
			m_nRef++;
			m_strFilename=strFilename;
			return m_pBitmap;
		}
		return NULL;

	}
	//NOT REACHABLE
	DebugBreak();
	return NULL;
}
コード例 #6
0
ファイル: misc.c プロジェクト: RareHare/reactos
/***********************************************************************
 *              AssertFail  (SETUPAPI.@)
 *
 * Shows an assert fail error messagebox
 *
 * PARAMS
 *   lpFile [I]         file where assert failed
 *   uLine [I]          line number in file
 *   lpMessage [I]      assert message
 *
 */
VOID WINAPI AssertFail(LPSTR lpFile, UINT uLine, LPSTR lpMessage)
{
    CHAR szModule[MAX_PATH];
    CHAR szBuffer[2048];
    LPSTR lpName;
//    LPSTR lpBuffer;

    TRACE("%s %u %s\n", lpFile, uLine, lpMessage);

    GetModuleFileNameA(hInstance, szModule, MAX_PATH);
    lpName = strrchr(szModule, '\\');
    if (lpName != NULL)
        lpName++;
    else
        lpName = szModule;

    wsprintfA(szBuffer,
              "Assertion failure at line %u in file %s: %s\n\nCall DebugBreak()?",
              uLine, lpFile, lpMessage);

    if (MessageBoxA(NULL, szBuffer, lpName, MB_SETFOREGROUND |
                    MB_TASKMODAL | MB_ICONERROR | MB_YESNO) == IDYES)
        DebugBreak();
}
コード例 #7
0
static int AddItemToGroup(struct ClcGroup *group,int iAboveItem)
{
	if (group==NULL) return 0;

	if(++group->contactCount>group->allocedCount) {
		group->allocedCount+=GROUP_ALLOCATE_STEP;
      //  if (group->contact) mir_free(group->contact);
		if(group->contact)	
		group->contact=(struct ClcContact*)mir_realloc(group->contact,sizeof(struct ClcContact)*group->allocedCount);
			else 
			group->contact=(struct ClcContact*)mir_alloc(sizeof(struct ClcContact)*group->allocedCount);
			
		if (group->contact==NULL||IsBadCodePtr((FARPROC)group->contact))
		{
			TRACE("!!!Bad Realloc AddItemToGroup");
			DebugBreak();
		}
	}
	memmove(group->contact+iAboveItem+1,group->contact+iAboveItem,sizeof(struct ClcContact)*(group->contactCount-iAboveItem-1));
    memset(&(group->contact[iAboveItem]),0,sizeof((group->contact[iAboveItem])));
	group->contact[iAboveItem].type=CLCIT_DIVIDER;
	//group->contact[iAboveItem].flags=0;
	memset(group->contact[iAboveItem].iExtraImage,0xFF,sizeof(group->contact[iAboveItem].iExtraImage));
  group->contact[iAboveItem].szText=NULL;
  group->contact[iAboveItem].szSecondLineText=NULL;
  group->contact[iAboveItem].szThirdLineText=NULL;
	//group->contact[iAboveItem].szText[0]='\0';
	//group->contact[iAboveItem].szSecondLineText[0]='\0';
	//group->contact[iAboveItem].szThirdLineText[0]='\0';
	//group->contact[iAboveItem].SubAllocated=0;
	//group->contact[iAboveItem].subcontacts=NULL;
	//group->contact[iAboveItem].SubExpanded=0;
	
	ClearRowByIndexCache();
	return iAboveItem;
}
コード例 #8
0
ファイル: DBStepNC.cpp プロジェクト: usnistgov/QIF
void CDBStepNC::ExecuteSql(CString tszSQL)
{
    HRESULT hr;
    try {

        CCommand<CDynamicAccessor, CRowset> commandInsert;
        //TCHAR tszSQL[] = _bstr_t(SQLCommandString);
        //hr = m_session.StartTransaction();
        if(FAILED(hr = commandInsert.Open(m_session,
                                          (LPCTSTR) tszSQL,
                                          NULL ,
                                          NULL,
                                          DBGUID_DBSQL,
                                          false)))
            DebugBreak();
        //if(FAILED(hr = m_session.Commit()))
        //	DebugBreak();


        //DatabaseConnection->BeginTrans();
//		SQLCommand->ActiveConnection = DatabaseConnection;
//		SQLCommand->CommandText = _bstr_t(SQLCommandString);
// 		SQLCommand->Execute(NULL, NULL, adCmdText);
    }
    catch(_com_error& e)
    {
        ATLTRACE("com error: %d - %s\n", e.Error(), (const char*)e.Description());
        Close();
        //DatabaseConnection->RollbackTrans();

    }
    //	DatabaseConnection->Commit();

    OutputDebugString("ExecuteSql Succeeded\n");

}
コード例 #9
0
ファイル: CIocpServer.cpp プロジェクト: brett19/cROSE
void CIocpServer::OnCompletionTrue( DWORD transfersize, ULONG_PTR key, CIocpIoData* iodata )
{
	CIocpSocket* client = m_Clients[key];
	if( client == 0 ) 
	{
		DebugBreak( );
		return;
	}
	if( transfersize > 0 )
	{
		iodata->bufferlen += transfersize;
		if( iodata->mode == IOMODE_RECV )
		{
			if( iodata->bufferlen == iodata->buffersize )
				client->RecvComplete( iodata );
			else
				client->RecvContinue( iodata );
		} else {
			if( iodata->bufferlen == iodata->buffersize )
				client->SendComplete( iodata );
			else
				client->SendContinue( iodata );
		}
	} else {
		client->CloseSocket( );
		g_IoDataPool.Release( iodata );

		client->m_Lock.Enter( );
		if( iodata->mode == IOMODE_RECV )
			client->m_RRefCount--;
		else
			client->m_SRefCount--;
		client->m_RefCount--;
		client->m_Lock.Leave( );
	}
};
コード例 #10
0
ファイル: wxdebug.cpp プロジェクト: DieBagger/MediaPortal-1
void WINAPI DbgAssert(LPCTSTR pCondition,LPCTSTR pFileName,INT iLine)
{
    if(g_fUseKASSERT)
    {
        DbgKernelAssert(pCondition, pFileName, iLine);
    }
    else
    {

        TCHAR szInfo[iDEBUGINFO];

        (void)StringCchPrintf(szInfo, NUMELMS(szInfo),TEXT("%s \nAt line %d of %s\nContinue? (Cancel to debug)"),
                 pCondition, iLine, pFileName);

        INT MsgId = MessageBoxOtherThread(NULL,szInfo,TEXT("ASSERT Failed"),
                                          MB_SYSTEMMODAL |
                                          MB_ICONHAND |
                                          MB_YESNOCANCEL |
                                          MB_SETFOREGROUND);
        switch (MsgId)
        {
          case IDNO:              /* Kill the application */

              FatalAppExit(FALSE, TEXT("Application terminated"));
              break;

          case IDCANCEL:          /* Break into the debugger */

              DebugBreak();
              break;

          case IDYES:             /* Ignore assertion continue execution */
              break;
        }
    }
}
コード例 #11
0
ファイル: nsDebugImpl.cpp プロジェクト: bringhurst/vbox
NS_IMETHODIMP 
nsDebugImpl::Abort(const char *aFile, PRInt32 aLine)
{
  InitLog();

   PR_LOG(gDebugLog, PR_LOG_ERROR, 
         ("###!!! Abort: at file %s, line %d", aFile, aLine));
   PR_LogFlush();
   fprintf(stderr, "\07 Abort\n");  fflush(stderr);
   fflush(stderr);

#if defined(_WIN32)
#ifdef _M_IX86
  long* __p = (long*) 0x7;
  *__p = 0x7;
#else /* _M_ALPHA */
  PR_Abort();
#endif
#elif defined(XP_MAC)
  ExitToShell();
#elif defined(XP_UNIX)
  PR_Abort();
#elif defined(XP_OS2)
  DebugBreak();
  return NS_OK;
#elif defined(XP_BEOS)
  {
#ifndef DEBUG_cls
	char buf[2000];
	sprintf(buf, "Abort: at file %s, line %d", aFile, aLine);
	DEBUGGER(buf);
#endif
  } 
#endif
  return NS_OK;
}
コード例 #12
0
ファイル: unexw32.c プロジェクト: aosm/emacs
/* Startup code for running on NT.  When we are running as the dumped
   version, we need to bootstrap our heap and .bss section into our
   address space before we can actually hand off control to the startup
   code supplied by NT (primarily because that code relies upon malloc ()).  */
void
_start (void)
{
  extern void mainCRTStartup (void);

#if 1
  /* Give us a way to debug problems with crashes on startup when
     running under the MSVC profiler. */
  if (GetEnvironmentVariable ("EMACS_DEBUG", NULL, 0) > 0)
    DebugBreak ();
#endif

  /* Cache system info, e.g., the NT page size.  */
  cache_system_info ();

  /* Grab our malloc arena space now, before CRT starts up. */
  init_heap ();

  /* This prevents ctrl-c's in shells running while we're suspended from
     having us exit.  */
  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);

  /* Prevent Emacs from being locked up (eg. in batch mode) when
     accessing devices that aren't mounted (eg. removable media drives).  */
  SetErrorMode (SEM_FAILCRITICALERRORS);

  /* Invoke the NT CRT startup routine now that our housecleaning
     is finished.  */
#ifdef HAVE_NTGUI
  /* determine WinMain args like crt0.c does */
  hinst = GetModuleHandle(NULL);
  lpCmdLine = GetCommandLine();
  nCmdShow = SW_SHOWDEFAULT;
#endif
  mainCRTStartup ();
}
コード例 #13
0
ファイル: dacfn.cpp プロジェクト: krk/coreclr
// Similar to DacGetTargetAddrForHostAddr above except that ptr can represent any pointer within a host data
// structure marshalled from the target (rather than just a pointer to the first field).
TADDR
DacGetTargetAddrForHostInteriorAddr(LPCVOID ptr, bool throwEx)
{
    // Our algorithm for locating the containing DAC instance will search backwards through memory in
    // DAC_INSTANCE_ALIGN increments looking for a valid header. The following constant determines how many of
    // these iterations we'll perform before deciding the caller made a mistake and didn't marshal the
    // containing instance from the target to the host properly. Lower values will determine the maximum
    // offset from the start of a marshalled structure at which an interior pointer can appear. Higher values
    // will bound the amount of time it takes to report an error in the case where code has been incorrectly
    // DAC-ized.
    const DWORD kMaxSearchIterations = 100;

#ifdef _PREFIX_

    // Dac accesses are not interesting for PREfix and cause alot of PREfix noise
    // so we just return the unmodified pointer for our PREFIX builds
    return (TADDR) ptr;

#else // !_PREFIX_

    // Preserve special pointer values.
    if (ptr == NULL || ((TADDR) ptr == (TADDR)-1))
    {
        return 0;
    }
    else
    {
        TADDR addr = 0;
        HRESULT status = E_FAIL;

        EX_TRY
        {
            // We're going to search backwards through memory from the pointer looking for a valid DAC
            // instance header. Initialize this search pointer to the first legal value it could hold.
            // Intuitively this would be ptr - sizeof(DAC_INSTANCE), but DAC_INSTANCE headers are further
            // constrained to lie on DAC_INSTANCE_ALIGN boundaries. DAC_INSTANCE_ALIGN is large (16 bytes) due
            // to the need to keep the marshalled structure also aligned for any possible need, so we gain
            // considerable performance from only needing to test for DAC_INSTANCE headers at
            // DAC_INSTANCE_ALIGN aligned addresses.
            DAC_INSTANCE * inst = (DAC_INSTANCE*)(((ULONG_PTR)ptr - sizeof(DAC_INSTANCE)) & ~(DAC_INSTANCE_ALIGN - 1));

            // When code is DAC'ized correctly then our search algorithm is guaranteed to terminate safely
            // before reading memory that doesn't belong to the containing DAC instance. Since people do make
            // mistakes we want to limit how long and far we search however. The counter below will let us
            // assert if we've likely tried to locate an interior host pointer in a non-marshalled structure.
            DWORD cIterations = 0;

            bool tryAgain = false;

            // Scan backwards in memory looking for a DAC_INSTANCE header.
            while (true)
            {
                // Step back DAC_INSTANCE_ALIGN bytes at a time (the initialization of inst above guarantees
                // we start with an aligned pointer value. Stop every time our potential DAC_INSTANCE header
                // has a correct signature value.
                while (tryAgain || inst->sig != DAC_INSTANCE_SIG)
                {
                    tryAgain = false;
                    inst = (DAC_INSTANCE*)((BYTE*)inst - DAC_INSTANCE_ALIGN);

                    // If we've searched a lot of memory (currently 100 * 16 == 1600 bytes) without success,
                    // then assume this is due to an issue DAC-izing code (if you really do have a field within a
                    // DAC marshalled structure whose offset is >1600 bytes then feel free to update the
                    // constant at the start of this method).
                    if (++cIterations > kMaxSearchIterations)
                    {
                        status = E_INVALIDARG;
                        break;
                    }
                }

                // Fall through to a DAC error if we searched too long without finding a header candidate.
                if (status == E_INVALIDARG)
                    break;

                // Validate our candidate header by looking up the target address it claims to map in the
                // instance hash. The entry should both exist and correspond exactly to our candidate instance
                // pointer.
                // TODO: but what if the same memory was marshalled more than once (eg. once as a DPTR, once as a VPTR)?
                if (inst == g_dacImpl->m_instances.Find(inst->addr))
                {
                    // We've found a valid DAC instance. Now validate that the marshalled structure it
                    // represents really does enclose the pointer we're asking about. If not, someone hasn't
                    // marshalled a containing structure before trying to map a pointer within that structure
                    // (we've just gone and found the previous, unrelated marshalled structure in host memory).
                    BYTE * parent = (BYTE*)(inst + 1);
                    if (((BYTE*)ptr + sizeof(LPCVOID)) <= (parent + inst->size))
                    {
                        // Everything checks out: we've found a DAC instance header and its address range
                        // encompasses the pointer we're interested in. Compute the corresponding target
                        // address by taking into account the offset of the interior pointer into its
                        // enclosing structure.
                        addr = inst->addr + ((BYTE*)ptr - parent);
                        status = S_OK;
                    }
                    else
                    {
                        // We found a valid DAC instance but it doesn't cover the address range containing our
                        // input pointer. Fall though to report an erroring DAC-izing code.
                        status = E_INVALIDARG;
                    }
                    break;
                }
                else
                {
                    // This must not really be a match, perhaps a coincidence?
                    // Keep searching
                    tryAgain = true;
                }
            }
        }
        EX_CATCH
        {
            status = E_INVALIDARG;
        }
        EX_END_CATCH(SwallowAllExceptions)

        if (status != S_OK)
        {
            if (g_dacImpl && g_dacImpl->m_debugMode)
            {
                DebugBreak();
            }

            if (throwEx)
            {
                // This means a pointer was supplied which doesn't actually point to somewhere in a marshalled
                // DAC instance.
                _ASSERTE_MSG(false, "DAC coding error: Attempt to get target address from a host interior "
                                    "pointer which is not an instance marshalled by DAC!");
                DacError(status);
            }
        }

        return addr;
    }
#endif // !_PREFIX_
}
コード例 #14
0
ファイル: dacfn.cpp プロジェクト: krk/coreclr
TADDR
DacGetTargetAddrForHostAddr(LPCVOID ptr, bool throwEx)
{
#ifdef _PREFIX_

    // Dac accesses are not interesting for PREfix and cause alot of PREfix noise
    // so we just return the unmodified pointer for our PREFIX builds
    return (TADDR) ptr;

#else // !_PREFIX_

    // Preserve special pointer values.
    if (ptr == NULL || ((TADDR) ptr == (TADDR)-1))
    {
        return 0;
    }
    else
    {
        TADDR addr = 0;
        HRESULT status = E_FAIL;

        EX_TRY
        {
            DAC_INSTANCE* inst = (DAC_INSTANCE*)ptr - 1;
            if (inst->sig == DAC_INSTANCE_SIG)
            {
                addr = inst->addr;
                status = S_OK;
            }
            else
            {
                status = E_INVALIDARG;
            }
        }
        EX_CATCH
        {
            status = E_INVALIDARG;
        }
        EX_END_CATCH(SwallowAllExceptions)

        if (status != S_OK)
        {
            if (g_dacImpl && g_dacImpl->m_debugMode)
            {
                DebugBreak();
            }

            if (throwEx)
            {
                // This means a pointer was supplied which doesn't actually point to the beginning of 
                // a marshalled DAC instance.
                _ASSERTE_MSG(false, "DAC coding error: Attempt to get target address from a host pointer "
                                    "which is not an instance marshalled by DAC!");
                DacError(status);
            }
        }

        return addr;
    }

#endif // !_PREFIX_
}
コード例 #15
0
ファイル: Debug.hpp プロジェクト: mattgreen/openim
		static void Break()
		{
			DebugBreak();
		}
コード例 #16
0
ファイル: osdep.c プロジェクト: changloong/gool
/*
    system halt on psError when built HALT_ON_PS_ERROR 
*/
void osdepBreak(void)
{
     DebugBreak();
}
コード例 #17
0
ファイル: ldr.cpp プロジェクト: lslx/patchframe
int main_f()
{	
	lpMyReserved = &__ImageBase;
	//simulation the host exe
	//HMEMORYMODULE hMemMod = LoadMemDll("patchframe.dll");

	unsigned char *buffer = (unsigned char*)VirtualAlloc(NULL, iPeModLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	memcpy(buffer, PeMod, iPeModLen);
	typedef ULONG_PTR (WINAPI *PF_ReflectiveLoader)(LPVOID lpParameter);
	PF_ReflectiveLoader pPF_ReflectiveLoader = (PF_ReflectiveLoader)GetRefLdrOffset((char*)buffer, "_ReflectiveLoader@4");
	if (pPF_ReflectiveLoader)
		pPF_ReflectiveLoader(lpMyReserved);
	
	//HMEMORYMODULE hMemMod = MemoryLoadLibrary(PeMod, iPeModLen);
	//HMODULE hMod = LoadLibraryA("patchframe.dll");
	//HMODULE hMod = LoadLibraryA("G:\\dev_code_x\\patchframe\\Debug\\patchframe.dll");

	// call in the dll and not return
	Sleep(INFINITE);
	DebugBreak();
	return 0;

	unsigned char *buf;
	unsigned int bufsize;
	buf = (unsigned char*)VirtualAlloc(NULL, bufsize + 5, MEM_COMMIT, PAGE_EXECUTE_READWRITE);


	//move self to another place and run
	PIMAGE_DOS_HEADER dos_header = &__ImageBase;
	PIMAGE_NT_HEADERS old_header = (PIMAGE_NT_HEADERS)&((const unsigned char *)(&__ImageBase))[dos_header->e_lfanew];
	DWORD dwProtect = 0;
	BOOL bChge = VirtualProtectEx(GetCurrentProcess(), &__ImageBase, old_header->OptionalHeader.SizeOfImage, PAGE_EXECUTE_READWRITE, &dwProtect);
	
	
	
	SYSTEM_INFO sysInfo;
	GetNativeSystemInfo(&sysInfo);
	size_t alignedImageSize = ALIGN_VALUE_UP(old_header->OptionalHeader.SizeOfImage, sysInfo.dwPageSize);

	// reserve memory for image of library
	// XXX: is it correct to commit the complete memory region at once?
	//      calling DllEntry raises an exception if we don't...
	unsigned char *code = (unsigned char *)VirtualAlloc(NULL,
			alignedImageSize,
			MEM_RESERVE | MEM_COMMIT,
			PAGE_READWRITE
			);
		if (code == NULL) {
			SetLastError(ERROR_OUTOFMEMORY);
			return NULL;
		};
	//do copy
		memcpy(code, dos_header, alignedImageSize);
		ptrdiff_t locationDelta = (ptrdiff_t)(code - old_header->OptionalHeader.ImageBase);

		bool isRelocated = PerformBaseRelocation(code, locationDelta);
		//fix the mem flag

		HANDLE hProcess = GetCurrentProcess();
		BOOL bExpandRegions = FALSE;
		BOOL bOk = TRUE;
		PVOID pvAddress = NULL;
		while (bOk) {

			VMQUERY vmq;
			bOk = VMQuery(hProcess, pvAddress, &vmq);

			if (bOk) {
				// Construct the line to be displayed, and add it to the list box.
				TCHAR szLine[1024];
// 				ConstructRgnInfoLine(hProcess, &vmq, szLine, _countof(szLine));
// 				ListBox_AddString(hWndLB, szLine);

				if (bExpandRegions) {
					for (DWORD dwBlock = 0; bOk && (dwBlock < vmq.dwRgnBlocks);
						dwBlock++) {

// 						ConstructBlkInfoLine(&vmq, szLine, _countof(szLine));
// 						ListBox_AddString(hWndLB, szLine);

						// Get the address of the next region to test.
						pvAddress = ((PBYTE)pvAddress + vmq.BlkSize);
						if (dwBlock < vmq.dwRgnBlocks - 1) {
							// Don't query the memory info after the last block.
							bOk = VMQuery(hProcess, pvAddress, &vmq);
						}
					}
				}

				// Get the address of the next region to test.
				pvAddress = ((PBYTE)vmq.pvRgnBaseAddress + vmq.RgnSize);
			}
		}
		CloseHandle(hProcess);


	int argsCount;
	arglist = CommandLineToArgvW(GetCommandLineW(), &argsCount);
	if (!arglist)
		return 0;

}
コード例 #18
0
int clock_gettime(clockid_t clock_id, struct timespec *tp)
{
    int rc = 0;

    if (clock_id == CLOCK_MONOTONIC)
    {
        static LARGE_INTEGER freq = { { 0, 0 } };
        LARGE_INTEGER counts;
        uint64_t t;

        QueryPerformanceCounter(&counts);
        if (freq.QuadPart == 0)
            QueryPerformanceFrequency(&freq);


#if __USE_REMOTE_IO_NL_DEVICE
#if defined(_DEBUG) && defined(_WIN32)
		if (!g_initialCounts)
		{
			//remote io: set the g_initialCounts here.
			DebugBreak();

			//must be set manually in the debugger:
			assert(g_initialCounts > 0);
			assert(counts.QuadPart > g_initialCounts);

			//'add' 2 mins to the cur time: we started the userspace ~2 mins after we started the kernel
			counts.QuadPart -= (freq.QuadPart * 2 * 60);

			g_deltaCounts = counts.QuadPart - g_initialCounts;
			counts.QuadPart = g_initialCounts;

			assert(g_deltaCounts > 0);
		}

		else
		{
			assert(g_deltaCounts > 0);
			assert(counts.QuadPart > g_deltaCounts);
			counts.QuadPart -= g_deltaCounts;
		}
#endif
#endif

        tp->tv_sec = counts.QuadPart / freq.QuadPart;
        /* Get the difference between the number of ns stored
        * in 'tv_sec' and that stored in 'counts' */
        t = tp->tv_sec * freq.QuadPart;
        t = counts.QuadPart - t;
        /* 't' now contains the number of cycles since the last second.
        * We want the number of nanoseconds, so multiply out by 1,000,000,000
        * and then divide by the frequency. */
        t *= 1000000000;
        tp->tv_nsec = t / freq.QuadPart;
    }
    else if (clock_id == CLOCK_REALTIME)
    {
        /* clock_gettime(CLOCK_REALTIME,...) is just an alias for gettimeofday with a
        * higher-precision field. */
        struct timeval tv;
        gettimeofday(&tv, NULL);
        tp->tv_sec = tv.tv_sec;
        tp->tv_nsec = tv.tv_usec * 1000;
    }
    else {
        errno = EINVAL;
        rc = -1;
    }

    return rc;
}
コード例 #19
0
ファイル: globalswin32.cpp プロジェクト: cran/muscle
void Break()
	{
	if (IsDebuggerPresent())
		DebugBreak();
	}
コード例 #20
0
ファイル: RegExtractor.cpp プロジェクト: 340211173/hf-2011
BOOL CRegExtractorGUI::ExtractRealRegistryValues(BOOL bRegistryView32,EmulatedRegistry::CHostKey* pHostKey,OUT BOOL* pErrorDetectedDuringExtraction)
{
    BOOL bSuccess = TRUE;
    HKEY hBaseKey = NULL;
    HKEY hRemoteBaseKey = NULL;
    HKEY hKey = NULL;
    TCHAR* RelatvePathFromBaseKey = NULL;
    *pErrorDetectedDuringExtraction = FALSE;
    
    ////////////////////////////////////////////////////
    // for pHostKey->KeysFilteringType == KeysFilteringType_ONLY_SPECIFIED; only
    ////////////////////////////////////////////////////
#ifdef _DEBUG
    if (pHostKey->KeysFilteringType != EmulatedRegistry::CHostKey::KeysFilteringType_ONLY_SPECIFIED)
        DebugBreak();
#endif    
    
    REGSAM RegSam = KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | KEY_READ;
    this->GetRegistryView(bRegistryView32,&RegSam);

    // for each specified key   
    std::vector<std::tstring*>::iterator iSpecifiedKeys;
    for (iSpecifiedKeys = pHostKey->SpecifiedKeys.begin();iSpecifiedKeys!=pHostKey->SpecifiedKeys.end();iSpecifiedKeys++)
    {
        std::tstring* pString = *iSpecifiedKeys;

        // get base key name and relative key from base key
        if (!this->GetBaseKeyFromFullPath((TCHAR*)pString->c_str(),&hBaseKey,&RelatvePathFromBaseKey))
        {
            free(RelatvePathFromBaseKey);
            return FALSE;
        }    
        
        // get base key
        if (pHostKey->IsLocalHost())
        {
            bSuccess = (::RegOpenKeyEx(hBaseKey,RelatvePathFromBaseKey,0,RegSam,&hKey) == ERROR_SUCCESS);
        }
        else // remote host
        {
            // remote registry must be enabled : see MSDN RegConnectRegistry for informations
            bSuccess = (::RegConnectRegistry((TCHAR*)pHostKey->KeyName.c_str(),hBaseKey,&hRemoteBaseKey) == ERROR_SUCCESS);
            if (bSuccess)
                bSuccess = (::RegOpenKeyEx(hRemoteBaseKey,RelatvePathFromBaseKey,0,RegSam,&hKey) == ERROR_SUCCESS);
        }
        
        // in case of success 
        if (bSuccess)
        {
            // create tree to subkey inside emulated registry
            TCHAR* pSplitter;
            TCHAR* LocalBuffer;
            TCHAR* KeyName;
            LocalBuffer = _tcsdup((TCHAR*)pString->c_str());
            KeyName = LocalBuffer;
            
            EmulatedRegistry::CKeyReplace* pUpperKey = (EmulatedRegistry::CKeyReplace*)pHostKey;
            EmulatedRegistry::CKeyReplace* pKey;

            pSplitter = KeyName; // provide a not empty value for splitter
            while(pSplitter)
            {
                pSplitter = _tcschr(KeyName,'\\');
                if (pSplitter)
                {
                    *pSplitter = 0;
                }
                if (!*KeyName)
                    break;
                pKey = pUpperKey->GetOrAddSubKey(KeyName);
                pUpperKey = pKey;
                KeyName = pSplitter+1;
            }
            free(LocalBuffer);
            
            // extract key values
            *pErrorDetectedDuringExtraction = *pErrorDetectedDuringExtraction || (!this->ExtractRealRegistryValues(bRegistryView32,pKey,hKey));
        }
        else
        {
            TCHAR Msg[2048];
            _sntprintf(Msg,2048, _T("Error opening key %s"),pString->c_str());
            this->ReportError(Msg);
            *pErrorDetectedDuringExtraction = TRUE;
        }
        
        // free memory
        free(RelatvePathFromBaseKey);
        if (hKey)
            ::RegCloseKey(hKey);
        if (hRemoteBaseKey)
            ::RegCloseKey(hRemoteBaseKey);
    
    }
    
    // return success status
    return bSuccess;
}
コード例 #21
0
ファイル: 40745.c プロジェクト: AlexxNica/exploit-database
int or_address_value_4(__in void* pAddress)
{
	WNDCLASSEXW stWC = {0};

	HWND	hWndParent = NULL;
	HWND	hWndChild = NULL;

	WCHAR*	pszClassName = L"cve-2016-7255";
	WCHAR*	pszTitleName = L"cve-2016-7255";

	void*	pId = NULL;
	MSG		stMsg = {0};

	do 
	{

		stWC.cbSize = sizeof(stWC);
		stWC.lpfnWndProc = DefWindowProcW;
		stWC.lpszClassName = pszClassName;
		
		if ( 0 == RegisterClassExW(&stWC) )
		{
			break;
		}

		hWndParent = CreateWindowExW(
			0,
			pszClassName,
			NULL,
			WS_OVERLAPPEDWINDOW|WS_VISIBLE,
			0,
			0,
			360,
			360,
			NULL,
			NULL,
			GetModuleHandleW(NULL),
			NULL
		);

		if (NULL == hWndParent)
		{
			break;
		}

		hWndChild = CreateWindowExW(
			0,
			pszClassName,
			pszTitleName,
			WS_OVERLAPPEDWINDOW|WS_VISIBLE|WS_CHILD,
			0,
			0,
			160,
			160,
			hWndParent,
			NULL,
			GetModuleHandleW(NULL),
			NULL
		);
		
		if (NULL == hWndChild)
		{
			break;
		}

		#ifdef _WIN64
			pId = ( (UCHAR*)pAddress - 0x28 ); 
		#else
			pId = ( (UCHAR*)pAddress - 0x14); 
		#endif // #ifdef _WIN64
		
		SetWindowLongPtr(hWndChild , GWLP_ID , (LONG_PTR)pId );

		DbgPrint("hWndChild = 0x%p\n" , hWndChild);
		DebugBreak();

		ShowWindow(hWndParent , SW_SHOWNORMAL);

		SetParent(hWndChild , GetDesktopWindow() );

		SetForegroundWindow(hWndChild);

		_sim_alt_shift_tab(4);
		
		SwitchToThisWindow(hWndChild , TRUE);
		
		_sim_alt_shift_esc();


		while( GetMessage(&stMsg , NULL , 0 , 0) )
		{	
			TranslateMessage(&stMsg);
			DispatchMessage(&stMsg);
		}
	

	} while (FALSE);

	if ( NULL != hWndParent )
	{
		DestroyWindow(hWndParent);
		hWndParent = NULL;
	}

	if ( NULL != hWndChild )
	{
		DestroyWindow(hWndChild);
		hWndChild = NULL;
	}

	UnregisterClassW(pszClassName , GetModuleHandleW(NULL) );

	return 0;
}
コード例 #22
0
ファイル: LyricsDlg.cpp プロジェクト: Feoggou/gen_ym10
void CLyricsDlg::OnOk(HWND hDlg)
{
	CLyricsDlg* pThis = (CLyricsDlg*)GetWindowLongPtrA(hDlg, GWL_USERDATA);

	//we must check that all seconds were written correctly
	deque<CListSide::LINE>::iterator I, J;
	bool bWrong = false;
	for (I = pThis->m_List.m_Table.m_Lines.begin(); I != pThis->m_List.m_Table.m_Lines.end(); I++)
	{
		//must not be the last
		if (I->nIndex != pThis->m_List.m_Table.m_Lines.back().nIndex)
		{
			J = I + 1;
			char str[7];
			GetWindowTextA(I->edSecond.m_hWnd, str, 7);
			string sec = str;
			int nrSec = atoi(sec.substr(0, 1).c_str());
			nrSec *= 60;
			int valI = nrSec;
			nrSec = atoi(sec.substr(2, 2).c_str());
			valI += nrSec;

			GetWindowTextA(J->edSecond.m_hWnd, str, 7);
			sec = str;
			nrSec = atoi(sec.substr(0, 1).c_str());
			nrSec *= 60;
			int valJ = nrSec;
			nrSec = atoi(sec.substr(2, 2).c_str());
			valJ += nrSec;
			if (valI >= valJ)
			{
				bWrong = true;
				break;
			}
		}
	}

	bool bWrong2 = true;

	for (I = pThis->m_List.m_Table.m_Lines.begin(); I != pThis->m_List.m_Table.m_Lines.end(); I++)
	{
		//must not be the last
		int len = GetWindowTextLength(I->edText.m_hWnd);
		if (len)
		{
			bWrong2 = false;
			break;
		}
	}

	if (bWrong2) bWrong = true;

	if (bWrong)
	{
		MessageBoxW(hDlg, L"Toate secundele trebuiesc setate în ordine crescătoare, te rog setează o valoare corectă", L"Repetiție", MB_ICONEXCLAMATION);
		//focus & selection
		SetFocus(J->edSecond.m_hWnd);
		SendMessage(J->edSecond.m_hWnd, EM_SETSEL, 0, 5);
		//scroll
		RECT rect;
		GetWindowRect(J->edSecond.m_hWnd, &rect);
		POINT pt = {rect.left, rect.top};
		ScreenToClient(GetParent(J->edSecond.m_hWnd), &pt);
		pThis->m_List.m_Table.ScrollTo(pt.y);
		return;
	}

	HANDLE hFile = OpenLyricsFile(hDlg);
	if (hFile == INVALID_HANDLE_VALUE) return;
	DWORD dwWritten;

	for (I = pThis->m_List.m_Table.m_Lines.begin(); I != pThis->m_List.m_Table.m_Lines.end(); I++)
	{
		GenListCtrl::VERSE verse;
		char* str = new char[7];
		GetWindowTextA(I->edSecond.m_hWnd, str, 7);

		//str e de forma mm:ss
		string sec = str;
		int nrSec = atoi(sec.substr(0, 1).c_str());
		nrSec *= 60;
		verse.nrSec = nrSec;
		nrSec = atoi(sec.substr(2, 2).c_str());
		verse.nrSec += nrSec;
		WriteFile(hFile, &verse.nrSec, sizeof(WORD), &dwWritten, 0);
		delete[] str;

		byte len = (byte)GetWindowTextLengthA(I->edText.m_hWnd);
		len++;
		str = new char[len];
		GetWindowTextA(I->edText.m_hWnd, str, len);
		WriteFile(hFile, &len, 1, &dwWritten, 0);
		WriteFile(hFile, str, len, &dwWritten, 0);
		delete[] str;
	}

	CloseHandle(hFile);

	if (genDll.m_sSavingSong == genDll.m_sCurrentSong)
		SendMessage(genDll.m_hWinamp, WM_COMMAND, IDC_WINAMP_STOP, 0);

	//we now rewrite the specified .mp3 file
	hFile = CreateFile(genDll.m_sSavingSong.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		DWORD dwError = GetLastError();
		char str[30];
		sprintf_s(str, 30, "Error 0x%x", dwError);
		MessageBoxA(genDll.m_hWinamp, str, "Error!", MB_ICONERROR);
#ifdef _DEBUG
		DebugBreak();
#endif
		EndDialog(hDlg, IDCANCEL);
		return;
	}

	//now, we search for ID3v1
	SetFilePointer(hFile, -128, 0, FILE_END);

	DWORD dwRead;
	ReadFile(hFile, &m_tagInfo, 128, &dwRead, 0);
	if (m_tagInfo.cT == 'T' && m_tagInfo.cA == 'A' && m_tagInfo.cG == 'G')
	{
		//it means the file already has an ID3v1. ensure that we read all (should always happen)
		if (dwRead != 128)
		{
			DWORD dwError = GetLastError();
			char str[30];
			sprintf_s(str, 30, "Error 0x%x", dwError);
			MessageBoxA(hDlg, str, "Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
			CloseHandle(hFile);
			EndDialog(hDlg, IDCANCEL);
			return;
		}

		//reposition again and write the new structure:
		SetFilePointer(hFile, -128, 0, FILE_END);
	}
	//else reposition to the end of file:
	else
	{
		memset(&m_tagInfo, 0, sizeof(m_tagInfo));
		m_tagInfo.cT = 'T'; m_tagInfo.cA = 'A'; m_tagInfo.cG = 'G';
		m_tagInfo.dGenre = 255;

		LARGE_INTEGER liSize;
		GetFileSizeEx(hFile, &liSize);

		SetFilePointer(hFile, 128, 0, FILE_END);
		if (false == SetEndOfFile(hFile))
		{
			DWORD dwError = GetLastError();
			int x = 0;
			x++;
		}

		GetFileSizeEx(hFile, &liSize);


		SetFilePointer(hFile, -128, 0, FILE_END);
	}

	GetDlgItemTextA(hDlg, IDC_ARTISTNAME, m_tagInfo.sArtistName, 30);
	GetDlgItemTextA(hDlg, IDC_ALBUMNAME, m_tagInfo.sAlbumName, 30);
	GetDlgItemTextA(hDlg, IDC_SONGNAME, m_tagInfo.sSongName, 30);

	if (false == WriteFile(hFile, &m_tagInfo, 128, &dwRead, 0))
	{
		DWORD dwError = GetLastError();
		char str[30];
		sprintf_s(str, "Error 0x%x", dwError);
		MessageBoxA(hDlg, str, "Error!", MB_ICONERROR);
#ifdef _DEBUG
		DebugBreak();
#endif
		CloseHandle(hFile);
		EndDialog(hDlg, IDCANCEL);
		return;
	}
	CloseHandle(hFile);

	//and finally, we add this lyrics info in the list.
	LYRICSINFO lyrinfo;
	lyrinfo.sAlbum = m_tagInfo.sAlbumName;
	lyrinfo.sArtist = m_tagInfo.sArtistName;
	lyrinfo.sSong = m_tagInfo.sSongName;
	lyrinfo.wsFileName = genDll.m_sSavingSong;
	genDll.m_LyricsFiles.push_back(lyrinfo);

	EndDialog(hDlg, IDOK);
}
コード例 #23
0
ファイル: mainwindow.cpp プロジェクト: Allen1203/bftrader
void MainWindow::on_actionDebugBreak_triggered()
{
    DebugBreak();
}
コード例 #24
0
ファイル: LyricsDlg.cpp プロジェクト: Feoggou/gen_ym10
HANDLE CLyricsDlg::OpenLyricsFile(HWND hDlg)
{
	//first, we get a key to the current user:
	HKEY hKey;
	char strError[30];
	
	if (0 != RegOpenCurrentUser(KEY_WRITE | KEY_READ, &hKey))
	{
		sprintf_s(strError, 30, "Error 0x%x.", GetLastError());
		MessageBoxA(genDll.m_hWinamp, strError, "Fatal Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
		return INVALID_HANDLE_VALUE;
	}

	if (0 != RegOpenKeyEx(hKey, L"Volatile Environment", 0, KEY_READ, &hKey))
	{
		sprintf_s(strError, 30, "Error 0x%x.", GetLastError());
		MessageBoxA(genDll.m_hWinamp, strError, "Fatal Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
		return INVALID_HANDLE_VALUE;
	}

	DWORD dwType;
	DWORD dwSize;
	wchar_t str[MAX_PATH];
	if (ERROR_SUCCESS != RegQueryValueEx(hKey, L"APPDATA", 0, &dwType, (LPBYTE)str, &dwSize))
//	if (ERROR_SUCCESS != RegGeValue(hKey, 0, L"APPDATA", RRF_RT_REG_SZ, &dwType, str, &dwSize))
	{
		sprintf_s(strError, 30, "Error 0x%x.", GetLastError());
		MessageBoxA(genDll.m_hWinamp, strError, "Fatal Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
		return INVALID_HANDLE_VALUE;
	}

	RegCloseKey(hKey);

	//create or open the directory:
	wstring wsPath = str;
	wsPath += L"\\Winamp";
	CreateDirectory(wsPath.data(), 0);
	wsPath += L"\\Plugins";
	CreateDirectory(wsPath.data(), 0);
	wsPath += L"\\Feoggou App";
	CreateDirectory(wsPath.data(), 0);
	wstring wsPath2 = wsPath;
	wsPath += L"\\*.lyr";

	//filename: 1.lyr, 2.lyr, ...

	//if the file does not exist, we create it. but we must make sure that that lyric does not exist.
	//file format:
	//HEADER:				'LYR'
	//						artist[30]
	//						album[30]
	//						song[30]
	//						.............
	//BODY:					sec (word)
	//						text len(byte)
	//						text (char*)

	//Get the data from the dialog. at least "Song" must be specified.
	char sSong[30], sArtist[30], sAlbum[30];
	GetDlgItemTextA(hDlg, IDC_SONGNAME, sSong, 30);
	GetDlgItemTextA(hDlg, IDC_ARTISTNAME, sArtist, 30);
	GetDlgItemTextA(hDlg, IDC_ALBUMNAME, sAlbum, 30);

	if (strlen(sSong) == 0)
	{
		MessageBoxA(hDlg, "Trebuie să specifici numele melodiei în caseta \"Melodie:\". ", "Salvare versuri", MB_ICONEXCLAMATION);
		return INVALID_HANDLE_VALUE;
	}
	
	if (strlen(sArtist) == 0)
	{
		int nResult = MessageBoxA(hDlg, "Este o idee bună să specifici numele artistului, dacă îl știi. Vrei să te întorci să îl scrii?", "Lipsește numele artistului", MB_ICONEXCLAMATION | MB_YESNO);
		if (nResult == IDYES) return INVALID_HANDLE_VALUE;
	}

	if (strlen(sAlbum) == 0)
	{
		int nResult = MessageBoxA(hDlg, "Este o idee bună să specifici numele albumului, dacă îl știi. Vrei să te întorci să îl scrii?", "Lipsește numele albumului", MB_ICONEXCLAMATION | MB_YESNO);
		if (nResult == IDYES) return INVALID_HANDLE_VALUE;
	}

	WIN32_FIND_DATA f_data;
	BOOL bResult =0;
	memset(&f_data, 0, sizeof(f_data));
	int fileNr = 0;
	HANDLE hSearch = FindFirstFile(wsPath.data(), &f_data);
	while (hSearch != INVALID_HANDLE_VALUE)
	{
		//make sure it is <number>.lyr
		wstring wsFileName = f_data.cFileName;
		wsFileName = wsFileName.erase(wsFileName.length() - 4, 4);
		fileNr = _wtoi(wsFileName.c_str());
		if (fileNr == 0) {FindNextFile(hSearch, &f_data); continue;}
		//we open the file:
		wstring sfn = wsPath2;
		sfn += '\\';
		sfn += f_data.cFileName;
		HANDLE hFile = CreateFile(sfn.c_str(), GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
		if (hFile == INVALID_HANDLE_VALUE) 
		{
			sprintf_s(strError, 30, "Error 0x%x has occured.", GetLastError());
			MessageBoxA(genDll.m_hWinamp, strError, "Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
			bResult = FindNextFile(hSearch, &f_data);
			if (bResult == 0 && GetLastError() == ERROR_NO_MORE_FILES) break;
			continue;
		}

		//we read the content
		char song[30] = "", artist[30] = "", album[30] = "", sLyr[3] = "";
		DWORD dwRead;
		ReadFile(hFile, sLyr, 3, &dwRead, 0);
		if (sLyr[0] != 'L' && sLyr[1] != 'Y' && sLyr[2] != 'R')
		{
			CloseHandle(hFile);
			bResult = FindNextFile(hSearch, &f_data);
			if (bResult == 0 && GetLastError() == ERROR_NO_MORE_FILES) break;
			continue;
		}

		ReadFile(hFile, artist, 30, &dwRead, 0);
		ReadFile(hFile, album, 30, &dwRead, 0);
		ReadFile(hFile, song, 30, &dwRead, 0);
		//now, how to check: first, song name: both must have it. check non-case sensitive.
		if (_stricmp(song, sSong) != 0)
		{
			CloseHandle(hFile);
			bResult = FindNextFile(hSearch, &f_data);
			if (bResult == 0 && GetLastError() == ERROR_NO_MORE_FILES) break;
			continue;
		}
		//otherwise, at least album or artist must exist and differ.
		bool art_dif = false, alb_dif = false;
		if (strlen(artist) == 0 || strlen(sArtist) == 0) art_dif = true;
		if (strlen(album) == 0 || strlen(sAlbum) == 0) alb_dif = true;

		if (!art_dif && !alb_dif)
		{
			string mesaj = "Un fișier de versuri cu același nume de melodie există deja.\n";
			if (strlen(artist)) {mesaj += "Numele artistului: "; mesaj += artist; mesaj += '\n';}
			if (strlen(album)) {mesaj += "Numele albumului: "; mesaj += album; mesaj += '\n';}
			mesaj += "Vrei să îl înlocuiești?";
			int nResult = MessageBoxA(hDlg, mesaj.data(), "Versuri deja existente", MB_ICONINFORMATION | MB_YESNO);
			CloseHandle(hFile);
			if (nResult == IDYES)
			{
				fileNr--;
				break;
			}
			else return INVALID_HANDLE_VALUE;
		}
		CloseHandle(hFile);

		bResult = FindNextFile(hSearch, &f_data);
		if (bResult == 0 && GetLastError() == ERROR_NO_MORE_FILES) break;
	}
	FindClose(hSearch);

	fileNr++;
	wchar_t file_name[10];
	_itow_s(fileNr, file_name, 10, 10);
	wsPath2 += L"\\";
	wsPath2 += file_name;
	wsPath2 += L".lyr";

	//we create the file
	HANDLE hNewFile = CreateFile(wsPath2.c_str(), GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

	DWORD dwWritten;
	WriteFile(hNewFile, "LYR", 3, &dwWritten, 0);
	WriteFile(hNewFile, sArtist, 30, &dwWritten, 0);
	WriteFile(hNewFile, sAlbum, 30, &dwWritten, 0);
	WriteFile(hNewFile, sSong, 30, &dwWritten, 0);

	return hNewFile;
}
コード例 #25
0
ファイル: Debug.cpp プロジェクト: aminere/StarportsPublic
	//! Warning
	void Debug::Warning(bool bCondition, const char* strFile, int line, const char* strFormat, ...)
	{
		if(!bCondition)
		{
			char buffer[2048];
			va_list va; 
			va_start(va, strFormat);
			vsprintf(buffer, strFormat, va);
			va_end(va);

			std::stringstream ss(std::stringstream::in | std::stringstream::out);
			ss << strFile << " @" << line << ": " << buffer;
			std::string str = ss.str();
			auto message = str.c_str();

			Log << "*** Warning ***\n" << message << "\n";				

#if SHOOT_PLATFORM == SHOOT_PLATFORM_WIN32
			int index = GetWarningIndex(strFile, line);
			if(index == -1)
			{
				// add new warning
				for(int i=0; i<MaxWarnings; ++i)
				{
					if(m_WarningInfos[i].bFree)
					{
						m_WarningInfos[i].bFree = false;
						m_WarningInfos[i].strFile = strFile;
						m_WarningInfos[i].Line = line;
						index = i;
						break;
					}
				}
			}

			if(index >= 0)
			{
				if(!m_WarningInfos[index].bDisabled)
				{
					auto choice = MessageBoxA(NULL, message, "Warning - Ignore / Debug / Continue", MB_CANCELTRYCONTINUE);
					switch(choice)
					{
					case IDCANCEL:
						m_WarningInfos[index].bDisabled = true;
						break;

					case IDTRYAGAIN:
						DebugBreak();
						break;

					case IDCONTINUE:
						m_WarningInfos[index].bDisabled = false;
						break;
					}
					m_WarningInfos[index].bFree = !m_WarningInfos[index].bDisabled;
				}
			}
			else
			{
				MessageBoxA(NULL, message, "Warning", MB_OK);
			}				
#endif
		}
	}
コード例 #26
0
ファイル: LyricsDlg.cpp プロジェクト: Feoggou/gen_ym10
void CLyricsDlg::UpdateByTagIDV2(HWND hDlg, HANDLE hFile, bool bArtist, bool bAlbum, bool bSong)
{
	//we fill the structure. we will see what kind it is:
	WINAMP_TAGV2 tagInfo;
	OVERLAPPED overl;
	DWORD dwRead;
	memset(&overl, 0, sizeof(overl));
	overl.Offset = 0;
	overl.hEvent = 0;
	ReadFile(hFile, &tagInfo, 10, &dwRead, &overl);
	GetOverlappedResult(hFile, &overl, &dwRead, true);

	if (dwRead < 10)
	{
		DWORD dwError = GetLastError();
		char str[10];
		sprintf_s(str, 10, "Error 0x%x", dwError);
		MessageBoxA(hDlg, str, "Error!", MB_ICONERROR);
#ifdef _DEBUG
		DebugBreak();
#endif
		EndDialog(hDlg, IDCANCEL);
		return;
	}

	if (tagInfo.cI == 'I' && tagInfo.cD == 'D' && tagInfo.c3 == '3')
	{
		DWORD dwSize = (tagInfo.nSize[0] << 7) + (tagInfo.nSize[1] << 7) + (tagInfo.nSize[2] << 7) + tagInfo.nSize[3];
		byte* buffer = new byte[dwSize];
		overl.Offset = 10;
		ReadFile(hFile, buffer, dwSize, &dwRead, &overl);
		GetOverlappedResult(hFile, &overl, &dwRead, true);
		if (dwRead < dwSize)
		{
			DWORD dwError = GetLastError();
			char str[10];
			sprintf_s(str, 10, "Error 0x%x", dwError);
			MessageBoxA(hDlg, str, "Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
			EndDialog(hDlg, IDCANCEL);
			return;
		}

		if (tagInfo.nVer1 == 2)
		{
			FRAME20 frame;
			int care = 0;
			BYTE finished = 0;
			for (int i = 0; i < dwSize - 3; i++)
			{
				care = 0;
				if (buffer[i] == 'T' && buffer[i+1] == 'A' && buffer[i+2] == 'L' && bAlbum)
					care = 1;
				else if (buffer[i] == 'T' && buffer[i+1] == 'T' && buffer[i+2] == '2' && bSong)
					care = 2;
				else if (buffer[i] == 'T' && buffer[i+1] == 'P' && buffer[i+2] == '1' && bArtist)
					care = 3;
				else continue;

				frame.cName[0] = buffer[i];
				frame.cName[1] = buffer[i+1];
				frame.cName[2] = buffer[i+2];

				frame.size[0] = buffer[i+3]; frame.size[1] = buffer[i+4]; frame.size[2] = buffer[i+5];
				DWORD dwSize = (buffer[i+3] << 7) + (buffer[i+4] << 7) + buffer[i+5];

				frame.encoding = buffer[i+6];
				if (frame.encoding == 0)
				{
					frame.str = new char[dwSize];
					strcpy_s(frame.str, dwSize, (char*)(i+7+buffer));
					frame.str[dwSize-1] = 0;
				}
				else//unicode:
				{
					frame.wstr = new wchar_t[dwSize/2];
					frame.str = new char[dwSize/2];
					memcpy_s(frame.wstr, dwSize-1, (wchar_t*)(i+9+buffer), dwSize-1);
					for (int j = 0; j < dwSize/2; j++) {frame.str[j] = frame.wstr[j];}
					frame.str[dwSize/2-1] = 0;
				}

				if (care == 1)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_ALBUMNAME, frame.str);
					finished |= 1;
					bAlbum = true;
				}
				else if (care == 2)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_SONGNAME, frame.str);
					finished |= 2;
					bSong = true;
				}
				else if (care == 3)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_ARTISTNAME, frame.str);
					finished |= 4;
					bArtist = true;
				}

				if (frame.str) delete[] frame.str;

				if (finished == 7) break;
			}
		}
		else if (tagInfo.nVer1 == 3 || tagInfo.nVer1 == 4)
		{
			FRAME34 frame;
			int care = 0;
			BYTE finished = 0;
			for (int i = 0; i < dwSize - 3; i++)
			{
				care = 0;
				if (buffer[i] == 'T' && buffer[i+1] == 'A' && buffer[i+2] == 'L' && buffer[i+3] == 'B' && bAlbum)
					care = 1;
				else if (buffer[i] == 'T' && buffer[i+1] == 'I' && buffer[i+2] == 'T' && buffer[i+3] == '2' && bSong)
					care = 2;
				else if (buffer[i] == 'T' && buffer[i+1] == 'P' && buffer[i+2] == 'E' && buffer[i+3] == '1' && bArtist)
					care = 3;
				else continue;
				
				frame.cName[0] = buffer[i];
				frame.cName[1] = buffer[i+1];
				frame.cName[2] = buffer[i+2];
				frame.cName[3] = buffer[i+3];

				frame.size[0] = buffer[i+4]; frame.size[1] = buffer[i+5]; frame.size[2] = buffer[i+6]; frame.size[3] = buffer[i+7];
				DWORD dwSize = (buffer[i+4] << 7) + (buffer[i+5] << 7) + (buffer[i+6] << 7) + buffer[i+7];
				
				frame.flags = MAKEWORD(buffer[i+8], buffer[i+9]);
				frame.encoding = buffer[i+10];
				if (frame.encoding == 0 || frame.encoding == 3)
				{
					frame.str = new char[dwSize];
					frame.str[dwSize-1] = 0;

					memcpy_s(frame.str, dwSize-1, (char*)(i+11+buffer), dwSize-1);
					for (int k = 0; k < dwSize - 1; k++)
						if (isascii(frame.str[k]) == false)
						{
							delete[] frame.str;
							frame.str = 0;
							break;
						}
//					strcpy_s(frame.str, dwSize + 1, (char*)(i+11+buffer));
				}
				else
				{
					frame.wstr = new wchar_t[dwSize/2];
					frame.wstr[dwSize/2-1] = 0;
					frame.str = new char[dwSize/2];
					memcpy_s(frame.wstr, dwSize-1, (wchar_t*)(i+13+buffer), dwSize-1);
					for (int j = 0; j < dwSize/2; j++) {frame.str[j] = frame.wstr[j];}
					frame.str[dwSize/2-1] = 0;
				}

				if (care == 1)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_ALBUMNAME, frame.str);
					finished |= 1;
					bAlbum = true;
				}
				else if (care == 2)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_SONGNAME, frame.str);
					finished |= 2;
					bSong = true;
				}
				else if (care == 3)
				{
					TrimString(frame.str);
					SetDlgItemTextA(hDlg, IDC_ARTISTNAME, frame.str);
					finished |= 4;
					bArtist = true;
				}

				if (frame.str) {delete[] frame.str; frame.str = 0;}
				if (frame.wstr) {delete[] frame.wstr; frame.str = 0;}

				if (finished == 7) break;
			}
		}

		delete[] buffer;
	}

	if (!bArtist || !bAlbum || !bSong)
		UpdateByFileName(hDlg, bArtist, bAlbum, bSong);
}
コード例 #27
0
ファイル: wxdebug.cpp プロジェクト: DragonZX/fdm2
void WINAPI DbgKernelAssert(const TCHAR *pCondition,const TCHAR *pFileName,INT iLine)
{
    DbgLog((LOG_ERROR,0,TEXT("Assertion FAILED (%s) at line %d in file %s"),
           pCondition, iLine, pFileName));
    DebugBreak();
}
コード例 #28
0
ファイル: LyricsDlg.cpp プロジェクト: Feoggou/gen_ym10
void CLyricsDlg::UpdateByTagIDV1(HWND hDlg)
{
	if (m_bIsSet)
	{
		if (GetWindowTextLengthA(GetDlgItem(hDlg, IDC_ARTISTNAME)) != 0 ||
			GetWindowTextLengthA(GetDlgItem(hDlg, IDC_ALBUMNAME)) != 0 ||
			GetWindowTextLengthA(GetDlgItem(hDlg, IDC_SONGNAME)) != 0)
		{
			return;
		}
	}

	genDll.m_sSavingSong = genDll.m_sCurrentSong;

	static WCHAR wstrlast[MAX_PATH] = L"";
	//now we load the tagInfo and display what we have
	
	if (wcslen(genDll.m_sCurrentSong) > 0 && 0 != wcscmp(wstrlast, genDll.m_sCurrentSong))
	{
		SetDlgItemTextA(hDlg, IDC_ARTISTNAME, "");
		SetDlgItemTextA(hDlg, IDC_ALBUMNAME, "");
		SetDlgItemTextA(hDlg, IDC_SONGNAME, "");

		bool bArtist = false;
		bool bAlbum = false;
		bool bSong = false;

		wcscpy_s(wstrlast, MAX_PATH, genDll.m_sCurrentSong);
		//load open the file for reading:
		HANDLE hFile = CreateFile(wstrlast, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED
, 0);
		if (hFile == INVALID_HANDLE_VALUE)
		{
			char errs[20];
			DWORD dwError = GetLastError();
			sprintf_s(errs, 20, "Error 0x%x", dwError);
			MessageBoxA(hDlg, errs, "Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
			return;
		}

		//so now, we have the file opened... we must load the last part of it:
		LARGE_INTEGER liSize;
		GetFileSizeEx(hFile, &liSize);
		DWORD dwRead;
		OVERLAPPED overl;
		memset(&overl, 0, sizeof(overl));
		overl.Offset = (DWORD)liSize.LowPart - 128;
		overl.hEvent = 0;
		ReadFile(hFile, &m_tagInfo, 128, &dwRead, &overl);
		GetOverlappedResult(hFile, &overl, &dwRead, true);

		if (m_tagInfo.cT == 'T' && m_tagInfo.cA == 'A' && m_tagInfo.cG == 'G')
		{
			if (dwRead != 128)
			{
				DWORD dwError = GetLastError();
				wsprintf(wstrlast, L"Error 0x%x", dwError);
				MessageBox(hDlg, wstrlast, L"Error!", MB_ICONERROR);
#ifdef _DEBUG
				DebugBreak();
#endif
				EndDialog(hDlg, IDCANCEL);
				return;
			}
			m_tagInfo.sAlbumName[29] = m_tagInfo.sArtistName[29] = m_tagInfo.sSongName[29] = 0;
			TrimString(m_tagInfo.sAlbumName);
			TrimString(m_tagInfo.sArtistName);
			TrimString(m_tagInfo.sSongName);

			SetDlgItemTextA(hDlg, IDC_ARTISTNAME, m_tagInfo.sArtistName);
			SetDlgItemTextA(hDlg, IDC_ALBUMNAME, m_tagInfo.sAlbumName);
			SetDlgItemTextA(hDlg, IDC_SONGNAME, m_tagInfo.sSongName);

			if (strlen(m_tagInfo.sArtistName) > 0) bArtist = true;
			if (strlen(m_tagInfo.sAlbumName) > 0) bAlbum = true;
			if (strlen(m_tagInfo.sSongName) > 0) bSong = true;
		}

		
		if (!bArtist || !bAlbum || !bSong)
			UpdateByTagIDV2(hDlg, hFile, bArtist, bAlbum, bSong);

		CloseHandle(hFile);
	}
}
コード例 #29
0
//--------------------------------------------------------------------------------------
// Name: Create()
// Desc: Initialize the class, create D3D and the font texture
//--------------------------------------------------------------------------------------
HRESULT Console::Create( LPCSTR strFontFileName, D3DCOLOR colBackColor,
                         D3DCOLOR colTextColor, UINT nLines )
{
    // Create Direct3D
    LPDIRECT3D9 pD3D = Direct3DCreate9( D3D_SDK_VERSION );

    // Check video mode settings
    XVIDEO_MODE VideoMode;
    ZeroMemory( &VideoMode, sizeof( VideoMode ) );
    XGetVideoMode( &VideoMode );

    BOOL bEnable720p = VideoMode.dwDisplayWidth >= 1280;

    m_d3dpp.BackBufferWidth = bEnable720p ? SCREEN_SIZE_X_720p : SCREEN_SIZE_X_DEFAULT;
    m_d3dpp.BackBufferHeight = bEnable720p ? SCREEN_SIZE_Y_720p : SCREEN_SIZE_Y_DEFAULT;

    // Calculate the safe area
    UINT uiSafeAreaPct = bEnable720p ? SAFE_AREA_PCT_HDTV : SAFE_AREA_PCT_4x3;

    m_cxSafeArea = ( m_d3dpp.BackBufferWidth * uiSafeAreaPct ) / 100;
    m_cySafeArea = ( m_d3dpp.BackBufferHeight * uiSafeAreaPct ) / 100;

    m_cxSafeAreaOffset = ( m_d3dpp.BackBufferWidth - m_cxSafeArea ) / 2;
    m_cySafeAreaOffset = ( m_d3dpp.BackBufferHeight - m_cySafeArea ) / 2;

    // Create the D3D device
    HRESULT hr = pD3D->CreateDevice( 0, D3DDEVTYPE_HAL, NULL,
                                     D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                     &m_d3dpp, ( ::D3DDevice** )&m_pd3dDevice );
    if( FAILED( hr ) )
    {
        ATG_PrintError( "Could not create D3D device!\n" );
        DebugBreak();
    }

    // Allow global access to the device
    g_pd3dDevice = m_pd3dDevice;

    // Create the font
    hr = m_Font.Create( strFontFileName );
    if( FAILED( hr ) )
    {
        ATG_PrintError( "Could not create font.\n" );
        DebugBreak();
    }

    // Save the colors
    m_colBackColor = colBackColor;
    m_colTextColor = colTextColor;

    // Calculate the number of lines on the screen
    FLOAT fCharWidth, fCharHeight;
    m_Font.GetTextExtent( L"i", &fCharWidth, &fCharHeight, FALSE );

    m_cScreenHeight = ( UINT )( m_cySafeArea / fCharHeight );
    m_cScreenWidth = ( UINT )( m_cxSafeArea / fCharWidth );

    m_cScreenHeightVirtual = max( m_cScreenHeight, nLines );

    m_fLineHeight = fCharHeight;

    // Allocate memory to hold the lines
    m_Buffer = new WCHAR[ m_cScreenHeightVirtual * ( m_cScreenWidth + 1 ) ];
    m_Lines = new WCHAR*[ m_cScreenHeightVirtual ];

    // Set the line pointers as indexes into the buffer
    for( UINT i = 0; i < m_cScreenHeightVirtual; i++ )
    {
        m_Lines[ i ] = m_Buffer + ( m_cScreenWidth + 1 ) * i;
    }

    m_bSuspendFlag = FALSE;

    // Clear the screen
    Clear();

    return hr;
}
コード例 #30
0
ファイル: LyricsDlg.cpp プロジェクト: Feoggou/gen_ym10
void CLyricsDlg::LoadFromFile(HWND hDlg)
{
	OPENFILENAME ofn;
	ZeroMemory(&ofn, sizeof(ofn));
	wchar_t strFile[260];

	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = hDlg;
	ofn.lpstrFilter = L"Fișiere Text (*.txt)\0*.txt\0\0";
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = strFile;
	ofn.lpstrFile[0] = 0;
	ofn.nMaxFile = sizeof(strFile);
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	// Display the Open dialog box. 

	if (GetOpenFileName(&ofn)==TRUE)
	{
		HANDLE hFile = CreateFile(ofn.lpstrFile, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES) NULL, 
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL);

		byte xch[2], ch;
		string str;
		byte dUnicode = 0;//0 = ANSI, 1 = UTF-8, 2 = UTF-16(FF FE) 3 = UTF-16BE (FE FF)
		DWORD dwRead;
		if (0 == ReadFile(hFile, xch, 2, &dwRead, 0))
		{
			MessageBoxA(hDlg, "Error! The file could not be read!", "Error!", MB_ICONERROR);
#ifdef _DEBUG
			DebugBreak();
#endif
			return;
		}

		if (xch[0]==0xFF && xch[1]==0xFE)
			dUnicode = 2;
		else if (xch[0]==0xFE && xch[1]==0xFF)
			dUnicode = 3;
		else if (!( __isascii(xch[0]) &&  __isascii(xch[1]) 
			|| iswascii(MAKEWORD(xch[0], xch[1]))))
		{
			if (MessageBoxW(hDlg, L"Fișierul ar putea fi afișat incorect datorită codării. Vrei să continui așa?", L"Problemă de codificare", MB_ICONEXCLAMATION | MB_YESNO) == IDNO)
				return;
		}

		if (!dUnicode)
			SetFilePointer(hFile, 0, 0, FILE_BEGIN);
		DWORD dwSize = GetFileSize(hFile, 0);
		byte* buffer = new byte[dwSize];
		ReadFile(hFile, buffer, dwSize, &dwRead, 0);
		if (dUnicode == 2)//FF FE
		{
//			while (ReadFile(hFile, xch, 2, &dwRead, 0) )
			for (int i = 0; i < dwSize-1; i += 2)
			{
				xch[0] = buffer[i]; xch[1] = buffer[i+1];
				if (xch[1]==0 && xch[0]!='\r') 
					str += xch[0];
			}
		}
		else if (dUnicode == 3)//FE FF
		{
			for (int i = 0; i < dwSize-1; i += 2)
			{
				xch[0] = buffer[i]; xch[1] = buffer[i+1];
				if (xch[0]==0 && xch[1]!='\r') 
					str += xch[1];
			}
		}
		else
		{
			for (int i = 0; i < dwSize; i++)
//			while (ReadFile(hFile, &ch, 1, &dwRead, 0))
			{
				ch = buffer[i];
				if (dwRead == 0) break;
				if (ch!='\r') str += ch;
			}
		}
		delete[] buffer;

		CloseHandle(hFile);
		SetList(hDlg, str);
	}
}