Feed aggregator
Ventrilo IP Change
So how do change my IP to bypass Ventrilo?
Obilivian - prerelease bug
I was reading my gaming magazine today and I found an interesting snippet of the development of oblivian. It is from Game Informer, June '10, page 27.
Gamings strangest glitches by Ben Reeves
Quote:The Elder Srolls IV: Oblivion
"During Oblivion, our new Radiant AI system - which let all the NPCs in the world think and act on their own - led to some of the best bugs. My favorite was a quest where you had to talk to a prisoner in jail. Sometimes, when playtesting, we would find him locked in his cell, dead. It took us forever to figure out why. Turns out, the guards in the jail could run out of food and get hungry. They would then go down and kill the prisoner to take his food. This all happened when the player wasn't there. I still don't remember how we figured it out, but the solution was easy: more guard food."
Todd Howard,
Game Director
Bethesda Softworks
Gamings strangest glitches by Ben Reeves
Quote:The Elder Srolls IV: Oblivion
"During Oblivion, our new Radiant AI system - which let all the NPCs in the world think and act on their own - led to some of the best bugs. My favorite was a quest where you had to talk to a prisoner in jail. Sometimes, when playtesting, we would find him locked in his cell, dead. It took us forever to figure out why. Turns out, the guards in the jail could run out of food and get hungry. They would then go down and kill the prisoner to take his food. This all happened when the player wasn't there. I still don't remember how we figured it out, but the solution was easy: more guard food."
Todd Howard,
Game Director
Bethesda Softworks
What it's like to own APPLE products
This is exactly how it feels to own apple products, and the phases you go through as you own them in your life.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
iPhone 4 vs EVO 4G: Total Cost of Ownership
Billshrink put up some interesting facts about the iPhone 4 and the new EVO 4G. Personally I always prefer android, but what do you think?
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Stem-Cell Tourism, research
Is America behind or ahead? Is it because our regulations are quite strong?
Very interesting article:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Very interesting article:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Linus Torvalds on C++ productivity
I found this on reddit, I thought it was an interesting discussion by the creator of Linux, one of the most famous programmers, Linus Torvalds:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
He discusses volunteer vs paid organizations. And how he works.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
He discusses volunteer vs paid organizations. And how he works.
Online Game and Server?
Hi all,
I am going to start my first online game with UDK. Unity3D was pretty good. I guess, UDK is better than Unity3D. At least, I can make high-quality games with UDK.
Here is my question. How big-online games are working with server. I was using PHP-MySQL to verify user information and login but I can't use it for this game. I need to buy dedicated server or P2P is enough for it?
If P2P is enough, Can I use Php-Mysql to store user point / information?
Max. Player in game: 32
Area: Very big (1000m2)
Any guidelines and ideas are welcome.
Thank you
I am going to start my first online game with UDK. Unity3D was pretty good. I guess, UDK is better than Unity3D. At least, I can make high-quality games with UDK.
Here is my question. How big-online games are working with server. I was using PHP-MySQL to verify user information and login but I can't use it for this game. I need to buy dedicated server or P2P is enough for it?
If P2P is enough, Can I use Php-Mysql to store user point / information?
Max. Player in game: 32
Area: Very big (1000m2)
Any guidelines and ideas are welcome.
Thank you
DLL Fun
Okay, I've finally started delving into C++ DLL's (fun fun fun), got a minor annoyance cropping up though. The exported functions on my DLL aren't named the same as in the source. I was wondering if anyone knew anything about this.
e.g.
my DLL exports the function:
AbstractAlgorithm * DLL_EXPORT getAlgorithm()
yet in the exports (and for dynamic loading) the function name is:
_Z12getAlgorithmv
the number appears to relate to the length of the function name, the _Z and the v at the end I have no idea about.
Any ideas?
Many thanks!
e.g.
my DLL exports the function:
AbstractAlgorithm * DLL_EXPORT getAlgorithm()
yet in the exports (and for dynamic loading) the function name is:
_Z12getAlgorithmv
the number appears to relate to the length of the function name, the _Z and the v at the end I have no idea about.
Any ideas?
Many thanks!
IllegalArgumentException
I am playing with J2ME but I failed after 2 days with this error. Everything seems good but when I started app. in emulator and click download button, it says C++ Programming
TRACE: <at java.lang.IllegalArgumentException>, Exception caught in Display class
java.lang.IllegalArgumentException
My code:
C++ Programming String string = ""; try { string = getUrl(new String("http://localhost/tvguide/get.php?channel=abc&date=03062010")); } catch (IOException e) { string = "Error"; System.out.println(e); } switchDisplayable(null, getTextBox()); // write post-action user code here textBox.setString(string);
getUrl() is returning String. I guess, I have problem with 'string' variable. When I change it to something like "hello world", it is working but not working with returned 'string' variable.
getUrl()
C++ Programming private String getUrl(String url) throws IOException { HttpConnection http = null; InputStream iStrm = null; String returnVal = ""; try { // Create the connection http = (HttpConnection) Connector.open(url); //---------------- // Client Request //---------------- // 1) Send request method http.setRequestMethod(HttpConnection.GET); // 2) Send header information (this header is optional) http.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); // 3) Send body/data - No data for this request //---------------- // Server Response //---------------- // 1) Get status Line System.out.println("Msg: " + http.getResponseMessage()); System.out.println("Code: " + http.getResponseCode()); // 2) Get header information if (http.getResponseCode() == HttpConnection.HTTP_OK) { // 3) Get data (show the file contents) iStrm = http.openInputStream(); int length = (int) http.getLength(); if (length > 0) { byte serverData[] = new byte[length]; iStrm.read(serverData); returnVal = new String(serverData); } } } finally { // Clean up if (iStrm != null) { iStrm.close(); } if (http != null) { http.close(); } } return returnVal; }
Thanks
My code:
C++ Programming String string = ""; try { string = getUrl(new String("http://localhost/tvguide/get.php?channel=abc&date=03062010")); } catch (IOException e) { string = "Error"; System.out.println(e); } switchDisplayable(null, getTextBox()); // write post-action user code here textBox.setString(string);
getUrl() is returning String. I guess, I have problem with 'string' variable. When I change it to something like "hello world", it is working but not working with returned 'string' variable.
getUrl()
C++ Programming private String getUrl(String url) throws IOException { HttpConnection http = null; InputStream iStrm = null; String returnVal = ""; try { // Create the connection http = (HttpConnection) Connector.open(url); //---------------- // Client Request //---------------- // 1) Send request method http.setRequestMethod(HttpConnection.GET); // 2) Send header information (this header is optional) http.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0"); // 3) Send body/data - No data for this request //---------------- // Server Response //---------------- // 1) Get status Line System.out.println("Msg: " + http.getResponseMessage()); System.out.println("Code: " + http.getResponseCode()); // 2) Get header information if (http.getResponseCode() == HttpConnection.HTTP_OK) { // 3) Get data (show the file contents) iStrm = http.openInputStream(); int length = (int) http.getLength(); if (length > 0) { byte serverData[] = new byte[length]; iStrm.read(serverData); returnVal = new String(serverData); } } } finally { // Clean up if (iStrm != null) { iStrm.close(); } if (http != null) { http.close(); } } return returnVal; }
Thanks
Pascal...
What is it good for?
Who is into pascal?
Who is into pascal?
Converting char* to a char array?
I can think of it as an algorythm, but is there any other solution?
How-To: Recover from Spills on Electronics!!!
This is something everyone should read and know full well. I know I've spilled a lot of coffee on my electronics. Sometimes it's just unavoidable, no matter how careful you are. So you should be aware of this.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
9 Inexpensive WAys to Solve All Problems
9 Inexpensive ways to solve the world's toughest problems.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Really cool and hilarious info.
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Really cool and hilarious info.
Ancient Aliens
So I was watching this new show on the History Channel called Guests cannot see links in the messages. Please register to forum by clicking here to see links..
The show discusses the theory that in ancient times, such as the ancient Egyptians, there were aliens that gave them tools and technology to create such impossible tasks of construction and art.
There are 1000 ton blocks in some places, that would be impossible to cut or move with ancient copper technology. There are precise works of art that only diamonds with computer precision could cut at such angles. But there weren't even any diamonds in the area. There was granite in places, that would need to be shipped 600 miles.
Anyway, the show was pretty interesting, and while you may not immediately believe it was aliens. It still makes you wonder how they did it.
The show discusses the theory that in ancient times, such as the ancient Egyptians, there were aliens that gave them tools and technology to create such impossible tasks of construction and art.
There are 1000 ton blocks in some places, that would be impossible to cut or move with ancient copper technology. There are precise works of art that only diamonds with computer precision could cut at such angles. But there weren't even any diamonds in the area. There was granite in places, that would need to be shipped 600 miles.
Anyway, the show was pretty interesting, and while you may not immediately believe it was aliens. It still makes you wonder how they did it.
Class & DLL
hi
i have a problem that i work in 3 days
i write a dll with codeblocks
it has a class that name is Data
and it has 2 function returning string
and i build it
but i cant add it to c# or asp.net
can u help me please
i have a problem that i work in 3 days
i write a dll with codeblocks
it has a class that name is Data
and it has 2 function returning string
and i build it
but i cant add it to c# or asp.net
can u help me please
Converting char array to hex bytes? [SOLVED]
Hello, I'm writing software to inject MIPS routines into a memory dump from a PSP game. I've been successful in opening the memory dump, looping through the memory, reading the data of each address, etc. However, I cannot seem to figure out how to convert the char array I'm using that has the extracted data (from the text box) to a byte array. The text box has contents that looks like this:
0055A534 3F800000 -----------------------------
Incorrect format for writing: char data[ ] = {'3','F','8','0','0','0','0','0'};
Correct format for writing: char data[ ] = {0x00, 0x00, 0x80, 0x3F};
If I have the top format, how do I convert it to the bottom format so that I can insert the data correctly?
Using the top portion, I get this:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Using the bottom portion, I get this, which is correct:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Here is my source so far, please, don't be quick to judge the sloppiness, the use of global variables, etc. I'm not here to ask about my cleanliness.
Code:
#include <windows.h>
#include <commctrl.h>
#include <iostream>
#include "menu.h"
#define INJECT 100
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
HWND codeBox = NULL;
void setMenu(HWND);
void openFile(HWND);
void closeFile();
void injectRoutine();
HWND hwnd;
FILE * memdump;
char * filebuffer;
bool dumpOpen = false;
int fSize = 0;
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
//HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Injection V. 1", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
236, /* The programs width */
435, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
codeBox = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "2055A534 3F800000",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOHSCROLL,
10, 10, 200, 300, hwnd, 0, GetModuleHandle(0), (0));
HWND injectButton = CreateWindow("button", "Inject Routine",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 330, 200, 30, hwnd, HMENU(INJECT), NULL, NULL);
setMenu(hwnd);
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_OPEN:
openFile(hwnd);
break;
case ID_CLOSE:
closeFile();
break;
case INJECT:
injectRoutine();
break;
case ID_EXIT:
if(dumpOpen = true){
free(filebuffer);
}
PostQuitMessage(0);
break;
}
break;
case WM_SIZE:
{
RECT rect;
GetWindowRect(hwnd, &rect);
SetWindowPos(hwnd, HWND_TOP, rect.left, rect.top, 236, 435, SWP_SHOWWINDOW);
break;
}
case WM_CTLCOLOREDIT:
HDC hdc = (HDC)wParam;
SetTextColor(hdc, RGB(0,0,255));
SetBkColor(hdc, RGB(0,0,0));
break;
case WM_DESTROY:
if(dumpOpen = true){
free(filebuffer);
}
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
void setMenu(HWND hwnd){
HMENU mainMenu = NULL;
HMENU subMenu = NULL;
mainMenu = CreateMenu();
subMenu = CreatePopupMenu();
AppendMenu(subMenu, MF_STRING, ID_OPEN, "Open Memory");
AppendMenu(subMenu, MF_STRING, ID_CLOSE, "Close Memory");
AppendMenu(subMenu, MF_SEPARATOR, NULL, NULL);
AppendMenu(subMenu, MF_STRING, ID_EXIT, "Exit");
AppendMenu(mainMenu, MF_STRING | MF_POPUP, (UINT)subMenu, "File");
SetMenu(hwnd, mainMenu);
}
void openFile(HWND hwnd){
if(dumpOpen == true){
MessageBox(hwnd, "Didn't you already open a memory dump?", "Error", MB_ICONERROR);
return;
}
OPENFILENAME ofn;
char file[MAX_PATH];
ZeroMemory(&file, sizeof(file));
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = file;
ofn.nMaxFile = sizeof(file);
ofn.lpstrFilter = "All\0*.*\0Ram\0*.ram\0Bin\0*.bin*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn) == true){
}
if(file[0] == '\0'){
return;
}
memdump = fopen(file, "rb");
if(!memdump){
MessageBox(hwnd, "Unable to open the specified file", "Error", MB_ICONERROR | MB_OK);
return;
}
fseek(memdump, 0, SEEK_END);
fSize = ftell(memdump);
rewind(memdump);
filebuffer = (char*)malloc(fSize);
fread(filebuffer, 1, fSize, memdump);
MessageBox(hwnd, "The memory dump was successfully loaded", "File Loaded", MB_ICONINFORMATION | MB_OK);
dumpOpen = true;
fclose(memdump);
//FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\test.bin", "wb+");
//fwrite(filebuffer, fSize, 1, test);
}
void closeFile(){
if(dumpOpen == false){
MessageBox(hwnd, "How can you close a dump you never opened?", "Error", MB_ICONERROR);
return;
}
else{
free(filebuffer);
dumpOpen = false;
MessageBox(hwnd, "The memory has been set free!", "Success", MB_ICONINFORMATION);
}
}
void injectRoutine(){
if(dumpOpen == false){
MessageBox(hwnd, "Whoa whoa, you can't inject into a non-existant memory dump! Open one first!", "Error", MB_ICONERROR);
return;
}
int lineCount = 0;
char buffer[17]; //17 for space
char address[9]; //includes the \0
char data[9]; //includes the \0
long curAddress = 0;
char lol[] = {0x00, 0x00, 0x80, 0x3f};
lineCount = SendMessage(codeBox, EM_GETLINECOUNT, 0, 0);
for(int x = 0; x < lineCount; x++){
SendMessage(codeBox, EM_GETLINE, x, (LPARAM)buffer); buffer[17] = '\0';
memcpy(address, buffer, 9);
for(int x = 0; x < 9; x++){
data[x] = buffer[x + 9];
data[9] = '\0';
}
char temp[9]; //DEBUG
FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\test.ram", "wb+");
for (int y = 0; y < lineCount; y++){
while(curAddress < fSize){
sprintf(temp, "%08lX", curAddress);
if(strncmp(temp, address, 8) == 0){
memcpy(&filebuffer[curAddress], lol, sizeof(lol));
}
curAddress += 4;
}
}
fwrite(filebuffer, 1, fSize, test); //This works fine, there's a problem with memcpy
SetWindowText(hwnd, "Done");
fclose(test);
}
}
I've solved my problem using the following code:
Code:
void injectRoutine(){
if(dumpOpen == false){
MessageBox(hwnd, "Whoa whoa, you can't inject into a non-existant memory dump! Open one first!", "Error", MB_ICONERROR);
return;
}
int lineCount = 0;
char buffer[17]; //17 for space
char address[9]; //includes the \0
char data[9]; //includes the \0
char windowText[20];
long curAddress = 0;
FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\Backup.ram", "wb+");
lineCount = SendMessage(codeBox, EM_GETLINECOUNT, 0, 0);
for(int x = 0; x < lineCount; x++){
SendMessage(codeBox, EM_GETLINE, x, (LPARAM)buffer); buffer[17] = '\0';
memcpy(address, buffer, 9);
for(int y = 0; y < 9; y++){
data[y] = buffer[y + 9];
data[9] = '\0';
}
char temp[9]; //DEBUG
while(curAddress < fSize){
sprintf(temp, "%08lX", curAddress);
if(strncmp(temp, address, 8) == 0){
unsigned int x = 0; sscanf(data, "%8x", &x);
memcpy(&filebuffer[curAddress], &x, sizeof(x));
break;
}
curAddress += 4;
}
curAddress = 0;
sprintf(windowText, "Pass: %d", x);
SetWindowText(hwnd, windowText);
}
fwrite(filebuffer, 1, fSize, test); //This works fine, there's a problem with memcpy
SetWindowText(hwnd, "Done");
fclose(test);
}
0055A534 3F800000 -----------------------------
Incorrect format for writing: char data[ ] = {'3','F','8','0','0','0','0','0'};
Correct format for writing: char data[ ] = {0x00, 0x00, 0x80, 0x3F};
If I have the top format, how do I convert it to the bottom format so that I can insert the data correctly?
Using the top portion, I get this:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Using the bottom portion, I get this, which is correct:
Guests cannot see links in the messages. Please register to forum by clicking here to see links.
Here is my source so far, please, don't be quick to judge the sloppiness, the use of global variables, etc. I'm not here to ask about my cleanliness.
Code:
#include <windows.h>
#include <commctrl.h>
#include <iostream>
#include "menu.h"
#define INJECT 100
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
HWND codeBox = NULL;
void setMenu(HWND);
void openFile(HWND);
void closeFile();
void injectRoutine();
HWND hwnd;
FILE * memdump;
char * filebuffer;
bool dumpOpen = false;
int fSize = 0;
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
//HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Injection V. 1", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
236, /* The programs width */
435, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
codeBox = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "2055A534 3F800000",
WS_CHILD | WS_VISIBLE | ES_MULTILINE | ES_AUTOHSCROLL,
10, 10, 200, 300, hwnd, 0, GetModuleHandle(0), (0));
HWND injectButton = CreateWindow("button", "Inject Routine",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
10, 330, 200, 30, hwnd, HMENU(INJECT), NULL, NULL);
setMenu(hwnd);
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case ID_OPEN:
openFile(hwnd);
break;
case ID_CLOSE:
closeFile();
break;
case INJECT:
injectRoutine();
break;
case ID_EXIT:
if(dumpOpen = true){
free(filebuffer);
}
PostQuitMessage(0);
break;
}
break;
case WM_SIZE:
{
RECT rect;
GetWindowRect(hwnd, &rect);
SetWindowPos(hwnd, HWND_TOP, rect.left, rect.top, 236, 435, SWP_SHOWWINDOW);
break;
}
case WM_CTLCOLOREDIT:
HDC hdc = (HDC)wParam;
SetTextColor(hdc, RGB(0,0,255));
SetBkColor(hdc, RGB(0,0,0));
break;
case WM_DESTROY:
if(dumpOpen = true){
free(filebuffer);
}
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
void setMenu(HWND hwnd){
HMENU mainMenu = NULL;
HMENU subMenu = NULL;
mainMenu = CreateMenu();
subMenu = CreatePopupMenu();
AppendMenu(subMenu, MF_STRING, ID_OPEN, "Open Memory");
AppendMenu(subMenu, MF_STRING, ID_CLOSE, "Close Memory");
AppendMenu(subMenu, MF_SEPARATOR, NULL, NULL);
AppendMenu(subMenu, MF_STRING, ID_EXIT, "Exit");
AppendMenu(mainMenu, MF_STRING | MF_POPUP, (UINT)subMenu, "File");
SetMenu(hwnd, mainMenu);
}
void openFile(HWND hwnd){
if(dumpOpen == true){
MessageBox(hwnd, "Didn't you already open a memory dump?", "Error", MB_ICONERROR);
return;
}
OPENFILENAME ofn;
char file[MAX_PATH];
ZeroMemory(&file, sizeof(file));
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = file;
ofn.nMaxFile = sizeof(file);
ofn.lpstrFilter = "All\0*.*\0Ram\0*.ram\0Bin\0*.bin*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn) == true){
}
if(file[0] == '\0'){
return;
}
memdump = fopen(file, "rb");
if(!memdump){
MessageBox(hwnd, "Unable to open the specified file", "Error", MB_ICONERROR | MB_OK);
return;
}
fseek(memdump, 0, SEEK_END);
fSize = ftell(memdump);
rewind(memdump);
filebuffer = (char*)malloc(fSize);
fread(filebuffer, 1, fSize, memdump);
MessageBox(hwnd, "The memory dump was successfully loaded", "File Loaded", MB_ICONINFORMATION | MB_OK);
dumpOpen = true;
fclose(memdump);
//FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\test.bin", "wb+");
//fwrite(filebuffer, fSize, 1, test);
}
void closeFile(){
if(dumpOpen == false){
MessageBox(hwnd, "How can you close a dump you never opened?", "Error", MB_ICONERROR);
return;
}
else{
free(filebuffer);
dumpOpen = false;
MessageBox(hwnd, "The memory has been set free!", "Success", MB_ICONINFORMATION);
}
}
void injectRoutine(){
if(dumpOpen == false){
MessageBox(hwnd, "Whoa whoa, you can't inject into a non-existant memory dump! Open one first!", "Error", MB_ICONERROR);
return;
}
int lineCount = 0;
char buffer[17]; //17 for space
char address[9]; //includes the \0
char data[9]; //includes the \0
long curAddress = 0;
char lol[] = {0x00, 0x00, 0x80, 0x3f};
lineCount = SendMessage(codeBox, EM_GETLINECOUNT, 0, 0);
for(int x = 0; x < lineCount; x++){
SendMessage(codeBox, EM_GETLINE, x, (LPARAM)buffer); buffer[17] = '\0';
memcpy(address, buffer, 9);
for(int x = 0; x < 9; x++){
data[x] = buffer[x + 9];
data[9] = '\0';
}
char temp[9]; //DEBUG
FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\test.ram", "wb+");
for (int y = 0; y < lineCount; y++){
while(curAddress < fSize){
sprintf(temp, "%08lX", curAddress);
if(strncmp(temp, address, 8) == 0){
memcpy(&filebuffer[curAddress], lol, sizeof(lol));
}
curAddress += 4;
}
}
fwrite(filebuffer, 1, fSize, test); //This works fine, there's a problem with memcpy
SetWindowText(hwnd, "Done");
fclose(test);
}
}
I've solved my problem using the following code:
Code:
void injectRoutine(){
if(dumpOpen == false){
MessageBox(hwnd, "Whoa whoa, you can't inject into a non-existant memory dump! Open one first!", "Error", MB_ICONERROR);
return;
}
int lineCount = 0;
char buffer[17]; //17 for space
char address[9]; //includes the \0
char data[9]; //includes the \0
char windowText[20];
long curAddress = 0;
FILE * test = fopen("C:\\Users\\The Syndicate\\Desktop\\Backup.ram", "wb+");
lineCount = SendMessage(codeBox, EM_GETLINECOUNT, 0, 0);
for(int x = 0; x < lineCount; x++){
SendMessage(codeBox, EM_GETLINE, x, (LPARAM)buffer); buffer[17] = '\0';
memcpy(address, buffer, 9);
for(int y = 0; y < 9; y++){
data[y] = buffer[y + 9];
data[9] = '\0';
}
char temp[9]; //DEBUG
while(curAddress < fSize){
sprintf(temp, "%08lX", curAddress);
if(strncmp(temp, address, 8) == 0){
unsigned int x = 0; sscanf(data, "%8x", &x);
memcpy(&filebuffer[curAddress], &x, sizeof(x));
break;
}
curAddress += 4;
}
curAddress = 0;
sprintf(windowText, "Pass: %d", x);
SetWindowText(hwnd, windowText);
}
fwrite(filebuffer, 1, fSize, test); //This works fine, there's a problem with memcpy
SetWindowText(hwnd, "Done");
fclose(test);
}