Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark machine code array as executable #4

Merged
merged 1 commit into from
Dec 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions proc_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include "proc_map.h"
#include <ddraw.h>
#include <memoryapi.h>

//-----for slider--------
//#include <math.h>
Expand All @@ -49,19 +50,6 @@ extern bool bMMX;



/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
VERY, VERY IMPORTANT:
You must build this with Visual Studio 6.0.
Visual Studio 2003 doesn't seem to let you read code segments ! ! !
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * *

*/

//------------------------------------------------------------------
static void *realAddress(void *fn)
{
Expand Down Expand Up @@ -609,7 +597,8 @@ void Process_Map_Asm(void *p1, void *p2)//, LPDIRECTDRAWSURFACE lpDDSurf)
// and hard-code our custom variables into the instructions (...our
// solution for not having enough registers), then execute the code.

unsigned char code[8192];
const SIZE_T code_size_bytes = 8192;
unsigned char * const code = (unsigned char *)VirtualAlloc(NULL, code_size_bytes, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
int codepos=0;

int start_codepos[16];
Expand Down Expand Up @@ -658,6 +647,8 @@ void Process_Map_Asm(void *p1, void *p2)//, LPDIRECTDRAWSURFACE lpDDSurf)
popa // release builds will break without this!
emms
};

VirtualFree(code, code_size_bytes, MEM_DECOMMIT);
}
else //32-bit case
{
Expand All @@ -667,7 +658,8 @@ void Process_Map_Asm(void *p1, void *p2)//, LPDIRECTDRAWSURFACE lpDDSurf)
// and hard-code our custom variables into the instructions (...our
// solution for not having enough registers), then execute the code.

unsigned char code[8192];
const SIZE_T code_size_bytes = 8192;
unsigned char * const code = (unsigned char *)VirtualAlloc(NULL, code_size_bytes, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
int codepos=0;

int start_codepos[16];
Expand Down Expand Up @@ -716,6 +708,8 @@ void Process_Map_Asm(void *p1, void *p2)//, LPDIRECTDRAWSURFACE lpDDSurf)
popa // release builds will break without this!
emms
};

VirtualFree(code, code_size_bytes, MEM_DECOMMIT);
}
else // MMX version
{
Expand Down