I wanted to ask 2 questions..there is a game and someone created some kind of anti-cheat for it. He also put in a scripting feature, where you can read maximum 4 bytes of a player's memory-adress you choose (from the game's process)..
I paste an examplescript here on how to USE it:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
// read 1 byte from 0x8CB7A5 representing the radio station player is currently listening to.
CAC_ReadMemory(playerid, 0x8CB7A5, 1);
}
return 1;
}
public CAC_OnMemoryRead(player_id, address, size, const content[])
{
if(address == 0x8CB7A5 && size == 1)
{
// "content" is an array with "size" elements, each cell containing 1 byte.
// We read only 1 byte, so the station id is at index 0.
if(content[0] == 0x07) // 0x07 = Radio X
{
SendClientMessage(player_id, -1, "Radio X is indeed the best station.");
}
else
{
SendClientMessage(player_id, -1, "What the hell are you listening to ?!");
}
}
return 1;
}
So the problem is that I have no idea how I find out a specific address..my goal is to find out an adress of a SPECIFIC .dll (which people inject to "cheat") that I can BAN the person from the game with a script...so I have this specific file on my deskop and I have no idea how to even start to find out what kind of memory-address this file would use if injected..
Thanks for any help in advance :)
Related
I have an EA with closes a trade on button click
//void CloseCurrentTrade(). It's called after successfull OrderSelect
int orderType = OrderType();
double price;
if (orderType == OP_BUY)
price = return MarketInfo(OrderSymbol(), MODE_BID);
else if (orderType == OP_SELL)
price = return MarketInfo(OrderSymbol(), MODE_ASK);
else
return;
int slippage = 20;
bool closed = OrderClose(OrderTicket(), OrderLots(), price, slippage);
if (closed)
return;
int lastError = GetLastError();
Sometimes it closes the trade and sometimes it returns error #129 (Invalid price). I can't figure out why. Most of the cases people just misuse bid/ask or don't have enouth slippage. I've try to use slippage up to 200, still the same error. Some EA's just try to close it several times (and it looks like a hack for me), but it does not help as well. There are some mentions that you need to call RefreshRates() before bid/ask, but documentaion says that you don't need to do that for MarketInfo.
I've run out of ideas what it could be. Why it can happen and how to avoid that? I'm testing it on FXCM Demo (if it is the case).
First make sure that you've selected the order properly, and try to use OrderClosePrice where possible(this will eliminate the need for checking the OP_SELL/OP_BUY)
//+------------------------------------------------------------------+
//| Close the latest order for this current symbol |
//+------------------------------------------------------------------+
void CloseCurrentTrade()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
if(OrderSymbol()!=Symbol()) continue;
if(OrderMagicNumber()!=MagicNum) continue; // if there is no magic number set, then no need for this(manual orders)
if(OrderType()>OP_SELL) continue;
if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),Slippage))
Print("Error in Closing the Order, Error : ",ErrorDescription(GetLastError()));
break; // assuming you want to close the latest trade only, exit the order closing loop
}
}
Also note that your broker might have restrictions on how far the closing price must be from the Order Opened price and other levels(sl/tp), in order to close an order. Refer here
Print and compare Ask/Bid && price when closed!=true. Beware that MarketInfo mode data is stored at Ask/Bid predefined variables already, so you can eliminate that if you OrderSelect in current symbol.
I have skip list contains an ADC, FIFO, DAC, FILO etc.
I want to know whether these words are used in the entire module or not .if used in the module should return the unused words.
I have a program but it is taking too much time to execute.
Please help me with this.
Here is the code :
Skip Search_In_Entire_Module(Skip List)
{
int sKey = 0
Skip sList = create()
string data = ""
string objText1
Object obj
for data in List do
{
int var_count = 0
for obj in m do
{
objText1 = obj."Object Text"
if objText1!=null then
{
if (isDeleted obj){continue}
if (table obj) {continue}
if (row obj) {continue}
if (cell obj) {continue}
Buffer buf = create()
buf = objText1
int index = 0
while(true)
{
index = contains(buf, data, index)
if(0 <= index)
{
index += length(data)
}
else
{
var_count++
break
}
}
delete(buf)
}
}
if (var_count ==0)
{
put(sList,sKey,data)
sKey++
}
}
return sList
}
Unused_Terminolody_Data = Search_In_Entire_Module(Terminology_Data)
Just wondering: why is this in a while loop?
while(true)
{
index = contains(buf, data, index)
if(0 <= index)
{
index += length(data)
}
else
{
var_count++
break
}
}
I would instead just do:
index = contains ( buf, data )
if ( index == -1 ) {
var_count++
}
buf = ""
I would also not keep deleting and recreating the buffer. Create the buffer up where you create the object variable, then set it equal to "" to clear it, then delete it at the end of the program.
Let me know if this helps!
Balthos makes good points, and I think there's a little more you could do. My adaptation of your function follows. Points to note:
I implemented Balthos's suggestions (above) of taking out the
'while' loop, and buffer creation/deletion.
I changed the function signature. Given that Skip lists are passed
by reference, and must be created and deleted outside the function
it's syntactically confusing (to me, anyway) to return them from a
function. So, I pass both skip lists (terms we're seeking, terms not
found) in as function parameters. Please excuse me changing variable
names - it helped me to understand what was going on more quickly.
There's no need to put the Object Text in a string - this is
relatively slow and consumes memory that will not be freed until
DOORS exits. So, I put the Object Text in a buffer earlier in the
function, and search that. The 'if (!null bufObjText)' at my line 34
is equivalent to your 'objText1!=null'. If you prefer, 'if
(bufObjText != null)' does the same.
The conditional 'if (var_count ==0)' is redundant - I moved it's
functions into an earlier 'if' block (my line 40).
I moved the tests for deleted, table, row and cell objects up, so
that they occur before we take the time to fill a buffer with object
text - so that's only done if necessary.
Item 2 probably isn't going to have a performance impact, but the others will. The only quesiton is, how large?
Please let us know if this improves the running time over what you currently have. I don't have a sufficiently large set of sample data to make meaningful comparisons with your code.
Module modCurrent = current
Skip skUnused_Terminology_Data = create
Skip skSeeking_Terminology_Data = create()
put (skSeeking_Terminology_Data, 0, "SPONG")
put (skSeeking_Terminology_Data, 1, "DoD")
void Search_In_Entire_Module(Skip skTermsSought, skTermsNotFound)
{
Object obj
Buffer bufObjText = create()
int intSkipKey = 0
int index = 0
string strSkipData = ""
for strSkipData in skTermsSought do
{
int var_count = 0
bool blFoundTerm = false
for obj in modCurrent do
{
if (isDeleted obj){continue}
if (table obj) {continue}
if (row obj) {continue}
if (cell obj) {continue}
bufObjText = obj."Object Text"
if (!null bufObjText) then
{
Regexp re = regexp2 strSkipData
blFoundTerm = search (re, bufObjText, 0)
if ( blFoundTerm ) {
put(skUnused_Terminology_Data, intSkipKey, strSkipData)
intSkipKey++
}
bufObjText = ""
}
}
delete (bufObjText)
}
Search_In_Entire_Module (skSeeking_Terminology_Data, skUnused_Terminology_Data)
string strNotFound
for strNotFound in skUnused_Terminology_Data do
{
print strNotFound "\n"
}
delete skUnused_Terminology_Data
delete skSeeking_Terminology_Data
I am trying to find the middle element of a double linked list in constant time complexity .
I came across the following http://www.geeksforgeeks.org/design-a-stack-with-find-middle-operation/ solution.
But I don't understand how to use the middle pointer.
Can anyone please help me understand this or give me a better solution .
I've re-written this code in C++ for explanation purposes:
#include <iostream>
typedef class Node* PNode;
class Node{
public:
PNode next;
PNode prev;
int data;
Node(){
next = nullptr;
prev = nullptr;
data = 0;
}
};
class List{
private:
//Attributes
PNode head;
PNode mid;
int count;
//Methods
void UpdateMiddle( bool _add );
public:
//Constructors
List(){
head = nullptr;
mid = nullptr;
count = 0;
}
~List(){
while( head != nullptr ){
this->delmiddle();
std::cout << count << std::endl;
}
}
//Methods
void push( int _data );
void pop();
int findmiddle();
void delmiddle();
};
void List::UpdateMiddle( bool _add ){
if( count == 0 ){
mid = nullptr;
}
else if( count == 1 ){
mid = head;
}
else{
int remainder = count%2;
if(_add){
if( remainder == 0 ){
mid = mid->prev;
}
}
else{
if( remainder == 1 ){
mid = mid->next;
}
}
}
}
void List::push( int _data ){
PNode new_node = new Node();
new_node->data = _data;
new_node->prev = nullptr;
new_node->next = head;
if( head != nullptr ) head->prev = new_node;
head = new_node;
count++;
UpdateMiddle( true );
}
void List::pop(){
if( head != nullptr ){
PNode del_node = head;
head = head->next;
if( head != nullptr ) head->prev = nullptr;
delete del_node;
count--;
UpdateMiddle(false);
}
else if( count != 0 ){
std::cout << "ERROR";
return;
}
}
int List::findmiddle(){
if( count > 0 ) return mid->data;
else return -1;
}
void List::delmiddle(){
if( mid != nullptr ){
if( count == 1 || count == 2){
this->pop();
}
else{
PNode del_mid = mid;
int remainder = count%2;
if( remainder == 0 ){
mid = del_mid->next;
mid->prev = del_mid->prev;
del_mid->prev->next = mid;
delete del_mid;
count--;
}
else{
mid = del_mid->prev;
mid->next = del_mid->next;
del_mid->next->prev = mid;
delete del_mid;
count--;
}
}
}
}
The push and pop functions are self-explanatory, they add nodes on top of the stack and delete the node on the top. In this code, the function UpdateMiddle is in charge of managing the mid pointer whenever a node is added or deleted. Its parameter _add tells it whether a node has been added or deleted. This info is important when there is more than two nodes.
Note that when the UpdateMiddle is called within push or pop, the counter has already been increased or decreased respectively. Let's start with the base case, where there is 0 nodes. mid will simply be a nullptr. When there is one node, mid will be that one node.
Now let's take the list of numbers "5,4,3,2,1". Currently the mid is 3 and count, the amount of nodes, is 5 an odd number. Let's add a 6. It will now be "6,5,4,3,2,1" and count will now be 6 an even number. The mid should also now be 4, as it is the first in the middle, but it still hasn't updated. However, now if we add 7 it will be "7,6,5,4,3,2,1", the count will be 7, an odd number, but notice that the mid wont change, it should still be 4.
A pattern can be observed from this. When adding a node, and count changes from even to odd, the mid stays the same, but from odd to even mid changes position. More specifically, it moves one position to the left. That is basically what UpdateMiddle does. By checking whether count is currently odd or even after adding or deleting a node, it decides if mid should be repositioned or not. It is also important to tell whether a node is added or deleted because the logic works in reverse to adding when deleting. This is basically the logic that is being applied in the code you linked.
This algorith works because the position of mid should be correct at all times before adding or deleting, and function UpdateMiddle assumes that the only changes were the addition or deletion of a node, and that prior to this addition or deletion the position of mid was correct. However, we make sure of this by making the attributes and our function UpdateMiddle private, and making it modifiable through the public functions.
The trick is that you don't find it via a search, rather you constantly maintain it as a property of the list. In your link, they define a structure that contains the head node, the middle node, and the number of nodes; since the middle node is a property of the structure, you can return it by simply accessing it directly at any time. From there, the trick is to maintain it: so the push and pop functions have to adjust the middle node, which is also shown in the code.
More depth: maintaining the middle node: we know given the count that for an odd number of nodes (say 9), the middle node is "number of nodes divided by 2 rounded up," so 9/2 = 4.5 rounded up = the 5th node. So if you start with a list of 8 nodes, and add a node, the new count is 9, and you'll need to shift the middle node to the "next" node. That is what they are doing when they check if the new count is even.
I need to write a job where i could fetch the index of an array element of EDT Dimension
e.g. In my EDT Dimension i have array elements A B C when i click over them for properties I see the index for A as 1, B as 2 and C as 3. Now with a job ui want to fetch the index value. Kindly Assist.
I'm not sure if I did understand the real problem. Some code sample could help.
The Dimensions Table has some useful methods like arrayIdx2Code.
Maybe the following code helps:
static void Job1(Args _args)
{
Counter idx;
Dimension dimension;
DimensionCode dimensionCode;
str name;
;
for (idx = 1; idx <= dimof(dimension); idx++)
{
dimensionCode = Dimensions::arrayIdx2Code(idx);
name = enum2str(dimensionCode);
// if (name == 'B') ...
info(strfmt("%1: %2", idx, name));
}
}
I found a way but still looking if there is any other solution.
static void Job10(Args _args)
{
Dicttype dicttype;
counter i;
str test;
;
test = "Client";
dicttype = new dicttype(132);//132 here is the id of edt dimension
for (i=1;i<=dicttype.arraySize();i++)
{
if ( dicttype.label(i) == test)
{
break;
}
}
print i;
pause;
}
Array elements A B C from your example are nothing else but simple labels - they cannot be used as identifiers. First of all, for user convenience the labels can be modified anytime, then even if they aren't, the labels are different in different languages, and so on and so forth.
Overall your approach (querying DictType) would be correct but I cannot think of any scenario that would actually require such a code.
If you clarified your business requirements someone could come up with a better solution.
I have a Conrec nightmare. I am trying to implement contour lines in ActionScript using Conrec. I have looked at both the java and javascript implementation and am still stuck. These are found here: http://paulbourke.net/papers/conrec/
Conrec will take grid data and assemble continuous contour lines. The problem is that it does not necessarily draw those lines in a continuous fashion. For example, it will draw A->B and then C->B and then C->D instead of A, B, C, D, etc.
The javascript implementation seems to be accounting for this and serializing the instructions into an array of draw points. Which is what I too want to accomplish in the end. That is it takes the instructions from the core Conrec logic (eg: A->B, C->B, C->D, etc) and organizes it into an A, B, C, D series. I think it will also return the series as a multi-dimensional array to accommodate broken lines (eg: [[A, B, C, D], [E, F, G]]). This last functionality is what I need to do in Actionscript.
This last part is where I am stuck. Ignore Conrec for now (I have given up on finding an Actionscript implementation), how can I organize these instructions into a collection of serial points? When Conrec gives me "draw point from X->Y" how can I first check if X or Y are already in a series and append either X or Y (whichever is not in the series) into the series? AND if neither are in the series, start a NEW series with X, Y as the starting set. Then check subsequent instructions against all existing series and connect series if they now start and stop on the same point? Also, I need to be able to allow for a series to close itself (eg: A, B, C, A) -- a loop (is that even possible?!).
I hope this makes sense. I'm not sure if there is a technical term for what I want to do beyond "concatenation". I also hope someone out there has done this with Conrec and can give me some pointers.
In the meantime, I am going to continue to plug away at this and see if I can come up with something but I am not confident in my abilities. I would really be thankful for some veteran or professional advice.
PS:
If you know another way to draw contour lines from grid data, I am open to alternatives. But I have to be able to implement it in Actionscript.
Ok, here is my first attempt at getting what I need done. I am not terribly happy with the result, but it seems to work.
package {
import flash.display.Sprite;
public class lineSeriesPointConcat extends Sprite {
public function lineSeriesPointConcat() {
init();
}
//directions [X -> Y]
//case 1: both counterclockwise, result is counterclockwise
private var case1:Array = [
["G1", "F1"],
["F1", "E1"],
["D1", "C1"],
["C1", "B1"],
["B1", "A1"],
["E1", "D1"], //link
["G1", "A1"] //loop
];
//case 2: clockwise, counterclockwise, result is clockwise
private var case2:Array = [
["E2", "F2"],
["F2", "G2"],
["D2", "C2"],
["C2", "B2"],
["B2", "A2"],
["E2", "D2"], //link
["G2", "A2"] //loop
];
//case 3: both clockwise, result is clockwise
private var case3:Array = [
["E3", "F3"],
["F3", "G3"],
["A3", "B3"],
["B3", "C3"],
["C3", "D3"],
["E3", "D3"], //link
["G3", "A3"] //loop
];
//case 4: counterclockwise, clockwise, result is clockwise
private var case4:Array = [
["G4", "F4"],
["F4", "E4"],
["A4", "B4"],
["B4", "C4"],
["C4", "D4"],
["E4", "D4"], //link
["G4", "A4"] //loop
];
private var collectedSeries:Array = [];
private function init():void {
var directions:Array = case1.concat(case2.concat(case3.concat(case4)));
for each (var direction:Array in directions) {
connect(direction[0], direction[1]);
}
trace ("final series:\n\t" + collectedSeries.join("\n\t"));
}
private function connect(from:String, to:String):void {
var series:Array;
var seriesStart:String;
var seriesEnd:String;
var seriesIndex:int;
var n:int = collectedSeries.length;
var i:int;
for (i = 0; i < n; i++) {
series = collectedSeries[i];
seriesStart = series[0];
seriesEnd = series[series.length - 1];
if (seriesStart == to) {
seriesStart = from;
series.unshift(from);
break;
} else if (seriesStart == from) {
seriesStart = to;
series.unshift(to);
break;
} else if (seriesEnd == to) {
seriesEnd = from;
series.push(from);
break;
} else if (seriesEnd == from) {
seriesEnd = to;
series.push(to);
break;
}
}
if (i == n) {
//this is a new series segment
series = [from, to];
seriesStart = from;
seriesEnd = to;
collectedSeries.push(series);
}
for (var j:int = 0; j < n; j++) {
var compareSeries:Array = collectedSeries[j];
if (compareSeries == series) {
//don't compare the series to itself.
continue;
}
var compSeriesStart:String = compareSeries[0];
var compSeriesEnd:String = compareSeries[compareSeries.length - 1];
if (compSeriesStart == compSeriesEnd) {
//this series loops on itself, it will not concatenate further
continue;
}
if (compSeriesStart == seriesEnd) {
trace ("case 1");
series = series.concat(compareSeries.slice(1));
} else if (compSeriesStart == seriesStart) {
trace ("case 2");
series = compareSeries.reverse().concat(series.slice(1));
} else if (compSeriesEnd == seriesStart) {
trace ("case 3");
series = compareSeries.concat(series.slice(1));
} else if (compSeriesEnd == seriesEnd) {
trace ("case 4");
series = compareSeries.concat(series.reverse().slice(1));
} else {
//no linkage between these two series
continue;
}
collectedSeries[i] = series; //replace one of the two segements
collectedSeries.splice(j, 1); //splice out the other
break;
}
trace ("series: " + series + (i == n ? " new" : ""));
}
}
}
This will give the following results:
A1,G1,F1,E1,D1,C1,B1,A1
G2,A2,B2,C2,D2,E2,F2,G2
G3,A3,B3,C3,D3,E3,F3,G3
G4,A4,B4,C4,D4,E4,F4,G4
I would still really appreciate any advice/feedback I can get. Does no one use Conrec?!
Edit: woops! I had a bug with the original splice()! sorry! fixed now
I just ported ConRec to Actionscript3 and seems to work fine, I haven't tested it thoroughly,
but it draws my contours the way I expect. Try it out if you will, I'm curious if it's a correct port. it's here:
http://www.jvanderspek.com/DEV/ConRec/ConRec.as
Ok, so there may be a much better alternative for Flash. I just found this link and it looks impressive. If this works, it obviates the original problem...
isolining package for ActionScript 3