Cxbx-Reloaded/Doc/RemovedCode.txt

221 lines
5.4 KiB
Plaintext

hrnm
#include <d3d8.h>
#include <stdio.h>
LPDIRECT3D8 g_pD3D = NULL; // Direct3D8
LPDIRECT3DDEVICE8 g_pD3DDevice = NULL; // Rendering Device
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
void SuperTest()
{
HWND hWnd = NULL;
// create window
{
// Register the window class
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3DTest", NULL };
RegisterClassEx( &wc );
// Create the application's window
hWnd = CreateWindow( "D3DTest", "D3DTest",
WS_OVERLAPPEDWINDOW, 100, 100, 640, 480,
GetDesktopWindow(), NULL, wc.hInstance, NULL );
}
printf("Direct3DCreate8(...)\n");
IDirect3D8 *pD3D = Direct3DCreate8(D3D_SDK_VERSION);
// update window
{
// Show the window
ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );
}
// create d3d device
{
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.BackBufferWidth = 640;
d3dpp.BackBufferHeight = 480;
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
d3dpp.BackBufferCount = 1;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
// NOTE: Necessary
d3dpp.Windowed = TRUE;
printf("CreateDevice(...)\n");
HRESULT ret = pD3D->CreateDevice
(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hWnd, // NOTE: Necessary
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp,
&g_pD3DDevice
);
if(FAILED(ret))
MessageBox(NULL, "Failed!", "SuperTest", MB_OK);
else
printf("PASSED\n");
}
// clear 3d device
{
// Clear the backbuffer and the zbuffer
g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0x44,0x44,0x44), 1.0f, 0);
}
// enter message look
{
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while(TRUE)
{
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
g_pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
}
}
return;
}
disassemble
// ******************************************************************
// * disassemble entry point 0x50 bytes
// ******************************************************************
{
const int BUF_SIZE = 0x50;
disassemble_init(0, INTEL_SYNTAX);
char buf[BUF_SIZE]; /* buffer of bytes to disassemble */
int pos = 0; /* current position in buffer */
int size = 0; /* size of instruction */
struct instr i; /* representation of the code instruction */
while(pos > BUF_SIZE)
{
disassemble_address(buf + pos, &i);
if(size)
{
printf("%.08X: %s", pos, i.mnemonic);
if(i.destType)
{
printf(" %s", i.dest);
if(i.srcType)
{
printf(", %s", i.src);
if(i.auxType)
{
printf(", %s", i.aux);
}
}
}
printf("\n");
pos += size;
}
else
{
pos++;
}
}
disassemble_cleanup();
}
xboxkrnl::NtOpenFile :
/*
char * checkString = "\\Device\\Harddisk0\\partition1\\";
if
(
CompareString
(
LOCALE_USER_DEFAULT,
NORM_IGNORECASE,
ObjectAttributes->ObjectName->Buffer,
ObjectAttributes->ObjectName->Length,
checkString,
strlen(checkString)
)
== CSTR_EQUAL
)
{
xntdll::OBJECT_ATTRIBUTES iObjectAttributes;
xntdll::UNICODE_STRING iUnicodeString =
{
30,
32,
L"C:\\Aaron\\XBoxHD"
};
InitializeObjectAttributes
(
&iObjectAttributes,
&iUnicodeString,
ObjectAttributes->Attributes,
ObjectAttributes->RootDirectory,
NULL
);
if(xntdll::ZwOpenFile(FileHandle, DesiredAccess, &iObjectAttributes, (xntdll::_IO_STATUS_BLOCK*)IoStatusBlock, ShareAccess, OpenOptions) == STATUS_SUCCESS)
MessageBox(NULL, (char*)ObjectAttributes->ObjectName->Buffer, "CxbxKrnl", MB_OK);
}
*/
logo bitmap dump:
FILE *outfile = fopen("C:\\Logo.txt", "wt");
for(uint32 d=0;d<dwLength;d++)
{
if(d%10 == 0)
fprintf(outfile, "\n");
fprintf(outfile, "0x%.02X, ", RLE[d]);
}
fprintf(outfile, "\nsize : %.08X", dwLength);
fclose(outfile);