Project1
标题: 脑残物Custom RGSS Player(Game.exe) [打印本页]
作者: 英顺的马甲 时间: 2015-3-26 10:27
标题: 脑残物Custom RGSS Player(Game.exe)
本帖最后由 英顺的马甲 于 2015-3-26 16:46 编辑
前几天比较看得懂c++后拿了第三方RGSS Player来改,于是就出了此脑残物
这脑残物对普通人来说比较有用的功能就只有会自动加载与exe同目录内fonts文件夹里的字体
不过这个exe有个缺点,那就是并不是所有的RGSS10XX.dll都支持(目前已知肯定支持的有原版的)
杀毒信息:https://www.virustotal.com/en/file/cba1f55c2ac3bc31e47ddf99897482e41600fe022db05bbb5bac40d24a90e3c6/analysis/1427335101/
下载:
EXE与源码.rar
(64.99 KB, 下载次数: 163)
如果你完全不懂API或c++之类的请回头
EXE源码,大神勿喷(其实喷也没关系) 额外功能
带有WndProc的范例:
Custom RGSS Player.rar
(2.97 MB, 下载次数: 321)
@晴兰 @orzfly @yangff 求吐槽
作者: taroxd 时间: 2015-3-26 12:42
本帖最后由 taroxd 于 2015-3-26 12:45 编辑
我是来调戏论坛高亮的,不过论坛高亮竟然没出事情
module WND
WM_ACTIVATE=0x0006
WM_ACTIVATEAPP=0x001C
WM_AFXFIRST=0x0360
WM_AFXLAST=0x037F
WM_APP=0x8000
WM_APPCOMMAND=0x0319
WM_ASKCBFORMATNAME=0x030C
WM_CANCELJOURNAL=0x004B
WM_CANCELMODE=0x001F
WM_CAPTURECHANGED=0x0215
WM_CHANGECBCHAIN=0x030D
WM_CHANGEUISTATE=0x0127
WM_CHAR=0x0102
WM_CHARTOITEM=0x002F
WM_CHILDACTIVATE=0x0022
WM_CLEAR=0x0303
WM_CLOSE=0x0010
WM_COMMAND=0x0111
WM_COMMNOTIFY=0x0044
WM_COMPACTING=0x0041
WM_COMPAREITEM=0x0039
WM_CONTEXTMENU=0x007B
WM_COPY=0x0301
WM_COPYDATA=0x004A
WM_CREATE=0x0001
WM_CTLCOLORBTN=0x0135
WM_CTLCOLORDLG=0x0136
WM_CTLCOLOREDIT=0x0133
WM_CTLCOLORLISTBOX=0x0134
WM_CTLCOLORMSGBOX=0x0132
WM_CTLCOLORSCROLLBAR=0x0137
WM_CTLCOLORSTATIC=0x0138
WM_CUT=0x0300
WM_DEADCHAR=0x0103
WM_DELETEITEM=0x002D
WM_DESTROY=0x0002
WM_DESTROYCLIPBOARD=0x0307
WM_DEVICECHANGE=0x0219
WM_DEVMODECHANGE=0x001B
WM_DISPLAYCHANGE=0x007E
WM_DRAWCLIPBOARD=0x0308
WM_DRAWITEM=0x002B
WM_DROPFILES=0x0233
WM_ENABLE=0x000A
WM_ENDSESSION=0x0016
WM_ENTERIDLE=0x0121
WM_ENTERMENULOOP=0x0211
WM_ENTERSIZEMOVE=0x0231
WM_ERASEBKGND=0x0014
WM_EXITMENULOOP=0x0212
WM_EXITSIZEMOVE=0x0232
WM_FONTCHANGE=0x001D
WM_GETDLGCODE=0x0087
WM_GETFONT=0x0031
WM_GETHOTKEY=0x0033
WM_GETICON=0x007F
WM_GETMINMAXINFO=0x0024
WM_GETOBJECT=0x003D
WM_GETTEXT=0x000D
WM_GETTEXTLENGTH=0x000E
WM_HANDHELDFIRST=0x0358
WM_HANDHELDLAST=0x035F
WM_HELP=0x0053
WM_HOTKEY=0x0312
WM_HSCROLL=0x0114
WM_HSCROLLCLIPBOARD=0x030E
WM_ICONERASEBKGND=0x0027
WM_IME_CHAR=0x0286
WM_IME_COMPOSITION=0x010F
WM_IME_COMPOSITIONFULL=0x0284
WM_IME_CONTROL=0x0283
WM_IME_ENDCOMPOSITION=0x010E
WM_IME_KEYDOWN=0x0290
WM_IME_KEYLAST=0x010F
WM_IME_KEYUP=0x0291
WM_IME_NOTIFY=0x0282
WM_IME_REQUEST=0x0288
WM_IME_SELECT=0x0285
WM_IME_SETCONTEXT=0x0281
WM_IME_STARTCOMPOSITION=0x010D
WM_INITDIALOG=0x0110
WM_INITMENU=0x0116
WM_INITMENUPOPUP=0x0117
WM_INPUT=0x00FF
WM_INPUTLANGCHANGE=0x0051
WM_INPUTLANGCHANGEREQUEST=0x0050
WM_KEYDOWN=0x0100
WM_KEYFIRST=0x0100
WM_KEYLAST=0x0109
WM_KEYUP=0x0101
WM_KILLFOCUS=0x0008
WM_LBUTTONDBLCLK=0x0203
WM_LBUTTONDOWN=0x0201
WM_LBUTTONUP=0x0202
WM_MBUTTONDBLCLK=0x0209
WM_MBUTTONDOWN=0x0207
WM_MBUTTONUP=0x0208
WM_MDIACTIVATE=0x0222
WM_MDICASCADE=0x0227
WM_MDICREATE=0x0220
WM_MDIDESTROY=0x0221
WM_MDIGETACTIVE=0x0229
WM_MDIICONARRANGE=0x0228
WM_MDIMAXIMIZE=0x0225
WM_MDINEXT=0x0224
WM_MDIREFRESHMENU=0x0234
WM_MDIRESTORE=0x0223
WM_MDISETMENU=0x0230
WM_MDITILE=0x0226
WM_MEASUREITEM=0x002C
WM_MENUCHAR=0x0120
WM_MENUCOMMAND=0x0126
WM_MENUDRAG=0x0123
WM_MENUGETOBJECT=0x0124
WM_MENURBUTTONUP=0x0122
WM_MENUSELECT=0x011F
WM_MOUSEACTIVATE=0x0021
WM_MOUSEFIRST=0x0200
WM_MOUSEHOVER=0x02A1
WM_MOUSELAST=0x020D
WM_MOUSELAST=0x0209
WM_MOUSELAST=0x020A
WM_MOUSELEAVE=0x02A3
WM_MOUSEMOVE=0x0200
WM_MOUSEWHEEL=0x020A
WM_MOVE=0x0003
WM_MOVING=0x0216
WM_NCACTIVATE=0x0086
WM_NCCALCSIZE=0x0083
WM_NCCREATE=0x0081
WM_NCDESTROY=0x0082
WM_NCHITTEST=0x0084
WM_NCLBUTTONDBLCLK=0x00A3
WM_NCLBUTTONDOWN=0x00A1
WM_NCLBUTTONUP=0x00A2
WM_NCMBUTTONDBLCLK=0x00A9
WM_NCMBUTTONDOWN=0x00A7
WM_NCMBUTTONUP=0x00A8
WM_NCMOUSEHOVER=0x02A0
WM_NCMOUSELEAVE=0x02A2
WM_NCMOUSEMOVE=0x00A0
WM_NCPAINT=0x0085
WM_NCRBUTTONDBLCLK=0x00A6
WM_NCRBUTTONDOWN=0x00A4
WM_NCRBUTTONUP=0x00A5
WM_NCXBUTTONDBLCLK=0x00AD
WM_NCXBUTTONDOWN=0x00AB
WM_NCXBUTTONUP=0x00AC
WM_NEXTDLGCTL=0x0028
WM_NEXTMENU=0x0213
WM_NOTIFY=0x004E
WM_NOTIFYFORMAT=0x0055
WM_NULL=0x0000
WM_PAINT=0x000F
WM_PAINTCLIPBOARD=0x0309
WM_PAINTICON=0x0026
WM_PALETTECHANGED=0x0311
WM_PALETTEISCHANGING=0x0310
WM_PARENTNOTIFY=0x0210
WM_PASTE=0x0302
WM_PENWINFIRST=0x0380
WM_PENWINLAST=0x038F
WM_POWER=0x0048
WM_POWERBROADCAST=0x0218
WM_PRINT=0x0317
WM_PRINTCLIENT=0x0318
WM_QUERYDRAGICON=0x0037
WM_QUERYENDSESSION=0x0011
WM_QUERYNEWPALETTE=0x030F
WM_QUERYOPEN=0x0013
WM_QUERYUISTATE=0x0129
WM_QUEUESYNC=0x0023
WM_QUIT=0x0012
WM_RBUTTONDBLCLK=0x0206
WM_RBUTTONDOWN=0x0204
WM_RBUTTONUP=0x0205
WM_RENDERALLFORMATS=0x0306
WM_RENDERFORMAT=0x0305
WM_SETCURSOR=0x0020
WM_SETFOCUS=0x0007
WM_SETFONT=0x0030
WM_SETHOTKEY=0x0032
WM_SETICON=0x0080
WM_SETREDRAW=0x000B
WM_SETTEXT=0x000C
WM_SETTINGCHANGE=0x001A
WM_SHOWWINDOW=0x0018
WM_SIZE=0x0005
WM_SIZECLIPBOARD=0x030B
WM_SIZING=0x0214
WM_SPOOLERSTATUS=0x002A
WM_STYLECHANGED=0x007D
WM_STYLECHANGING=0x007C
WM_SYNCPAINT=0x0088
WM_SYSCHAR=0x0106
WM_SYSCOLORCHANGE=0x0015
WM_SYSCOMMAND=0x0112
WM_SYSDEADCHAR=0x0107
WM_SYSKEYDOWN=0x0104
WM_SYSKEYUP=0x0105
WM_TABLET_FIRST=0x02C0
WM_TABLET_LAST=0x02DF
WM_TCARD=0x0052
WM_THEMECHANGED=0x031A
WM_TIMECHANGE=0x001E
WM_TIMER=0x0113
WM_UNDO=0x0304
WM_UNICHAR=0x0109
WM_UNINITMENUPOPUP=0x0125
WM_UPDATEUISTATE=0x0128
WM_USER=0x0400
WM_USERCHANGED=0x0054
WM_VKEYTOITEM=0x002E
WM_VSCROLL=0x0115
WM_VSCROLLCLIPBOARD=0x030A
WM_WINDOWPOSCHANGED=0x0047
WM_WINDOWPOSCHANGING=0x0046
WM_WININICHANGE=0x001A
WM_WTSSESSION_CHANGE=0x02B1
WM_XBUTTONDBLCLK=0x020D
WM_XBUTTONDOWN=0x020B
WM_XBUTTONUP=0x020C
API_CWP=Win32API.new('user32.dll','CallWindowProc','llill','l')
API_SWL=Win32API.new('user32.dll','SetWindowLong','lil','l')
API_RMM=Win32API.new('kernel32.dll','RtlMoveMemory','lpi','v')
module_function
def bind
const_set(:ADDR_OWP,API_SWL.call(hWnd,-4,ADDR_NWP))
API_RMM.call(ADDR_AOWP,[ADDR_OWP].pack('L'),4)
instance_eval{undef :bind}
end
def origWndProc(hwnd,message,wParam,lParam)
return API_CWP.call(ADDR_OWP,hwnd,message,wParam,lParam)
end
def WndProc(hwnd,message,wParam,lParam)
return WND.origWndProc(hwnd,message,wParam,lParam)
end
def __call_wndproc(ptr_ret,ptr_state,hwnd,message,wParam,lParam)
ret=WND.WndProc(hwnd,message,wParam,lParam)
ret=ret.eql?(true)?1:ret.eql?(false)?0:ret
API_RMM.call(ptr_ret,[ret.to_i].pack('L'),4)
API_RMM.call(ptr_state,[1].pack('i'),1)
end
end
module WND
WM_ACTIVATE=0x0006
WM_ACTIVATEAPP=0x001C
WM_AFXFIRST=0x0360
WM_AFXLAST=0x037F
WM_APP=0x8000
WM_APPCOMMAND=0x0319
WM_ASKCBFORMATNAME=0x030C
WM_CANCELJOURNAL=0x004B
WM_CANCELMODE=0x001F
WM_CAPTURECHANGED=0x0215
WM_CHANGECBCHAIN=0x030D
WM_CHANGEUISTATE=0x0127
WM_CHAR=0x0102
WM_CHARTOITEM=0x002F
WM_CHILDACTIVATE=0x0022
WM_CLEAR=0x0303
WM_CLOSE=0x0010
WM_COMMAND=0x0111
WM_COMMNOTIFY=0x0044
WM_COMPACTING=0x0041
WM_COMPAREITEM=0x0039
WM_CONTEXTMENU=0x007B
WM_COPY=0x0301
WM_COPYDATA=0x004A
WM_CREATE=0x0001
WM_CTLCOLORBTN=0x0135
WM_CTLCOLORDLG=0x0136
WM_CTLCOLOREDIT=0x0133
WM_CTLCOLORLISTBOX=0x0134
WM_CTLCOLORMSGBOX=0x0132
WM_CTLCOLORSCROLLBAR=0x0137
WM_CTLCOLORSTATIC=0x0138
WM_CUT=0x0300
WM_DEADCHAR=0x0103
WM_DELETEITEM=0x002D
WM_DESTROY=0x0002
WM_DESTROYCLIPBOARD=0x0307
WM_DEVICECHANGE=0x0219
WM_DEVMODECHANGE=0x001B
WM_DISPLAYCHANGE=0x007E
WM_DRAWCLIPBOARD=0x0308
WM_DRAWITEM=0x002B
WM_DROPFILES=0x0233
WM_ENABLE=0x000A
WM_ENDSESSION=0x0016
WM_ENTERIDLE=0x0121
WM_ENTERMENULOOP=0x0211
WM_ENTERSIZEMOVE=0x0231
WM_ERASEBKGND=0x0014
WM_EXITMENULOOP=0x0212
WM_EXITSIZEMOVE=0x0232
WM_FONTCHANGE=0x001D
WM_GETDLGCODE=0x0087
WM_GETFONT=0x0031
WM_GETHOTKEY=0x0033
WM_GETICON=0x007F
WM_GETMINMAXINFO=0x0024
WM_GETOBJECT=0x003D
WM_GETTEXT=0x000D
WM_GETTEXTLENGTH=0x000E
WM_HANDHELDFIRST=0x0358
WM_HANDHELDLAST=0x035F
WM_HELP=0x0053
WM_HOTKEY=0x0312
WM_HSCROLL=0x0114
WM_HSCROLLCLIPBOARD=0x030E
WM_ICONERASEBKGND=0x0027
WM_IME_CHAR=0x0286
WM_IME_COMPOSITION=0x010F
WM_IME_COMPOSITIONFULL=0x0284
WM_IME_CONTROL=0x0283
WM_IME_ENDCOMPOSITION=0x010E
WM_IME_KEYDOWN=0x0290
WM_IME_KEYLAST=0x010F
WM_IME_KEYUP=0x0291
WM_IME_NOTIFY=0x0282
WM_IME_REQUEST=0x0288
WM_IME_SELECT=0x0285
WM_IME_SETCONTEXT=0x0281
WM_IME_STARTCOMPOSITION=0x010D
WM_INITDIALOG=0x0110
WM_INITMENU=0x0116
WM_INITMENUPOPUP=0x0117
WM_INPUT=0x00FF
WM_INPUTLANGCHANGE=0x0051
WM_INPUTLANGCHANGEREQUEST=0x0050
WM_KEYDOWN=0x0100
WM_KEYFIRST=0x0100
WM_KEYLAST=0x0109
WM_KEYUP=0x0101
WM_KILLFOCUS=0x0008
WM_LBUTTONDBLCLK=0x0203
WM_LBUTTONDOWN=0x0201
WM_LBUTTONUP=0x0202
WM_MBUTTONDBLCLK=0x0209
WM_MBUTTONDOWN=0x0207
WM_MBUTTONUP=0x0208
WM_MDIACTIVATE=0x0222
WM_MDICASCADE=0x0227
WM_MDICREATE=0x0220
WM_MDIDESTROY=0x0221
WM_MDIGETACTIVE=0x0229
WM_MDIICONARRANGE=0x0228
WM_MDIMAXIMIZE=0x0225
WM_MDINEXT=0x0224
WM_MDIREFRESHMENU=0x0234
WM_MDIRESTORE=0x0223
WM_MDISETMENU=0x0230
WM_MDITILE=0x0226
WM_MEASUREITEM=0x002C
WM_MENUCHAR=0x0120
WM_MENUCOMMAND=0x0126
WM_MENUDRAG=0x0123
WM_MENUGETOBJECT=0x0124
WM_MENURBUTTONUP=0x0122
WM_MENUSELECT=0x011F
WM_MOUSEACTIVATE=0x0021
WM_MOUSEFIRST=0x0200
WM_MOUSEHOVER=0x02A1
WM_MOUSELAST=0x020D
WM_MOUSELAST=0x0209
WM_MOUSELAST=0x020A
WM_MOUSELEAVE=0x02A3
WM_MOUSEMOVE=0x0200
WM_MOUSEWHEEL=0x020A
WM_MOVE=0x0003
WM_MOVING=0x0216
WM_NCACTIVATE=0x0086
WM_NCCALCSIZE=0x0083
WM_NCCREATE=0x0081
WM_NCDESTROY=0x0082
WM_NCHITTEST=0x0084
WM_NCLBUTTONDBLCLK=0x00A3
WM_NCLBUTTONDOWN=0x00A1
WM_NCLBUTTONUP=0x00A2
WM_NCMBUTTONDBLCLK=0x00A9
WM_NCMBUTTONDOWN=0x00A7
WM_NCMBUTTONUP=0x00A8
WM_NCMOUSEHOVER=0x02A0
WM_NCMOUSELEAVE=0x02A2
WM_NCMOUSEMOVE=0x00A0
WM_NCPAINT=0x0085
WM_NCRBUTTONDBLCLK=0x00A6
WM_NCRBUTTONDOWN=0x00A4
WM_NCRBUTTONUP=0x00A5
WM_NCXBUTTONDBLCLK=0x00AD
WM_NCXBUTTONDOWN=0x00AB
WM_NCXBUTTONUP=0x00AC
WM_NEXTDLGCTL=0x0028
WM_NEXTMENU=0x0213
WM_NOTIFY=0x004E
WM_NOTIFYFORMAT=0x0055
WM_NULL=0x0000
WM_PAINT=0x000F
WM_PAINTCLIPBOARD=0x0309
WM_PAINTICON=0x0026
WM_PALETTECHANGED=0x0311
WM_PALETTEISCHANGING=0x0310
WM_PARENTNOTIFY=0x0210
WM_PASTE=0x0302
WM_PENWINFIRST=0x0380
WM_PENWINLAST=0x038F
WM_POWER=0x0048
WM_POWERBROADCAST=0x0218
WM_PRINT=0x0317
WM_PRINTCLIENT=0x0318
WM_QUERYDRAGICON=0x0037
WM_QUERYENDSESSION=0x0011
WM_QUERYNEWPALETTE=0x030F
WM_QUERYOPEN=0x0013
WM_QUERYUISTATE=0x0129
WM_QUEUESYNC=0x0023
WM_QUIT=0x0012
WM_RBUTTONDBLCLK=0x0206
WM_RBUTTONDOWN=0x0204
WM_RBUTTONUP=0x0205
WM_RENDERALLFORMATS=0x0306
WM_RENDERFORMAT=0x0305
WM_SETCURSOR=0x0020
WM_SETFOCUS=0x0007
WM_SETFONT=0x0030
WM_SETHOTKEY=0x0032
WM_SETICON=0x0080
WM_SETREDRAW=0x000B
WM_SETTEXT=0x000C
WM_SETTINGCHANGE=0x001A
WM_SHOWWINDOW=0x0018
WM_SIZE=0x0005
WM_SIZECLIPBOARD=0x030B
WM_SIZING=0x0214
WM_SPOOLERSTATUS=0x002A
WM_STYLECHANGED=0x007D
WM_STYLECHANGING=0x007C
WM_SYNCPAINT=0x0088
WM_SYSCHAR=0x0106
WM_SYSCOLORCHANGE=0x0015
WM_SYSCOMMAND=0x0112
WM_SYSDEADCHAR=0x0107
WM_SYSKEYDOWN=0x0104
WM_SYSKEYUP=0x0105
WM_TABLET_FIRST=0x02C0
WM_TABLET_LAST=0x02DF
WM_TCARD=0x0052
WM_THEMECHANGED=0x031A
WM_TIMECHANGE=0x001E
WM_TIMER=0x0113
WM_UNDO=0x0304
WM_UNICHAR=0x0109
WM_UNINITMENUPOPUP=0x0125
WM_UPDATEUISTATE=0x0128
WM_USER=0x0400
WM_USERCHANGED=0x0054
WM_VKEYTOITEM=0x002E
WM_VSCROLL=0x0115
WM_VSCROLLCLIPBOARD=0x030A
WM_WINDOWPOSCHANGED=0x0047
WM_WINDOWPOSCHANGING=0x0046
WM_WININICHANGE=0x001A
WM_WTSSESSION_CHANGE=0x02B1
WM_XBUTTONDBLCLK=0x020D
WM_XBUTTONDOWN=0x020B
WM_XBUTTONUP=0x020C
API_CWP=Win32API.new('user32.dll','CallWindowProc','llill','l')
API_SWL=Win32API.new('user32.dll','SetWindowLong','lil','l')
API_RMM=Win32API.new('kernel32.dll','RtlMoveMemory','lpi','v')
module_function
def bind
const_set(:ADDR_OWP,API_SWL.call(hWnd,-4,ADDR_NWP))
API_RMM.call(ADDR_AOWP,[ADDR_OWP].pack('L'),4)
instance_eval{undef :bind}
end
def origWndProc(hwnd,message,wParam,lParam)
return API_CWP.call(ADDR_OWP,hwnd,message,wParam,lParam)
end
def WndProc(hwnd,message,wParam,lParam)
return WND.origWndProc(hwnd,message,wParam,lParam)
end
def __call_wndproc(ptr_ret,ptr_state,hwnd,message,wParam,lParam)
ret=WND.WndProc(hwnd,message,wParam,lParam)
ret=ret.eql?(true)?1:ret.eql?(false)?0:ret
API_RMM.call(ptr_ret,[ret.to_i].pack('L'),4)
API_RMM.call(ptr_state,[1].pack('i'),1)
end
end
作者: 长虹剑 时间: 2015-8-19 13:17
本帖最后由 长虹剑 于 2015-8-20 15:06 编辑
@英顺的马甲 百度空间的链接失效了,你给的参考链接打不开,不知哪里还有。
还有我很想知道RGSSxxx.dll到底是如何调用的,如何用纯ruby来启动程序,或者如何才能在我自己的ruby程序中使用RGSS的内置类。
请问楼主是如何知道 dll 里面有 RGSSEval,RGSSGameMain 等函数的,并且如何知道是用顺序,也就是楼主破解了dll了?我想知道如何破解,还有在rgss300.dll中RGSSInitialize是不存在的,所以如何给rgss300重写个启动器呢?
请给一个思路
@晴兰
作者: 长虹剑 时间: 2015-8-20 15:14
用纯ruby实现Game.exe 目前写到这里了,参照你的那个程序写的,目前还没有写窗口的生成,打算就是完全调用Winapi实现。 还有本来想基于rgss3写的,但是你给的这个例子不能用,我也不知道dll有什么,怎么用。- # -*- coding:utf-8 -*-
- require 'Win32API'
- require 'pathname'
- require 'iniparse' #读取ini文件
- require 'cstruct/win32struct'
- MAX_PATH=100
- Gameini="Game.ini"
- #----------
- #FindWindow=Win32API.new("user32", "FindWindow", ['P','P'], 'L')
- LoadLibraryA=Win32API.new("kernel32", "LoadLibraryA", ['P'], 'L')
- GetProcAddress=Win32API.new("kernel32", "GetProcAddress", ['L','P'], 'L')
- #-------
- szAppPath=Pathname.new(File.dirname(__FILE__)).realpath
- #puts Dir.getwd 获得当前的执行目录 ***
- Dir.chdir(szAppPath) #改变当前目录
- hd_gameini=IniParse.parse( File.read "#{Gameini}" )
- szLibrary=hd_gameini["Game"]["Library"]
- szTitle=hd_gameini["Game"]["Title"]
- szScripts=hd_gameini["Game"]["Scripts"]
- #通过核心库加载程序
- hRgssCore = LoadLibraryA.Call(szLibrary);
- pRGSSEval=Win32API.new(szLibrary, "RGSSEval", ['P'], 'I') # 这种方式只是使用,根本没加入内存
- #pRGSSEval=GetProcAddress.Call(hRgssCore,"RGSSEval") #之后就不会用了
- pRGSSSetupRTP=Win32API.new(szLibrary, "RGSSSetupRTP", ['P','P','I'], 'B')
- pRGSSInitialize=Win32API.new(szLibrary, "RGSSInitialize", 'L', 'L')
- pRGSSGameMain=Win32API.new(szLibrary, "RGSSGameMain", ['L','P','P'], 'V')
- #puts Win32API::COLOR_WINDOWFRAME
- pRGSSInitialize.Call(hRgssCore)
- pRGSSEval.Call(" s=Sprite.new "); #不报错
- pRGSSEval.Call(" p 12*7+2 "); #正常显示了
- #还差窗口显示
- #puts pRGSSEval
- #pRGSSEval.Call("$DEBUG = true");
- #exit
- #hInstance=FindWindow.Call("ConsoleWindowClass",nil)
复制代码
作者: 英顺的马甲 时间: 2015-8-21 17:19
# coding: gbk
require 'win32api'
def err_msg(format, *args)
Win32API.new('user32', 'MessageBox', 'lppl', 'i').call(@hWnd ? @hWnd : 0, format % args, @title, 16)
stop
end
def stop
Win32API.new('kernel32', 'FreeLibrary', 'l', 'i').call(@hRGSSCore) if @hRGSSCore and @hRGSSCore != 0
Win32API.new('user32', 'DestroyWindow', 'l', 'i').call(@hWnd) if @hWnd and @hWnd != 0
Win32API.new('user32', 'UnregisterClass', 'pl', 'i').call(WndClassName, @hInstance)
exit
end
WndClassName = "RGSS Player"
DefaultLibrary = "RGSS102J.dll"
DefaultTitle = "Untitled"
DefaultScripts = "Data\\Scripts.rxdata"
@library = [0].pack('C') * 100
@title = [0].pack('C') * 100
@scripts = [0].pack('C') * 100
@hInstance = Win32API.new('kernel32', 'GetModuleHandle', 'l', 'l').call(0)
Win32API.new('user32', 'ShowWindow', 'li', 'i').call(Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, 0)
@inipath = File.basename(__FILE__).sub(/\.rb$/i, '.ini')
@inipath = File.join(Dir.pwd, @inipath).gsub(/\//, "\\")
if File.exist?(@inipath)
gpps = Win32API.new('kernel32', 'GetPrivateProfileString', 'ppppip', 'i')
gpps.call('Game', 'Library', DefaultLibrary, @library, 100, @inipath)
gpps.call('Game', 'Title', DefaultTitle, @title, 100, @inipath)
gpps.call('Game', 'Scripts', DefaultScripts, @scripts, 100, @inipath)
@library.delete([0].pack('C'))
@title.delete([0].pack('C'))
@scripts.delete([0].pack('C'))
else
@library = DefaultLibrary
@title = DefaultTitle
@scripts = DefaultScripts
end
if File.exist?(File.basename(__FILE__).sub(/\.rb$/i, '.rgssad'))
@rgssad = File.basename(__FILE__).sub(/\.rb$/i, '.rgssad')
@rgssad = File.join(Dir.pwd, @rgssad).gsub(/\//, "\\")
end
@wndclass = [
43, # style
Win32API.new('kernel32', 'GetProcAddress', 'lp', 'l').call(
Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call('User32.dll'),
'DefWindowProcW'), # wndproc
0, # class extra
0, # wnd extra
@hInstance,
Win32API.new('user32', 'LoadIcon', 'll', 'l').call(0, 32512), # icon
Win32API.new('user32', 'LoadCursor', 'll', 'l').call(0, 32512), # cursor
Win32API.new('gdi32', 'GetStockObject', 'i', 'l').call(4), # brush
0, # menu name
WndClassName # class name
].pack('ILiiLLLLLp')
temp = Win32API.new('user32', 'RegisterClass', 'p', 'l').call(@wndclass)
err_msg("注册窗口类失败 %s。", WndClassName) if temp == 0
gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
width = gsm.call(7) * 2 + 640
height = gsm.call(8) * 2 + gsm.call(4) + 480
x = (gsm.call(0) - width) / 2
y = (gsm.call(1) - height) / 2
@hWnd = Win32API.new('user32','CreateWindowExA','lpplllllllll','l').call(
0x100, WndClassName, @title, 0x90CA0000, x, y, width, height, 0, 0, @hInstance, 0)
err_msg("创建窗口失败 %s。", @title) if @hWnd == 0
@hRGSSCore = Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call(@library)
err_msg("加载RGSS核心库失败 %s。", @library) if @hRGSSCore == 0
def get_check(ary)
begin
Kernel.const_set(ary[0], Win32API.new(@library, *ary))
rescue Exception
err_msg("获取RGSS核心库导出函数失败 %s。", ary[0])
end
end
get_check(%w{RGSSEval p i})
get_check(%w{RGSSInitialize l v})
get_check(%w{RGSSGameMain lpl v})
get_check(%w{RGSSSetupRTP ppi})
undef :get_check
rtpname = [0].pack('C') * 1024
if (RGSSSetupRTP.call(@inipath, rtpname, 1024) == 0)
err_msg("没有发现 RGSS-RTP %s。", rtpname.delete([0].pack('C')))
end
RGSSInitialize.call(@hRGSSCore)
if ARGV.include?("btest")
RGSSEval.call("$DEBUG = true; $BTEST = true")
@rgssad = nil
elsif ARGV.include?('debug')
RGSSEval.call("$DEBUG = true")
end
RGSSGameMain.call(@hWnd, @scripts, @rgssad ? rgssad.object_id * 2 + 16 : 0)
stop
# coding: gbk
require 'win32api'
def err_msg(format, *args)
Win32API.new('user32', 'MessageBox', 'lppl', 'i').call(@hWnd ? @hWnd : 0, format % args, @title, 16)
stop
end
def stop
Win32API.new('kernel32', 'FreeLibrary', 'l', 'i').call(@hRGSSCore) if @hRGSSCore and @hRGSSCore != 0
Win32API.new('user32', 'DestroyWindow', 'l', 'i').call(@hWnd) if @hWnd and @hWnd != 0
Win32API.new('user32', 'UnregisterClass', 'pl', 'i').call(WndClassName, @hInstance)
exit
end
WndClassName = "RGSS Player"
DefaultLibrary = "RGSS102J.dll"
DefaultTitle = "Untitled"
DefaultScripts = "Data\\Scripts.rxdata"
@library = [0].pack('C') * 100
@title = [0].pack('C') * 100
@scripts = [0].pack('C') * 100
@hInstance = Win32API.new('kernel32', 'GetModuleHandle', 'l', 'l').call(0)
Win32API.new('user32', 'ShowWindow', 'li', 'i').call(Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, 0)
@inipath = File.basename(__FILE__).sub(/\.rb$/i, '.ini')
@inipath = File.join(Dir.pwd, @inipath).gsub(/\//, "\\")
if File.exist?(@inipath)
gpps = Win32API.new('kernel32', 'GetPrivateProfileString', 'ppppip', 'i')
gpps.call('Game', 'Library', DefaultLibrary, @library, 100, @inipath)
gpps.call('Game', 'Title', DefaultTitle, @title, 100, @inipath)
gpps.call('Game', 'Scripts', DefaultScripts, @scripts, 100, @inipath)
@library.delete([0].pack('C'))
@title.delete([0].pack('C'))
@scripts.delete([0].pack('C'))
else
@library = DefaultLibrary
@title = DefaultTitle
@scripts = DefaultScripts
end
if File.exist?(File.basename(__FILE__).sub(/\.rb$/i, '.rgssad'))
@rgssad = File.basename(__FILE__).sub(/\.rb$/i, '.rgssad')
@rgssad = File.join(Dir.pwd, @rgssad).gsub(/\//, "\\")
end
@wndclass = [
43, # style
Win32API.new('kernel32', 'GetProcAddress', 'lp', 'l').call(
Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call('User32.dll'),
'DefWindowProcW'), # wndproc
0, # class extra
0, # wnd extra
@hInstance,
Win32API.new('user32', 'LoadIcon', 'll', 'l').call(0, 32512), # icon
Win32API.new('user32', 'LoadCursor', 'll', 'l').call(0, 32512), # cursor
Win32API.new('gdi32', 'GetStockObject', 'i', 'l').call(4), # brush
0, # menu name
WndClassName # class name
].pack('ILiiLLLLLp')
temp = Win32API.new('user32', 'RegisterClass', 'p', 'l').call(@wndclass)
err_msg("注册窗口类失败 %s。", WndClassName) if temp == 0
gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
width = gsm.call(7) * 2 + 640
height = gsm.call(8) * 2 + gsm.call(4) + 480
x = (gsm.call(0) - width) / 2
y = (gsm.call(1) - height) / 2
@hWnd = Win32API.new('user32','CreateWindowExA','lpplllllllll','l').call(
0x100, WndClassName, @title, 0x90CA0000, x, y, width, height, 0, 0, @hInstance, 0)
err_msg("创建窗口失败 %s。", @title) if @hWnd == 0
@hRGSSCore = Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call(@library)
err_msg("加载RGSS核心库失败 %s。", @library) if @hRGSSCore == 0
def get_check(ary)
begin
Kernel.const_set(ary[0], Win32API.new(@library, *ary))
rescue Exception
err_msg("获取RGSS核心库导出函数失败 %s。", ary[0])
end
end
get_check(%w{RGSSEval p i})
get_check(%w{RGSSInitialize l v})
get_check(%w{RGSSGameMain lpl v})
get_check(%w{RGSSSetupRTP ppi})
undef :get_check
rtpname = [0].pack('C') * 1024
if (RGSSSetupRTP.call(@inipath, rtpname, 1024) == 0)
err_msg("没有发现 RGSS-RTP %s。", rtpname.delete([0].pack('C')))
end
RGSSInitialize.call(@hRGSSCore)
if ARGV.include?("btest")
RGSSEval.call("$DEBUG = true; $BTEST = true")
@rgssad = nil
elsif ARGV.include?('debug')
RGSSEval.call("$DEBUG = true")
end
RGSSGameMain.call(@hWnd, @scripts, @rgssad ? rgssad.object_id * 2 + 16 : 0)
stop
作者: 长虹剑 时间: 2015-8-21 20:45
多谢楼主,看了你的程序真的让我大开眼见,没想到winapi还可以这样用,让程序减少了不少。其实今天中午我的程序也写完了,但是有300行之多,主要是定义了半天cstruct。刚才看了你的程序,下载后在我这里运行不了,所以就想到用你的程序来简化我的程序。本来想另外开帖,又觉得是在这个帖里面长大的所以就放在这里了。
示例工程如下
RGSS纯ruby启动器.zip
(1.13 MB, 下载次数: 120)
程序代码如下- # -*- coding:utf-8 -*-
- =begin
- 参考资料
- https://rpg.blue/thread-377723-1-1.html 想法来源(后来还用楼主的脚本重新改写)
- http://skandhas.iteye.com/blog/809806 解决了创建windows窗口的问题
- 有些windows的常量没有定义需要查看MSDN
- http://rpg.blue/thread-282803-1-1.html 解决了最后读不了脚本文件的问题
- 解决不了的问题
- 1.RTP无法加载(也不知道加载是什么原理)
- 2.想知道RGSS.dll是如何实现的
- 3.RGSSGameMain 究竟干了什么,为什么之前的RGSSEval不能使用Sprite
- =end
- require 'Win32API'
- require 'pathname'
- require 'iniparse' #读取ini文件
- RGSSversion=3 # 1 or 3
- Gameini="Game_debug.ini" #"Game.ini"
- WndClassName = "Pure Ruby Window For RGSS"
- @title=WndClassName
- #--------
- szAppPath=Pathname.new(File.dirname(__FILE__)).realpath
- #puts Dir.getwd 获得当前的执行目录 ***
- Dir.chdir(szAppPath) #改变当前目录
- #-------------
- #隐藏掉控制台
- #Win32API.new('user32', 'ShowWindow', 'li', 'i').call(
- # Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, 0)
- #-------------
- @hInstance = Win32API.new('kernel32', 'GetModuleHandle', 'l', 'l').call(0)
- @wndclass = [
- 43, # style
- Win32API.new('kernel32', 'GetProcAddress', 'lp', 'l').call(
- Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call('User32.dll'),
- 'DefWindowProcW'), # wndproc
- 0, # class extra
- 0, # wnd extra
- @hInstance,
- Win32API.new('user32', 'LoadIcon', 'll', 'l').call(0, 32512), # icon
- Win32API.new('user32', 'LoadCursor', 'll', 'l').call(0, 32512), # cursor
- Win32API.new('gdi32', 'GetStockObject', 'i', 'l').call(4), # brush
- 0, # menu name
- WndClassName # class name
- ].pack('ILiiLLLLLp')
- atom = Win32API.new('user32', 'RegisterClass', 'p', 'l').call(@wndclass)
- atom &=0x0000ffff
- return if atom==0
- #在第一个实现的脚本中atom本来是要用在WndClassName位置的
- x=200; y=100; width=640 ; height=480
- @hWnd = Win32API.new('user32','CreateWindowExA','lpplllllllll','l').call(
- 0x100, WndClassName, @title, 0x90CA0000, x, y, width, height, 0, 0, @hInstance, 0)
- #-------------
- hd_gameini=IniParse.parse( File.read "#{Gameini}" )
- szLibrary=hd_gameini["Game"]["Library"]
- szTitle =hd_gameini["Game"]["Title"]
- szScripts=hd_gameini["Game"]["Scripts"]
- szRtpName=hd_gameini["Game"]["RTP"]
- @title=szTitle
- #通过核心库加载程序
- @hRgssCore = Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call(szLibrary)
- pRGSSEval=Win32API.new(szLibrary, "RGSSEval", ['P'], 'I')
- pRGSSSetupRTP=Win32API.new(szLibrary, "RGSSSetupRTP", ['P','P','I'], 'B')
- pRGSSInitialize=if RGSSversion==3
- Win32API.new(szLibrary, "RGSSInitialize3", 'L', 'L')
- elsif RGSSversion==1
- Win32API.new(szLibrary, "RGSSInitialize", 'L', 'L')
- end
- pRGSSGameMain=Win32API.new(szLibrary, "RGSSGameMain", ['L','P','P'], 'V')
- #puts Win32API::COLOR_WINDOWFRAME
- def stop
- Win32API.new('kernel32', 'FreeLibrary', 'l', 'i').call(@hRGSSCore) if @hRGSSCore and @hRGSSCore != 0
- Win32API.new('user32', 'DestroyWindow', 'l', 'i').call(@hWnd) if @hWnd and @hWnd != 0
- Win32API.new('user32', 'UnregisterClass', 'pl', 'i').call(WndClassName, @hInstance)
- exit
- end
- #RTP就是不行
- szRtpName= [0].pack('C') * 1024
- p pRGSSSetupRTP.Call("#{Gameini}", szRtpName, 1024)
- pRGSSInitialize.Call(@hRgssCore) # 没有这个就不行,说明还是有关系的
- szScripts="Scripts.rvdata2"
- class String
- MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
- WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
- def to_uni
- len = MultiByteToWideChar.call 65001, 0, self, -1, nil, 0
- buf = "\0" * (len * 2 + 2)
- MultiByteToWideChar.call 65001, 0, self, -1, buf, buf.size / 2
-
- buf
- end
-
- def from_uni
- len = WideCharToMultiByte.call 65001, 0, (self.respond_to?(:force_encoding) ? self.force_encoding("ASCII-8BIT") : self) + "\000\000", -1, nil, 0, nil, nil
- ret = "\0" * len
- WideCharToMultiByte.call 65001, 0, self, -1, ret, ret.size, nil, nil
-
- self.respond_to?(:force_encoding) ?
- ret.force_encoding("ASCII-8BIT").delete("\000") :
- ret.delete("\000")
- end
- end
- pRGSSGameMain.call(@hWnd,szScripts.to_uni,"") #必须这样才行
- stop
复制代码
作者: 浮云半仙 时间: 2016-1-20 20:46
本帖最后由 浮云半仙 于 2016-1-20 20:47 编辑
看了各位大神的代码,本蒟蒻深受启发,然而最终我只写出来个窗口...(并不了解RGSS的dll{:2_276:})- #encoding:utf-8
- require 'Win32API'
- unless defined?(Ocra)
- Win32API.new("user32", "ShowWindow", "li", "i").call(Win32API.new("kernel32", "GetConsoleWindow", 'l', 'l').call(0),0)
- #隐藏控制台
- end
- WS_OVERLAPPEDWINDOW = 0xcf0000
- WS_VISIBLE = 0x10000000
- IDI_APPLICATION = 32512
- SW_HIDE = 0
- SW_NORMAL = 1
- IDC_ARROW = 32512
- COLOR_WINDOW = 5
- GetLastError = Win32API.new("kernel32", "GetLastError", nil, "i")
- GetProcAddress = Win32API.new("kernel32", "GetProcAddress", "lp", "l")
- GetModuleHandle = Win32API.new("kernel32", "GetModuleHandle", "l", "l")
- GetModuleHandleByName = Win32API.new("kernel32", "GetModuleHandle", "p", "l")
- LoadLibrary = Win32API.new("kernel32", "LoadLibrary", "p", "l")
- RegisterClass = Win32API.new("user32", "RegisterClass", "p", "i")
- FreeLibrary = Win32API.new("kernel32", "FreeLibrary", "l", "i")
- CreateWindowEx = Win32API.new("user32", "CreateWindowEx", "lppliiiillll", "l")
- MessageBox = Win32API.new("user32", "MessageBox", "ippi", "i")
- GetMessage = Win32API.new("user32", "GetMessage","plll", "i")
- DispatchMessage = Win32API.new("user32", "DispatchMessage", "p", "i")
- def msg_box(title, text)
- MessageBox.call(0, text.to_s, title.to_s, 0)
- end
- unless defined?(Ocra)
- classname = "win32appruby233" #窗口类名
- hInstance = GetModuleHandle.call 0 #程序实例句柄
- hDll = LoadLibrary.call "user32.dll" #加载user32.dll
- Win32API.new("user32", "UnregisterClass", "pl", "i").call(classname, hInstance)
- #先反注册一下窗口类名...然而八成没啥用...
- ar_DefWindowProc = GetProcAddress.call hDll, "DefWindowProcW"
- #user32.dll里面DefWindowProcW的地址
- wc = [0, ar_DefWindowProc, 0, 0, hInstance,
- Win32API.new("user32", "LoadIcon", "ll", "l").call(hInstance, IDI_APPLICATION),
- Win32API.new("user32", "LoadCursor", "ll", "l").call(hInstance, IDC_ARROW),
- COLOR_WINDOW + 1, #窗体颜色
- 0,
- classname].pack("lllllllllp")
- #参见WNDCLASS结构体,打包地址,句柄可以用 'l'
-
- if RegisterClass.call(wc) == 0
- msg_box "Error!", "Fail to register window class, Error code:#{GetLastError.call}"
- exit
- end
- hWnd = CreateWindowEx.call(0, classname, "Ruby big law is good", #title
- WS_VISIBLE | WS_OVERLAPPEDWINDOW, #style
- 200, 100, 544, 416, #x, y, width, height
- 0, 0,
- hInstance, 0)
- #参见CreateWindowEx的参数
- Win32API.new("user32", "ShowWindow", "li", "i").call hWnd, SW_NORMAL
- #让窗口显示出来
- if hWnd == 0
- msg_box("Error!", "Fail to CreateWindow")
- exit
- end
- msg = "0"*24 #MSG结构体的大小为24byte,开够空间
- while GetMessage.call(msg, 0, 0, 0) #消息循环
- DispatchMessage.call(msg)
- end
- Win32API.new("user32", "UnregisterClass", "pl", "i").call(classname, hInstance)
- end
复制代码 膜拜各位神犇
BTW:win10上运行不了,报错注册窗口类失败。貌似win10上GetProcAddress一直返回0...好奇怪...{:2_278:}
作者: 浮云半仙 时间: 2016-1-22 21:29
taroxd 发表于 2015-3-26 12:42
我是来调戏论坛高亮的,不过论坛高亮竟然没出事情
{:2_270:}求解..ADDR_NWP,ADDR_AOWP怎么粗来的{:2_271:}
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |