Llamo a la api, para poder modificar el recurso de una aplicacion desde otra, es la unica manera que encontre.
Los exes estan hechos en c# ambos.
Saludos
Los exes estan hechos en c# ambos.
Saludos
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr BeginUpdateResource(string pFileName, bool bDeleteExistingResources);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool UpdateResource(IntPtr hUpdate, string lpType, string lpName, ushort wLanguage, IntPtr lpData, uint cbData);
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool EndUpdateResource(IntPtr hUpdate, bool fDiscard);
static unsafe void Main()
{
string path = "c:\\users\\sean\\desktop\\resourcer.exe";
IntPtr hResource = BeginUpdateResource(path, false);
if (hResource.ToInt32() == 0)
throw new Exception("File Not Found");
string newMessage = File.ReadAllText("c:\\users\\sean\\desktop\\newMessage.txt");
Byte[] bytes = new ASCIIEncoding().GetBytes(newMessage);
GCHandle bHandle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
IntPtr ptr = bHandle.AddrOfPinnedObject();
ushort id = (ushort)Language.MakeLanguageID();
if (UpdateResource(hResource, "FILE", "eva.txt", id, ptr, (uint)bytes.Length))
EndUpdateResource(hResource, false);
else
MessageBox.Show("Did not update", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public static class Language
{
public static int MakeLanguageID()
{
CultureInfo currentCulture = CultureInfo.CurrentCulture;
int pid = GetPid(currentCulture.LCID);
int sid = GetSid(currentCulture.LCID);
return (((ushort)pid) << 10) | ((ushort)sid);
}
public static int GetPid(int lcid)
{ return ((ushort)lcid) & 0x3ff; }
public static int GetSid(int lcid)
{ return ((ushort)lcid) >> 10; }
}
}
string strNewPathToSave = "new.txt";
Assembly assembly = Assembly.GetExecutingAssembly();
Stream resourceStream = assembly.GetManifestResourceStream("WindowsFormsApplication2.Resources.eva.txt");
System.IO.FileStream fs = System.IO.File.OpenWrite(strNewPathToSave);
try
{
// Save the File...
byte[] buffer = new byte[resourceStream.Length];
resourceStream.Read(buffer, 0, (int)resourceStream.Length);
fs.Write(buffer, 0, buffer.Length);
}
finally
{
fs.Close();
}
for(int i=0;i<tamanio;i++)
{
if(buffer[i] == '*' && buffer[i+1] == '*')
{
exe1 = buffer+i+2;
a = i+2;
break;
}
void crearFichero(char* buffer1, int tamanio1, char* buffer2, int tamanio2)
{
char info[1];
char info2[1];
info[0] = '*';
info[1] = '*';
info2[0] = '°';
info2[1] = '°';
CopyFile("main.exe","bindedm.exe",TRUE);
ofstream escritura1("bindedm.exe", ofstream::binary | ofstream::app);
escritura1.write(info, strlen(info));
escritura1.write(buffer1, tamanio1);
escritura1.write(info2, strlen(info2));
escritura1.write(buffer2, tamanio2);
escritura1.close();
}