当前位置:首页 > 百科 > 正文

关于OPENLEAKS的信息

  • 百科
  • 2023-02-28 11:05:47
  • 55
摘要: 今天给各位分享OPENLEAKS的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!本文目录...

今天给各位分享OPENLEAKS的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

《Open Secrets Wiki Leaks》txt下载在线阅读全文,求百度网盘云资源

《Open Secrets》(New York Times Staff)电子书网盘下载免费在线阅读

链接:

提取码: jq3i

书名:Open Secrets

作者:New York Times Staff

出版社:Grove Press

出版年份:2011-4-19

页数:608

内容简介:

In 2010, the anti-secrecy organization known as WikiLeaks made headlines around the world when it released thousands of classified U.S. government diplomatic cables and battlefield reports. The New York Times played a crucial role in breaking the WikiLeaks story, and “Open Secrets” is the definitive chronicle of the documents’ release and the controversy that ensued. It includes detailed analyses of the documents by Times correspondents; opinion essays by Frank Rich, Maureen Dowd and others; and the full text of all the cables and war logs posted on The Times's Web site, along with 27 new cables selected for this volume. It also includes an essay in which the executive editor of The Times, Bill Keller, explains how the newspaper came to publish documents obtained by WikiLeaks, and why it did; expanded profiles of Julian Assange, WikiLeaks's founder, and Bradley Manning, the Army private suspected of being his source; and original essays on what the fracas has revealed about American diplomacy and government secrecy. A legal and technological thriller and a primer on world politics, "Open Secrets" is also a field guide to how information and power are wielded today, and why it matters.

ios leaks 对应 源代码怎么修改

Here are some tips for finding leaks in our project:

1. 打开Instruments调试工具控制栏, Xcode - Open Dev Tool - Instruments

2.选择Leaks工具

3.设置Leaks内选项 选择Leaks, 选择Call Tree

4.Run your App !

5.设置Call Tree 选择Invert Call Tree , Hide System Libraries,

然后选择Leaks的项目 Target为你运行中的App, 点击红色圆圈运行,操作你App,

有红色的柱状就代表有内存泄露,查看相应的代码,解决!

在MFC中,如何读取外部的位图文件,让它显示在图片控件(Picture Control)中?

告诉你一个最简单的方法,你一定可以的,弄好了记得给我加分.

1.在你的对话框添一个按钮和一个图片控件(Picture Control).

2.添加一个类,我这里上传不了,只能将.h和.cpp复制过来,你再将拷贝到txt里,改一下扩展名就可以了。

这是Picture.h

#if !defined(AFX_PICTURE_H__COPYFREE_BY_YOVAV_GAD__SOURCES_AT_SUPERMAIN_DOT_COM__INCLUDED_)

#define AFX_PICTURE_H__COPYFREE_BY_YOVAV_GAD__SOURCES_AT_SUPERMAIN_DOT_COM__INCLUDED_

#if _MSC_VER 1000

#pragma once

#endif // _MSC_VER 1000

class CPicture

{

public:

void FreePictureData();

BOOL Load(CString sFilePathName);

BOOL Load(UINT ResourceName, LPCSTR ResourceType);

BOOL LoadPictureData(BYTE* pBuffer, int nSize);

BOOL SaveAsBitmap(CString sFilePathName);

BOOL Show(CDC* pDC, CPoint LeftTop, CPoint WidthHeight, int MagnifyX, int MagnifyY);

BOOL Show(CDC* pDC, CRect DrawRect);

BOOL ShowBitmapResource(CDC* pDC, const int BMPResource, CPoint LeftTop);

BOOL UpdateSizeOnDC(CDC* pDC);

CPicture();

virtual ~CPicture();

IPicture* m_IPicture; // Same As LPPICTURE (typedef IPicture __RPC_FAR *LPPICTURE)

LONG m_Height; // Height (In Pixels Ignor What Current Device Context Uses)

LONG m_Weight; // Size Of The Image Object In Bytes (File OR Resource)

LONG m_Width; // Width (In Pixels Ignor What Current Device Context Uses)

};

#endif

这是Picture.cpp

#include "stdafx.h"

#include "Picture.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

#define HIMETRIC_INCH 2540

#define ERROR_TITLE "CPicture Error" // Error Title (Related To This Class)...

//-----------------------------------------------------------------------------

// Does: Constructor - Create a New CPicture Object To Hold Picture Data

// ~~~~

//

//-----------------------------------------------------------------------------

CPicture::CPicture()

//=============================================================================

{

m_IPicture = NULL;

m_Height = 0;

m_Weight = 0;

m_Width = 0;

}

//-----------------------------------------------------------------------------

// Does: Destructor - Free Data And Information From The CPicture Object

// ~~~~

//

//-----------------------------------------------------------------------------

CPicture::~CPicture()

//=============================================================================

{

if(m_IPicture != NULL) FreePictureData(); // Important - Avoid Leaks...

}

//-----------------------------------------------------------------------------

// Does: Free The Allocated Memory That Holdes The IPicture Interface Data

// ~~~~ And Clear Picture Information

//

// Note: This Might Also Be Useful If U Only Need To Show The Picture Once

// ~~~~~ Or If U Copy The Picture To The Device Context, So It Can Still

// Remain On Screen - But IPicture Data Is Not Needed No More

//

//-----------------------------------------------------------------------------

void CPicture::FreePictureData()

//=============================================================================

{

if(m_IPicture != NULL)

{

m_IPicture-Release();

m_IPicture = NULL;

m_Height = 0;

m_Weight = 0;

m_Width = 0;

}

}

//-----------------------------------------------------------------------------

// Does: Open a Resource And Load It Into IPicture (Interface)

// ~~~~ (.BMP .DIB .EMF .GIF .ICO .JPG .WMF)

//

// Note: When Adding a Bitmap Resource It Would Automatically Show On "Bitmap"

// ~~~~ This NOT Good Coz We Need To Load It From a Custom Resource "BMP"

// To Add a Custom Rresource: Import Resource - Open As - Custom

// (Both .BMP And .DIB Should Be Found Under "BMP")

//

// InPut: ResourceName - As a UINT Defined (Example: IDR_PICTURE_RESOURCE)

// ~~~~~ ResourceType - Type Name (Example: "JPG")

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::Load(UINT ResourceName, LPCSTR ResourceType)

//=============================================================================

{

BOOL bResult = FALSE;

HGLOBAL hGlobal = NULL;

HRSRC hSource = NULL;

LPVOID lpVoid = NULL;

int nSize = 0;

if(m_IPicture != NULL) FreePictureData(); // Important - Avoid Leaks...

hSource = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(ResourceName), ResourceType);

if(hSource == NULL)

{

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "FindResource() Failed\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

hGlobal = LoadResource(AfxGetResourceHandle(), hSource);

if(hGlobal == NULL)

{

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "LoadResource() Failed\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

lpVoid = LockResource(hGlobal);

if(lpVoid == NULL)

{

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "LockResource() Failed\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

nSize = (UINT)SizeofResource(AfxGetResourceHandle(), hSource);

if(LoadPictureData((BYTE*)hGlobal, nSize)) bResult = TRUE;

UnlockResource(hGlobal); // 16Bit Windows Needs This

FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)

m_Weight = nSize; // Update Picture Size Info...

if(m_IPicture != NULL) // Do Not Try To Read From Memory That Is Not Exist...

{

m_IPicture-get_Height(m_Height);

m_IPicture-get_Width(m_Width);

// Calculate Its Size On a "Standard" (96 DPI) Device Context

m_Height = MulDiv(m_Height, 96, HIMETRIC_INCH);

m_Width = MulDiv(m_Width, 96, HIMETRIC_INCH);

}

else // Picture Data Is Not a Known Picture Type

{

m_Height = 0;

m_Width = 0;

bResult = FALSE;

}

return(bResult);

}

//-----------------------------------------------------------------------------

// Does: Open a File And Load It Into IPicture (Interface)

// ~~~~ (.BMP .DIB .EMF .GIF .ICO .JPG .WMF)

//

// InPut: sFilePathName - Path And FileName Target To Save

// ~~~~~

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::Load(CString sFilePathName)

//=============================================================================

{

BOOL bResult = FALSE;

CFile PictureFile;

CFileException e;

int nSize = 0;

if(m_IPicture != NULL) FreePictureData(); // Important - Avoid Leaks...

if(PictureFile.Open(sFilePathName, CFile::modeRead | CFile::typeBinary, e))

{

nSize = PictureFile.GetLength();

BYTE* pBuffer = new BYTE[nSize];

if (PictureFile.Read(pBuffer, nSize) 0 ) //从文件读到pBuffer

{ if(LoadPictureData(pBuffer, nSize)) bResult = TRUE; }//接作调用函数读pBuffer

PictureFile.Close();

delete [] pBuffer;

}

else // Open Failed...

{

TCHAR szCause[255];

e.GetErrorMessage(szCause, 255, NULL);

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, szCause, ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

bResult = FALSE;

}

m_Weight = nSize; // Update Picture Size Info...

if(m_IPicture != NULL) // Do Not Try To Read From Memory That Is Not Exist...

{

m_IPicture-get_Height(m_Height);

m_IPicture-get_Width(m_Width);

// Calculate Its Size On a "Standard" (96 DPI) Device Context

m_Height = MulDiv(m_Height, 96, HIMETRIC_INCH);

m_Width = MulDiv(m_Width, 96, HIMETRIC_INCH);

}

else // Picture Data Is Not a Known Picture Type

{

m_Height = 0;

m_Width = 0;

bResult = FALSE;

}

return(bResult);

}

//-----------------------------------------------------------------------------

// Does: Read The Picture Data From a Source (File / Resource)

// ~~~~ And Load It Into The Current IPicture Object In Use

//

// InPut: Buffer Of Data Source (File / Resource) And Its Size

// ~~~~~

//

// OutPut: Feed The IPicture Object With The Picture Data

// ~~~~~~ (Use Draw Functions To Show It On a Device Context)

// TRUE If Succeeded...

//-----------------------------------------------------------------------------

BOOL CPicture::LoadPictureData(BYTE *pBuffer, int nSize)

//=============================================================================

{

BOOL bResult = FALSE;

HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, nSize);

if(hGlobal == NULL)

{

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "Can not allocate enough memory\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

void* pData = GlobalLock(hGlobal);

memcpy(pData, pBuffer, nSize);

GlobalUnlock(hGlobal);

IStream* pStream = NULL;

if(CreateStreamOnHGlobal(hGlobal, TRUE, pStream) == S_OK)

{

HRESULT hr;

if((hr = OleLoadPicture(pStream, nSize, FALSE, IID_IPicture, (LPVOID *)m_IPicture)) == E_NOINTERFACE)

{

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "IPicture interface is not supported\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

else // S_OK

{

pStream-Release();

pStream = NULL;

bResult = TRUE;

}

}

FreeResource(hGlobal); // 16Bit Windows Needs This (32Bit - Automatic Release)

return(bResult);

}

//-----------------------------------------------------------------------------

// Does: Draw The Loaded Picture Direct To The Client DC

// ~~~~

//

// Note: Bigger OR Smaller Dimentions Than The Original Picture Size

// ~~~~ Will Draw The Picture Streached To Its New Given NEW Dimentions...

//

// InPut: pDC - Given DC To Draw On

// ~~~~~ DrawRect - Dimentions Of The Picture To Draw (As a Rectangle)

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::Show(CDC *pDC, CRect DrawRect)

//=============================================================================

{

if (pDC == NULL || m_IPicture == NULL) return FALSE;

long Width = 0;

long Height = 0;

m_IPicture-get_Width(Width);

m_IPicture-get_Height(Height);

HRESULT hrP = NULL;

hrP = m_IPicture-Render(pDC-m_hDC,

DrawRect.left, // Left

DrawRect.top, // Top

DrawRect.right - DrawRect.left, // Right

DrawRect.bottom - DrawRect.top, // Bottom

0,

Height,

Width,

-Height,

DrawRect);

if (SUCCEEDED(hrP)) return(TRUE);

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "Can not allocate enough memory\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

//-----------------------------------------------------------------------------

// Does: Draw The Loaded Picture Direct To The Client DC

// ~~~~

//

// Note: Bigger OR Smaller Dimentions Than The Original Picture Size

// ~~~~ Will Draw The Picture Streached To Its New Given Dimentions...

//

// InPut: pDC - Given DC To Draw On

// ~~~~~ LeftTop - Opening Point To Start Drawing (Left,Top)

// WidthHeight - Dimentions Of The Picture To Draw (Width,Height)

// MagnifyX - Magnify Pixel Width, 0 = Default (No Magnify)

// MagnifyY - Magnify Pixel Height, 0 = Default (No Magnify)

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::Show(CDC *pDC, CPoint LeftTop, CPoint WidthHeight, int MagnifyX, int MagnifyY)

//=============================================================================

{

if (pDC == NULL || m_IPicture == NULL) return FALSE;

long Width = 0;

long Height = 0;

m_IPicture-get_Width(Width);

m_IPicture-get_Height(Height);

if(MagnifyX == NULL) MagnifyX = 0;

if(MagnifyY == NULL) MagnifyY = 0;

MagnifyX = int(MulDiv(Width, pDC-GetDeviceCaps(LOGPIXELSX), HIMETRIC_INCH) * MagnifyX);

MagnifyY = int(MulDiv(Height,pDC-GetDeviceCaps(LOGPIXELSY), HIMETRIC_INCH) * MagnifyY);

CRect DrawRect(LeftTop.x, LeftTop.y, MagnifyX, MagnifyY);

HRESULT hrP = NULL;

hrP = m_IPicture-Render(pDC-m_hDC,

LeftTop.x, // Left

LeftTop.y, // Top

WidthHeight.x +MagnifyX, // Width

WidthHeight.y +MagnifyY, // Height

0,

Height,

Width,

-Height,

DrawRect);

if(SUCCEEDED(hrP)) return(TRUE);

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "Can not allocate enough memory\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

return(FALSE);

}

//-----------------------------------------------------------------------------

// Does: Saves The Picture That Is Stored In The IPicture Object As a Bitmap

// ~~~~ (Converts From Any Known Picture Type To a Bitmap / Icon File)

//

// InPut: sFilePathName - Path And FileName Target To Save

// ~~~~~

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::SaveAsBitmap(CString sFilePathName)

//=============================================================================

{

BOOL bResult = FALSE;

ILockBytes *Buffer = 0;

IStorage *pStorage = 0;

IStream *FileStream = 0;

BYTE *BufferBytes;

STATSTG BytesStatistics;

DWORD OutData;

long OutStream;

CFile BitmapFile; CFileException e;

double SkipFloat = 0;

DWORD ByteSkip = 0;

_ULARGE_INTEGER RealData;

CreateILockBytesOnHGlobal(NULL, TRUE, Buffer); // Create ILockBytes Buffer

HRESULT hr = ::StgCreateDocfileOnILockBytes(Buffer,

STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, pStorage);

hr = pStorage-CreateStream(L"PICTURE",

STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, 0, FileStream);

m_IPicture-SaveAsFile(FileStream, TRUE, OutStream); // Copy Data Stream

FileStream-Release();

pStorage-Release();

Buffer-Flush();

// Get Statistics For Final Size Of Byte Array

Buffer-Stat(BytesStatistics, STATFLAG_NONAME);

// Cut UnNeeded Data Coming From SaveAsFile() (Leave Only "Pure" Picture Data)

SkipFloat = (double(OutStream) / 512); // Must Be In a 512 Blocks...

if(SkipFloat DWORD(SkipFloat)) ByteSkip = (DWORD)SkipFloat + 1;

else ByteSkip = (DWORD)SkipFloat;

ByteSkip = ByteSkip * 512; // Must Be In a 512 Blocks...

// Find Difference Between The Two Values

ByteSkip = (DWORD)(BytesStatistics.cbSize.QuadPart - ByteSkip);

// Allocate Only The "Pure" Picture Data

RealData.LowPart = 0;

RealData.HighPart = 0;

RealData.QuadPart = ByteSkip;

BufferBytes = (BYTE*)malloc(OutStream);

if(BufferBytes == NULL)

{

Buffer-Release();

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, "Can not allocate enough memory\t", ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

}

Buffer-ReadAt(RealData, BufferBytes, OutStream, OutData);

if(BitmapFile.Open(sFilePathName, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite, e))

{

BitmapFile.Write(BufferBytes, OutData);

BitmapFile.Close();

bResult = TRUE;

}

else // Write File Failed...

{

TCHAR szCause[255];

e.GetErrorMessage(szCause, 255, NULL);

HWND hWnd = AfxGetApp()-GetMainWnd()-m_hWnd;

MessageBoxEx(hWnd, szCause, ERROR_TITLE, MB_OK | MB_ICONSTOP, LANG_ENGLISH);

bResult = FALSE;

}

Buffer-Release();

free(BufferBytes);

return(bResult);

}

//-----------------------------------------------------------------------------

// Does: Draw a Bitmap Resource To The Client DC (Using Bitblt())

// ~~~~ It Will Use The Bitmap Resource Original Size (Width And Height)

// (.BMP .DIB)

//

// Note: This Function Is Just Another Simple Way Of Displaying a Bitmap Resource,

// ~~~~ It Is Not Connected With The IPicture Interface And Can Be Used

// As a StandAlone On Any Device Context (Directly)

//

// InPut: BMPResource - Resource Name As Defined In The Resources

// ~~~~~ pDC - Given DC To Draw On

// LeftTop - Opening Point To Start Drawing (Left,Top)

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::ShowBitmapResource(CDC *pDC, const int BMPResource, CPoint LeftTop)

//=============================================================================

{

if (pDC == NULL) return(FALSE);

CBitmap BMP;

if(BMP.LoadBitmap(BMPResource))

{

// Get Bitmap Details

BITMAP BMPInfo;

BMP.GetBitmap(BMPInfo);

// Create An In-Memory DC Compatible With The Display DC We R Gonna Paint On

CDC DCMemory;

DCMemory.CreateCompatibleDC(pDC);

// Select The Bitmap Into The In-Memory DC

CBitmap* pOldBitmap = DCMemory.SelectObject(BMP);

// Copy Bits From The In-Memory DC Into The On-Screen DC

pDC-BitBlt(LeftTop.x, LeftTop.y, BMPInfo.bmWidth, BMPInfo.bmHeight, DCMemory, 0, 0, SRCCOPY);

DCMemory.SelectObject(pOldBitmap); // (As Shown In MSDN Example...)

}

else

{

TRACE0("ERROR: Can Not Find The Bitmap Resource\n");

return(FALSE);

}

return(TRUE);

}

//-----------------------------------------------------------------------------

// Does: Get The Original Picture Pixel Size (Ignor What Current DC Is Using)

// ~~~~ Pointer To a Device Context Is Needed For Pixel Calculation,

//

// Also Updates The Class's Height And Width Properties,

// (Coz Till Now We Had No Device Context To Work With...96 DPI Assumed)

//

// InPut: The Client DC (Needed To Check The Size Of The Pixels)

// ~~~~~

//

// OutPut: TRUE If Succeeded...

// ~~~~~~

//-----------------------------------------------------------------------------

BOOL CPicture::UpdateSizeOnDC(CDC *pDC)

//=============================================================================

{

if(pDC == NULL || m_IPicture == NULL) { m_Height = 0; m_Width = 0; return(FALSE); };

m_IPicture-get_Height(m_Height);

m_IPicture-get_Width(m_Width);

// Get Current DPI - Dot Per Inch

int CurrentDPI_X = pDC-GetDeviceCaps(LOGPIXELSX);

int CurrentDPI_Y = pDC-GetDeviceCaps(LOGPIXELSY);

// Use a "Standard" Print (When Printing)

if(pDC-IsPrinting())

{

CurrentDPI_X = 96;

CurrentDPI_Y = 96;

}

m_Height = MulDiv(m_Height, CurrentDPI_Y, HIMETRIC_INCH);

m_Width = MulDiv(m_Width, CurrentDPI_X, HIMETRIC_INCH);

return(TRUE);

}

3.在对话框头文件定义:

先包含头文件#include "Picture.h"

再定义

CPicture m_Pic;

4.给按钮的函数里写上:(注意,这个IDC_SHOWPIC)是你那个显示控件的ID号.

CRect rect;

GetDlgItem(IDC_SHOWPIC)-GetWindowRect(rect);

ScreenToClient(rect);

CFile f;

CString FilePathName;

CFileException e;

CFileDialog dlg(TRUE,NULL,NULL,0,_T("All Files (*.*)|*.*|BMP (*.bmp)|*.bmp|DIB (*.dib)|*.dib|EMF (*.emf)|*.emf|GIF (*.gif)|*.gif|ICO (*.ico)|*.ico|JPG (*.jpg)|*.jpg|WMF (*.wmf)|*.wmf||"),NULL);

if(dlg.DoModal()==IDOK)

{

FilePathName=dlg.GetPathName();

if(m_Pic.m_IPicture != NULL) m_Pic.FreePictureData();

m_Pic.Load(FilePathName);

CClientDC dc(this);

m_Pic.UpdateSizeOnDC(dc);

m_Pic.Show(dc, rect);

}

OPENLEAKS的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、OPENLEAKS的信息别忘了在本站进行查找喔。

发表评论