コード例 #1
0
// address: 0x401140
void proc10(unsigned int param1, char *param2, __size32 param3, __size32 param4, __size32 param5, __size32 param6) {
    __size32 eax; 		// r24
    int edx; 		// r26
    int esp; 		// r28

    eax = _stat64i32();
    if (eax != 0) {
L1:
        edx = perror(param2);
        proc13(pc, pc, param2, param6, param5, param4, pc, param1, global0 ^ (esp - 76), 1, global0 ^ esp - 76 ^ esp - 76, edx, param3, param4, param5, param6, LOGICALFLAGS32(global0 ^ esp - 76 ^ esp - 76), LOGICALFLAGS32(global0 ^ esp - 76 ^ esp - 76), LOGICALFLAGS32(global0 ^ esp - 76 ^ esp - 76));
    }
    eax = fopen(param2, "rb");
    if (eax != 0) {
        if (param1 > 0) {
            *(__size32*)(esp - 4) = edi;
            *(__size32*)(esp - 4) = 16;
            *(__size32*)(esp - 4) = 1;
            *(__size32*)(esp - 4) = ecx;
            (*ebx)();
            if ( !flags) {
                *(__size32*)(esp - 4) = esi;
                *(__size32*)(esp - 4) = edx;
                proc14(*(esp + 4), *(esp + 8));
            }
        }
        *(__size32*)(esp - 4) = edi;
        fclose(*(esp + 4));
        proc13();
    }
    goto L1;
}
コード例 #2
0
void TakeScreenshot() {
    if(RealDevice==NULL) return;
    HRESULT hr;
    IDirect3DSurface* surface;
	RECT r;
	RECT* pRect=0;
//#ifndef RELEASE
//	hr=RealDevice->CreateOffscreenPlainSurface(1280,1024,
//        D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL);
//#else
	DWORD width, height;
	if(JointInfo.WNDwindowed) {
		D3DDISPLAYMODE mode;
		RealDevice->GetDisplayMode(0, &mode);
		hr=RealDevice->CreateOffscreenPlainSurface(mode.Width,mode.Height,D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL);
		HWND win=FindWindow("morrowind", "morrowind");
		//GetWindowRect(win, &r);
		POINT p; p.x = 0; p.y = 0;
		ClientToScreen(win, &p);
		GetClientRect(win, &r);
		r.left += p.x;
		r.top += p.y;
		r.right += p.x;
		r.bottom += p.y;
		if(r.left < 0) r.left = 0;
		if(r.top < 0) r.top = 0;
		if((UINT)r.right >= mode.Width) r.right = (LONG)mode.Width - 1;
		if((UINT)r.bottom >= mode.Height) r.bottom = (LONG)mode.Height - 1;
		pRect=&r;
		width=mode.Width;
		height=mode.Height;
	} else {
		width=JointInfo.GraphicsWidth;
		height=JointInfo.GraphicsHeight;
		hr=RealDevice->CreateOffscreenPlainSurface(JointInfo.GraphicsWidth,JointInfo.GraphicsHeight, D3DFMT_A8R8G8B8,D3DPOOL_SCRATCH,&surface,NULL);
	}
//#endif
	if(hr!=D3D_OK) return;
	hr=RealDevice->GetFrontBufferData(0,surface);
	if(hr==D3D_OK) {
		D3DLOCKED_RECT rect2;
		hr=surface->LockRect(&rect2, 0, 0);
		if(hr==D3D_OK&&!(rect2.Pitch%4)) {
			DWORD *ptr=(DWORD*)rect2.pBits;
			rect2.Pitch/=4;
			for(DWORD y=0;y<height;y++) {
				DWORD offset=y*rect2.Pitch;
				for(DWORD x=0;x<width;x++) {
					ptr[offset+x]|=0xff000000;
				}
			}

			surface->UnlockRect();
		}
		char FileNameEnds[40]=".bmp\0\0\0\0.jpg\0\0\0\0.dds\0\0\0\0.png\0\0\0\0.tga\0\0\0";
		char FileNameEnd[8];
		char FileNameStart[240];
		char FileName[256];
		char Number[6];
		FileNameStart[0] = '\0';
		struct _stat64i32 unused;
		if (strlen(SSDir) > 0) {
			bool usedir = true;
			if (_stat64i32(SSDir, &unused) == -1 && !CreateDirectory(SSDir, NULL)) usedir = false;
			if (usedir) {
				strcat_s(FileNameStart, 240, SSDir);
				strcat_s(FileNameStart, 240, "\\");
			}
		}
		strcat_s(FileNameStart, 240, SSName);
		for (int i = 0; i < 8; ++i) FileNameEnd[i] = FileNameEnds[i + SSFormat * 8];
		for (unsigned long ui = 1; ui <= 99999; ++ui) {
			FileName[0] = '\0';
			strcat_s(FileName, 256, FileNameStart);
			char* FNamEnd = FileName + strlen(FileName);
			_ultoa_s(ui, Number, 6, 10);
			for (int i = strlen(Number); i < SSMinNumChars; ++i) *(FNamEnd++) = '0';
			*FNamEnd = '\0';
			strcat_s(FileName, 256, Number);
			strcat_s(FileName, FileNameEnd);
			if (_stat64i32(FileName, &unused) == -1) {
				switch (SSFormat) {
					case 0:
						hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_BMP, surface, NULL, pRect);
						break;
					case 1:
						hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_JPG, surface, NULL, pRect);
						break;
					case 2:
						hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_DDS, surface, NULL, pRect);
						break;
					case 3:
						hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_PNG, surface, NULL, pRect);
						break;
					case 4:
						hr = D3DXSaveSurfaceToFile(FileName, D3DXIFF_TGA, surface, NULL, pRect);
						break;
					default:
						hr = -1;                    
				}
			break;
			}
		}
	}
	if(hr == D3D_OK) {
		SETSTATUS("Screen shot saved");
	} else {
		SETSTATUS("Screen shot failed");
	}
	surface->Release();
}