elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: AIO elhacker.NET 2021 Compilación herramientas análisis y desinfección malware


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Problema Funcion Beep de kernel32.dll
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problema Funcion Beep de kernel32.dll  (Leído 2,708 veces)
dRak0

Desconectado Desconectado

Mensajes: 234


Ver Perfil WWW
Problema Funcion Beep de kernel32.dll
« en: 23 Julio 2014, 02:07 am »

Que tal , estaba repasando un poco las funciones de kernel32 y , no se porque , no me funciona Beep.

Código:
#include <stdio.h>
#include <windows.h>

int main(int argc,char **argv)
{
typedef int (*punteroExitProcess)(UINT);
typedef int (*punteroBeep)(DWORD,DWORD);
typedef DWORD (*punteroGetCurrentProcessId)(void);
HMODULE dirKernel32=GetModuleHandle("kernel32.dll");
punteroExitProcess punteroExit=NULL;
punteroBeep punteroBep=NULL;
punteroGetCurrentProcessId GetCurrentProcessId2=NULL;
punteroExit=(punteroExitProcess)GetProcAddress(dirKernel32,"ExitProcess");
punteroBep=(punteroBeep)GetProcAddress(dirKernel32,"Beep");
GetCurrentProcessId2=(punteroGetCurrentProcessId)GetProcAddress(dirKernel32,"GetCurrentProcessId");
printf("Kernel32:%p\nExitProcess:%p\nBeep:%p\nGetCurrentProcessId:%p\n",dirKernel32,punteroExit,punteroBep,GetCurrentProcessId2);
printf("PID=%d\n",GetCurrentProcessId2());
punteroBep(1000,3000);
punteroExit(0);

}

Perdonen los nombres.La idea era obtener la direccion en memoria de kernel32 y jugar un poco con las funciones de este , a travez de punteros a funciones. Claro que hay formas mas faciles , solo era para repasar un poco.


En línea

Eternal Idol
Kernel coder
Moderador
***
Desconectado Desconectado

Mensajes: 5.935


Israel nunca torturó niños, ni lo volverá a hacer.


Ver Perfil WWW
Re: Problema Funcion Beep de kernel32.dll
« Respuesta #1 en: 23 Julio 2014, 10:33 am »

El codigo esta bien en principio y en mi maquina funciona, fijate cual es el estado del driver beep (sc query beep), tiene que estar cargado en memoria para que escuches el beep. Siempre comproba el retorno de las funciones y usa GetLastError donde corresponda.

Hay algo que deberias cambiar y es la convencion de llamada de los punteros a funcion, practicamente siempre deberia ser __stdcall (WINAPI) al ser la API de Windows (por defecto es C); eso lo consultas en la MSDN facilmente.

Trata de hacer coincidir el puntero a funcion, en su tipo de retorno, convencion de llamada y parametros. Ej.:

ExitProcess

Código
  1. typedef VOID (__stdcall *punteroExitProcess)(UINT);


Beep function

Remarks

A long time ago, all PC computers shared a common 8254 programable interval timer chip for the generation of primitive sounds. The Beep function was written specifically to emit a beep on that piece of hardware.

On these older systems, muting and volume controls have no effect on Beep; you would still hear the tone. To silence the tone, you used the following commands:

net stop beep

sc config beep start= disabled

Since then, sound cards have become standard equipment on almost all PC computers. As sound cards became more common, manufacturers began to remove the old timer chip from computers. The chips were also excluded from the design of server computers. The result is that Beep did not work on all computers without the chip. This was okay because most developers had moved on to calling the MessageBeep function that uses whatever is the default sound device instead of the 8254 chip.

Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.

In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.


« Última modificación: 23 Julio 2014, 10:35 am por Eternal Idol » En línea

La economía nunca ha sido libre: o la controla el Estado en beneficio del Pueblo o lo hacen los grandes consorcios en perjuicio de éste.
Juan Domingo Perón
dRak0

Desconectado Desconectado

Mensajes: 234


Ver Perfil WWW
Re: Problema Funcion Beep de kernel32.dll
« Respuesta #2 en: 23 Julio 2014, 10:47 am »

El codigo esta bien en principio y en mi maquina funciona, fijate cual es el estado del driver beep (sc query beep), tiene que estar cargado en memoria para que escuches el beep. Siempre comproba el retorno de las funciones y usa GetLastError donde corresponda.

Hay algo que deberias cambiar y es la convencion de llamada de los punteros a funcion, practicamente siempre deberia ser __stdcall (WINAPI) al ser la API de Windows (por defecto es C); eso lo consultas en la MSDN facilmente.

Trata de hacer coincidir el puntero a funcion, en su tipo de retorno, convencion de llamada y parametros. Ej.:

ExitProcess

Código
  1. typedef VOID (__stdcall *punteroExitProcess)(UINT);


Beep function

Remarks

A long time ago, all PC computers shared a common 8254 programable interval timer chip for the generation of primitive sounds. The Beep function was written specifically to emit a beep on that piece of hardware.

On these older systems, muting and volume controls have no effect on Beep; you would still hear the tone. To silence the tone, you used the following commands:

net stop beep

sc config beep start= disabled

Since then, sound cards have become standard equipment on almost all PC computers. As sound cards became more common, manufacturers began to remove the old timer chip from computers. The chips were also excluded from the design of server computers. The result is that Beep did not work on all computers without the chip. This was okay because most developers had moved on to calling the MessageBeep function that uses whatever is the default sound device instead of the 8254 chip.

Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.

In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.


Gracias por la correccion, de ahora en mas pondre la convencion de llamada de la funcion,asi se limpia bien el stack.

Solucionado lo del beep.
En línea

Eternal Idol
Kernel coder
Moderador
***
Desconectado Desconectado

Mensajes: 5.935


Israel nunca torturó niños, ni lo volverá a hacer.


Ver Perfil WWW
Re: Problema Funcion Beep de kernel32.dll
« Respuesta #3 en: 23 Julio 2014, 11:24 am »

De nadas  ::)
En línea

La economía nunca ha sido libre: o la controla el Estado en beneficio del Pueblo o lo hacen los grandes consorcios en perjuicio de éste.
Juan Domingo Perón
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Problema KERNEL32.dll de MakeCriticalSectionGlobal
Juegos y Consolas
Lainuxxx 0 3,286 Último mensaje 29 Julio 2004, 10:23 am
por Lainuxxx
En el PC no suena el Beep al arrancar y no arranca « 1 2 »
Hardware
javier234- 10 13,319 Último mensaje 14 Abril 2013, 21:04 pm
por javier234-
[HELP] Borrar un carater, matener fondo y beep
ASM
samirllorente 0 1,967 Último mensaje 28 Mayo 2015, 11:32 am
por samirllorente
Ayuda please. Función (beep) sonido.
Windows
Juancamunoz 8 3,885 Último mensaje 21 Julio 2015, 17:57 pm
por Randomize
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines