unsigned long SysPutEA(unsigned char *name, unsigned long numargs, RXSTRING args[], char *queuename, RXSTRING *retstr) { unsigned long rc; /* Ret code */ unsigned long act; /* open action */ void *fealist; /* fealist buffer */ EAOP2 eaop; /* eaop structure */ PFEA2 pfea; /* pfea structure */ HFILE handle; /* file handle */ if (numargs != 3 || !RXVALIDSTRING(args[0]) || !RXVALIDSTRING(args[1])) return INVALID_ROUTINE; if (rc = DosOpen2(args[0].strptr, &handle, &act, 0L, 0, OPEN_ACTION_OPEN_IF_EXISTS, OPEN_ACCESS_READWRITE + OPEN_SHARE_DENYWRITE + OPEN_FLAGS_FAIL_ON_ERROR + OPEN_FLAGS_WRITE_THROUGH, NULL)) { RETVAL(rc) } if (DosAllocMem((PPVOID)&fealist, 0x00010000L, AllocFlag)) { BUILDRXSTRING(retstr, ERROR_NOMEM); return VALID_ROUTINE; } eaop.fpFEA2List = (PFEA2LIST)fealist;/* Set memory for the FEA */ eaop.fpGEA2List = NULL; /* GEA is unused */ pfea = &eaop.fpFEA2List->list[0]; /* point to first FEA */ pfea->fEA = '\0'; /* set the flags */ /* Size of FEA name field */ pfea->cbName = (BYTE)args[1].strlength; /* Size of Value for this one */ pfea->cbValue = (SHORT)args[2].strlength; /* Set the name of this FEA */ strcpy((PSZ)pfea->szName, args[1].strptr); /* Set the EA value */ memcpy((PSZ)pfea->szName+(pfea->cbName+1), args[2].strptr, args[2].strlength); pfea->oNextEntryOffset = 0; /* no next entry */ eaop.fpFEA2List->cbList = /* Set the total size var */ sizeof(ULONG) + sizeof(FEA2) + pfea->cbName + pfea->cbValue; /* set the file info */ rc = DosSetFileInfo(handle, 2, (PSZ)&eaop, sizeof(EAOP2)); DosClose(handle); /* Close the File */ DosFreeMem(fealist); /* Free the memory */ RETVAL(rc) }
static void test3( void ) { printf("***** Test3: Copy to source memory which is destination memory " "of other source memory...\n"); static const char *p1Str = "6789067890"; static const char *p2Str = "1234512345"; static const char *p3Str = "1234567890"; char *p1; char *p2; char *p3; DosAllocMem(( PPVOID )&p1, ALLOC_SIZE, fPERM | PAG_COMMIT ); strcpy( p1, p3Str); p2 = copyOnWrite( p1, COPY_SIZE ); p3 = copyOnWrite( p2, COPY_SIZE ); printf("p1 = %p, p2 = %p, p3 = %p\n", p1, p2, p3 ); printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 ); printf("Copying %.5s to ( p2 + 5 )\n", p2Str ); memcpy( p2 + 5, p2Str, 5 ); printf("Copying %.5s to p1\n", p1 + 5 ); memcpy( p1, p1 + 5, 5 ); printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 ); fprintf( stderr, "Test3: "); if( memcmp( p1, p1Str, strlen( p1Str )) || memcmp( p2, p2Str, strlen( p2Str )) || memcmp( p3, p3Str, strlen( p3Str ))) fprintf( stderr, "Failed\n"); else fprintf( stderr, "Succeeded\n"); DosFreeMem( p3 ); DosFreeMem( p2 ); DosFreeMem( p1 ); }
static void usalo_freebuf(SCSI *usalp) { if (usalp->bufbase && DosFreeMem(usalp->bufbase)) { fprintf((FILE *)usalp->errfile, "Cannot free buffer memory for ASPI-Router!\n"); /* Free our memory buffer if not already done */ } if (buffer == usalp->bufbase) buffer = NULL; usalp->bufbase = NULL; }
PRStatus _MD_MemUnmap(void *addr, PRUint32 len) { PRUint32 rv; /* we just have to trust that addr & len are those used by MemMap */ rv = DosFreeMem(addr); if (rv) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, rv); return PR_FAILURE; } return PR_SUCCESS; }
void main(void) { initFileTable(); initProcess(0,0); initMemory(); APIRET rc; PVOID pv; rc = DosAllocSharedMem(&pv, "\\SHAREMEM\\Ivan", 8192, PAG_COMMIT|PAG_READ|PAG_WRITE); if(rc==0) rc = DosFreeMem(pv); printf("rc=%d\n",rc); }
// FreeRxString -- Free a REXX string. // // Return: none // void FreeRxString( PRXSTRING rxString) { if ( rxString != NULL && rxString->strptr != NULL) { DosFreeMem(rxString->strptr); rxString->strptr = NULL; rxString->strlength = 0; } }
int ReadConfigFile(HWND hwnd, char szFileSpec[],char **ppBuffer) { ULONG ulStatus; HFILE hFile; FILESTATUS3 stFileInfo; int iCount; char szMessage[CCHMAXPATH]; APIRET rc; if ((rc = DosOpen(szFileSpec,&hFile,&ulStatus,0L,0,1,0x0022,(PEAOP2)0L)) != 0) { if (hwnd != NULLHANDLE) { sprintf(szMessage,"Could not open %s - Error = %u",szFileSpec,rc); MessageBox(HWND_DESKTOP,szMessage); } return(0); } DosQueryFileInfo(hFile,1,&stFileInfo,sizeof(FILESTATUS3)); iCount = stFileInfo.cbFile; if ((rc = DosAllocMem((PVOID)ppBuffer,(iCount + 10),(PAG_COMMIT | PAG_READ | PAG_WRITE))) != NO_ERROR) { if (hwnd != NULLHANDLE) { sprintf(szMessage,"Unable to Allocate memory to read %s - %u",szFileSpec,rc); MessageBox(HWND_DESKTOP,szMessage); } iCount = 0; } if (DosRead(hFile,(PVOID)*ppBuffer,iCount,(ULONG *)&iCount) != 0) { DosFreeMem(*ppBuffer); iCount = 0; } else { /* ** ignore/remove EOF character, if present */ if ((*ppBuffer)[(iCount) - 1] == '\x1a') iCount--; /* ** Add LF and CR to end of file, if not already there */ if ((*ppBuffer)[iCount - 1] != '\x0a') { (*ppBuffer)[(iCount)++] = '\x0d'; (*ppBuffer)[(iCount)++] = '\x0a'; } } DosClose(hFile); return(iCount); }
BOOL MemHeapTerm(VOID) { if ( hp ) { return !(_uclose(hp) || _udestroy(hp, _FORCE) || DosSubUnsetMem(pbasemem) || DosFreeMem(pbasemem)); } /* endif */ closeLogFile(); return FALSE; }
VOID Clipper_RestoreClipboard( VOID ) { // Переносим в Clipboard предыдущие данные. CHAR Mozilla_internal_format[] = "text/unicode"; PutStringIntoClipboard( Enhancer.Application, Clipper.RTSettings.Clipboard_data_Text, Clipper.RTSettings.Clipboard_data_UCS2, Clipper.RTSettings.Clipboard_data_UCS2_length, Mozilla_internal_format ); // Освобождаем память. if( Clipper.RTSettings.Clipboard_data_Text != NULL ) { DosFreeMem( Clipper.RTSettings.Clipboard_data_Text ); Clipper.RTSettings.Clipboard_data_Text = NULL; } if( Clipper.RTSettings.Clipboard_data_UCS2 != NULL ) { DosFreeMem( Clipper.RTSettings.Clipboard_data_UCS2 ); Clipper.RTSettings.Clipboard_data_UCS2 = NULL; } Clipper.RTSettings.Clipboard_data_Text_length = 0; Clipper.RTSettings.Clipboard_data_UCS2_length = 0; // Возврат. return; }
void * _MD_MemMap(PRFileMap *fmap, PROffset64 offset, PRUint32 len) { PRUint32 rv; void *addr; /* prevent mappings beyond EOF + remainder of page */ if (offset + len > fmap->md.maxExtent) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return NULL; } if (PR_Seek64(fmap->fd, offset, PR_SEEK_SET) == -1) { return NULL; } /* try for high memory, fall back to low memory if hi-mem fails */ #if defined(MOZ_OS2_HIGH_MEMORY) rv = DosAllocMem(&addr, len, OBJ_ANY | PAG_COMMIT | PAG_READ | PAG_WRITE); if (rv) #endif { rv = DosAllocMem(&addr, len, PAG_COMMIT | PAG_READ | PAG_WRITE); if (rv) { PR_SetError(PR_OUT_OF_MEMORY_ERROR, rv); return NULL; } } if (PR_Read(fmap->fd, addr, len) == -1) { DosFreeMem(addr); return NULL; } /* don't permit writes if readonly */ if (fmap->prot == PR_PROT_READONLY) { rv = DosSetMem(addr, len, PAG_READ); if (rv) { DosFreeMem(addr); PR_SetError(PR_UNKNOWN_ERROR, rv); return NULL; } } return addr; }
MRESULT EXPENTRY helpProc( HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2 ) { LONG bytes; IPT ipt; switch ( msg ) { case WM_INITDLG: WinSendMsg (WinWindowFromID(hwndDlg, ID_HELPENTRY), MLM_SETTEXTLIMIT, MPFROMLONG (30000L), (MPARAM) 0L); WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY), MLM_SETTEXTCOLOR, MPFROMLONG (CLR_DARKBLUE), 0L); WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY), MLM_SETBACKCOLOR, MPFROMLONG (CLR_WHITE), 0L); bytes = loadFile("DataPad.DOC"); if( bytes <= 0 ) { DosFreeMem(iobuf); WinDismissDlg( hwndDlg, TRUE ); } WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY), MLM_SETIMPORTEXPORT, (MPARAM) iobuf, MPFROMLONG(bytes)); ipt = -1; WinSendMsg(WinWindowFromID(hwndDlg, ID_HELPENTRY), MLM_IMPORT, (MPARAM)&ipt, MPFROMLONG(bytes)); DosFreeMem(iobuf); return WinDefDlgProc( hwndDlg, msg, mp1, mp2 ); default : return WinDefDlgProc( hwndDlg, msg, mp1, mp2 ); } }
static void test6( void ) { printf("***** Test6: Decommit source memory...\n"); static const char *p2Str = "6789067890"; static const char *p3Str = "1234567890"; char *p1; char *p2; char *p3; DosAllocMem(( PPVOID )&p1, ALLOC_SIZE, fPERM | PAG_COMMIT ); strcpy( p1, p3Str); p2 = copyOnWrite( p1, COPY_SIZE ); p3 = copyOnWrite( p2, COPY_SIZE ); printf("p1 = %p, p2 = %p, p3 = %p\n", p1, p2, p3 ); printf("p1 = [%s], p2 = [%s], p3 = [%s]\n", p1, p2, p3 ); printf("Decommiting p1\n"); printf("DosSetMem( p1 ) = %ld\n", DosSetMem( p1, ALLOC_SIZE, PAG_DECOMMIT )); printf("Copying %.5s to p2\n", p2 + 5 ); memcpy( p2, p2 + 5, 5 ); printf("p2 = [%s], p3 = [%s]\n", p2, p3 ); fprintf( stderr, "Test6: "); if( memcmp( p2, p2Str, strlen( p2Str )) || memcmp( p3, p3Str, strlen( p3Str ))) fprintf( stderr, "Failed\n"); else fprintf( stderr, "Succeeded\n"); DosFreeMem( p3 ); DosFreeMem( p2 ); DosFreeMem( p1 ); }
//save current settings to the given ini file BOOL CBZSave(HINI hIni, char szClass[], PVOID pData, char szCustomName[]) { PLUGINSHARE *pPluginShare; char szShareName[32]; char szSaveName[128]; pPluginShare = (PLUGINSHARE *) pData; //if null, this is a default apply, so load shared memory. if (pPluginShare == NULL) { strcpy(szShareName, PLUGIN_SHARE); strcat(szShareName, szClass); // if shared mem is not available, try allocating temporary space! if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ | PAG_WRITE) != NO_ERROR) { //try Allocating temporary space for the plugin data so we can write to the ini file if (DosAllocMem((PPVOID) & pPluginShare, sizeof(PLUGINSHARE), PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR) return (FALSE); //No Good... can't save. } //write pPluginShare to the ini file! strcpy(szSaveName, szClass); strcat(szSaveName, "_CBZLINESPlugin"); PrfWriteProfileData(hIni, "UserOptionsData", szSaveName, pPluginShare, sizeof(PLUGINSHARE)); DosFreeMem(pPluginShare); } else { strcpy(szSaveName, szCustomName); strcat(szSaveName, "_"); strcat(szSaveName, szClass); strcat(szSaveName, "_CBZLINESPlugin"); PrfWriteProfileData(hIni, "CustomOptionsData", szSaveName, pPluginShare, sizeof(PLUGINSHARE)); } return (TRUE); }
/*@ XBitmap :: ReleaseFilterStruct (XBitmapFilter * params) @group loading/saving a bitmap @remarks Released bitmap-filters created by XBitmap :: GetImportFilter/GetExportFilter and XGLibFileDialog @parameters <t 'ø' c=2> øchar * filename øfilename of the file to load (later) <\t> @exceptions If the method fails to create a new bitmap an exception of the type XException is thrown. */ void XBitmap :: ReleaseFilterStruct (XBitmapFilter * params) { int n; if(params) { if (BFT_TIFF == params->cFilterID) for (n = 0; n < BFP_TIFF_TAGCOUNT; n++) { free (((XTIFFExportFilter*) params)->pszTagValue [n]); ((XTIFFExportFilter*) params)->pszTagValue [n] = NULL; } DosFreeMem (params); } /* end if */ params = NULL; }
char *PSBMLoadBitmapFile( char *pszFileName, GBM *pgbm, GBMRGB *pgbmrgb ) { HFILE hBMPFile; ULONG ulNewFile; ULONG ulStride; ULONG cbData; char *pchData; if( DosOpen( pszFileName, &hBMPFile, &ulNewFile, 0L, FILE_NORMAL, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYWRITE | OPEN_ACCESS_READONLY, NULL ) != 0L ) { return( NULL ); } if( GBMReadBMPHeader( hBMPFile, pgbm ) != TRUE ) // read bmp header { DosClose( hBMPFile ); return( NULL ); } if( GBMReadPalette( hBMPFile, pgbm, pgbmrgb ) != TRUE ) // read bmp palette { DosClose( hBMPFile ); return( NULL ); } ulStride = ( ( pgbm->w * pgbm->bpp + 31 ) / 32 ) * 4; // calculate size of data and alloc it cbData = pgbm->h * ulStride; if( DosAllocMem( ( PPVOID )&pchData, cbData, PAG_READ | PAG_WRITE | PAG_COMMIT ) != 0 ) { DosClose( hBMPFile ); return( NULL ); } if( GBMReadData( hBMPFile, pgbm, pchData ) != TRUE ) // read it in { DosFreeMem( pchData ); DosClose( hBMPFile ); return( NULL ); } DosClose( hBMPFile ); return( pchData ); }
void scsi_close_device ( ) { if (postSema) DosCloseEventSem(postSema); // Close event semaphore. postSema = 0; if (driver_handle) // Close driver. DosClose(driver_handle); driver_handle = 0; if (buffer) // Free buffer. DosFreeMem(buffer); buffer = 0; }
ICQSHAREMEM * EXPENTRY icqIPCGetSharedBlock(void) { int rc = -1; ICQSHAREMEM *shareBlock; if(DosGetNamedSharedMem((PPVOID) &shareBlock,PWICQ_SHAREMEM,PAG_READ|PAG_WRITE)) return NULL; if(shareBlock->sz == sizeof(ICQSHAREMEM) && shareBlock->si == sizeof(ICQINSTANCE)) return shareBlock; DosFreeMem(shareBlock); return NULL; }
_WCRTLINK unsigned _dos_freemem( mem_id mem ) { #if defined(__386__) || defined(__PPC__) APIRET rc; rc = DosFreeMem( mem ); if( rc ) { return( __set_errno_dos_reterr( rc ) ); } return( 0 ); #elif defined( _M_I86 ) // defined inside heap return( __FreeSeg( mem ) ); #else #error platform not supported #endif }
LONG SelectScalableFont(HPS hPS, CHAR *pszFacename) { LONG cFonts; /* Fonts Count */ LONG lFontsTotal = 0L; /* Fonts Total Count */ LONG lMatch = 1L; /* Font Match Value */ PFONTMETRICS pfm; /* Font Metrics Pointer */ register INT i; /* Loop Counter */ /* Get the number of fonts for the face name */ /* provided */ DosAllocMem((PPVOID)(PVOID)&pfm, (ULONG)(sizeof(FONTMETRICS) * (cFonts = GpiQueryFonts(hPS, QF_PUBLIC, pszFacename, &lFontsTotal, sizeof(FONTMETRICS), (PFONTMETRICS)NULL))), PAG_READ | PAG_WRITE | PAG_COMMIT); /* Make a pointer for the memory allocated for */ /* the font metrics and get the font metrics for */ /* the number of fonts for the face name */ /* provided */ GpiQueryFonts(hPS, QF_PUBLIC, pszFacename, &cFonts, sizeof(FONTMETRICS), pfm); /* Loop through the font metrics returned to */ /* locate the desired font by matching the x and */ /* y device resolution of the font and the point */ /* size */ for ( i = 0; i < (INT)cFonts; i++ ) if ( (pfm[i].sXDeviceRes == 1000) && (pfm[i].sYDeviceRes == 1000) ) { /* Font found, get the match value to allow the */ /* exact font to be selected by the calling */ /* application */ lMatch = pfm[i].lMatch; break; } /* Release the memory allocated for the font */ /* metrics array */ DosFreeMem(pfm); /* Return the match value to the calling */ /* application */ return(lMatch); }
int main (VOID) { PVOID pvShrObject = NULL; /* Pointer to shared memory object */ PSZ pszMemName = "\\SHAREMEM\\MYTOOL\\APPLICAT.DAT"; /* Object name */ PVOID pvAltObject = NULL; /* Alternate pointer to shared memory */ APIRET rc = NO_ERROR; /* Return code */ ULONG ulObjSize = 1024; /* Size (system rounds to 4096 - page bdy) */ rc = DosAllocSharedMem(&pvShrObject, /* Pointer to object pointer */ pszMemName, /* Name for shared memory */ ulObjSize, /* Desired size of object */ PAG_COMMIT | /* Commit memory */ PAG_WRITE ); /* Allocate memory as read/write */ if (rc != NO_ERROR) { printf("DosAllocSharedMem error: return code = %u\n",rc); return 1; } strcpy(pvShrObject, "Write your shared application data here."); /* Get the address of the shared memory and reference it that way. (Done for illustrative purposes only, this is how another process would go about accessing the named shared memory.) */ rc = DosGetNamedSharedMem(&pvAltObject, /* Pointer to pointer of object */ pszMemName, /* Name of shared memory */ PAG_READ); /* Want read-only access */ if (rc != NO_ERROR) { printf("DosGetNamedSharedMem error: return code = %u\n",rc); return 1; } printf("Shared data read was \"%s\"\n",pvAltObject); rc = DosFreeMem(pvShrObject); if (rc != NO_ERROR) { printf("DosFreeMem error: return code = %u\n",rc); return 1; } return NO_ERROR; }
APIRET os2APIENTRY DosPurgeQueue(HQUEUE hq) { Queue *q=(Queue*)hq; if(q>=queue && q<queue+MAXQUEUES && q->used==1) { WaitForSingleObject(q->hmtx_modify,INFINITE); for(int i=0; i<q->elements; i++) if(q->e[i].putter!=GetCurrentProcessId()) DosFreeMem(q->e[i].base); q->elements = 0; ResetEvent(q->hev_notempty); if(q->uhev_notempty!=0) { ULONG ul; DosResetEventSem(q->uhev_notempty,&ul); } ReleaseMutex(q->hmtx_modify); return 0; } else return 337; }
VOID storeMsg( char *format, ... ) { static char buf[ 257 ] = { 0, }; PVOID msg = NULL; va_list arg; va_start( arg, format ); vsprintf( buf, format, arg ); va_end( arg ); DosAllocSharedMem( &msg, NULL, strlen( buf ) + 1, fALLOCSHR ); strcpy( msg, buf ); WinSendMsg( hwndKHS, KHSM_STOREMSG, ( MPARAM )msg, 0 ); DosFreeMem( msg ); }
/*************************************************************************** * * * BOOL close_driver() * * * * Closes the device driver * * Returns: * * TRUE - Success * * FALSE - Unsuccessful closing of device driver * * * * Preconditions: ASPI Router driver has be opened with open_driver * * * ***************************************************************************/ static BOOL close_driver() { ULONG rc; /* return value */ if (driver_handle) { rc = DosClose(driver_handle); if (rc) return (FALSE); /* closing failed -> return false */ driver_handle = 0; if (DosCloseEventSem(postSema)) fprintf(stderr, "Cannot close event semaphore!\n"); if (buffer && DosFreeMem(buffer)) { fprintf(stderr, "Cannot free buffer memory for ASPI-Router!\n"); /* Free our memory buffer if not already done */ } buffer = NULL; } return (TRUE); }
/* * This function calls the allocation function depending on which * method was compiled into the library: it can be native allocation * (DosAllocMem/DosFreeMem) or C-Library based allocation (malloc/free). * Actually, for pixel buffers that we use this function for, cairo * uses _cairo_malloc_abc, so we use that here, too. And use the * change to check the size argument */ void *_buffer_alloc (size_t a, size_t b, const unsigned int size) { /* check length like in the _cairo_malloc_abc macro, but we can leave * away the unsigned casts as our arguments are unsigned already */ size_t nbytes = b && a >= INT32_MAX / b ? 0 : size && a*b >= INT32_MAX / size ? 0 : a * b * size; void *buffer = NULL; #ifdef OS2_USE_PLATFORM_ALLOC APIRET rc = NO_ERROR; rc = DosAllocMem ((PPVOID)&buffer, nbytes, #ifdef OS2_HIGH_MEMORY /* only if compiled with high-memory support, */ OBJ_ANY | /* we can allocate anywhere! */ #endif PAG_READ | PAG_WRITE | PAG_COMMIT); if (rc != NO_ERROR) { /* should there for some reason be another error, let's return * a null surface and free the buffer again, because that's * how a malloc failure would look like */ if (rc != ERROR_NOT_ENOUGH_MEMORY && buffer) { DosFreeMem (buffer); } return NULL; } #else buffer = malloc (nbytes); #endif /* This does not seem to be needed, malloc'd space is usually * already zero'd out! */ /* * memset (buffer, 0x00, nbytes); */ return buffer; }
APIRET APIENTRY DosListIO(ULONG ulCmdMode, ULONG ulNumentries, PLISTIO pListIO) { PLISTIO q; PLISTIOL pListIOL, p; ULONG rc, rc2; int i; rc2 = DosAllocMem((void **)&pListIOL, ulNumentries * sizeof(LISTIOL), PAG_COMMIT | PAG_READ | PAG_WRITE); if (rc2) return rc2; for (i = 0, p = pListIOL, q = pListIO; i < ulNumentries; i++, p++, q++) { p->hFile = q->hFile; p->CmdFlag = q->CmdFlag; p->Offset.ulLo = q->Offset; p->Offset.ulHi = 0; p->pBuffer = q->pBuffer; p->NumBytes = q->NumBytes; } rc = DosListIOL(ulCmdMode, ulNumentries, pListIOL); for (i = 0, p = pListIOL, q = pListIO; i < ulNumentries; i++, p++, q++) { q->Offset = p->Offset.ulLo; q->pBuffer = p->pBuffer; q->Actual = p->Actual; } rc2 = DosFreeMem(pListIOL); if (rc2) return rc2; return rc; }
//cleanup resources generated by CBZInit BOOL CBZDestroy(HWND hwnd, PVOID pData) { PLUGINSHARE *pPluginData; pPluginData = (PLUGINSHARE *) pData; //Restore the Original Images. #if 0 WinSendMsg(hwnd, MM_SETITEMHANDLE, MPFROMSHORT(SC_RESTORE), MPFROMLONG(pPluginData->hbmOldRestore) ); WinSendMsg(hwnd, MM_SETITEMHANDLE, MPFROMSHORT(SC_MAXIMIZE), MPFROMLONG(pPluginData->hbmOldMaximize) ); WinSendMsg(hwnd, MM_SETITEMHANDLE, MPFROMSHORT(SC_HIDE), MPFROMLONG(pPluginData->hbmOldHide) ); WinSendMsg(hwnd, MM_SETITEMHANDLE, MPFROMSHORT(SC_MINIMIZE), MPFROMLONG(pPluginData->hbmOldMinimize) ); WinSendMsg(hwnd, MM_SETITEMHANDLE, MPFROMSHORT(SC_CLOSE), MPFROMLONG(pPluginData->hbmOldClose) ); #endif if (pPluginData->hbmActiveMinimize != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmActiveMinimize); if (pPluginData->hbmInactiveMinimize != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmInactiveMinimize); if (pPluginData->hbmActiveMaximize != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmActiveMaximize); if (pPluginData->hbmInactiveMaximize != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmInactiveMaximize); if (pPluginData->hbmActiveRestore != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmActiveRestore); if (pPluginData->hbmInactiveRestore != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmInactiveRestore); if (pPluginData->hbmActiveClose != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmActiveClose); if (pPluginData->hbmInactiveClose != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmInactiveClose); if (pPluginData->hbmActiveHide != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmActiveHide); if (pPluginData->hbmInactiveHide != NULLHANDLE) GpiDeleteBitmap(pPluginData->hbmInactiveHide); DosFreeMem(pPluginData); return (TRUE); }
void os2ldRemoveFromHeap(Heap_t H, void *memory, size_t size) { if (H != os2ldHeap) { xf86Msg(X_ERROR, "OS2LD: Heap corruption in ShrinkHeap, p=%08x\n",H); return; } /* Currently we do nothing, as we do not keep track of the * commited memory */ /* Only handle it if it is the base address */ if (memory == os2ldBase) { DosFreeMem(os2ldBase); #ifdef DEBUG xf86Msg(X_INFO,"OS2LD: total heap area deallocated\n"); #endif os2ldBase = 0; FirstTime = TRUE; } }
int PutClipText(ClipData *cd) { int rc; ULONG PostCount; char *mem; rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn); if (rc != 0) return -1; /* rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet);*/ /* if (rc != 0) return -1;*/ rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut); if (rc != 0) return -1; rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd); if (rc != 0) return -1; DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT); DosResetEventSem(hevEnd, &PostCount); if (0 == DosAllocSharedMem((void **)&mem, MEM_PREFIX "CLIPDATA", cd->fLen + 5, PAG_COMMIT | PAG_READ | PAG_WRITE)) { ULONG L = cd->fLen; memcpy((void *)mem, (void *)&L, 4); strcpy(mem + 4, cd->fChar); } DosPostEventSem(hevPut); DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT); DosPostEventSem(hevPut); DosReleaseMutexSem(hmtxSyn); DosCloseEventSem(hevPut); /* DosCloseEventSem(hevGet); */ DosCloseEventSem(hevEnd); DosCloseMutexSem(hmtxSyn); if (mem) DosFreeMem(mem); return 0; }
int EXPENTRY icqIPCQueryInstance(ULONG *instance) { int rc = -1; ICQSHAREMEM *shareBlock; int f; rc = DosGetNamedSharedMem((PPVOID) &shareBlock,PWICQ_SHAREMEM,PAG_READ|PAG_WRITE); DBGTrace(rc); if(rc) return rc; if(shareBlock->sz == sizeof(ICQSHAREMEM) && shareBlock->si == sizeof(ICQINSTANCE)) { /* Tenho um bloco valido, procuro por um UIN ativo */ *instance = 0; rc = ERROR_FILE_NOT_FOUND; for(f=0; f < PWICQ_MAX_INSTANCES && !*instance;f++) { if( (shareBlock->i+f)->uin ) { rc = 0; *instance = (shareBlock->i+f)->uin; } } } else { rc = ERROR_INVALID_BLOCK; } DosFreeMem(shareBlock); return rc; }
//change current settings. BOOL CBZApply(char szClass[], KEY_VALUE * kv, int count, int enabledState, PVOID pData) { int i; PLUGINSHARE *pPluginShare; char szShareName[32]; char szSaveName[32]; BOOL bDefaultApply = FALSE; pPluginShare = (PLUGINSHARE *) pData; //if null, this is a default apply, so load shared memory. if (pPluginShare == NULL) { strcpy(szShareName, PLUGIN_SHARE); strcat(szShareName, szClass); // if shared mem is not available, try allocating temporary space! if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ | PAG_WRITE) != NO_ERROR) { return FALSE; } bDefaultApply = TRUE; } pPluginShare->sEnabledStates = enabledState; //loop through each key/value pair and set appropriate parameters for (i = 0; i < count; i++) { if (strcmp(kv[i].key, "ImageFile") == 0) { strcpy(pPluginShare->szImageFile, kv[i].value); } } //end for loop if (bDefaultApply) DosFreeMem(pPluginShare); return TRUE; }