本文整理汇总了C++中OutputDebugString函数的典型用法代码示例。如果您正苦于以下问题:C++ OutputDebugString函数的具体用法?C++ OutputDebugString怎么用?C++ OutputDebugString使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OutputDebugString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WndProc2
//.........这里部分代码省略.........
case WM_ERASEBKGND:
return FALSE;
case WM_VSCROLL:
//((HWND)lParam)
switch(LOWORD(wParam))
{
case SB_LINEUP:
iVerPos += 5;
break;
case SB_LINEDOWN:
iVerPos -= 5;
break;
case SB_PAGEUP:
iVerPos += 20;
break;
case SB_PAGEDOWN:
iVerPos -= 20;
break;
case SB_THUMBPOSITION:
iVerPos = 100 - HIWORD(wParam);
//OutputDebugString("hello\n");
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
if (iVerPos < 5)
{
iVerPos = 0;
}
else if (iVerPos > 100)
{
iVerPos = 100;
}
stScrollInfoVer.fMask = SIF_POS;
stScrollInfoVer.nPos = 100 - iVerPos;
SetScrollInfo(hWnd, SB_VERT, &stScrollInfoVer, TRUE);
{
char dbg[255] = {0};
sprintf(dbg, "Ver:%d\n", stScrollInfoVer.nPos);
OutputDebugString(dbg);
}
break;
case WM_HSCROLL:
//((HWND)lParam)
switch(LOWORD(wParam))
{
case SB_LINEUP:
iHorPos += 5;
break;
case SB_LINEDOWN:
iHorPos -= 5;
break;
case SB_PAGEUP:
iHorPos += 20;
break;
case SB_PAGEDOWN:
iHorPos -= 20;
break;
case SB_THUMBPOSITION:
iHorPos = 100 - HIWORD(wParam);
//OutputDebugString("hello\n");
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
if (iHorPos < 5)
{
iHorPos = 0;
}
else if (iHorPos > 95)
{
iHorPos = 100;
}
stScrollInfoHor.fMask = SIF_POS;
stScrollInfoHor.nPos = 100 - iHorPos;
SetScrollInfo(hWnd, SB_HORZ, &stScrollInfoHor, TRUE);
{
char dbg[255] = {0};
sprintf(dbg, "Hor:%d\n", stScrollInfoHor.nPos);
OutputDebugString(dbg);
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
示例2: OutputDebugString
//-----------------------------------------------------------------------------
// Purpose: Draws text to the screen inside the given rectangular region, using the given font
//-----------------------------------------------------------------------------
bool CGameEngineGL::BDrawString( HGAMEFONT hFont, RECT rect, DWORD dwColor, DWORD dwFormat, const char *pchText )
{
if ( !hFont )
{
OutputDebugString( "Someone is calling BDrawString with a null font handle\n" );
return false;
}
if ( !pchText || !*pchText )
{
return true;
}
// Very simple cache of complete strings as whole textures.
// There are much better ways of doing efficient text rendering.
// If nothing else we should expire the strings not being used.
HGAMETEXTURE hTexture;
char szFontPrefix[32];
sprintf( szFontPrefix, "%d:", hFont );
std::map< std::string, HGAMETEXTURE >::iterator iter;
iter = m_MapStrings.find( std::string(szFontPrefix) + std::string(pchText) );
if ( iter == m_MapStrings.end() )
{
static SDL_Color white = { 0xff, 0xff, 0xff, 0xff };
// Calculate the text block size
int nWrapLength = 0;
int w, h;
char *s = (char *)pchText;
for ( char *p = strchr( s, '\n' ); p; p = strchr( s, '\n' ) )
{
*p = '\0';
if ( TTF_SizeUTF8( m_MapGameFonts[ hFont ], s, &w, &h ) == 0 )
{
nWrapLength = std::max( w, nWrapLength );
}
*p = '\n';
s = p + 1;
}
if ( TTF_SizeUTF8( m_MapGameFonts[ hFont ], s, &w, &h ) == 0 )
{
nWrapLength = std::max( w, nWrapLength );
}
SDL_Surface *surface = TTF_RenderUTF8_Blended_Wrapped( m_MapGameFonts[ hFont ], pchText, white, nWrapLength );
if ( !surface )
{
OutputDebugString( "Out of memory\n" );
return false;
}
uint32 uWidth = power_of_two( surface->w );
uint32 uHeight = power_of_two( surface->h );
byte *pRGBAData = (byte *)malloc( uWidth*uHeight*4 );
if ( !pRGBAData )
{
OutputDebugString( "Out of memory\n" );
return false;
}
memset( pRGBAData, 0, uWidth*uHeight*4 );
byte *src = (byte*)surface->pixels;
byte *dst = pRGBAData;
memset(dst, 0xff, uWidth*4);
for ( uint32 row = 0; row < surface->h; ++row )
{
memcpy( dst, src, surface->w * 4 );
src += surface->pitch;
dst += uWidth * 4;
}
hTexture = HCreateTexture( pRGBAData, uWidth, uHeight );
free( pRGBAData );
// Record the actual text width and height
m_MapTextures[ hTexture ].m_uWidth = surface->w;
m_MapTextures[ hTexture ].m_uHeight = surface->h;
SDL_FreeSurface( surface );
m_MapStrings[ std::string(szFontPrefix) + std::string(pchText) ] = hTexture;
}
else
{
hTexture = iter->second;
}
int nWidth = m_MapTextures[ hTexture ].m_uWidth;
int nHeight = m_MapTextures[ hTexture ].m_uHeight;
float u = (float)nWidth / power_of_two(nWidth);
float v = (float)nHeight / power_of_two(nHeight);
// Get text position
int nLeft = rect.left, nTop = rect.top;
if ( dwFormat & TEXTPOS_TOP )
{
nTop = rect.top;
//.........这里部分代码省略.........
示例3: switch
void cStatement::Do(){// Metodo para ejecutar Acciones
switch(meType){
case 1:{// eStatementRemove
// std::string lacObject = macParam1 + " Removed \n";
// OutputDebugString( lacObject.c_str());
cLevel &lLevel = cGame::Get().GetLevel();
lLevel.Remove( macParam1);
;}break;
case 2:{// eStatementMessage
// std::string lacObject = macParam1 + " Message Sended \n";
// OutputDebugString( lacObject.c_str());
cGame::Get().PrintMessage(macParam1);// le enviamos una solicitud que imprima el bendito mensaje a Game
;}break;
case 3:{// eStatementMove
// std::string lacObject = macParam1 + " moved to " + macParam2 + "\n";
// OutputDebugString( lacObject.c_str());
cLevel &lLevel = cGame::Get().GetLevel();
lLevel.Move( macParam1, macParam2[0]);
;}break;
case 4:{// eStatementConversation
// std::string lacObject = macParam1 + " moved to " + macParam2 + "\n";
// OutputDebugString( "\n Realizando conversación: \n");
cConversationManager::Get().StartConversation(macParam1); // macParam1 == "Comienzo"
;}break;
case 5:{// eStatementExit
cGame::Get().SetFinish(true);
;}break;
case 6:{// eStatementUpdateStats
// points & lives
if ( macParam1 == "scoreup" )
cGame::Get().PlayerScored(atoi(macParam2.c_str()));
else
if ( macParam1 == "PlayerDies")
{
cGame::Get().PlayerDies();
cGame::Get().SetPlayingMode(false);
}
// cGame::Get().PrintMessage(macParam1);
;}break;
default:{// es una Condicional ejecutada como acción
OutputDebugString(" Error: using Do Method with Conditionants ");
;}break;
}
;}
示例4: log
/**
* Perform the actual logging.
* @param val
*/
void log(std::stringstream & val)
{
std::lock_guard<std::recursive_mutex> l1(mutex_);
static const bool use_file = true;
if (use_file)
{
static std::string path =
filesystem::data_path() + "debug.log"
;
if (ofstream_.is_open() == false)
{
ofstream_.open(
path, std::fstream::out | std::fstream::app
);
}
if (ofstream_.is_open() == true)
{
/**
* Limit size.
*/
if (ofstream_.tellp() > 10 * 1000000)
{
ofstream_.close();
ofstream_.open(path, std::fstream::out);
}
ofstream_ << val.str() << std::endl;
ofstream_.flush();
}
}
static bool use_cout = true;
if (use_cout)
{
#if (defined _WIN32 || defined WIN32) || (defined _WIN64 || defined WIN64)
#if defined(_UNICODE)
DWORD len = MultiByteToWideChar(
CP_ACP, 0, val.str().c_str(), -1, NULL, 0
);
std::unique_ptr<wchar_t> buf(new wchar_t[len]);
MultiByteToWideChar(
CP_ACP, 0, val.str().c_str(), -1, buf.get(), len
);
OutputDebugString(buf.get());
OutputDebugString(L"\n");
std::cerr << val.str() << std::endl;
#else
OutputDebugString(val.str().c_str());
OutputDebugString(L"\n");
std::cerr << val.str() << std::endl;
#endif // _UNICODE
#else // Not Windows.
#if (defined __ANDROID__)
__android_log_print(
ANDROID_LOG_DEBUG, "logger", val.str().c_str()
);
#else
std::cerr << val.str() << std::endl;
#endif
#endif // defined _WIN32 || defined WIN32) || (defined _WIN64 || defined WIN64
}
}
示例5: if
BOOL CTrackDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
int nChar = pMsg->wParam;
if((nChar == 'Z') || (nChar == 'X'))
{
if((pMsg->lParam & 0xFFFF) == 1)
{
CString str;
BOOL stepped = FALSE;
if((nChar == 'Z') && (m_step != LEFT))
{
m_step = LEFT;
m_numSteps++;
stepped = TRUE;
}
else if ((nChar == 'X') && (m_step != RIGHT))
{
m_step = RIGHT;
m_numSteps++;
stepped = TRUE;
}
if(stepped && m_racing)
{
m_progress.SetPos(m_numSteps);
if(m_numSteps == m_totalSteps)
{
DWORD diff;
m_racing = FALSE;
diff = (GetTickCount() - m_start);
str.Format("%0.3fs\n", diff / 1000.0);
OutputDebugString(str);
MessageBox(str);
UpdateData();
m_info = "DONE";
// Report the stats.
////////////////////
ReportStats(diff);
// Update best time(s) if needed.
/////////////////////////////////
CString * topStr;
CString * bestStr;
DWORD topTime;
DWORD bestTime;
if(m_event == EVENT_50)
{
topStr = &m_top50;
bestStr = &m_best50;
}
else if(m_event == EVENT_100)
{
topStr = &m_top100;
bestStr = &m_best100;
}
else
{
topStr = &m_top200;
bestStr = &m_best200;
}
topTime = (DWORD)(atof(*topStr) * 1000);
bestTime = (DWORD)(atof(*bestStr) * 1000);
if(!bestTime || (diff < bestTime))
{
bestStr->Format("%0.3f", diff / 1000.0);
if(diff < topTime)
*topStr = *bestStr;
}
UpdateData(FALSE);
m_event = EVENT_NONE;
}
}
}
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
示例6: DbgMsg
void CLoginPage::OnBnClickedSigninButton()
{
// TODO: Add your control notification handler code here
if (CXfireCore::IsConnected()){
if (::PostThreadMessage(g_nActiveThreadID, WM_TERM_THREAD, 0, 0) == 0) {
DbgMsg(L"Thread 0x%02x possibly already terminated\n", g_nActiveThreadID);
}
return;
}
CXfireCore::InitToZero();
WCHAR cTemp[0x100];
::GetWindowText(GetDlgItem(IDC_USERNAME)->GetSafeHwnd(),cTemp,0x100);
WideCharToMultiByte( CP_ACP, // ANSI Code Page
0, // No special handling of unmapped chars
cTemp, // wide-character string to be converted
0x100,
CXfireCore::s_cUserName,
0x100,
NULL, NULL ); // Unrepresented char replacement - Use Default
::GetWindowText(GetDlgItem(IDC_PASSWORD)->GetSafeHwnd(),cTemp,0x100);
WideCharToMultiByte( CP_ACP, // ANSI Code Page
0, // No special handling of unmapped chars
cTemp, // wide-character string to be converted
0x100,
CXfireCore::s_cPassword,
0x100,
NULL, NULL ); // Unrepresented char replacement - Use Default
if (strlen(CXfireCore::s_cUserName)<1 ||
strlen(CXfireCore::s_cPassword)<1 ) {
AfxMessageBox(L"Your username or password is too short.",MB_ICONINFORMATION|MB_OK);
return;
}
SaveUserData();
// GetDlgItem(IDC_SIGNIN_BUTTON)->EnableWindow(FALSE);
GetDlgItem(IDC_CONNECT_STATUS)->SetWindowText(L"Please wait connecting...");
CClientThread* pThread = (CClientThread*)AfxBeginThread(RUNTIME_CLASS(CClientThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
if (!pThread)
{
OutputDebugString(L"CClientThread AfxBeginThread Failed!!!CRITICAL ERROR \n");
return;
}
m_pClientThread=pThread;
g_nActiveThreadID=pThread->m_nThreadID;
pThread->m_socket.m_pThread = pThread; // the thread that m_socket lives
// Now start the thread.
pThread->ResumeThread();
}
示例7: Compress
///////////////////////////////////////////////////////////
//功能: 压缩指定文件或文件夹
///////////////////////////////////////////////////////////
DWORD Compress(char* szInFilePath,char* szOutCabPath,char* pkey)
{
CCompress i_Compress;
//压缩后的文件cab路径
if(szOutCabPath == NULL)
{
OutputDebugString("Compress ERROR: Output file name can not be NULL!");
return 2;
}
//设置加密KEY
if(pkey != NULL)
{
i_Compress.SetEncryptionKey(pkey, (DWORD)strlen(pkey));
}
else
{
#ifdef ENCRYPE_VERSION
i_Compress.SetEncryptionKey("HYResources", (DWORD)strlen("HYResources"));
#endif
}
//单字符串转换为宽字符串 szOutCabPath
int nLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szOutCabPath, -1, NULL, 0 );
wchar_t* szOutCabPathW = new wchar_t[nLen+1];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szOutCabPath, -1, szOutCabPathW, nLen );
//初始化
if(!i_Compress.CreateFCIContextW(szOutCabPathW))
{
OutputDebugString("Compress ERROR: Could not create FCI context!");
return 3;
}
//单字符串转换为宽字符串 szInFilePath
nLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szInFilePath, -1, NULL, 0 );
wchar_t* szInFilePathW = new wchar_t[nLen+1];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szInFilePath, -1, szInFilePathW, nLen );
//开始压缩
//要压缩的文件夹或文件夹
if(PathIsDirectory(szInFilePath))
{
if (!i_Compress.AddFolderW(szInFilePathW))
{
OutputDebugString("Compress ERROR:AddFolder fail!\n");
return 4;
}
}
else
{
wchar_t * wpNameInCab= wcsrchr(szInFilePathW,'\\');
if(wpNameInCab != NULL)
wpNameInCab++;
if(!i_Compress.AddFileW(szInFilePathW,wpNameInCab))
{
OutputDebugString("Compress ERROR:AddFile fail!\n");
return 4;
}
}
//释放资源
if (!i_Compress.DestroyFCIContext())
{
OutputDebugString("Compress ERROR: Could not flush Cabinet!\n");
return 5;
}
delete [] szInFilePathW;
delete [] szOutCabPathW;
return 0;
}
示例8: ExtractToStream
///////////////////////////////////////////////////////////
//功能: 解压到指定流
///////////////////////////////////////////////////////////
DWORD ExtractToStream(char* szCabFilePath,char *szFileFlag,char **szOutStream,char* pkey)
{
CExtract i_ExtrFile;
CExtract::kCallbacks k_ExtrCallbacks;
k_ExtrCallbacks.f_OnBeforeCopyFile = &OnBeforeCopyFile;
i_ExtrFile .SetCallbacks(&k_ExtrCallbacks);
if(szCabFilePath == NULL || !PathFileExists(szCabFilePath))
{
OutputDebugString("Extract Error: cab file not exist!");
return 1;
}
if(pkey != NULL)
{
i_ExtrFile.SetDecryptionKey(pkey,(DWORD)strlen(pkey));
}
else
{
#ifdef ENCRYPE_VERSION
i_ExtrFile.SetDecryptionKey("HYResources",(DWORD)strlen("HYResources"));
#endif
}
if(szFileFlag == NULL)
{
OutputDebugString("Extract ERROR: szFileFlag can not be NULL");
return 2;
}
if (!i_ExtrFile.CreateFDIContext())
{
OutputDebugString("Extract ERROR: Could not create FDI context");
return 3;
}
int nLen = MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szCabFilePath, -1, NULL, 0 );
wchar_t* szCabFilePathW = new wchar_t[nLen+1];
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szCabFilePath, -1, szCabFilePathW, nLen );
if(!i_ExtrFile.IsCabinetW(szCabFilePathW, NULL))
{
OutputDebugString("Extract Error: The file is not a valid Cabinet!");
return 4;
}
if (!i_ExtrFile.ExtractFileW(szCabFilePathW, L"MEMORY", szFileFlag))
{
OutputDebugString("Extract ERROR: Maybe the key or the FileFlag is wrong!");
return 5;
}
int nFileLen = 0;
char *pFile = (char*)i_ExtrFile.mi_ExtractMem.GetData(&nFileLen);
char* pStream = NULL;
if(nFileLen == 0 || pFile == NULL)
{
OutputDebugString("Extract ERROR: no file is expressed!");
return 6;
}
try
{
pStream = new char[nFileLen+1];
}
catch(...)
{
OutputDebugString("Extract ERROR: express exception");
delete [] szCabFilePathW;
return 7;
}
strncpy(pStream,pFile,nFileLen);
pStream[nFileLen] = '\0';
*szOutStream = pStream;
delete [] szCabFilePathW;
return 0;
}
示例9: WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
BYTE *t;
char disp[128];
CBusPortThread pt;
CController ct;
BYTE group[6];
BYTE buf[528];
DWORD bytes;
DWORD id;
int i;
struct tag_doorstatus ds;
struct log_tag *log;
pt.OpenPort();
pt.CreateThread();
Sleep(1000);
ct.SetMachineAddr(1);
ct.LinkBusPort(&pt);
//
if( ct.Test() )
{
/* ds.crc = 0;
ds.param = 0;
ds.t.hour_start = 0;
ds.t.hour_end = 23;
ds.t.minute_start = 0;
ds.t.minute_end = 59;
ds.t.weeks = 7;
ds.t.other = 0;
t = (BYTE *)&ds;
chk = 0;
for( int i = 0; i < DOOR_STATE_SIZE; i++)
chk ^= t[i];
ds.crc = chk;
//F142080008000143F100B8FB010000CC8E00
ct.SetLongData( DOOR_STATE_PAGE, 0, (BYTE *)&ds,DOOR_STATE_SIZE);
//F101080008000100
ct.GetLongData( DOOR_STATE_PAGE, 0, (BYTE *)&ds,DOOR_STATE_SIZE);
*/
/*
for( i = 0; i < 6;i++)
group[i] = 0;
if( ct.User_Add(0x00000001, group, 6, 0) )
OutputDebugString("User_Add:Success\n");
else
{
wsprintf(disp,"User_Add:Fail 0x%04lx",ct.GetErrCode());
OutputDebugString("User_Add:Fail\n");
}
if( ct.GetLongData( USER_ID_PAGE + 30, 0, (BYTE *)buf,200))
OutputDebugString("GetLongData:Success\n");
else
{
wsprintf(disp,"GetLongData:Fail 0x%04lx",ct.GetErrCode());
OutputDebugString(disp);
}
*/
id = 0;
while( 1 )
{
bytes = sizeof(buf);
if ( !ct.DownloadLog( id, (struct log_tag *)buf, &bytes) )
continue;
bytes /= 16;
for( i = 0; i < bytes; i++ )
{
log = (struct log_tag *)(buf + 16 * i) ;
wsprintf(disp,"[0x%08lx] Node:0x%02lx, type: 0x%2lx 20%02ld-%02ld-%02ld %02ld:%02ld:%02ld\n",
log->id, log->node,
log->time.year, log->time.month, log->time.day,
log->time.hour, log->time.minute, log->time.second );
OutputDebugString(disp);
id = log->id;
}
}
}
pt.ExitThread();
pt.ClosePort();
return 0;
}
示例10: IntegrityCheckModule
bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac, unsigned long *pMacFileLocation)
{
std::auto_ptr<MessageAuthenticationCode> mac(NewIntegrityCheckingMAC());
unsigned int macSize = mac->DigestSize();
SecByteBlock tempMac;
SecByteBlock &actualMac = pActualMac ? *pActualMac : tempMac;
actualMac.resize(macSize);
unsigned long tempLocation;
unsigned long &macFileLocation = pMacFileLocation ? *pMacFileLocation : tempLocation;
macFileLocation = 0;
MeterFilter verifier(new HashFilter(*mac, new ArraySink(actualMac, actualMac.size())));
// MeterFilter verifier(new FileSink("c:\\dt.tmp"));
std::ifstream moduleStream;
#ifdef CRYPTOPP_WIN32_AVAILABLE
HMODULE h;
{
char moduleFilenameBuf[MAX_PATH] = "";
if (moduleFilename == NULL)
{
#if (_MSC_VER >= 1400 && !defined(_STLPORT_VERSION)) // ifstream doesn't support wide filename on other compilers
wchar_t wideModuleFilename[MAX_PATH];
if (GetModuleFileNameW(s_hModule, wideModuleFilename, MAX_PATH) > 0)
{
moduleStream.open(wideModuleFilename, std::ios::in | std::ios::binary);
h = GetModuleHandleW(wideModuleFilename);
}
else
#endif
{
GetModuleFileNameA(s_hModule, moduleFilenameBuf, MAX_PATH);
moduleFilename = moduleFilenameBuf;
}
}
#endif
if (moduleFilename != NULL)
{
moduleStream.open(moduleFilename, std::ios::in | std::ios::binary);
#ifdef CRYPTOPP_WIN32_AVAILABLE
h = GetModuleHandleA(moduleFilename);
moduleFilename = NULL;
}
#endif
}
if (!moduleStream)
{
#ifdef CRYPTOPP_WIN32_AVAILABLE
OutputDebugString("Crypto++ DLL integrity check failed. Cannot open file for reading.");
#endif
return false;
}
FileStore file(moduleStream);
#ifdef CRYPTOPP_WIN32_AVAILABLE
// try to hash from memory first
const byte *memBase = (const byte *)h;
const IMAGE_DOS_HEADER *ph = (IMAGE_DOS_HEADER *)memBase;
const IMAGE_NT_HEADERS *phnt = (IMAGE_NT_HEADERS *)(memBase + ph->e_lfanew);
const IMAGE_SECTION_HEADER *phs = IMAGE_FIRST_SECTION(phnt);
DWORD nSections = phnt->FileHeader.NumberOfSections;
size_t currentFilePos = 0;
size_t checksumPos = (byte *)&phnt->OptionalHeader.CheckSum - memBase;
size_t checksumSize = sizeof(phnt->OptionalHeader.CheckSum);
size_t certificateTableDirectoryPos = (byte *)&phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY] - memBase;
size_t certificateTableDirectorySize = sizeof(phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY]);
size_t certificateTablePos = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].VirtualAddress;
size_t certificateTableSize = phnt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_SECURITY].Size;
verifier.AddRangeToSkip(0, checksumPos, checksumSize);
verifier.AddRangeToSkip(0, certificateTableDirectoryPos, certificateTableDirectorySize);
verifier.AddRangeToSkip(0, certificateTablePos, certificateTableSize);
while (nSections--)
{
switch (phs->Characteristics)
{
default:
break;
case IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ:
case IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ:
unsigned int sectionSize = STDMIN(phs->SizeOfRawData, phs->Misc.VirtualSize);
const byte *sectionMemStart = memBase + phs->VirtualAddress;
unsigned int sectionFileStart = phs->PointerToRawData;
size_t subSectionStart = 0, nextSubSectionStart;
do
{
const byte *subSectionMemStart = sectionMemStart + subSectionStart;
size_t subSectionFileStart = sectionFileStart + subSectionStart;
size_t subSectionSize = sectionSize - subSectionStart;
nextSubSectionStart = 0;
unsigned int entriesToReadFromDisk[] = {IMAGE_DIRECTORY_ENTRY_IMPORT, IMAGE_DIRECTORY_ENTRY_IAT};
for (unsigned int i=0; i<COUNTOF(entriesToReadFromDisk); i++)
{
//.........这里部分代码省略.........
示例11: defined
/// Get center of mass of units in army (account for world wrap!)
CvPlot* CvArmyAI::GetCenterOfMass(DomainTypes eDomainRequired)
{
int iTotalX = 0;
int iTotalY = 0;
int iNumUnits = 0;
#if defined(MOD_BALANCE_CORE)
UnitHandle pUnit = GetFirstUnit();
if (!pUnit)
return NULL;
int iTotalX2 = 0;
int iTotalY2 = 0;
int iWorldWidth = GC.getMap().getGridWidth();
int iWorldHeight = GC.getMap().getGridHeight();
//the first unit is our reference ...
int iRefX = pUnit->getX();
int iRefY = pUnit->getY();
iNumUnits++;
pUnit = GetNextUnit();
while(pUnit)
{
int iDX = pUnit->getX() - iRefX;
int iDY = pUnit->getY() - iRefY;
if (GC.getMap().isWrapX())
{
if( iDX > +(iWorldWidth / 2))
iDX -= iWorldWidth;
if( iDX < -(iWorldWidth / 2))
iDX += iWorldWidth;
}
if (GC.getMap().isWrapY())
{
if( iDY > +(iWorldHeight / 2))
iDY -= iWorldHeight;
if( iDY < -(iWorldHeight / 2))
iDY += iWorldHeight;
}
iTotalX += iDX;
iTotalY += iDY;
iTotalX2 += iDX*iDX;
iTotalY2 += iDY*iDY;
iNumUnits++;
pUnit = GetNextUnit();
}
if (iNumUnits==0)
return NULL;
//this is for debugging
float fVarX = (iTotalX2 / (float)iNumUnits) - (iTotalX/(float)iNumUnits)*(iTotalX/(float)iNumUnits);
float fVarY = (iTotalY2 / (float)iNumUnits) - (iTotalY/(float)iNumUnits)*(iTotalY/(float)iNumUnits);
//finally, compute average (with rounding)
int iAvgX = (iTotalX + (iNumUnits / 2)) / iNumUnits + iRefX;
int iAvgY = (iTotalY + (iNumUnits / 2)) / iNumUnits + iRefY;
if (fVarX > 64 || fVarY > 64)
{
CvString msg = CvString::format("Warning: Army %d with %d units Center of Mass (%d,%d) has a large variance (%.2f,%.2f)\n", GetID(), iNumUnits, iAvgX, iAvgY, fVarX, fVarY);
OutputDebugString( msg.c_str() );
}
//this handles wrapped coordinates
CvPlot* pCOM = GC.getMap().plot(iAvgX, iAvgY);
if (!pCOM)
return NULL;
//don't return it directly but use the plot of the closest unit
pUnit = GetFirstUnit();
std::vector<SPlotWithScore> vPlots;
while (pUnit)
{
if (eDomainRequired == NO_DOMAIN || pUnit->plot()->getDomain()==eDomainRequired)
vPlots.push_back( SPlotWithScore(pUnit->plot(),plotDistance(*pUnit->plot(),*pCOM)) );
pUnit = GetNextUnit();
}
if (vPlots.empty())
return NULL;
//this sorts ascending!
std::sort(vPlots.begin(),vPlots.end());
return vPlots.front().pPlot;
#else
CvPlot* pRtnValue = NULL;
UnitHandle pUnit;
int iReferenceUnitX = -1;
int iWorldWidth = GC.getMap().getGridWidth();
//.........这里部分代码省略.........
示例12: WinMain
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE ignoreMe0, LPSTR ignoreMe1, INT ignoreMe2)
{
HRESULT hr = S_OK;
HWND hWnd = NULL;
HDC hDC = NULL;
HGLRC hRC = NULL;
MSG msg = {};
PIXELFORMATDESCRIPTOR pfd;
LARGE_INTEGER previousTime;
LARGE_INTEGER freqTime;
double aveDeltaTime = 0.0;
LPCSTR wndName = "Flow Snake";
IFC( InitWindow(hWnd, g_width, g_height, wndName) );
hDC = GetDC(hWnd);
// Create the GL context.
ZeroMemory(&pfd, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 24;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
int pixelFormat = ChoosePixelFormat(hDC, &pfd);
SetPixelFormat(hDC, pixelFormat, &pfd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
IFC( Init() );
QueryPerformanceFrequency(&freqTime);
QueryPerformanceCounter(&previousTime);
// -------------------
// Start the Game Loop
// -------------------
while (msg.message != WM_QUIT)
{
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
LARGE_INTEGER currentTime;
__int64 elapsed;
double deltaTime;
QueryPerformanceCounter(¤tTime);
elapsed = currentTime.QuadPart - previousTime.QuadPart;
deltaTime = double(elapsed) / freqTime.QuadPart;
aveDeltaTime = aveDeltaTime * 0.9 + 0.1 * deltaTime;
previousTime = currentTime;
IFC( Update(deltaTime) );
Render();
SwapBuffers(hDC);
if (glGetError() != GL_NO_ERROR)
{
Error("OpenGL error.\n");
}
}
}
Cleanup:
if(hRC) wglDeleteContext(hRC);
if(hDC) ReleaseDC(hWnd, hDC);
if(hWnd) DestroyWindow(hWnd);
char strBuf[256];
sprintf_s(strBuf, "Average frame duration = %.3f ms\n", aveDeltaTime*1000.0f);
OutputDebugString(strBuf);
return FAILED(hr);
}
示例13: OutputDebugString
SocketTracker::SocketTracker(void):MotionTracker()
{
OutputDebugString("Socket Tracker Created\n");
init();
}
示例14: sprintf_s
void LgbZOrderDlogBar::syncWithView(
CDrawGUIView *pView,
const CString &fileName,
const std::vector<int> &zClipTics,
const bool &setZClipToMax,
LgbZLeanBounds_t limits,
Lgb_UserZVals_t userVals )
{
char buff[100];
#ifdef DEBUG
sprintf_s( buff, 100, "%s %d, %d, %d, %d\n", "LgbZOrderDlogBar set to\n:ZLean, ZClip, ZClipMin, ZClipMax",
userVals.zLeanVal, userVals.zClipVal, zClipTics.front(), zClipTics.back() );
OutputDebugString(buff);
if( setZClipToMax )
OutputDebugString("setZClipToMax == true\n");
else
OutputDebugString("setZClipToMax == false\n");
for(size_t i=0;i<zClipTics.size();i++){
sprintf_s( buff, 100, "%s %d %s %d\n", "Tic[", i, "]=: ", zClipTics[i] );
OutputDebugString(buff);
}
#endif
this->SetWindowTextA( fileName );
m_pCDrawGuiView = pView;
m_cZLimits = limits;
m_cZUserVals = userVals;
m_ctlSlider_ZLean.m_pDlogBar = this;
m_ctlSlider_ZLean.SetRangeMin( m_cZLimits.zLeanMin );
m_ctlSlider_ZLean.SetRangeMax( m_cZLimits.zLeanMax );
m_ctlSlider_ZLean.SetPos ( m_cZUserVals.zLeanVal );
m_ctlSlider_ZClip.m_pDlogBar = this;
m_ctlSlider_ZClip.SetRangeMin( zClipTics.front() );
m_ctlSlider_ZClip.SetRangeMax( zClipTics.back() );
if(setZClipToMax)
m_ctlSlider_ZClip.SetPos( zClipTics.back() );
else
m_ctlSlider_ZClip.SetPos( m_cZUserVals.zClipVal );
m_ctlEdit_ZClip.SetWindowTextA( intToString( m_ctlSlider_ZClip.GetPos() ));
m_ctlEdit_ZLeanVal.SetWindowTextA( intToString( m_ctlSlider_ZLean.GetPos() ));
m_ctlSlider_ZLean.SetTic( 1 );
m_ctlSlider_ZLean.SetTic( 2 );
m_ctlSlider_ZLean.SetTic( 3 );
m_ctlSlider_ZLean.SetTicFreq( 1 );
m_ctlSlider_ZClip.ClearTics(0);
m_ctlSlider_ZClip.SetTicFreq( 1 );
for(size_t i=0;i<zClipTics.size();i++){
m_ctlSlider_ZClip.SetTic( zClipTics[i] );
}
m_ctlSlider_ZClip.RedrawWindow();
UpdateData(false);
}
示例15: AccessReceiver
size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned long maxTime, bool checkDelimiter, byte delimiter)
{
NetworkReceiver &receiver = AccessReceiver();
lword maxSize = byteCount;
byteCount = 0;
bool forever = maxTime == INFINITE_TIME;
Timer timer(Timer::MILLISECONDS, forever);
BufferedTransformation *t = AttachedTransformation();
if (m_outputBlocked)
goto DoOutput;
while (true)
{
if (m_dataBegin == m_dataEnd)
{
if (receiver.EofReceived())
break;
if (m_waitingForResult)
{
if (receiver.MustWaitForResult() &&
!receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()),
CallStack("NetworkSource::DoPump() - wait receive result", 0)))
break;
unsigned int recvResult = receiver.GetReceiveResult();
#if CRYPTOPP_TRACE_NETWORK
OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
#endif
m_dataEnd += recvResult;
m_waitingForResult = false;
if (!receiver.MustWaitToReceive() && !receiver.EofReceived() && m_dataEnd != m_buf.size())
goto ReceiveNoWait;
}
else
{
m_dataEnd = m_dataBegin = 0;
if (receiver.MustWaitToReceive())
{
if (!receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()),
CallStack("NetworkSource::DoPump() - wait receive", 0)))
break;
receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd);
m_waitingForResult = true;
}
else
{
ReceiveNoWait:
m_waitingForResult = true;
// call Receive repeatedly as long as data is immediately available,
// because some receivers tend to return data in small pieces
#if CRYPTOPP_TRACE_NETWORK
OutputDebugString((IntToString((unsigned int)this) + ": Receiving " + IntToString(m_buf.size()-m_dataEnd) + " bytes\n").c_str());
#endif
while (receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd))
{
unsigned int recvResult = receiver.GetReceiveResult();
#if CRYPTOPP_TRACE_NETWORK
OutputDebugString((IntToString((unsigned int)this) + ": Received " + IntToString(recvResult) + " bytes\n").c_str());
#endif
m_dataEnd += recvResult;
if (receiver.EofReceived() || m_dataEnd > m_buf.size() /2)
{
m_waitingForResult = false;
break;
}
}
}
}
}
else
{
m_putSize = UnsignedMin(m_dataEnd - m_dataBegin, maxSize - byteCount);
if (checkDelimiter)
m_putSize = std::find(m_buf+m_dataBegin, m_buf+m_dataBegin+m_putSize, delimiter) - (m_buf+m_dataBegin);
DoOutput:
size_t result = t->PutModifiable2(m_buf+m_dataBegin, m_putSize, 0, forever || blockingOutput);
if (result)
{
if (t->Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()),
CallStack("NetworkSource::DoPump() - wait attachment", 0)))
goto DoOutput;
else
{
m_outputBlocked = true;
return result;
}
}
m_outputBlocked = false;
byteCount += m_putSize;
m_dataBegin += m_putSize;
if (checkDelimiter && m_dataBegin < m_dataEnd && m_buf[m_dataBegin] == delimiter)
//.........这里部分代码省略.........