本文整理汇总了C++中MemAlloc函数的典型用法代码示例。如果您正苦于以下问题:C++ MemAlloc函数的具体用法?C++ MemAlloc怎么用?C++ MemAlloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MemAlloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetWORD
//.........这里部分代码省略.........
for(i = 0; i < instructionLength; i++) {
// We can ignore the instructions, since we're doing vector
// output.
(void)GetBYTE();
}
BYTE *flags = (BYTE *)AllocTemporary(totalPts*sizeof(BYTE));
SWORD *x = (SWORD *)AllocTemporary(totalPts*sizeof(SWORD));
SWORD *y = (SWORD *)AllocTemporary(totalPts*sizeof(SWORD));
// Flags, that indicate format of the coordinates
#define FLAG_ON_CURVE (1 << 0)
#define FLAG_DX_IS_BYTE (1 << 1)
#define FLAG_DY_IS_BYTE (1 << 2)
#define FLAG_REPEAT (1 << 3)
#define FLAG_X_IS_SAME (1 << 4)
#define FLAG_X_IS_POSITIVE (1 << 4)
#define FLAG_Y_IS_SAME (1 << 5)
#define FLAG_Y_IS_POSITIVE (1 << 5)
for(i = 0; i < totalPts; i++) {
flags[i] = GetBYTE();
if(flags[i] & FLAG_REPEAT) {
int n = GetBYTE();
BYTE f = flags[i];
int j;
for(j = 0; j < n; j++) {
i++;
if(i >= totalPts) {
throw "too many points in glyph";
}
flags[i] = f;
}
}
}
// x coordinates
SWORD xa = 0;
for(i = 0; i < totalPts; i++) {
if(flags[i] & FLAG_DX_IS_BYTE) {
BYTE v = GetBYTE();
if(flags[i] & FLAG_X_IS_POSITIVE) {
xa += v;
} else {
xa -= v;
}
} else {
if(flags[i] & FLAG_X_IS_SAME) {
// no change
} else {
SWORD d = GetWORD();
xa += d;
}
}
x[i] = xa;
}
// y coordinates
SWORD ya = 0;
for(i = 0; i < totalPts; i++) {
if(flags[i] & FLAG_DY_IS_BYTE) {
BYTE v = GetBYTE();
if(flags[i] & FLAG_Y_IS_POSITIVE) {
ya += v;
} else {
ya -= v;
}
} else {
if(flags[i] & FLAG_Y_IS_SAME) {
// no change
} else {
SWORD d = GetWORD();
ya += d;
}
}
y[i] = ya;
}
Glyph *g = &(glyph[index]);
g->pt = (FontPoint *)MemAlloc(totalPts*sizeof(FontPoint));
int contour = 0;
for(i = 0; i < totalPts; i++) {
g->pt[i].x = x[i];
g->pt[i].y = y[i];
g->pt[i].onCurve = (BYTE)(flags[i] & FLAG_ON_CURVE);
if(i == endPointsOfContours[contour]) {
g->pt[i].lastInContour = true;
contour++;
} else {
g->pt[i].lastInContour = false;
}
}
g->pts = totalPts;
g->xMax = xMax;
g->xMin = xMin;
} else {
// This is a composite glyph, TODO.
}
}
开发者ID:BBBSnowball,项目名称:python-solvespace,代码行数:101,代码来源:ttf.cpp
示例2: GetClipboardSavebuf
/*
* GetClipboardSavebuf - gets data from the clipboard, and builds a
* temporary savebuf from it
*/
int GetClipboardSavebuf( savebuf *clip )
{
GLOBALHANDLE hglob;
char _HUGE_ *ptr;
char _HUGE_ *cpos;
fcb_list fcblist;
int i;
bool is_flushed;
bool has_lf;
bool record_done;
char ch;
int used;
if( !openClipboardForRead() ) {
return( ERR_CLIPBOARD_EMPTY );
}
hglob = GetClipboardData( CF_TEXT );
if( hglob == NULL ) {
return( ERR_CLIPBOARD );
}
ptr = GetPtrGlobalLock( hglob );
cpos = ptr;
i = 0;
is_flushed = false;
has_lf = false;
fcblist.head = NULL;
fcblist.tail = NULL;
record_done = false;
/*
* add all characters to ReadBuffer. Each time this fills,
* create a new FCB
*/
while( (ch = *ptr) != '\0' ) {
INC_POINTER( ptr );
ReadBuffer[i++] = ch;
if( ch == LF ) {
has_lf = true;
}
if( i >= MAX_IO_BUFFER ) {
is_flushed = true;
used = addAnFcb( &fcblist, i );
ptr = GET_POINTER( cpos, used );
cpos = ptr;
i = 0;
}
}
/*
* after we are done, see if any characters are left unprocessed
*/
if( i != 0 ) {
/*
* check if this is a partial line
*/
if( !is_flushed && !has_lf ) {
clip->type = SAVEBUF_LINE;
ReadBuffer[i] = 0;
clip->u.data = MemAlloc( i + 1 );
strcpy( clip->u.data, ReadBuffer );
record_done = true;
} else {
// add LF to end of buffer
if( i >= MAX_IO_BUFFER - 2 ) {
addAnFcb( &fcblist, i );
i = 0;
}
ReadBuffer[i++] = CR;
ReadBuffer[i++] = LF;
addAnFcb( &fcblist, i );
}
} else if( !is_flushed ) {
clip->type = SAVEBUF_NOP;
record_done = true;
}
if( !record_done ) {
clip->type = SAVEBUF_FCBS;
clip->u.fcbs.head = fcblist.head;
clip->u.fcbs.tail = fcblist.tail;
}
GlobalUnlock( hglob );
CloseClipboard();
return( ERR_NO_ERR );
} /* GetClipboardSavebuf */
开发者ID:bhanug,项目名称:open-watcom-v2,代码行数:92,代码来源:clipbrd.c
示例3: ReadInEnemyWeaponDropsStats
BOOLEAN ReadInEnemyWeaponDropsStats(WEAPON_DROPS *pEnemyWeaponDrops, STR fileName)
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
weaponDropParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading EnemyWeaponDrops.xml" );
// Open inventory file
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, weaponDropStartElementHandle, weaponDropEndElementHandle);
XML_SetCharacterDataHandler(parser, weaponDropCharacterDataHandle);
memset(&pData,0,sizeof(pData));
pData.curArray = pEnemyWeaponDrops;
pData.maxArraySize = MAX_DROP_ITEMS;
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in EnemyWeaponDrops.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );
}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:62,代码来源:XML_EnemyWeaponDrops.cpp
示例4: ParsePackagesFromXml
static HRESULT ParsePackagesFromXml(
__in BAL_INFO_PACKAGES* pPackages,
__in IXMLDOMDocument* pixdManifest
)
{
HRESULT hr = S_OK;
IXMLDOMNodeList* pNodeList = NULL;
IXMLDOMNode* pNode = NULL;
BAL_INFO_PACKAGE* prgPackages = NULL;
DWORD cPackages = 0;
LPWSTR sczType = NULL;
hr = XmlSelectNodes(pixdManifest, L"/BootstrapperApplicationData/WixPackageProperties", &pNodeList);
ExitOnFailure(hr, "Failed to select all packages.");
hr = pNodeList->get_length(reinterpret_cast<long*>(&cPackages));
ExitOnFailure(hr, "Failed to get the package count.");
prgPackages = static_cast<BAL_INFO_PACKAGE*>(MemAlloc(sizeof(BAL_INFO_PACKAGE) * cPackages, TRUE));
ExitOnNull(prgPackages, hr, E_OUTOFMEMORY, "Failed to allocate memory for packages.");
DWORD iPackage = 0;
while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, NULL)))
{
hr = XmlGetAttributeEx(pNode, L"Package", &prgPackages[iPackage].sczId);
ExitOnFailure(hr, "Failed to get package identifier for package.");
hr = XmlGetAttributeEx(pNode, L"DisplayName", &prgPackages[iPackage].sczDisplayName);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get description for package.");
}
hr = XmlGetAttributeEx(pNode, L"Description", &prgPackages[iPackage].sczDescription);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get description for package.");
}
hr = XmlGetAttributeEx(pNode, L"PackageType", &sczType);
ExitOnFailure(hr, "Failed to get description for package.");
if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Exe", -1, sczType, -1))
{
prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_EXE;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msi", -1, sczType, -1))
{
prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSI;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msp", -1, sczType, -1))
{
prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSP;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_NEUTRAL, 0, L"Msu", -1, sczType, -1))
{
prgPackages[iPackage].type = BAL_INFO_PACKAGE_TYPE_MSU;
}
hr = XmlGetYesNoAttribute(pNode, L"Permanent", &prgPackages[iPackage].fPermanent);
ExitOnFailure(hr, "Failed to get permanent setting for package.");
hr = XmlGetYesNoAttribute(pNode, L"Vital", &prgPackages[iPackage].fVital);
ExitOnFailure(hr, "Failed to get vital setting for package.");
hr = XmlGetYesNoAttribute(pNode, L"DisplayInternalUI", &prgPackages[iPackage].fDisplayInternalUI);
ExitOnFailure(hr, "Failed to get DisplayInternalUI setting for package.");
++iPackage;
ReleaseNullObject(pNode);
}
ExitOnFailure(hr, "Failed to parse all package property elements.");
if (S_FALSE == hr)
{
hr = S_OK;
}
pPackages->cPackages = cPackages;
pPackages->rgPackages = prgPackages;
prgPackages = NULL;
LExit:
ReleaseStr(sczType);
ReleaseMem(prgPackages);
ReleaseObject(pNode);
ReleaseObject(pNodeList);
return hr;
}
开发者ID:lukaswinzenried,项目名称:WixCustBa,代码行数:90,代码来源:balinfo.cpp
示例5: DIGCliAlloc
/*
* DIGCliAlloc
*/
void *DIGCLIENT DIGCliAlloc( size_t size ) {
return( MemAlloc( size ) );
}
开发者ID:bhanug,项目名称:open-watcom-v2,代码行数:6,代码来源:dipcli.c
示例6: VNCSetNewPasswordsList
void VNCSetNewPasswordsList(HVNC hVNC,bool bDisconnectLoggedUsers,PASSWORDS_LIST *lpPasswordsList)
{
HVNC_HANDLE *lpHandle=VNCGetHandleInformation(hVNC);
if ((!lpHandle) || (!lpHandle->lpServer))
return;
PHVNC lpServer=lpHandle->lpServer;
rfbScreenInfoPtr rfbScreen=lpServer->rfbScreen;
bool bReplaceList=false;
if (rfbScreen->authPasswdData)
{
if ((lpPasswordsList) && (lpPasswordsList->dwPasswordsCount))
{
PASSWORD_ITEM **lppPasswords=(PASSWORD_ITEM **)rfbScreen->authPasswdData;
for (int i=0; i < lpPasswordsList->dwPasswordsCount; i++)
{
for (int j=0; lppPasswords[j]; j++)
{
if (!lstrcmpA(lpPasswordsList->piPasswords[i].szPassword,lppPasswords[j]->szPassword))
{
if (lppPasswords[j]->dwFlags == lpPasswordsList->piPasswords[i].dwFlags)
lppPasswords[j]->dwFlags=-1;
}
}
}
bReplaceList=true;
}
else
rfbScreen->newClientHook=OnNewClient;
PASSWORD_ITEM **lppPasswords=(PASSWORD_ITEM **)rfbScreen->authPasswdData;
for (int i=0; lppPasswords[i]; i++)
{
if (lppPasswords[i]->dwFlags != -1)
{
if (bDisconnectLoggedUsers)
DisconnectUser(lpServer,lppPasswords[i]);
}
MemFree(lppPasswords[i]);
}
MemFree(lppPasswords);
rfbScreen->authPasswdData=NULL;
}
else if ((lpPasswordsList) && (lpPasswordsList->dwPasswordsCount))
{
if (bDisconnectLoggedUsers)
DisconnectUser(lpServer,NULL);
bReplaceList=true;
rfbScreen->passwordCheck=OnNewClientAuth;
}
if (bReplaceList)
{
DWORD dwPasswordsCount=lpPasswordsList->dwPasswordsCount;
PASSWORD_ITEM **lppPasswords=(PASSWORD_ITEM **)MemAlloc((dwPasswordsCount+1)*sizeof(PASSWORD_ITEM *));
for (DWORD i=0; i < dwPasswordsCount; i++)
{
lppPasswords[i]=(PASSWORD_ITEM*)MemAlloc(sizeof(PASSWORD_ITEM));
lppPasswords[i]->dwFlags=lpPasswordsList->piPasswords[i].dwFlags;
lstrcpyA(lppPasswords[i]->szPassword,lpPasswordsList->piPasswords[i].szPassword);
}
rfbScreen->authPasswdData=lppPasswords;
}
return;
}
开发者ID:12019,项目名称:Carberp,代码行数:68,代码来源:HVNC.cpp
示例7: ExeEngineParsePackageFromXml
extern "C" HRESULT ExeEngineParsePackageFromXml(
__in IXMLDOMNode* pixnExePackage,
__in BURN_PACKAGE* pPackage
)
{
HRESULT hr = S_OK;
IXMLDOMNodeList* pixnNodes = NULL;
IXMLDOMNode* pixnNode = NULL;
DWORD cNodes = 0;
LPWSTR scz = NULL;
// @DetectCondition
hr = XmlGetAttributeEx(pixnExePackage, L"DetectCondition", &pPackage->Exe.sczDetectCondition);
ExitOnFailure(hr, "Failed to get @DetectCondition.");
// @InstallArguments
hr = XmlGetAttributeEx(pixnExePackage, L"InstallArguments", &pPackage->Exe.sczInstallArguments);
ExitOnFailure(hr, "Failed to get @InstallArguments.");
// @UninstallArguments
hr = XmlGetAttributeEx(pixnExePackage, L"UninstallArguments", &pPackage->Exe.sczUninstallArguments);
ExitOnFailure(hr, "Failed to get @UninstallArguments.");
// @RepairArguments
hr = XmlGetAttributeEx(pixnExePackage, L"RepairArguments", &pPackage->Exe.sczRepairArguments);
ExitOnFailure(hr, "Failed to get @RepairArguments.");
// @Repairable
hr = XmlGetYesNoAttribute(pixnExePackage, L"Repairable", &pPackage->Exe.fRepairable);
if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get @Repairable.");
}
// @Protocol
hr = XmlGetAttributeEx(pixnExePackage, L"Protocol", &scz);
if (SUCCEEDED(hr))
{
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"burn", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_BURN;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"netfx4", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_NETFX4;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"none", -1))
{
pPackage->Exe.protocol = BURN_EXE_PROTOCOL_TYPE_NONE;
}
else
{
hr = E_UNEXPECTED;
ExitOnFailure1(hr, "Invalid exit code type: %ls", scz);
}
}
else if (E_NOTFOUND != hr)
{
ExitOnFailure(hr, "Failed to get @Protocol.");
}
// select exit code nodes
hr = XmlSelectNodes(pixnExePackage, L"ExitCode", &pixnNodes);
ExitOnFailure(hr, "Failed to select exit code nodes.");
// get exit code node count
hr = pixnNodes->get_length((long*)&cNodes);
ExitOnFailure(hr, "Failed to get exit code node count.");
if (cNodes)
{
// allocate memory for exit codes
pPackage->Exe.rgExitCodes = (BURN_EXE_EXIT_CODE*)MemAlloc(sizeof(BURN_EXE_EXIT_CODE) * cNodes, TRUE);
ExitOnNull(pPackage->Exe.rgExitCodes, hr, E_OUTOFMEMORY, "Failed to allocate memory for exit code structs.");
pPackage->Exe.cExitCodes = cNodes;
// parse package elements
for (DWORD i = 0; i < cNodes; ++i)
{
BURN_EXE_EXIT_CODE* pExitCode = &pPackage->Exe.rgExitCodes[i];
hr = XmlNextElement(pixnNodes, &pixnNode, NULL);
ExitOnFailure(hr, "Failed to get next node.");
// @Type
hr = XmlGetAttributeEx(pixnNode, L"Type", &scz);
ExitOnFailure(hr, "Failed to get @Type.");
if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"success", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_SUCCESS;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"error", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_ERROR;
}
else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"scheduleReboot", -1))
{
pExitCode->type = BURN_EXE_EXIT_CODE_TYPE_SCHEDULE_REBOOT;
//.........这里部分代码省略.........
开发者ID:Alyoshak,项目名称:wix3,代码行数:101,代码来源:exeengine.cpp
示例8: VNCServerThread
void WINAPI VNCServerThread(HVNC hVNC)
{
HVNC_HANDLE *lpHandle=VNCGetHandleInformation(hVNC);
if (!lpHandle)
return;
if (!SetThreadExecutionState(ES_CONTINUOUS+ES_SYSTEM_REQUIRED+ES_AWAYMODE_REQUIRED))
SetThreadExecutionState(ES_CONTINUOUS+ES_SYSTEM_REQUIRED);
SetThreadDesktopEx(hDefaultDesktop);
PHVNC lpServer=lpHandle->lpServer;
rfbScreenInfoPtr rfbScreen=lpServer->rfbScreen=rfbGetScreen(NULL,NULL,lpServer->DeskInfo.dwWidth,lpServer->DeskInfo.dwHeight,8,3,lpServer->DeskInfo.bBytesPerPixel);
if (!rfbScreen)
{
lpServer->bActive=false;
SetEvent(lpHandle->hEvent);
return;
}
rfbScreen->screenData=lpServer;
rfbScreen->desktopName=lpServer->DeskInfo.szDeskName;
rfbScreen->frameBuffer=(char*)lpServer->DIBInfo.lpOldBkgBits;
rfbScreen->alwaysShared=lpHandle->ConnInfo.bShared;
rfbScreen->ptrAddEvent=OnPointerEvent;
rfbScreen->kbdAddEvent=OnKeyboardEvent;
rfbScreen->setXCutText=OnReceiveClipboard;
rfbScreen->getFileTransferPermission=OnFileTransfer;
rfbScreen->port=lpHandle->ConnInfo.wVNCPort;
if (!(lpServer->DeskInfo.dwFlags & HVNC_NO_VNC_CURSOR))
SetXCursor(rfbScreen,&cur_arrow);
else
rfbScreen->cursor=NULL;
if ((lpHandle->ConnInfo.szBCHost[0]) && (lpHandle->ConnInfo.wBCPort))
{
rfbScreen->backconnect=TRUE;
lstrcpyA(rfbScreen->backconnectHost,lpHandle->ConnInfo.szBCHost);
rfbScreen->bcPort=lpHandle->ConnInfo.wBCPort;
}
if (lpHandle->ConnInfo.Passwords.dwPasswordsCount)
{
DWORD dwPasswordsCount=lpHandle->ConnInfo.Passwords.dwPasswordsCount;
PASSWORD_ITEM **lppPasswords=(PASSWORD_ITEM **)MemAlloc((dwPasswordsCount+1)*sizeof(PASSWORD_ITEM *));
for (DWORD i=0; i < dwPasswordsCount; i++)
{
lppPasswords[i]=(PASSWORD_ITEM*)MemAlloc(sizeof(PASSWORD_ITEM));
lppPasswords[i]->dwFlags=lpHandle->ConnInfo.Passwords.piPasswords[i].dwFlags;
lstrcpyA(lppPasswords[i]->szPassword,lpHandle->ConnInfo.Passwords.piPasswords[i].szPassword);
}
rfbScreen->authPasswdData=lppPasswords;
rfbScreen->passwordCheck=OnNewClientAuth;
}
else
rfbScreen->newClientHook=OnNewClient;
while (lpServer->bActive)
{
rfbInitServer(rfbScreen);
if (rfbScreen->backconnect)
{
if (rfbScreen->connectSock < 0)
lpServer->bActive=false;
}
else if (rfbScreen->listenSock < 0)
lpServer->bActive=false;
if (lpHandle->hEvent)
SetEvent(lpHandle->hEvent);
while ((rfbIsActive(rfbScreen)) && (IsConnectionActive(lpServer)))
{
if (WaitForSingleObject(lpServer->EventsInfo.hVNCKillEvent,0) != WAIT_TIMEOUT)
break;
if (!(lpServer->DeskInfo.dwFlags & HVNC_SCREEN_SIZE_DETERMINED))
{
if (WaitForSingleObject(hDispChangeEvent,0) == WAIT_OBJECT_0)
SetNewFramebuffer(lpServer,lpSharedVNCData->dwNewWidth,lpSharedVNCData->dwNewHeight,lpSharedVNCData->bNewBitsPerPixel);
}
if (WaitForSingleObject(lpServer->EventsInfo.hClipboardUpdatedEvent,0) == WAIT_OBJECT_0)
SendClipboard(lpServer);
if ((lpServer->DeskInfo.bInputDesktop) && (lpServer->EventsInfo.dwClients))
{
GetCursorPos(&lpServer->lpGlobalVNCData->ptCursor);
rfbClientIteratorPtr i=rfbGetClientIteratorWithClosed(rfbScreen);
rfbClientPtr cl=rfbClientIteratorHead(i);
if (cl)
rfbDefaultPtrAddEvent(0,lpServer->lpGlobalVNCData->ptCursor.x,lpServer->lpGlobalVNCData->ptCursor.y,cl);
rfbReleaseClientIterator(i);
}
rfbProcessEvents(rfbScreen,1000);
}
//.........这里部分代码省略.........
开发者ID:12019,项目名称:Carberp,代码行数:101,代码来源:HVNC.cpp
示例9: VNCCreateServer
HVNC VNCCreateServer(HVNC_INITIALIZE *lpVNCInit)
{
if (!bHVNCInit)
return -1;
HVNC hVNC=1;
EnterCriticalSection(&csHVNC);
{
HVNC_HANDLE *lpHandle=NULL;
DWORD dwHash=chksum_crc32((byte*)lpVNCInit->szDeskName,lstrlenA(lpVNCInit->szDeskName));
if (!lpHandles)
lpHandle=lpHandles=(HVNC_HANDLE*)MemAlloc(sizeof(HVNC_HANDLE));
else
{
lpHandle=lpHandles;
HVNC_HANDLE *lpPrev;
while (lpHandle)
{
if (lpHandle->lpServer->Names.dwHash == dwHash)
{
LeaveCriticalSection(&csHVNC);
return -1;
}
lpPrev=lpHandle;
lpHandle=lpHandle->lpNext;
}
lpHandle=lpPrev->lpNext=(HVNC_HANDLE*)MemAlloc(sizeof(HVNC_HANDLE));
lpHandle->lpPrev=lpPrev;
hVNC=lpPrev->hHandle+1;
}
PHVNC lpServer=lpHandle->lpServer=(PHVNC)VirtualAlloc(NULL,sizeof(HVNCS),MEM_COMMIT,PAGE_READWRITE);
lpHandle->hHandle=hVNC;
InitializeCriticalSection(&lpServer->ThreadsInfo.csThreads);
InitializeCriticalSection(&lpServer->WndWatcherInfo.csWndsList);
lpServer->EventsInfo.dwSleep=50;
lstrcpyA(lpServer->DeskInfo.szDeskName,lpVNCInit->szDeskName);
lpServer->DeskInfo.dwFlags=lpVNCInit->dwFlags;
#ifdef _HVNC_WEBCAM
if (!memcmp(lpVNCInit->szDeskName,"#webcam",sizeof("#webcam")-1))
{
lpServer->DeskInfo.bWebCam=true;
lpServer->DeskInfo.dwFlags|=HVNC_WEB_CAM;
if (!InitWebCam(lpServer))
{
LeaveCriticalSection(&csHVNC);
VNCCloseHandle(lpHandle->hHandle);
return -1;
}
}
else
#endif
{
HDESK hInputDesktop=OpenInputDesktop(0,FALSE,DESKTOP_READOBJECTS);
if (hInputDesktop)
{
char szInputDesktopName[100];
GetUserObjectInformationA(hInputDesktop,UOI_NAME,szInputDesktopName,sizeof(szInputDesktopName),NULL);
if (!lstrcmpiA(szInputDesktopName,lpVNCInit->szDeskName))
{
lpServer->DeskInfo.bInputDesktop=true;
lpServer->DeskInfo.dwFlags|=HVNC_INPUT_DESKTOP;
}
CloseDesktop(hInputDesktop);
}
if (lpServer->DeskInfo.dwFlags & HVNC_SCREEN_SIZE_DETERMINED)
{
if ((!lpVNCInit->bBitsPerPixel) || (!lpVNCInit->dwHeight) || (!lpVNCInit->dwWidth))
{
LeaveCriticalSection(&csHVNC);
VNCCloseHandle(lpHandle->hHandle);
return -1;
}
SetScreenSize(lpServer,lpVNCInit->dwHeight,lpVNCInit->dwWidth,lpVNCInit->bBitsPerPixel);
}
}
lpServer->Names.dwHash=dwHash;
InitGlobalDataNames(lpServer);
if (!InitGlobalData(lpServer))
{
LeaveCriticalSection(&csHVNC);
VNCCloseHandle(lpHandle->hHandle);
return -1;
}
lpServer->lpClientGoneHook=lpVNCInit->lpClientGoneHook;
lpServer->lpNewClientHook=lpVNCInit->lpNewClientHook;
if (!(lpServer->DeskInfo.dwFlags & HVNC_NO_INJECTS))
{
lstrcpyA(lpServer->lpGlobalVNCData->szDeskName,lpServer->DeskInfo.szDeskName);
lpServer->lpGlobalVNCData->dwDeskFlags=lpVNCInit->dwFlags;
WaitForSingleObject(hHandlesMutex,INFINITE);
for (int i=0; i < HVNC_MAX_HANDLES; i++)
{
if (!lpHandlesMapping[i])
//.........这里部分代码省略.........
开发者ID:12019,项目名称:Carberp,代码行数:101,代码来源:HVNC.cpp
示例10: syncIncrust
static void syncIncrust(Common::Serializer &s) {
int numEntries = 0;
backgroundIncrustStruct *pl, *pl1;
uint8 dummyByte = 0;
uint16 dummyWord = 0;
uint32 dummyLong = 0;
if (s.isSaving()) {
// Figure out the number of entries to save
pl = backgroundIncrustHead.next;
while (pl) {
++numEntries;
pl = pl->next;
}
}
s.syncAsSint16LE(numEntries);
pl = s.isSaving() ? backgroundIncrustHead.next : &backgroundIncrustHead;
pl1 = &backgroundIncrustHead;
for (int i = 0; i < numEntries; ++i) {
backgroundIncrustStruct *t = s.isSaving() ? pl :
(backgroundIncrustStruct *)mallocAndZero(sizeof(backgroundIncrustStruct));
s.syncAsUint32LE(dummyLong);
s.syncAsSint16LE(t->objectIdx);
s.syncAsSint16LE(t->type);
s.syncAsSint16LE(t->overlayIdx);
s.syncAsSint16LE(t->X);
s.syncAsSint16LE(t->Y);
s.syncAsSint16LE(t->frame);
s.syncAsSint16LE(t->scale);
s.syncAsSint16LE(t->backgroundIdx);
s.syncAsSint16LE(t->scriptNumber);
s.syncAsSint16LE(t->scriptOverlayIdx);
s.syncAsUint32LE(dummyLong);
s.syncAsSint16LE(t->saveWidth);
s.syncAsSint16LE(t->saveHeight);
s.syncAsSint16LE(t->saveSize);
s.syncAsSint16LE(t->savedX);
s.syncAsSint16LE(t->savedY);
s.syncBytes((byte *)t->name, 13);
s.syncAsByte(dummyByte);
s.syncAsSint16LE(t->spriteId);
s.syncAsUint16LE(dummyWord);
if (t->saveSize) {
if (s.isLoading())
t->ptr = (byte *)MemAlloc(t->saveSize);
s.syncBytes(t->ptr, t->saveSize);
}
if (s.isSaving())
pl = pl->next;
else {
t->next = NULL;
pl->next = t;
t->prev = pl1->prev;
pl1->prev = t;
pl = t;
}
}
}
开发者ID:vladimir-zahradnik,项目名称:scummvm,代码行数:65,代码来源:saveload.cpp
示例11: InitTags
void InitTags(void)
{
struct tag *tp;
for(tp = tags; tp->name != null; ++tp)
install(tp->name, tp->versions, tp->model, tp->parser, tp->chkattrs);
tag_html = lookup("html");
tag_head = lookup("head");
tag_body = lookup("body");
tag_frameset = lookup("frameset");
tag_frame = lookup("frame");
tag_noframes = lookup("noframes");
tag_meta = lookup("meta");
tag_title = lookup("title");
tag_base = lookup("base");
tag_hr = lookup("hr");
tag_pre = lookup("pre");
tag_listing = lookup("listing");
tag_h1 = lookup("h1");
tag_h2 = lookup("h2");
tag_p = lookup("p");
tag_ul = lookup("ul");
tag_ol = lookup("ol");
tag_dir = lookup("dir");
tag_li = lookup("li");
tag_dl = lookup("dl");
tag_dt = lookup("dt");
tag_dd = lookup("dd");
tag_td = lookup("td");
tag_th = lookup("th");
tag_tr = lookup("tr");
tag_col = lookup("col");
tag_br = lookup("br");
tag_a = lookup("a");
tag_link = lookup("link");
tag_b = lookup("b");
tag_i = lookup("i");
tag_strong = lookup("strong");
tag_em = lookup("em");
tag_big = lookup("big");
tag_small = lookup("small");
tag_param = lookup("param");
tag_option = lookup("option");
tag_optgroup = lookup("optgroup");
tag_img = lookup("img");
tag_map = lookup("map");
tag_area = lookup("area");
tag_nobr = lookup("nobr");
tag_wbr = lookup("wbr");
tag_font = lookup("font");
tag_spacer = lookup("spacer");
tag_layer = lookup("layer");
tag_center = lookup("center");
tag_style = lookup("style");
tag_script = lookup("script");
tag_noscript = lookup("noscript");
tag_table = lookup("table");
tag_caption = lookup("caption");
tag_form = lookup("form");
tag_textarea = lookup("textarea");
tag_blockquote = lookup("blockquote");
tag_applet = lookup("applet");
tag_object = lookup("object");
tag_div = lookup("div");
tag_span = lookup("span");
/* create dummy entry for all xml tags */
xml_tags = (Dict *)MemAlloc(sizeof(*xml_tags));
xml_tags->name = null;
xml_tags->versions = VERS_ALL;
xml_tags->model = CM_BLOCK;
xml_tags->parser = null;
xml_tags->chkattrs = null;
}
开发者ID:IliyanKafedzhiev,项目名称:FacultyOfMathematicAndInformatic,代码行数:75,代码来源:tags.c
示例12: AllocateAcl
/********************************************************************
AllocateAcl - allocate an acl and populate it with this user and
permission information user could be user or domain\user
********************************************************************/
HRESULT AllocateAcl(SCA_SMBP* pssp, PACL* ppACL)
{
HRESULT hr = S_OK;
EXPLICIT_ACCESSW* pEA = NULL;
DWORD cEA = 0;
DWORD dwCounter = 0;
PSID psid = NULL;
LPCWSTR wzUser = NULL;
DWORD nPermissions = 0;
DWORD nErrorReturn = 0;
ACCESS_MODE accessMode = NOT_USED_ACCESS;
cEA = pssp->dwUserPermissionCount + 1;
if (cEA >= MAXSIZE_T / sizeof(EXPLICIT_ACCESSW))
{
ExitOnFailure1(hr = E_OUTOFMEMORY, "Too many user permissions to allocate: %u", cEA);
}
pEA = static_cast<EXPLICIT_ACCESSW*>(MemAlloc(cEA * sizeof(EXPLICIT_ACCESSW), TRUE));
ExitOnNull(pEA, hr, E_OUTOFMEMORY, "failed to allocate memory for explicit access structure");
// figure out how big the psid is
for (dwCounter = 0; dwCounter < pssp->dwUserPermissionCount; ++dwCounter)
{
wzUser = pssp->pUserPerms[dwCounter].wzUser;
nPermissions = pssp->pUserPerms[dwCounter].nPermissions;
accessMode = pssp->pUserPerms[dwCounter].accessMode;
//
// create the appropriate SID
//
// figure out the right user to put into the access block
if (0 == lstrcmpW(wzUser, L"Everyone"))
{
hr = AclGetWellKnownSid(WinWorldSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"Administrators"))
{
hr = AclGetWellKnownSid(WinBuiltinAdministratorsSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"LocalSystem"))
{
hr = AclGetWellKnownSid(WinLocalSystemSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"LocalService"))
{
hr = AclGetWellKnownSid(WinLocalServiceSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"NetworkService"))
{
hr = AclGetWellKnownSid(WinNetworkServiceSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"AuthenticatedUser"))
{
hr = AclGetWellKnownSid(WinAuthenticatedUserSid, &psid);
}
else if (0 == lstrcmpW(wzUser, L"Guests"))
{
hr = AclGetWellKnownSid(WinBuiltinGuestsSid, &psid);
}
else if(0 == lstrcmpW(wzUser, L"CREATOR OWNER"))
{
hr = AclGetWellKnownSid(WinCreatorOwnerSid, &psid);
}
else
{
hr = AclGetAccountSid(NULL, wzUser, &psid);
}
ExitOnFailure1(hr, "failed to get sid for account: %ls", wzUser);
// we now have a valid pSid, fill in the EXPLICIT_ACCESS
/* Permissions options: (see sca.sdh for defined sdl options)
#define GENERIC_READ (0x80000000L) 2147483648
#define GENERIC_WRITE (0x40000000L) 1073741824
#define GENERIC_EXECUTE (0x20000000L) 536870912
#define GENERIC_ALL (0x10000000L) 268435456
*/
pEA[dwCounter].grfAccessPermissions = nPermissions;
pEA[dwCounter].grfAccessMode = accessMode;
pEA[dwCounter].grfInheritance = SUB_CONTAINERS_AND_OBJECTS_INHERIT;
#pragma prefast(push)
#pragma prefast(disable:25029)
::BuildTrusteeWithSidW(&(pEA[dwCounter].Trustee), psid);
#pragma prefast(pop)
}
// create a new ACL that contains the ACE
*ppACL = NULL;
#pragma prefast(push)
#pragma prefast(disable:25029)
nErrorReturn = ::SetEntriesInAclW(dwCounter, pEA, NULL, ppACL);
#pragma prefast(pop)
ExitOnFailure(hr = HRESULT_FROM_WIN32(nErrorReturn), "failed to allocate ACL");
//.........这里部分代码省略.........
开发者ID:925coder,项目名称:wix3,代码行数:101,代码来源:scasmbexec.cpp
示例13: sizeof
ALERROR CGImageCache::ConvertToChannel (HBITMAP hTransparency, CGChannelStruct **retpTrans)
// ConvertToChannel
//
// Converts an 8-bit grayscale bitmap to a channel format
{
BITMAP bm;
CGChannelStruct *pTrans;
HDC hDC;
BYTE bmibuffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
BITMAPINFO *bmi = (BITMAPINFO *)bmibuffer;
RGBQUAD *pColors = (RGBQUAD *)&bmi[1];
// Get some basic info about the bitmap
GetObject(hTransparency, sizeof(BITMAP), &bm);
// Allocate a buffer
pTrans = (CGChannelStruct *)MemAlloc(sizeof(CGChannelStruct) + bm.bmWidthBytes * bm.bmHeight);
if (pTrans == NULL)
return ERR_MEMORY;
// Initialize some stuff
pTrans->cxWidthBytes = bm.bmWidthBytes;
pTrans->cxWidth = bm.bmWidth;
pTrans->cyHeight = bm.bmHeight;
pTrans->pMap = (BYTE *)&pTrans[1];
// Create a BITMAPINFO structure describing how we want the bits
// to be returned to us
utlMemSet(bmi, sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD), 0);
bmi->bmiHeader.biSize = sizeof(BITMAPINFO);
bmi->bmiHeader.biWidth = bm.bmWidth;
bmi->bmiHeader.biHeight = -bm.bmHeight; // negative means top-down
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biBitCount = 8;
bmi->bmiHeader.biCompression = BI_RGB;
hDC = CreateCompatibleDC(NULL);
GetDIBits(hDC, hTransparency, 0, bm.bmHeight, pTrans->pMap, bmi, DIB_RGB_COLORS);
DeleteDC(hDC);
// Color table
#if 0
int i;
for (i = 0; i < 256; i++)
kernelDebugLogMessage("TEST: Color %d = %d,%d,%d",
i,
pColors[i].rgbRed,
pColors[i].rgbGreen,
pColors[i].rgbBlue);
// Convert from palette indeces to grayscale values
for (i = 0; i < pTrans->cxWidthBytes * pTrans->cyHeight; i++)
{
if ((i % pTrans->cxWidthBytes) == 32)
kernelDebugLogMessage("TEST: Color index %d", pTrans->pMap[i]);
pTrans->pMap[i] = pColors[pTrans->pMap[i]].rgbBlue;
}
#endif
// Done
*retpTrans = pTrans;
return NOERROR;
}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:74,代码来源:CGImageCache.cpp
示例14: ReadInLBEPocketPopups
BOOLEAN ReadInLBEPocketPopups(STR fileName)
{
HWFILE hFile;
UINT32 uiBytesRead;
UINT32 uiFSize;
CHAR8 * lpcBuffer;
XML_Parser parser = XML_ParserCreate(NULL);
pocketPopupParseData pData;
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading pocketPopups.xml" );
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
if ( !hFile )
return( FALSE );
uiFSize = FileGetSize(hFile);
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
//Read in block
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
{
MemFree(lpcBuffer);
return( FALSE );
}
lpcBuffer[uiFSize] = 0; //add a null terminator
FileClose( hFile );
XML_SetElementHandler(parser, pocketPopupStartElementHandle, pocketPopupEndElementHandle);
XML_SetCharacterDataHandler(parser, pocketPopupCharacterDataHandle);
memset(&pData,0,sizeof(pData));
XML_SetUserData(parser, &pData);
XML_SetUserData(parser, &pData);
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
{
CHAR8 errorBuf[511];
sprintf(errorBuf, "XML Parser Error in Pocket.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
LiveMessage(errorBuf);
MemFree(lpcBuffer);
return FALSE;
}
/*
// dummy popup
popupDef* popup = new popupDef();
popup->addOption(new std::wstring(L"Option one"),NULL,NULL);
popup->addOption(new std::wstring(L"Option two"),NULL,NULL);
popup->addOption(new std::wstring(L"Option three"),NULL,NULL);
LBEPocketPopup[5] = *popup;
*/
MemFree(lpcBuffer);
XML_ParserFree(parser);
return( TRUE );
}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:70,代码来源:XML_LBEPocketPopup.cpp
示例15: NewSurfaceLocal
/*
* NewSurfaceLocal
*
* Construct a new surface local object.
*/
LPDDRAWI_DDRAWSURFACE_LCL NewSurfaceLocal( LPDDRAWI_DDRAWSURFACE_LCL this_lcl, LPVOID lpvtbl )
{
LPDDRAWI_DDRAWSURFACE_LCL pnew_lcl;
DWORD surf_size_lcl;
DWORD surf_size;
LPDDRAWI_DIRECTDRAW_GBL pdrv;
/*
* NOTE: This single allocation can allocate space for local surface
* structure (DDRAWI_DDRAWSURFACE_LCL) and the additional local surface
* structure (DDRAWI_DDRAWSURFACE_MORE). As the local object can be
* variable sized this can get pretty complex. The layout of the
* various objects in the allocation is as follows:
*
* +-----------------+---------------+
* | SURFACE_LCL | SURFACE_MORE |
* | (variable) | |
* +-----------------+---------------+
* <- surf_size_lcl ->
* <- surf_size --------------------->
*/
if( this_lcl->dwFlags & DDRAWISURF_HASOVERLAYDATA )
{
DPF( 4, "OVERLAY DATA SPACE" );
surf_size_lcl = sizeof( DDRAWI_DDRAWSURFACE_LCL );
}
else
{
surf_size_lcl = offsetof( DDRAWI_DDRAWSURFACE_LCL, ddckCKSrcOverlay );
}
surf_size = surf_size_lcl + sizeof( DDRAWI_DDRAWSURFACE_MORE );
pnew_lcl = MemAlloc( surf_size );
if( pnew_lcl == NULL )
{
return NULL;
}
pdrv = this_lcl->lpGbl->lpDD;
/*
* set up local data
*/
pnew_lcl->lpSurfMore = (LPDDRAWI_DDRAWSURFACE_MORE) (((LPSTR) pnew_lcl) + surf_size_lcl);
pnew_lcl->lpGbl = this_lcl->lpGbl;
pnew_lcl->lpAttachList = NULL;
pnew_lcl->lpAttachListFrom = NULL;
pnew_lcl->dwProcessId = GetCurrentProcessId();
pnew_lcl->dwLocalRefCnt = 0;
pnew_lcl->dwFlags = this_lcl->dwFlags;
pnew_lcl->ddsCaps = this_lcl->ddsCaps;
pnew_lcl->lpDDPalette = NULL;
pnew_lcl->lpDDClipper = NULL;
pnew_lcl->lpSurfMore->lpDDIClipper = NULL;
pnew_lcl->dwModeCreatedIn = this_lcl->dwModeCreatedIn;
pnew_lcl->dwBackBufferCount = 0;
pnew_lcl->ddckCKDestBlt.dwColorSpaceLowValue = 0;
pnew_lcl->ddckCKDestBlt.dwColorSpaceHighValue = 0;
pnew_lcl->ddckCKSrcBlt.dwColorSpaceLowValue = 0;
pnew_lcl->ddckCKSrcBlt.dwColorSpaceHighValue = 0;
pnew_lcl->dwReserved1 = this_lcl->dwReserved1;
/*
* set up overlay specific data
*/
if( this_lcl->dwFlags & DDRAWISURF_HASOVERLAYDATA )
{
pnew_lcl->ddckCKDestOverlay.dwColorSpaceLowValue = 0;
pnew_lcl->ddckCKDestOverlay.dwColorSpaceHighValue = 0;
pnew_lcl->ddckCKSrcOverlay.dwColorSpaceLowValue = 0;
pnew_lcl->ddckCKSrcOverlay.dwColorSpaceHighValue = 0;
pnew_lcl->lpSurfaceOverlaying = NULL;
pnew_lcl->rcOverlaySrc.top = 0;
pnew_lcl->rcOverlaySrc.left = 0;
pnew_lcl->rcOverlaySrc.bottom = 0;
pnew_lcl->rcOverlaySrc.right = 0;
pnew_lcl->rcOverlayDest.top = 0;
pnew_lcl->rcOverlayDest.left = 0;
pnew_lcl->rcOverlayDest.bottom = 0;
pnew_lcl->rcOverlayDest.right = 0;
pnew_lcl->dwClrXparent = 0;
pnew_lcl->dwAlpha = 0;
/*
* if this is an overlay, link it in
*/
if( this_lcl->ddsCaps.dwCaps & DDSCAPS_OVERLAY )
{
pnew_lcl->dbnOverlayNode.next = pdrv->dbnOverlayRoot.next;
pnew_lcl->dbnOverlayNode.prev = (LPVOID)(&(pdrv->dbnOverlayRoot));
pdrv->dbnOverlayRoot.next = (LPVOID)(&(pnew_lcl->dbnOverlayNode));
pnew_lcl->dbnOverlayNode.next->prev = (LPVOID)(&(pnew_lcl->dbnOverlayNode));
// pnew_lcl->dbnOverlayNode.object = pnew_int;
}
}
//.........这里部分代码省略.........
开发者ID:Gaikokujin,项目名称:WinNT4,代码行数:101,代码来源:ddsiunk.c
示例16: main
int main( int argc, char *argv[] )
{
int i;
FILE *f;
int rxflag;
int buff_stdin;
int ch;
screenHeight = GetConsoleHeight();
screenWidth = GetConsoleWidth();
workBuff = MemAlloc( BUFF_SIZE );
buff_stdin = 1;
rxflag = 0;
for( ;; ) {
ch = GetOpt( &argc, argv, "#cftXp:n:", usageMsg );
if( ch == -1 ) {
break;
}
switch( ch ) {
case 'c':
clearScreen = 1;
break;
case 'f':
foldLines = 0;
break;
case 't':
buff_stdin = 0;
break;
case 'n':
screenHeight = atoi( OptArg )+1;
break;
case 'p':
promptString = strdup( OptA
|
请发表评论