Domingo 22 de Diciembre de 2024, 12:58
SoloCodigo
Bienvenido(a),
Visitante
. Por favor,
ingresa
o
regístrate
.
¿Perdiste tu
email de activación?
Inicio
Foros
Chat
Ayuda
Buscar
Ingresar
Registrarse
SoloCodigo
»
Foros
»
Programación General
»
ASM (Ensamblador)
(Moderador:
Eternal Idol
) »
Consulta Sobre Programacion De Dll En Asm
« anterior
próximo »
Imprimir
Páginas: [
1
]
Autor
Tema: Consulta Sobre Programacion De Dll En Asm (Leído 1587 veces)
L3andro
Nuevo Miembro
Mensajes: 8
Consulta Sobre Programacion De Dll En Asm
«
en:
Lunes 17 de Diciembre de 2007, 18:00 »
0
Hola a todos, bueno quisiera consultarles lo siguiente, estoy intentando trabajar con una DLL programada en ASM, tengo algunas cuantas dudas sobre el tema, las cuales seguramente no sean muy complicadas de contestar.
Bueno el codigo Fuente completo hasta ahora de la DLL es el siguiente:
Código: Text
;EasyCodeName=Module1,1
.386
.Model flat, StdCall
Option CaseMap:none
Include \masm32\include\windows.inc
Include \masm32\include\user32.inc
Include \masm32\include\kernel32.inc
Include \masm32\include\masm32.inc
IncludeLib \masm32\lib\user32.lib
IncludeLib \masm32\lib\kernel32.lib
IncludeLib \masm32\lib\masm32.lib
Include \masm32\macros\MACROS.ASM
.Const
MEMSIZE Equ 175535
LittleBuffer Equ 10H
GSAuthKey1 Equ 00BE2329H
GSAuthKey2 Equ 0AED66CE1H
GSAuthKey3 Equ 0F1499052H
GSAuthKey4 Equ 0EBE9BBF1H
GSAuthKey5 Equ 0A6B3H
GSAuthKey6 Equ 0DBH
.Data
ItemKor DB "..\data\lang\Kor\item(Kor).txt", 0
ItemVTM DB "..\data\lang\vtm\item(Vtm).txt", 0
SkillKor DB "..\data\lang\Kor\skill(Kor).txt", 0
SkillVTM DB "..\data\lang\vtm\skill(Vtm).txt", 0
QuestKor DB "..\data\lang\Kor\Quest(Kor).txt", 0
QuestVTM DB "..\data\lang\Vtm\Quest(Vtm).txt", 0
CheckSum DB "..\data\lang\Kor\CheckSum.dat", 0
Monster DB "..\data\Monster.txt", 0
Gate DB "..\data\gate.txt", 0
MonsterBase DB "..\data\MonsterSetBase.txt", 0
Shop0 DB "..\data\Shop0.txt", 0
Shop1 DB "..\data\Shop1.txt", 0
Shop2 DB "..\data\Shop2.txt", 0
Shop3 DB "..\data\Shop3.txt", 0
Shop4 DB "..\data\Shop4.txt", 0
Shop5 DB "..\data\Shop5.txt", 0
Shop6 DB "..\data\Shop6.txt", 0
Shop7 DB "..\data\Shop7.txt", 0
Shop8 DB "..\data\Shop8.txt", 0
Shop9 DB "..\data\Shop9.txt", 0
Shop10 DB "..\data\Shop10.txt", 0
Shop11 DB "..\data\Shop11.txt", 0
Shop12 DB "..\data\Shop12.txt", 0
MoveReqKor DB "..\data\lang\Kor\movereq(kor).txt", 0
MoveReqVTM DB "..\data\lang\Vtm\movereq(Vtm).txt", 0
ItemSetOption DB "..\data\lang\Kor\itemsetoption(Kor).txt", 0
ItemSetType DB "..\data\lang\Kor\itemsettype(Kor).txt", 0
CommonLoc DB "..\data\lang\Kor\CommonLoc.cfg", 0
GameServerInfo DB "GameServerInfo", 0
ClientVersion DB "ClientExeVersion", 0
ClientSerial DB "ClientExeSerial", 0
ServerName DD LittleBuffer Dup(0)
VersionServer DD LittleBuffer Dup(0)
ClientVersionReturn DD LittleBuffer Dup(0)
ClientSerialReturn DD LittleBuffer Dup(0)
AGGSOffset DD ?
AGSOffset2 DD ?
FirstTime DD ?
.Data?
hFile HANDLE ?
hMemory HANDLE ?
pMemory DWord ?
SizeReadWrite DWord ?
.Code
DllEntry Proc hInstDLL:HINSTANCE, reason:DWord, reserved1:DWord
Mov Eax, TRUE
Ret
DllEntry EndP
AGSetInfo Proc
Mov Eax, DWord Ptr Ss:[Ebp + 18H]
Mov Ecx, DWord Ptr Ss:[Ebp + 14H]
Mov Edx, DWord Ptr Ss:[Ebp + 0CH]
Mov Ebx, DWord Ptr Ss:[Ebp + 20H]
Mov ServerName, Eax
Mov VersionServer, Ecx
Mov AGGSOffset, Edx
Mov AGSOffset2, Ebx
Xor Eax, Eax
Ret
AGSetInfo EndP
AGGetKey Proc
Mov Edx, GSAuthKey1
Mov Eax, DWord Ptr Ss:[Ebp + 8]
Mov DWord Ptr Ds:[Eax], Edx
Mov Edx, GSAuthKey2
Mov DWord Ptr Ds:[Eax + 4], Edx
Mov Edx, GSAuthKey3
Mov DWord Ptr Ds:[Eax + 8], Edx
Mov Edx, GSAuthKey4
Mov DWord Ptr Ds:[Eax + 0CH], Edx
Mov Cx, GSAuthKey5
Mov Word Ptr Ds:[Eax + 10H], Cx
Mov Dl, GSAuthKey6
Mov Byte Ptr Ds:[Eax + 12H], Dl
Xor Eax, Eax
Ret
AGGetKey EndP
AGRequestData Proc
Local Number:DWord
Cmp FirstTime, 0
Jnz DeleteBuffer
Mov FirstTime, 1
Jmp SwitchNumbers
DeleteBuffer:
Invoke CloseHandle, hFile
Invoke GlobalUnlock, pMemory
Invoke GlobalFree, hMemory
SwitchNumbers:
Mov Ecx, DWord Ptr Ss:[Ebp + 0CH]
Mov Number, Ecx
Switch Number
Case 0
Mov Eax, Offset ItemKor
Case 1
Mov Eax, Offset ItemVTM
Case 2
Mov Eax, Offset SkillKor
Case 3
Mov Eax, Offset SkillVTM
Case 4
Mov Eax, Offset QuestKor
Case 5
Mov Eax, Offset QuestVTM
Case 6
Mov Eax, Offset CheckSum
Case 7
Mov Eax, Offset Monster
Case 8
Mov Eax, Offset Gate
Case 9
Mov Eax, Offset MonsterBase
Case 0BH
Mov Eax, Offset Shop0
Case 0CH
Mov Eax, Offset Shop1
Case 0DH
Mov Eax, Offset Shop2
Case 0EH
Mov Eax, Offset Shop3
Case 0FH
Mov Eax, Offset Shop4
Case 10H
Mov Eax, Offset Shop5
Case 11H
Mov Eax, Offset Shop6
Case 12H
Mov Eax, Offset Shop7
Case 13H
Mov Eax, Offset Shop8
Case 14H
Mov Eax, Offset Shop9
Case 15H
Mov Eax, Offset Shop10
Case 16H
Mov Eax, Offset Shop11
Case 17H
Mov Eax, Offset Shop12
Case 18H
Mov Eax, Offset MoveReqKor
Case 1AH
Mov Eax, Offset ItemSetOption
Case 1CH
Mov Eax, Offset ItemSetType
EndSw
LoadFile:
Invoke CreateFile, Eax, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, NULL
Mov hFile, Eax
Invoke GlobalAlloc, GMEM_MOVEABLE Or GMEM_ZEROINIT, MEMSIZE
Mov hMemory, Eax
Invoke GlobalLock, hMemory
Mov pMemory, Eax
Invoke ReadFile, hFile, pMemory, MEMSIZE - 1, Addr SizeReadWrite, NULL
Xor Eax, Eax
Ret
AGRequestData EndP
AGGetDataBufferSize Proc
Mov Eax, SizeReadWrite
Ret
AGGetDataBufferSize EndP
AGGetDataBuffer Proc
Mov Eax, pMemory
Ret
AGGetDataBuffer EndP
AGGetClientVersion Proc
Invoke GetPrivateProfileString, Addr GameServerInfo, Addr ClientVersion, NULL, Addr ClientVersionReturn, 14H, Addr CommonLoc
Invoke GetPrivateProfileString, Addr GameServerInfo, Addr ClientSerial, NULL, Addr ClientSerialReturn, 14H, Addr CommonLoc
Mov Eax, DWord Ptr Ds:[ClientVersionReturn]
Mov Ecx, DWord Ptr Ds:[ClientVersionReturn + 4]
Mov Edx, DWord Ptr Ss:[Ebp + 8]
Mov DWord Ptr Ds:[Edx], Eax
Mov DWord Ptr Ds:[Edx + 4], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn]
Mov Ecx, DWord Ptr Ds:[ClientSerialReturn + 4]
Mov Edx, DWord Ptr Ss:[Ebp + 0CH]
Mov DWord Ptr Ds:[Edx], Eax
Mov DWord Ptr Ds:[Edx + 4], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn + 8]
Mov Ecx, DWord Ptr Ds:[ClientSerialReturn + 0CH]
Mov DWord Ptr Ds:[Edx + 8], Eax
Mov DWord Ptr Ds:[Edx + 0CH], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn + 10H]
Mov DWord Ptr Ds:[Edx + 10H], Eax
Xor Eax, Eax
Ret
AGGetClientVersion EndP
End DllEntry
Asi como esta, funciona bien... Ahora mi consulta es la siguiente, me decidi a agregarle algunas funciones mas de configuracion, añadiendo un .ini - y quisiera ver si esto esta bien y si de estarlo hay alguna forma de optimizar el codigo si pueden asesorarme, o corregirme de estar mal.
Lo que agrego seria lo siguiente.
Dentro de .Data añado esto:
Código: Text
.Data
IsGlobalChatBuff DB 1 Dup(0)
GChatLevelBuff DB 4 Dup(0)
GChatMoneyBuff DB 4 Dup(0)
Sections DB "Config", 0
IniFileName DB "./Config.ini" , 0
Y posteriormente creo un nuevo Proc de la siguiente manera:
Código: Text
LoadConfig Proc
Invoke GetPrivateProfileInt, Addr Sections, Addr IsGlobalChat, 0, Addr IniFileName
Mov DWord Ptr Ds:[IsGlobalChatBuff], Eax
Invoke GetPrivateProfileInt, Addr Sections, Addr GChatLevel, 50, Addr IniFileName
Mov DWord Ptr Ds:[GChatLevelBuff], Eax
Invoke GetPrivateProfileInt, Addr Sections, Addr GChatMoney, 10000, Addr IniFileName
Mov DWord Ptr Ds:[GChatMoneyBuff], Eax
Retn
LoadConfig EndP
Las opciones son muchisimas mas, pero en resumen la idea es esa, y esto quedaria de la siguiente manera:
Código: Text
.386
.Model flat, StdCall
Option CaseMap:none
Include \masm32\include\windows.inc
Include \masm32\include\user32.inc
Include \masm32\include\kernel32.inc
Include \masm32\include\masm32.inc
IncludeLib \masm32\lib\user32.lib
IncludeLib \masm32\lib\kernel32.lib
IncludeLib \masm32\lib\masm32.lib
Include \masm32\macros\MACROS.ASM
.Const
MEMSIZE Equ 175535
LittleBuffer Equ 10H
GSAuthKey1 Equ 00BE2329H
GSAuthKey2 Equ 0AED66CE1H
GSAuthKey3 Equ 0F1499052H
GSAuthKey4 Equ 0EBE9BBF1H
GSAuthKey5 Equ 0A6B3H
GSAuthKey6 Equ 0DBH
.Data
IsGlobalChatBuff DB 1 Dup(0)
GChatLevelBuff DB 4 Dup(0)
GChatMoneyBuff DB 4 Dup(0)
Sections DB "Config", 0
IniFileName DB "./Config.ini" , 0
ItemKor DB "..\data\lang\Kor\item(Kor).txt", 0
ItemVTM DB "..\data\lang\vtm\item(Vtm).txt", 0
SkillKor DB "..\data\lang\Kor\skill(Kor).txt", 0
SkillVTM DB "..\data\lang\vtm\skill(Vtm).txt", 0
QuestKor DB "..\data\lang\Kor\Quest(Kor).txt", 0
QuestVTM DB "..\data\lang\Vtm\Quest(Vtm).txt", 0
CheckSum DB "..\data\lang\Kor\CheckSum.dat", 0
Monster DB "..\data\Monster.txt", 0
Gate DB "..\data\gate.txt", 0
MonsterBase DB "..\data\MonsterSetBase.txt", 0
Shop0 DB "..\data\Shop0.txt", 0
Shop1 DB "..\data\Shop1.txt", 0
Shop2 DB "..\data\Shop2.txt", 0
Shop3 DB "..\data\Shop3.txt", 0
Shop4 DB "..\data\Shop4.txt", 0
Shop5 DB "..\data\Shop5.txt", 0
Shop6 DB "..\data\Shop6.txt", 0
Shop7 DB "..\data\Shop7.txt", 0
Shop8 DB "..\data\Shop8.txt", 0
Shop9 DB "..\data\Shop9.txt", 0
Shop10 DB "..\data\Shop10.txt", 0
Shop11 DB "..\data\Shop11.txt", 0
Shop12 DB "..\data\Shop12.txt", 0
MoveReqKor DB "..\data\lang\Kor\movereq(kor).txt", 0
MoveReqVTM DB "..\data\lang\Vtm\movereq(Vtm).txt", 0
ItemSetOption DB "..\data\lang\Kor\itemsetoption(Kor).txt", 0
ItemSetType DB "..\data\lang\Kor\itemsettype(Kor).txt", 0
CommonLoc DB "..\data\lang\Kor\CommonLoc.cfg", 0
GameServerInfo DB "GameServerInfo", 0
ClientVersion DB "ClientExeVersion", 0
ClientSerial DB "ClientExeSerial", 0
ServerName DD LittleBuffer Dup(0)
VersionServer DD LittleBuffer Dup(0)
ClientVersionReturn DD LittleBuffer Dup(0)
ClientSerialReturn DD LittleBuffer Dup(0)
AGGSOffset DD ?
AGSOffset2 DD ?
FirstTime DD ?
.Data?
hFile HANDLE ?
hMemory HANDLE ?
pMemory DWord ?
SizeReadWrite DWord ?
.Code
DllEntry Proc hInstDLL:HINSTANCE, reason:DWord, reserved1:DWord
Mov Eax, TRUE
Ret
DllEntry EndP
LoadConfig Proc
Invoke GetPrivateProfileInt, Addr Sections, Addr IsGlobalChat, 0, Addr IniFileName
Mov DWord Ptr Ds:[IsGlobalChatBuff], Eax
Invoke GetPrivateProfileInt, Addr Sections, Addr GChatLevel, 50, Addr IniFileName
Mov DWord Ptr Ds:[GChatLevelBuff], Eax
Invoke GetPrivateProfileInt, Addr Sections, Addr GChatMoney, 10000, Addr IniFileName
Mov DWord Ptr Ds:[GChatMoneyBuff], Eax
Retn
LoadConfig EndP
AGSetInfo Proc
Mov Eax, DWord Ptr Ss:[Ebp + 18H]
Mov Ecx, DWord Ptr Ss:[Ebp + 14H]
Mov Edx, DWord Ptr Ss:[Ebp + 0CH]
Mov Ebx, DWord Ptr Ss:[Ebp + 20H]
Mov ServerName, Eax
Mov VersionServer, Ecx
Mov AGGSOffset, Edx
Mov AGSOffset2, Ebx
Xor Eax, Eax
Ret
AGSetInfo
AGGetKey Proc
Mov Edx, GSAuthKey1
Mov Eax, DWord Ptr Ss:[Ebp + 8]
Mov DWord Ptr Ds:[Eax], Edx
Mov Edx, GSAuthKey2
Mov DWord Ptr Ds:[Eax + 4], Edx
Mov Edx, GSAuthKey3
Mov DWord Ptr Ds:[Eax + 8], Edx
Mov Edx, GSAuthKey4
Mov DWord Ptr Ds:[Eax + 0CH], Edx
Mov Cx, GSAuthKey5
Mov Word Ptr Ds:[Eax + 10H], Cx
Mov Dl, GSAuthKey6
Mov Byte Ptr Ds:[Eax + 12H], Dl
Xor Eax, Eax
Ret
AGGetKey EndP
AGRequestData Proc
Local Number:DWord
Cmp FirstTime, 0
Jnz DeleteBuffer
Mov FirstTime, 1
Jmp SwitchNumbers
DeleteBuffer:
Invoke CloseHandle, hFile
Invoke GlobalUnlock, pMemory
Invoke GlobalFree, hMemory
SwitchNumbers:
Mov Ecx, DWord Ptr Ss:[Ebp + 0CH]
Mov Number, Ecx
Switch Number
Case 0
Mov Eax, Offset ItemKor
Case 1
Mov Eax, Offset ItemVTM
Case 2
Mov Eax, Offset SkillKor
Case 3
Mov Eax, Offset SkillVTM
Case 4
Mov Eax, Offset QuestKor
Case 5
Mov Eax, Offset QuestVTM
Case 6
Mov Eax, Offset CheckSum
Case 7
Mov Eax, Offset Monster
Case 8
Mov Eax, Offset Gate
Case 9
Mov Eax, Offset MonsterBase
Case 0BH
Mov Eax, Offset Shop0
Case 0CH
Mov Eax, Offset Shop1
Case 0DH
Mov Eax, Offset Shop2
Case 0EH
Mov Eax, Offset Shop3
Case 0FH
Mov Eax, Offset Shop4
Case 10H
Mov Eax, Offset Shop5
Case 11H
Mov Eax, Offset Shop6
Case 12H
Mov Eax, Offset Shop7
Case 13H
Mov Eax, Offset Shop8
Case 14H
Mov Eax, Offset Shop9
Case 15H
Mov Eax, Offset Shop10
Case 16H
Mov Eax, Offset Shop11
Case 17H
Mov Eax, Offset Shop12
Case 18H
Mov Eax, Offset MoveReqKor
Case 1AH
Mov Eax, Offset ItemSetOption
Case 1CH
Mov Eax, Offset ItemSetType
EndSw
LoadFile:
Invoke CreateFile, Eax, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, NULL
Mov hFile, Eax
Invoke GlobalAlloc, GMEM_MOVEABLE Or GMEM_ZEROINIT, MEMSIZE
Mov hMemory, Eax
Invoke GlobalLock, hMemory
Mov pMemory, Eax
Invoke ReadFile, hFile, pMemory, MEMSIZE - 1, Addr SizeReadWrite, NULL
Xor Eax, Eax
Ret
AGRequestData EndP
AGGetDataBufferSize Proc
Mov Eax, SizeReadWrite
Ret
AGGetDataBufferSize EndP
AGGetDataBuffer Proc
Mov Eax, pMemory
Ret
AGGetDataBuffer EndP
AGGetClientVersion Proc
Invoke GetPrivateProfileString, Addr GameServerInfo, Addr ClientVersion, NULL, Addr ClientVersionReturn, 14H, Addr CommonLoc
Invoke GetPrivateProfileString, Addr GameServerInfo, Addr ClientSerial, NULL, Addr ClientSerialReturn, 14H, Addr CommonLoc
Mov Eax, DWord Ptr Ds:[ClientVersionReturn]
Mov Ecx, DWord Ptr Ds:[ClientVersionReturn + 4]
Mov Edx, DWord Ptr Ss:[Ebp + 8]
Mov DWord Ptr Ds:[Edx], Eax
Mov DWord Ptr Ds:[Edx + 4], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn]
Mov Ecx, DWord Ptr Ds:[ClientSerialReturn + 4]
Mov Edx, DWord Ptr Ss:[Ebp + 0CH]
Mov DWord Ptr Ds:[Edx], Eax
Mov DWord Ptr Ds:[Edx + 4], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn + 8]
Mov Ecx, DWord Ptr Ds:[ClientSerialReturn + 0CH]
Mov DWord Ptr Ds:[Edx + 8], Eax
Mov DWord Ptr Ds:[Edx + 0CH], Ecx
Mov Eax, DWord Ptr Ds:[ClientSerialReturn + 10H]
Mov DWord Ptr Ds:[Edx + 10H], Eax
Xor Eax, Eax
Ret
AGGetClientVersion EndP
End DllEntry
Bueno mi consulta es la nombrada, quisiera saber si los ultimos agregados como el del .ini para configuracion estan bien aplicados, y si hay alguna manera de optimizar el codigo.
Saludos y desde ya gracias.
Tweet
Single I Want To learn as much that Likes
Studying ASM, You can Help Me?
Imprimir
Páginas: [
1
]
« anterior
próximo »
SoloCodigo
»
Foros
»
Programación General
»
ASM (Ensamblador)
(Moderador:
Eternal Idol
) »
Consulta Sobre Programacion De Dll En Asm