Foros del Web » Programacin para mayores de 30 ;) » C/C++ »

Problema con programa c++

Estas en el tema de Problema con programa c++ en el foro de C/C++ en Foros del Web. Me sale estos errores al compilar el programa en visual c++ 2008. Cdigo: archivo.cpp(33) : error C2664: 'CreateThread' : cannot convert parameter 3 from 'int32_t ...
  #1 (permalink)  
Antiguo 26/04/2015, 13:02
 
Fecha de Ingreso: octubre-2008
Mensajes: 4
Antigedad: 15 aos, 6 meses
Puntos: 0
Problema con programa c++

Me sale estos errores al compilar el programa en visual c++ 2008.

Cdigo:
archivo.cpp(33) : error C2664: 'CreateThread' : cannot convert parameter 3 from 'int32_t *' to 'LPTHREAD_START_ROUTINE'
        There is no context in which this conversion is possible
archivo.cpp(52) : error C2664: 'GetProcAddress' : cannot convert parameter 1 from 'int32_t *' to 'HMODULE'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
archivo.cpp(53) : error C2440: 'initializing' : cannot convert from 'FARPROC' to 'int32_t (__cdecl *)(void)'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
archivo.cpp(55) : error C2664: 'VirtualProtect' : cannot convert parameter 4 from 'int32_t *' to 'PDWORD'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
archivo.cpp(56) : error C2664: 'VirtualProtect' : cannot convert parameter 4 from 'int32_t *' to 'PDWORD'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
El Codigo Fuente es este:
Cdigo:
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <windows.h>

/* -------- Function Prototypes --------- */

int32_t entry_point(int32_t a1);
void function_10001038(void);
void function_100010d0(void);

/* ---------- Global Variables ---------- */

int32_t g1 = -0x7c1374ab; // 0x10001038
bool g2 = false; // gpr0

/* ------------- Functions -------------- */

// Address range: 0x10001000 - 0x10001035
int32_t entry_point(int32_t a1) {
    // bb
    int32_t v1;
    switch (v1) {
        case 1: {
            // 0x10001009
            g2 = true;
            CreateThread(0, 0, &g1, NULL, 0, NULL);
            // branch -> 0x10001034
            break;
        }
        case 0: {
            // 0x1000102d
            ExitProcess(0);
            // branch -> 0x10001034
            break;
        }
    }
    // 0x10001034
    return 1;
}

// Address range: 0x10001038 - 0x100010ca
void function_10001038(void) {
    // bb
    GetModuleHandleA("entitiesmp.dll");
    int32_t (*func)() = GetProcAddress(g2 ? (int32_t *)function_10001038 : NULL, "CRangeWeapon_DLLClass"); // 0x1000104e
    int32_t (*func2)() = GetProcAddress(GetModuleHandleA("entitiesmp.dll"), "CNpcSkeletonMusketeer2_DLLClass"); // 0x10001065
    int32_t * lpflOldProtect;
    VirtualProtect((int32_t *)*(int32_t *)func, 96, 64, lpflOldProtect);
    VirtualProtect((int32_t *)*(int32_t *)func2, 96, 64, lpflOldProtect);
    *(int8_t *)func = *(int8_t *)func2;
    int32_t v1 = 95; // 0x10001095
    // branch -> 0x1000108d
    while (v1 != 0) {
        // 0x1000108d
        func = (int32_t (*)())((int32_t)func + 1);
        func2 = (int32_t (*)())((int32_t)func2 + 1);
        *(int8_t *)func = *(int8_t *)func2;
        v1--;
        // continue -> 0x1000108d
    }
    // 0x10001097
    MessageBoxA(NULL, "s", "Probando si funciona", 0);
}
  #2 (permalink)  
Antiguo 26/04/2015, 13:11
lareto
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Problema con programa c++

Hola; deberas leer sobre la funcin CreateThread:
https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx
  #3 (permalink)  
Antiguo 26/04/2015, 16:50
 
Fecha de Ingreso: octubre-2008
Mensajes: 4
Antigedad: 15 aos, 6 meses
Puntos: 0
Respuesta: Problema con programa c++

Logre solucionar ese error ahora el problema son con las funciones GetProcAddress y VirtualProtect que hasta ahora no logro resolver.
  #4 (permalink)  
Antiguo 26/04/2015, 18:32
 
Fecha de Ingreso: octubre-2008
Mensajes: 4
Antigedad: 15 aos, 6 meses
Puntos: 0
Respuesta: Problema con programa c++

Ahora no me sale errores pero el DLL generado no me trabaja bien.
Asi es como quedo.

Cdigo:
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <windows.h>

/* -------- Function Prototypes --------- */

int32_t entry_point(int32_t a1);
void function_10001038(void);
void function_100010d0(void);

/* ---------- Global Variables ---------- */

int32_t g1 = -0x7c1374ab; // 0x10001038
bool g2 = false; // gpr0

/* ------------- Functions -------------- */

// Address range: 0x10001000 - 0x10001035
int32_t entry_point(int32_t a1) {
    // bb
    int32_t v1 = 0;
    switch (v1) {
        case 1: {
            // 0x10001009
            g2 = true;
            CreateThread(0, 0, * (LPTHREAD_START_ROUTINE *) &g1, NULL, 0, NULL);
            // branch -> 0x10001034
            break;
        }
        case 0: {
            // 0x1000102d
            ExitProcess(0);
            // branch -> 0x10001034
            break;
        }
    }
    // 0x10001034
    return 1;
}

// Address range: 0x10001038 - 0x100010ca
void function_10001038(void) {
    // bb
    typedef int32_t (*funca)();
	typedef int32_t (*funca2)();
    funca func = (funca)GetProcAddress(GetModuleHandleA("entitiesmp.dll"), "CRangeWeapon_DLLClass"); // 0x1000104e
    funca2 func2 = (funca2) GetProcAddress(GetModuleHandleA("entitiesmp.dll"), "CNpcSkeletonMusketeer2_DLLClass"); // 0x10001065
    unsigned long lpflOldProtect;
    VirtualProtect((int32_t *)*(int32_t *)func, 96, 64, &lpflOldProtect);
    VirtualProtect((int32_t *)*(int32_t *)func2, 96, 64, &lpflOldProtect);
    *(int8_t *)func = *(int8_t *)func2;
    int32_t v1 = 95; // 0x10001095
    // branch -> 0x1000108d
    while (v1 != 0) {
        // 0x1000108d
        func = (int32_t (*)())((int32_t)func + 1);
        func2 = (int32_t (*)())((int32_t)func2 + 1);
        *(int8_t *)func = *(int8_t *)func2;
        v1--;
        // continue -> 0x1000108d
    }
}
  #5 (permalink)  
Antiguo 26/04/2015, 20:20
lareto
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: Problema con programa c++

Definitivamente, creo que deberas volver a leer sobre CreateThread
  #6 (permalink)  
Antiguo 26/04/2015, 23:24
 
Fecha de Ingreso: abril-2015
Mensajes: 1
Antigedad: 9 aos
Puntos: 0
Respuesta: Problema con programa c++

Hola,

Disculpen que me desve un poco del tema, estoy aprendiendo a programar y tengo el siguiente problema que se me corrompe o cambia el archivo fuente a archivo codigo, de un momento a otro, veces he estado trabajando por horas y toda la informacin se me trastorna y ya no es legible para mi, me siento frustrado y nose pq pasa esto.

me aparece un poco de codigo de la siguiente manera para que se explique de mejor manera lo que sucede.

MZ   @ €  !L!This program cannot be run in DOS mode.

$ PE L X   x *  @        L          4 .text ,w  x  ` P`.data (  | @ 0.rdata  *
~ @ `@.eh_fram  ˆ @ [email protected] 0
€ `.idata 
* @ 0.CRT   @ 0.tls   @ 0 Sƒ‹D$ ‹ ‹ =‘ wM= s[= …Ž D$ $ gt ƒ„ …… 1ƒ[ & =” t=– tL=“ uۻ t& 1D$ $
t ƒ„ …t*$ иŸ= u–D$ $ s ƒtL…„u$ иdf$ иOD$ $ ‰s ƒ3D$ $ ms ƒt& D$ $ Ls …۸„‰D$  ‹D$ ' U‰SƒP@ …tD$ D$ $ ƒ $ @ s ƒ  4@ …tB‹0@ @ ‰D$‹C‰$r 4@ ‰D$‹C0‰$r 4@ ‰D$‹CP‰$“r –r ‹ @ ‰™
ƒ „r ‹ ‰D$ @ ‰D$@ ‰$ ‰ir ‰$1s ƒ<D$,‰D$@ D$ @ $@ D$, ƒ‰D$ D$(‰D$-r ƒ<Ѓ$  @ t& ' ƒ$  @ t& ' @@ ‰' 4@ U‰ƒ$ *@ †r ˆ$@ ƒ…tD$*@ ‰$rr ƒ‰…tD$@ $@ ҡ$@ …t:$)*@ ;r ƒ…tD$7*@ ‰$'r ƒ‰…t $$@ Ív U‰ƒ$ *@ q €$@ ƒ…tD$K*@ ‰$q ƒ‰…t $@ ÐU‰ƒ‰M‹E‹U‰‹E‹U ‰P U‰ƒ‰M‹E‹U‰‹E‹U ‰P

Por favor, si alguien puede aydeme, he perdido ya bastantes horas de trabajo al perder por completo mi archivo fuente.
  #7 (permalink)  
Antiguo 27/04/2015, 00:50
 
Fecha de Ingreso: octubre-2014
Ubicacin: Madrid
Mensajes: 1.212
Antigedad: 9 aos, 7 meses
Puntos: 204
Respuesta: Problema con programa c++

Cita:
Iniciado por gufazu Ver Mensaje
Por favor, si alguien puede aydeme, he perdido ya bastantes horas de trabajo al perder por completo mi archivo fuente.
1. No escribas respuestas en un hilo para hacer una pregunta que no tiene nada que ver con el tema original. Crear nuevos hilos es gratis.

2. Lo que ests mostrando es el cdigo ejecutable... no el cdigo fuente. No ser que al configurar la compilacin ests diciendo al compilador que el programa final lo guarde en el archivo donde tienes el cdigo fuente?

Etiquetas: funcion, int, programa
Atencin: Ests leyendo un tema que no tiene actividad desde hace ms de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:00.