fishluo 发表于 2013-10-25 17:16:19

求汇编大神帮帮呀?这个问题困恼我两天了。

本帖最后由 fishluo 于 2013-10-25 17:21 编辑

#include <windows.h>
#include <d3d9.h>
#include <time.h>
#include <iostream>
using namespace std;

#pragma comment(lib,"d3d9.lib")
#pragma comment(lib,"d3dx9.lib")

//program settings
const string APPTITLE = "Direct3D_Windowed";
const int SCREENW = 1024;
const int SCREENH = 768;

//Direct3D objects
LPDIRECT3D9 d3d = NULL;   
LPDIRECT3DDEVICE9 d3ddev = NULL;   

bool gameover = false;

//macro to detect key presses
#define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)


/**
** Game initialization function
**/
bool Game_Init(HWND window)
{
    MessageBox(window, "Game_Init", "BREAKPOINT", 0);

    //initialize Direct3D
    d3d = Direct3DCreate9(D3D_SDK_VERSION);
    if (d3d == NULL)
    {
      MessageBox(window, "Error initializing Direct3D", "Error", MB_OK);
      return 0;
    }

    //set Direct3D presentation parameters
    D3DPRESENT_PARAMETERS d3dpp;   
    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferCount = 1;
    d3dpp.BackBufferWidth = SCREENW;
    d3dpp.BackBufferHeight = SCREENH;
    d3dpp.hDeviceWindow = window;

    //create Direct3D device
    d3d->CreateDevice(
      D3DADAPTER_DEFAULT,   
      D3DDEVTYPE_HAL,   
      window,
      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
      &d3dpp,   
      &d3ddev);

    if (d3ddev == NULL)
    {
      MessageBox(window, "Error creating Direct3D device", "Error", MB_OK);
      return 0;
    }

    return true;
}

/**
** Game update function
**/
void Game_Run(HWND hwnd)
{
    //make sure the Direct3D device is valid
    if (!d3ddev) return;

    //clear the backbuffer to bright green
    d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,255,0), 1.0f, 0);
      
    //start rendering
    if (d3ddev->BeginScene())
    {
      //do something?
      
      //stop rendering
      d3ddev->EndScene();

      //copy back buffer on the screen
      d3ddev->Present(NULL, NULL, NULL, NULL);
    }

    //check for escape key (to exit program)
    if (KEY_DOWN(VK_ESCAPE))
      PostMessage(hwnd, WM_DESTROY, 0, 0);
}

/**
** Game shutdown function
**/
void Game_End(HWND hwnd)
{
    //display close message
    MessageBox(hwnd, "Program is about to end", "Game_End", MB_OK);

    //free memory
    if (d3ddev) d3ddev->Release();
    if (d3d) d3d->Release();
}


/**
** Windows event handling function
**/
LRESULT WINAPI WinProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
      case WM_DESTROY:
            gameover = true;
            PostQuitMessage(0);
            return 0;
    }
    return DefWindowProc( hWnd, msg, wParam, lParam );
}

/**
** Main Windows entry function
**/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    //set the new window's properties
    //previously found in the MyRegisterClass function
    WNDCLASSEX wc;
    wc.cbSize = sizeof(WNDCLASSEX);   
    wc.style         = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc   = (WNDPROC)WinProc;
    wc.cbClsExtra   = 0;
    wc.cbWndExtra   = 0;
    wc.hInstance   = hInstance;
    wc.hIcon         = NULL;
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName= NULL;
    wc.lpszClassName = APPTITLE.c_str();
    wc.hIconSm       = NULL;
    RegisterClassEx(&wc);

    //create a new window
    //previously found in the InitInstance function
    HWND window = CreateWindow( APPTITLE.c_str(), APPTITLE.c_str(),
       WS_OVERLAPPEDWINDOW,
       CW_USEDEFAULT, CW_USEDEFAULT,
       SCREENW, SCREENH,
       NULL, NULL, hInstance, NULL);

    //was there an error creating the window?
    if (window == 0) return 0;

    //display the window
    ShowWindow(window, nCmdShow);
    UpdateWindow(window);
      
    //initialize the game
    if (!Game_Init(window)) return 0;


    // main message loop
    MSG message;
    while (!gameover)
    {
      if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))   
      {
            TranslateMessage(&message);
            DispatchMessage(&message);
      }

      Game_Run(window);
    }

    Game_End(window);

    return message.wParam;
}
//如何把这个C++代码。改为汇编。//d3d9.dll 里面有没有这个CreateDevice 函数。为何PEID查找不到。//汇编如何 调用 DirectX 组件,//d3d9.h如何改为d3d9.inc//有没有哪个大神 整理好这些 头文件了的//大家帮帮我吧。:cry

levoer 发表于 2013-10-25 17:28:53

谢谢啊啊啊啊

levoer 发表于 2013-10-25 17:29:38

谢谢啊啊啊

血狼 发表于 2013-10-26 14:15:27

楼主难道用编译器编不了么?

fishluo 发表于 2013-10-26 21:21:37

血狼 发表于 2013-10-26 14:15 static/image/common/back.gif
楼主难道用编译器编不了么?

把这C++代码改成asm代码?

血狼 发表于 2013-10-29 14:59:43

楼主试试用VC 编译器反汇编一下

福禄娃娃 发表于 2013-10-31 21:40:51

直接生成exe程序,然后用IDA反汇编下吧,IDA生成的反汇编代码基本和源代码符合。

fishluo 发表于 2013-11-13 17:21:03

福禄娃娃 发表于 2013-10-31 21:40 static/image/common/back.gif
直接生成exe程序,然后用IDA反汇编下吧,IDA生成的反汇编代码基本和源代码符合。

求个 ASM调用COM组件对象。生成一个窗口的例子。版主大人

bigshan 发表于 2013-11-13 17:27:58

这是c代码啊。楼主用vc调试啊。

福禄娃娃 发表于 2013-11-13 17:30:23

fishluo 发表于 2013-11-13 17:21 static/image/common/back.gif
求个 ASM调用COM组件对象。生成一个窗口的例子。版主大人

你指的是win32汇编生成一个窗口的例子吗?

fishluo 发表于 2013-11-24 20:44:04

福禄娃娃 发表于 2013-11-13 17:30 static/image/common/back.gif
你指的是win32汇编生成一个窗口的例子吗?

我已经找到方法了!谢谢了

ヽ朝暮是安然 发表于 2013-11-26 12:57:31

我来看看代码的....

阔怀 发表于 2015-8-12 12:29:02

{:1_1:}
页: [1]
查看完整版本: 求汇编大神帮帮呀?这个问题困恼我两天了。