忍者ブログ

銀朱工房

クッソ初心者がダンジョンRPGを作成する パソコンって何ですかって人が頑張ってダンジョンRPGを作ったローという感じ クソゲーが出来上がる過程を報告って感じですね やった内容は右のカテゴリーから参照お願いいたします。

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

objdump

MinGWのユーティリティ(objdump)で実行可能ファイルの依存DLLを調べることができる

MinGW/binを環境変数にいれておけば
objdump -p x.exe | find "DLL" で依存DLLを調べれる

Usage: objdump <option(s)> <file(s)>
 Display information from object <file(s)>.
 At least one of the following switches must be given:
  -a, --archive-headers    Display archive header information
  -f, --file-headers       Display the contents of the overall file header
  -p, --private-headers    Display object format specific file header contents
  -P, --private=OPT,OPT... Display object format specific contents
  -h, --[section-]headers  Display the contents of the section headers
  -x, --all-headers        Display the contents of all headers
  -d, --disassemble        Display assembler contents of executable sections
  -D, --disassemble-all    Display assembler contents of all sections
  -S, --source             Intermix source code with disassembly
  -s, --full-contents      Display the full contents of all sections requested
  -g, --debugging          Display debug information in object file
  -e, --debugging-tags     Display debug information using ctags style
  -G, --stabs              Display (in raw form) any STABS info in the file
  -W[lLiaprmfFsoRt] or
  --dwarf[=rawline,=decodedline,=info,=abbrev,=pubnames,=aranges,=macro,=frames,
          =frames-interp,=str,=loc,=Ranges,=pubtypes,
          =gdb_index,=trace_info,=trace_abbrev,=trace_aranges]
                           Display DWARF info in the file
  -t, --syms               Display the contents of the symbol table(s)
  -T, --dynamic-syms       Display the contents of the dynamic symbol table
  -r, --reloc              Display the relocation entries in the file
  -R, --dynamic-reloc      Display the dynamic relocation entries in the file
  @<file>                  Read options from <file>
  -v, --version            Display this program's version number
  -i, --info               List object formats and architectures supported
  -H, --help               Display this information

拍手[0回]

PR

ウインドウクラス

WNDCLASS

typedef struct _WNDCLASS {
    UINT     style;          //ウィンドウのスタイル
    WNDPROC lpfnWndProc;    //ウィンドウプロシージャ
    int     cbClsExtra;     //補助メモリ
    int     cbWndExtra;     //補助メモリ
    HANDLE  hInstance;      //インスタンスハンドル
    HICON   hIcon;          //アイコン
    HCURSOR hCursor;        //カーソル
    HBRUSH  hbrBackground;  //背景ブラシ
    LPCTSTR lpszMenuName;   //メニュー名
    LPCTSTR lpszClassName;  //クラス名
} WNDCLASS;

Style:
CS_HREDRAW:ウインドウのサイズが水平方向に変更されたときに再描画
CS_VREDRAW:垂直方向に変更されたときに再描画

lpfnWndProc:ウインドウになんらかのイベントが発生するたびに呼び出されるコールバック関数
DefWindowProc():既定のウィンドウプロシージャ

cbClsExtra:

cbWndExtra:

hInstance:
WinMain()関数が引数で受け取ったインスタンスハンドルを設定する

hIcon:
ウインドウのアイコンを設定する
標準のアイコンでいい場合はNULLでよい
NULL以外はLoadIcon()で指定するらしいがまだ調べていない

hCursor:
ウインドウのカーソルを設定する
標準のカーソルでいい場合はNULLでよい
NULL以外はLoadCursor() で指定するらしいがまだ調べていない

hbrBackground:
クライアント領域をどんな風に塗りつぶすか指定
”GetStockObject”はgdi32.libに入っているのでコンパイルする際ライブラリがリンクされている必要がある
Mingwでのコンパイルオプション:-lgdi32

lpszMenuName:
メニューの名前

lpszClassName:

どのウインドウクラスを使うかの指定

拍手[0回]

またコケタ(window表示にて)その4

さてと、背景の色を変えましょう

  winclass.hCursor = NULL;
  winclass.hbrBackground = (HBRUSH)color_BACKGROUND + 1;
  winclass.lpszMenuName = NULL;
  winclass.lpszClassName = WIN_NAME;

ウインドウクラスの背景ブラシを
hbrBackground = (HBRUSH)color_BACKGROUND + 1;

hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
これでクライアント領域が白になるであろ

レッツコンパイル
コマンドプロンプトからエイットナ

D:\Workspace>gcc.exe window.c
C:\Users\XXXXX\AppData\Local\Temp\ccc2rzHu.o:window.c:(.text+0x3e): undefined reference to `GetStockObject@4'
collect2.exe: error: ld returned 1 exit status

ムッキィ!! ノ`⌒´)ノ ┫:・'.::・┻┻:・'.::・
お前もかブルータス!!

さっそくgoogle先生に聞きました。
結論:ライブラリが足りてない
”GetStockObject”はgdi32.libの中に入っていますとのことでした。
該当するのは、-lgdi32のコンパイルオプションですね

ちなみに私が作成したバイナリには、どんなライブラリがリンクされているのか調べてみましょう

コマンドプロンプトから
objedump -pを打つべし

D:\Workspace>objdump -p a.exe | find "DLL"
vma: Hint Time Forward DLL First
DLL Name: KERNEL32.dll
DLL Name: msvcrt.dll
DLL Name: USER32.dll
ふむ、たしかにGDI32.dllの姿がございません。

先生が曰く、kernek32.lib, user32.lib, gdi32.libの指定が必要らしい
GDI32.dllだけないね

ぶっこんでコンパイルしてみよう
D:\Workspace>gcc.exe window.c -lgdi32

D:\Workspace>a.exe
・・・(*`д´)b OK!

ーーーーー実行結果ーーーー

うまくいきました。

拍手[0回]

またコケタ(window表示にて)その3

さて今度こそいけるでしょう

ーーーーーSource Codeーーーーー
#include <windows.h>

#define WIN_NAME TEXT("winwin")

int WINAPI WinMain( HINSTANCE hInstance,
                    HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,
                    int nCmdShow )
{
  HWND hWnd;
  WNDCLASS winclass;
 
  winclass.style = CS_HREDRAW | CS_VREDRAW;
  winclass.lpfnWndProc = DefWindowProc;
  winclass.cbClsExtra = 0;
  winclass.cbWndExtra = 0;
  winclass.hInstance = hInstance;
  winclass.hIcon = NULL;
  winclass.hCursor = NULL;
  winclass.hbrBackground = (HBRUSH)color_BACKGROUND + 1;
  winclass.lpszMenuName = NULL;
  winclass.lpszClassName = WIN_NAME;
 
  if ( !RegisterClass( &winclass ) ) {
    MessageBox( NULL, TEXT("トゥルットゥルットゥル"), NULL, MB_OK );
    return 0;
  }
 
  hWnd = CreateWindow( WIN_NAME, TEXT("testtest"),
                        WS_OVERLAPPEDWINDOW,
                        100, 100, 400, 300,
                        NULL, NULL, hInstance, NULL );
   
  if( hWnd == NULL ) {
    MessageBox( NULL, TEXT("トットットゥルットゥルットゥル"), NULL, MB_OK );
    return 0;
  }
 
  ShowWindow( hWnd, SW_SHOW );
 
  MessageBox( NULL, TEXT("めでたしめてたし"), NULL, MB_OK );

  return 0;
}

ーーーーーーーーーーーーーーーーーーーーーーーーー
実行結果

表示できたー♪
だがまてなんか想像してたのとちゃうで~
クライアント領域の色が白を想像してたんですが
背景のブラシの色カテミッカ

つづく

拍手[0回]

プロフィール

HN:
ンメローン
性別:
男性
職業:
なんちゃってソフト屋さん
趣味:
いろいろある多趣味である
自己紹介:
寝るのが大好きなキモオタです。
しいていうなら、
ただの通りすがりのメロンみたいなものですよ

カレンダー

08 2024/09 10
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

ブログ内検索

フリーエリア

最新CM

[08/30 imitazione cartier anelli oro donna]
[02/17 kos3xnqd9v3]
[02/16 uem4paid3j2]

バーコード

コガネモチ

P R

ページ